From e1cb5e0f55ce695c738a06117f43d927fbb3b42b Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Fri, 28 Oct 2022 10:23:36 +0200
Subject: [PATCH] Adds a sequence property

---
 ohmpi.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/ohmpi.py b/ohmpi.py
index 27183c6b..ad000458 100644
--- a/ohmpi.py
+++ b/ohmpi.py
@@ -60,7 +60,7 @@ class OhmPi(object):
         if on_pi is None:
             _, on_pi = OhmPi.get_platform()
 
-        self.sequence = sequence
+        self._sequence = sequence
         self.use_mux = use_mux
         self.on_pi = on_pi  # True if run from the RaspberryPi with the hardware, otherwise False for random data
         self.status = 'idle'  # either running or idle
@@ -143,6 +143,22 @@ class OhmPi(object):
         self.cmd_thread = threading.Thread(target=self._control)
         self.cmd_thread.start()
 
+    @property
+    def sequence(self):
+        """Gets or sets sequence"""
+        if self._sequence is not None:
+            assert isinstance(self._sequence, np.ndarray)
+        return self._sequence
+
+    @sequence.setter
+    def sequence(self, sequence):
+        if sequence is not None:
+            assert isinstance(sequence, np.ndarray)
+            self.use_mux = True
+        else:
+            self.use_mux = False
+        self._sequence = sequence
+
     def _control(self):
         def on_message(client, userdata, message):
             command = message.payload.decode('utf-8')
-- 
GitLab