Skip to content
Snippets Groups Projects

Resolve L2SS-247 "2021 07 06 branched from master attribute testing"

Merged Resolve L2SS-247 "2021 07 06 branched from master attribute testing"
All threads resolved!
All threads resolved!
Files
23
@@ -26,23 +26,24 @@ class attribute_wrapper(attribute):
"""
# 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
# 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,))
self.comms_id = comms_id # store data that can be used to identify the comms interface to use. not used by the wrapper itself
self.comms_annotation = comms_annotation # store data that can be used by the comms interface. not used by the wrapper itself
self.numpy_type = datatype # tango changes our attribute to their representation (E.g numpy.int64 becomes "DevLong64")
self.init_value = init_value
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
if datatype is numpy.str_:
if datatype is numpy.str_ or datatype is numpy.str:
datatype = str
self.numpy_type = datatype # tango changes our attribute to their representation (E.g numpy.int64 becomes "DevLong64")
# check if not scalar
if is_scalar:
# scalar, just set the single dimension.
@@ -130,7 +131,15 @@ class attribute_wrapper(attribute):
else:
numpy_dims = dims
value = numpy.zeros(numpy_dims, dtype=self.numpy_type)
if self.dim_x == 1:
if self.numpy_type == str:
value = ''
else:
value = self.numpy_type(0)
else:
value = numpy.zeros(numpy_dims, dtype=self.numpy_type)
return value
def set_comm_client(self, client):
Loading