diff --git a/devices/APSCTL.py b/devices/APSCTL.py index b9d47680875422b60bc124917e342dbf177d7ac2..068ec2ab411c25395e06577121d78ffc575cdb55 100644 --- a/devices/APSCTL.py +++ b/devices/APSCTL.py @@ -187,6 +187,11 @@ class APSCTL(hardware_device): # ---------- def main(args=None, **kwargs): """Main function of the SDP module.""" + + from util.lofar_logging import configure_logger + import logging + configure_logger(logging.getLogger()) + return run((APSCTL,), args=args, **kwargs) diff --git a/devices/PCC.py b/devices/PCC.py index 37acfc1d3fa48cb3db4ce1dd4ebdd7a0ffa6b667..e8eb9bc94b689bc616ce49dba9601b0ed99de7a7 100644 --- a/devices/PCC.py +++ b/devices/PCC.py @@ -243,6 +243,11 @@ class PCC(hardware_device): # ---------- def main(args=None, **kwargs): """Main function of the PCC module.""" + + from util.lofar_logging import configure_logger + import logging + configure_logger(logging.getLogger()) + return run((PCC,), args=args, **kwargs) diff --git a/devices/SDP.py b/devices/SDP.py index 09a8c809ab52fda9dfdbc37b39f9a42fcff871c5..56091d98bcd2f2eca6ff859e8ec0590c044b8854 100644 --- a/devices/SDP.py +++ b/devices/SDP.py @@ -167,6 +167,11 @@ class SDP(hardware_device): # ---------- def main(args=None, **kwargs): """Main function of the SDP module.""" + + from util.lofar_logging import configure_logger + import logging + configure_logger(logging.getLogger()) + return run((SDP,), args=args, **kwargs) diff --git a/devices/SNMP.py b/devices/SNMP.py index db748639ef3c784792b0d5e2211019b50bac1e9f..eb90b276896f5e07f16eceb43c1dbf810da1b2ae 100644 --- a/devices/SNMP.py +++ b/devices/SNMP.py @@ -110,6 +110,11 @@ class SNMP(hardware_device): # ---------- def main(args=None, **kwargs): """Main function of the PCC module.""" + + from util.lofar_logging import configure_logger + import logging + configure_logger(logging.getLogger()) + return run((SNMP,), args=args, **kwargs) diff --git a/devices/Statistics.py b/devices/Statistics.py index b397898e5b76c026dcd82ae18b014374062800aa..856beffdee18b228d2cbadd433c6c4364a5d04be 100644 --- a/devices/Statistics.py +++ b/devices/Statistics.py @@ -90,7 +90,12 @@ class SST(hardware_device): # ---------- def main(args=None, **kwargs): """Main function of the Statistics Device module.""" - return run((SST,), args=args, **kwargs) + + from util.lofar_logging import configure_logger + import logging + configure_logger(logging.getLogger()) + + return run((Statistics,), args=args, **kwargs) if __name__ == '__main__': diff --git a/devices/clients/opcua_connection.py b/devices/clients/opcua_connection.py index f6915250da6dfe25cfe07b75722b3f6e170a4ca0..0f7ca6dc4066806f02b56e2668110bd14d85c51f 100644 --- a/devices/clients/opcua_connection.py +++ b/devices/clients/opcua_connection.py @@ -199,7 +199,8 @@ class ProtocolAttribute: value = numpy.array(self.node.get_value()) if self.dim_y + self.dim_x == 1: - return numpy.array([value]) + # scalar + return value elif self.dim_y != 0: value = numpy.array(numpy.split(value, indices_or_sections=self.dim_y)) elif self.dim_y + self.dim_x == 1: diff --git a/devices/util/attribute_wrapper.py b/devices/util/attribute_wrapper.py index d4584f01b78b22d0ee634d91963d2b80adcd29f4..5953a1c8cb4e62d34df0be81e6cc4ae5cf29eca9 100644 --- a/devices/util/attribute_wrapper.py +++ b/devices/util/attribute_wrapper.py @@ -21,11 +21,13 @@ class attribute_wrapper(attribute): comms_annotation: data passed along to the attribute. can be given any form of data. handling is up to client implementation datatype: any numpy datatype - dims: dimensions of the + dims: dimensions of the attribute as a tuple, or (1,) for a scalar. init_value: value """ - # ensure the type is a numpy array + # ensure the type is a numpy array. + # see also https://pytango.readthedocs.io/en/stable/server_api/server.html?highlight=devlong#module-tango.server for + # more details about type conversion Python/numpy -> PyTango if "numpy" not in str(datatype) and datatype != str: raise TypeError("Attribute needs to be a Tango-supported numpy or str type, but has type \"%s\"" % (datatype,)) @@ -33,7 +35,7 @@ class attribute_wrapper(attribute): self.numpy_type = datatype # tango changes our attribute to their representation (E.g numpy.int64 becomes "DevLong64") self.init_value = init_value - max_dim_y = 0 + is_scalar = dims == (1,) # tango doesn't recognise numpy.str_, for consistencies sake we convert it here and hide this from the top level # NOTE: discuss, idk if this is an important detail somewhere else @@ -41,8 +43,12 @@ class attribute_wrapper(attribute): datatype = str # check if not scalar - if isinstance(dims, tuple): - + if is_scalar: + # scalar, just set the single dimension. + # Tango defines a scalar as having dimensions (1,0), see https://pytango.readthedocs.io/en/stable/server_api/attribute.html + max_dim_x = 1 + max_dim_y = 0 + else: # get first dimension max_dim_x = dims[0] @@ -54,9 +60,8 @@ class attribute_wrapper(attribute): max_dim_y = dims[1] # wrap the datatype tuple in another tuple for 2d arrays/images datatype = (datatype,) - else: - # scalar, just set the single dimension - max_dim_x = 1 + else: + max_dim_y = 0 if access == AttrWriteType.READ_WRITE: """ if the attribute is of READ_WRITE type, assign the RW and write function to it"""