diff --git a/devices/SDP.py b/devices/SDP.py index 94aae242c74473439d5e9155556e1350d8ffef6d..a89c1fddf1d30e3c8e715c9226723db6ee29812e 100644 --- a/devices/SDP.py +++ b/devices/SDP.py @@ -95,7 +95,7 @@ class SDP(hardware_device): tr_uptime_R = attribute_wrapper(comms_annotation=["2:tr_uptime_R"], datatype=numpy.uint64) fpga_firmware_version_R = attribute_wrapper(comms_annotation=["2:fpga_firmware_version_R"], datatype=numpy.str_, dims=(16,)) - fpga_hardware_version_R = attribute_wrapper(comms_annotation=["2:fpga_hardware_version_R "], datatype=numpy.str_, dims=(16,)) + fpga_hardware_version_R = attribute_wrapper(comms_annotation=["2:fpga_hardware_version_R"], datatype=numpy.str_, dims=(16,)) tr_software_version_R = attribute_wrapper(comms_annotation=["2:tr_software_version_R"], datatype=numpy.str_) diff --git a/devices/clients/opcua_connection.py b/devices/clients/opcua_connection.py index f55922df8dba4ca5dbb6c78db5600a7287d5f9ad..f2cc35146391f5adc23b2d6d9b29823abcc89204 100644 --- a/devices/clients/opcua_connection.py +++ b/devices/clients/opcua_connection.py @@ -51,6 +51,7 @@ class OPCUAConnection(CommClient): fault_func() return + # determine namespace used try: if type(namespace) is str: @@ -64,6 +65,7 @@ class OPCUAConnection(CommClient): self.name_space_index = 2 self.obj = self.client.get_objects_node() + self.check_nodes() def _servername(self): return self.client.server_url.geturl() @@ -83,6 +85,21 @@ class OPCUAConnection(CommClient): self.streams.error_stream("Could not connect to server %s: %s", self._servername(), e) raise Exception("Could not connect to server %s", self._servername()) from e + def check_nodes(self): + """ + function purely for debugging/development only. Simply lists all top level nodes and the nodes below that + """ + + for i in self.obj.get_children(): + print(i.get_browse_name()) + for j in i.get_children(): + try: + print(j.get_browse_name(), j.get_data_type_as_variant_type()) + except: + print(j.get_browse_name()) + finally: + pass + def disconnect(self): """ @@ -160,7 +177,6 @@ class OPCUAConnection(CommClient): self.streams.debug_stream("connected OPC ua node {} of type {} to attribute with dimensions: {} x {} ".format(str(node_name)[:len(node_name)-1], str(ua_type)[len("VariantType."):], dim_x, dim_y)) except: pass - # return the read/write functions return prot_attr.read_function, prot_attr.write_function @@ -182,12 +198,17 @@ class ProtocolAttribute: """ value = numpy.array(self.node.get_value()) - if self.dim_y != 0: + if self.dim_y + self.dim_x == 1: + return numpy.array([value]) + elif self.dim_y != 0: value = numpy.array(numpy.split(value, indices_or_sections=self.dim_y)) else: value = numpy.array(value) + return value + + def write_function(self, value): """ write_RW function