Skip to content
Snippets Groups Projects
Commit 2af22e10 authored by Thomas Juerges's avatar Thomas Juerges
Browse files

Merge branch 'L2SS-281-Bug_fixes_attribute_extender_from_L2SS-244' into 'master'

L2SS-281: Move attribute extender bug fixes to a dedicated master branch

Closes L2SS-281

See merge request !61
parents d55e5217 a80fa93f
Branches
Tags
1 merge request!61L2SS-281: Move attribute extender bug fixes to a dedicated master branch
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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__':
......
......@@ -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:
......
......@@ -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]
......@@ -55,8 +61,7 @@ class attribute_wrapper(attribute):
# wrap the datatype tuple in another tuple for 2d arrays/images
datatype = (datatype,)
else:
# scalar, just set the single dimension
max_dim_x = 1
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"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment