Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Remove metaclasses in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Michel committed Jan 16, 2017
1 parent c60fc13 commit 1890f6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 31 deletions.
8 changes: 2 additions & 6 deletions 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)
Expand All @@ -18,4 +14,4 @@ def strftime(self, format):


if __name__ == "__main__":
run([Clock])
Clock.run_server()
18 changes: 2 additions & 16 deletions 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
Expand All @@ -24,14 +14,10 @@
"""

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):
Expand All @@ -57,4 +43,4 @@ def mktime(self, tupl):


if __name__ == "__main__":
run([Clock,])
Clock.run_server()
19 changes: 10 additions & 9 deletions 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 = {}
Expand All @@ -35,8 +35,8 @@ def transition_function(self, func_str):
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()
Expand All @@ -57,13 +57,14 @@ def step(self):
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()

0 comments on commit 1890f6c

Please sign in to comment.