1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#!/usr/bin/env python3
# SPDX-FileCopyrightText: All Contributors to the PyTango project
# SPDX-License-Identifier: LGPL-3.0-or-later
"""Trivial example of a low-level API device server."""
import sys
import tango
class Motor(tango.Device_6Impl):
def __init__(self, cl, name):
tango.Device_6Impl.__init__(self, cl, name)
Motor.init_device(self)
def delete_device(self):
pass
def init_device(self):
self.get_device_properties(self.get_device_class())
self.attr_position_read = 1.0
def always_executed_hook(self):
pass
def read_position(self, attr):
attr.set_value(self.attr_position_read)
def read_attr_hardware(self, data):
pass
class MotorClass(tango.DeviceClass):
class_property_list = {}
device_property_list = {}
cmd_list = {}
attr_list = {"position": [[tango.DevDouble, tango.SCALAR, tango.READ]]}
def __init__(self, name):
tango.DeviceClass.__init__(self, name)
self.set_type(name)
def main():
try:
util = tango.Util(sys.argv)
util.add_class(MotorClass, Motor, "Motor")
U = tango.Util.instance()
U.server_init()
U.server_run()
except tango.DevFailed as exc:
print(f"-------> Received a DevFailed exception: {exc}")
except Exception as exc:
print(f"-------> An unforeseen exception occurred: {exc}")
if __name__ == "__main__":
main()
|