From 0849c30e162c936cd43e173c5cafd143c18edbb3 Mon Sep 17 00:00:00 2001
From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl>
Date: Sat, 13 Feb 2021 04:00:55 +0100
Subject: [PATCH] Specify weights dtype when reading and flatten 2d into 1d
 before writing

---
 SDP/SDP/SDP.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/SDP/SDP/SDP.py b/SDP/SDP/SDP.py
index d488b408e..2dbc7b808 100644
--- a/SDP/SDP/SDP.py
+++ b/SDP/SDP/SDP.py
@@ -310,7 +310,7 @@ class SDP(Device):
     @fault_on_error
     def read_fpga_scrap_R(self):
         """Return the fpga_scrap_R attribute."""
-        self._fpga_scrap_R = numpy.array(self.attribute_mapping["fpga_scrap_R"].get_data_value().Value.Value)
+        self._fpga_scrap_R = numpy.array(self.attribute_mapping["fpga_scrap_R"].get_value(), dtype = numpy.int32)
         return self._fpga_scrap_R
 
     @only_when_on
@@ -351,7 +351,7 @@ class SDP(Device):
     @fault_on_error
     def read_fpga_weights_R(self):
         """Return the fpga_weights_R attribute."""
-        value = numpy.array(numpy.split(numpy.array(self.attribute_mapping["fpga_weights_R"].get_value()), indices_or_sections = 16))
+        value = numpy.array(numpy.split(numpy.array(self.attribute_mapping["fpga_weights_R"].get_value(), dtype = numpy.int16), indices_or_sections = 16))
         self._fpga_weights_R = value
         return self._fpga_weights_R
 
@@ -365,7 +365,7 @@ class SDP(Device):
     @fault_on_error
     def write_fpga_weights_RW(self, value):
         """Return the fpga_weights_RW attribute."""
-        self.attribute_mapping["fpga_weights_RW"].set_data_value(opcua.ua.uatypes.Variant(value = value.tolist(), varianttype=opcua.ua.VariantType.Int16))
+        self.attribute_mapping["fpga_weights_RW"].set_data_value(opcua.ua.uatypes.Variant(value = value.flatten().tolist(), varianttype=opcua.ua.VariantType.Int16))
         _fpga_weights_RW = value
 
     @only_when_on
-- 
GitLab