diff --git a/devices/HW_device_template.py b/devices/HW_device_template.py index 0249747de12fa08893d0c1c4c3534827b61f59f1..cd7880672caf41e65db841408353896a795c5549 100644 --- a/devices/HW_device_template.py +++ b/devices/HW_device_template.py @@ -11,10 +11,11 @@ # PyTango imports from tango.server import run +from tango import AttrWriteType # Additional import -from src.attribute_wrapper import * -from src.hardware_device import * +from src.attribute_wrapper import attribute_wrapper +from src.hardware_device import hardware_device __all__ = ["HW_dev"] diff --git a/devices/PCC.py b/devices/PCC.py index b1bc93d9c66e8d961faa7dfb12a065492a5dc575..79b8a82281ecdd28adf8099e0fa8594dea255a1e 100644 --- a/devices/PCC.py +++ b/devices/PCC.py @@ -15,11 +15,12 @@ from tango import DebugIt from tango.server import run, command from tango.server import device_property +from tango import AttrWriteType # Additional import from clients.opcua_connection import OPCUAConnection -from src.attribute_wrapper import * -from src.hardware_device import * +from src.attribute_wrapper import attribute_wrapper +from src.hardware_device import hardware_device from src.lofar_logging import device_logging_to_python __all__ = ["PCC", "main"] diff --git a/devices/SDP.py b/devices/SDP.py index 05a5841bf939310840395242013ae164df5e1618..35c03232e8e0fb42b272f25325f20cad9ba03340 100644 --- a/devices/SDP.py +++ b/devices/SDP.py @@ -14,14 +14,16 @@ # PyTango imports from tango.server import run from tango.server import device_property +from tango import AttrWriteType # Additional import from clients.opcua_connection import OPCUAConnection -from src.attribute_wrapper import * -from src.hardware_device import * +from src.attribute_wrapper import attribute_wrapper +from src.hardware_device import hardware_device from src.lofar_logging import device_logging_to_python +import numpy __all__ = ["SDP", "main"] diff --git a/devices/clients/test_client.py b/devices/clients/test_client.py index 640d2edb5fb09833cfe808703f02e14356d8157b..b191d991ff85d3a201415224b0ee33572fcbd188 100644 --- a/devices/clients/test_client.py +++ b/devices/clients/test_client.py @@ -1,11 +1,11 @@ -from src.comms_client import * +from src.comms_client import CommClient import numpy import os # <class 'numpy.bool_'> -class example_client(CommClient): +class test_client(CommClient): """ this class provides an example implementation of a comms_client. Durirng initialisation it creates a correctly shaped zero filled value. on read that value is returned and on write its modified. @@ -47,7 +47,9 @@ class example_client(CommClient): the annotation can be in whatever format may be required. it is up to the user to handle its content example annotation may include: - a file path and file line/location - - COM object path + - server address + - IDs + - data structures """ # as this is an example, just print the annotation diff --git a/devices/src/attribute_wrapper.py b/devices/src/attribute_wrapper.py index 66dcd4bb3b297e0fa46cce5d28ae6c74e034f0ac..98faf037c363fa92006bc656f821d636b5b396c0 100644 --- a/devices/src/attribute_wrapper.py +++ b/devices/src/attribute_wrapper.py @@ -84,7 +84,6 @@ class attribute_wrapper(attribute): self.write_function(value) device.value_dict[self] = value - self.fget = read_RW self.fset = write_RW @@ -96,8 +95,8 @@ class attribute_wrapper(attribute): @fault_on_error def read_R(device): """ - _read_R reads the attribute value, stores it and returns it" - """ + _read_R reads the attribute value, stores it and returns it" + """ device.value_dict[self] = self.read_function() return device.value_dict[self] @@ -109,8 +108,8 @@ class attribute_wrapper(attribute): def initial_value(self): """ - returns a numpy array filled with zeroes fit to the size of the attribute. Or if init_value is not the default None, return that value - """ + returns a numpy array filled with zeroes fit to the size of the attribute. Or if init_value is not the default None, return that value + """ if self.init_value is not None: return self.init_value @@ -130,16 +129,16 @@ class attribute_wrapper(attribute): def set_comm_client(self, client): """ - takes a communications client as input arguments This client should be of a class containing a "get_mapping" function - and return a read and write function that the wrapper will use to get/set data. - """ + takes a communications client as input arguments This client should be of a class containing a "get_mapping" function + and return a read and write function that the wrapper will use to get/set data. + """ try: self.read_function, self.write_function = client.setup_attribute(self.comms_annotation, self) except Exception as e: def pass_func(value=None): pass - logger.error("Exception while setting %s read/write functions. using pass function instead.", self.comms_annotation) + logger.error("Exception while setting %s attribute with annotation: '%s' read/write functions. using pass function instead to to keep running", client.__class__.__name__, self.comms_annotation) self.read_function = pass_func self.write_function = pass_func diff --git a/devices/src/comms_client.py b/devices/src/comms_client.py index 0405c737d5ca4a7b7d943475a9e959d11bfc5cad..f189ce3fdec74bad5c40c2186bfc6b3f3c207cca 100644 --- a/devices/src/comms_client.py +++ b/devices/src/comms_client.py @@ -44,7 +44,6 @@ class CommClient(Thread): # keep trying to connect if not self.connected: if self.connect(): - # self.standby_func() pass else: # we retry only once, to catch exotic network issues. if the infra or hardware is down, diff --git a/devices/src/hardware_device.py b/devices/src/hardware_device.py index 2a2dafb57dbfcf36ae7b232619bf7b24447385d0..431cbe9718fb3b586eea9a23aaa65aa1134fa59d 100644 --- a/devices/src/hardware_device.py +++ b/devices/src/hardware_device.py @@ -16,7 +16,7 @@ from tango.server import Device, command from tango import DevState, DebugIt # Additional import -from src.attribute_wrapper import * +from src.attribute_wrapper import attribute_wrapper from src.lofar_logging import log_exceptions __all__ = ["hardware_device"] diff --git a/devices/test_device.py b/devices/test_device.py index 1d7a2f486771ebcfab4a322078afff4094550775..38f688cc0cb715667b8237c4358f32024ced582a 100644 --- a/devices/test_device.py +++ b/devices/test_device.py @@ -16,7 +16,7 @@ from tango.server import device_property from tango import DevState # Additional import -from clients.test_client import example_client +from clients.test_client import test_client from src.attribute_wrapper import * from src.hardware_device import * @@ -71,13 +71,13 @@ class test_device(hardware_device): self.set_state(DevState.INIT) # set up the test client - self.example_client = example_client(self.Fault, self) + self.test_client = test_client(self.Fault, self) # map an access helper class for i in self.attr_list(): - i.set_comm_client(self.example_client) + i.set_comm_client(self.test_client) - self.example_client.start() + self.test_client.start() # ----------