diff options
author | Sandor Bodo-Merle <sbodomerle@gmail.com> | 2017-01-31 11:39:16 +0100 |
---|---|---|
committer | Sandor Bodo-Merle <sbodomerle@gmail.com> | 2017-01-31 11:39:16 +0100 |
commit | 5c7435f4003be654eb511f3a989ad5ac3a092a55 (patch) | |
tree | 1142b90a5ab8346c0497c60fa6350506a88ad20a /examples | |
parent | a7434436eddcd651a1cd2c7db72e4543495998a8 (diff) |
Import Upstream version 9.2.1
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Clock/Clock.py | 8 | ||||
-rw-r--r-- | examples/Clock/ClockDS.py | 18 | ||||
-rw-r--r-- | examples/TuringMachine/TuringMachine.py | 19 |
3 files changed, 14 insertions, 31 deletions
diff --git a/examples/Clock/Clock.py b/examples/Clock/Clock.py index faa24a6..fea1bdc 100644 --- a/examples/Clock/Clock.py +++ b/examples/Clock/Clock.py @@ -1,15 +1,11 @@ import time -from PyTango.server import run -from PyTango.server import Device, DeviceMeta -from PyTango.server import attribute, command +from PyTango.server import Device, attribute, command class Clock(Device): - __metaclass__ = DeviceMeta @attribute def time(self): - """The time attribute""" return time.time() @command(dtype_in=str, dtype_out=str) @@ -18,4 +14,4 @@ class Clock(Device): if __name__ == "__main__": - run([Clock]) + Clock.run_server() diff --git a/examples/Clock/ClockDS.py b/examples/Clock/ClockDS.py index 24ad822..5e1ecde 100644 --- a/examples/Clock/ClockDS.py +++ b/examples/Clock/ClockDS.py @@ -1,14 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# This file is part of PyTango (http://pytango.rtfd.io) -# -# Copyright 2013-2015 European Synchrotron Radiation Facility, Grenoble, France -# -# Distributed under the terms of the GNU Lesser General Public License, -# either version 3 of the License, or (at your option) any later version. -# See LICENSE.txt for more info. -# ------------------------------------------------------------------------------ """ Clock Device server showing how to write a TANGO server with a Clock device @@ -24,14 +14,10 @@ commands: """ import time - -from PyTango.server import Device, DeviceMeta -from PyTango.server import attribute, command -from PyTango.server import run +from PyTango.server import Device, attribute, command class Clock(Device): - __metaclass__ = DeviceMeta @attribute(dtype=float) def time(self): @@ -57,4 +43,4 @@ class Clock(Device): if __name__ == "__main__": - run([Clock,]) + Clock.run_server() diff --git a/examples/TuringMachine/TuringMachine.py b/examples/TuringMachine/TuringMachine.py index 994c72b..958291d 100644 --- a/examples/TuringMachine/TuringMachine.py +++ b/examples/TuringMachine/TuringMachine.py @@ -1,14 +1,14 @@ import json from PyTango import DevState -from PyTango.server import Device, DeviceMeta, run +from PyTango.server import Device from PyTango.server import attribute, command, device_property + class TuringMachine(Device): - __metaclass__ = DeviceMeta blank_symbol = device_property(dtype=str, default_value=" ") initial_state = device_property(dtype=str, default_value="init") - + def init_device(self): Device.init_device(self) self.__tape = {} @@ -35,8 +35,8 @@ class TuringMachine(Device): self.__transition_function = tf = {} for k, v in json.loads(func_str).items(): tf[tuple(str(k).split(","))] = map(str, v) - print tf - + print(tf) + @attribute(dtype=str) def tape(self): s, keys = "", self.__tape.keys() @@ -57,13 +57,14 @@ class TuringMachine(Device): elif y[2] == "L": self.__head -= 1 self.__state = y[0] - print self.__state + print(self.__state) def dev_state(self): if self.__state in self.__final_states: return DevState.ON else: return DevState.RUNNING - - -run([TuringMachine]) + + +if __name__ == "__main__": + TuringMachine.run_server() |