From 95f0af5d41b91be173faf577b64030f1fa0ab435 Mon Sep 17 00:00:00 2001
From: thijs snijder <snijder@astron.nl>
Date: Tue, 11 May 2021 09:32:45 +0200
Subject: [PATCH] fixed scalar string issues

---
 devices/SDP.py                      |  2 +-
 devices/clients/opcua_connection.py | 25 +++++++++++++++++++++++--
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/devices/SDP.py b/devices/SDP.py
index 94aae242c..a89c1fddf 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 f55922df8..f2cc35146 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
-- 
GitLab