From edaa2682f0678507abded709444b9ddf24cdabd8 Mon Sep 17 00:00:00 2001
From: awatlet <arnaud.watlet@umons.ac.be>
Date: Thu, 12 Oct 2023 10:10:16 +0200
Subject: [PATCH] Refactors test_mux in test_mux_one_relay in OhmpiHardware

---
 dev/test_mb_2024_1_mux_2024.py | 11 ++++++++---
 ohmpi/hardware_system.py       |  2 +-
 ohmpi/ohmpi.py                 |  2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/dev/test_mb_2024_1_mux_2024.py b/dev/test_mb_2024_1_mux_2024.py
index 873b0ae4..0f119bb6 100644
--- a/dev/test_mb_2024_1_mux_2024.py
+++ b/dev/test_mb_2024_1_mux_2024.py
@@ -51,6 +51,10 @@ if stand_alone:
     current = tx.current
     mux.switch(elec_dict={'A': [1], 'B': [4], 'M': [2], 'N': [3]}, state='off')
     print(f'Resistance: {voltage / current :.2f} ohm, voltage: {voltage:.2f} mV, current: {current:.2f} mA')
+    mux.reset()
+    mux.test({'A': [i for i in range(1, 9)], 'B': [i for i in range(1, 9)],
+              'M': [i for i in range(1, 9)], 'N': [i for i in range(1, 9)]}, activation_time=.1)
+    mux.reset()
 
 # mux as part of a OhmPiHardware system
 if part_of_hardware_system:
@@ -65,8 +69,9 @@ if part_of_hardware_system:
     # time.sleep(1.)
     # k.switch_mux(electrodes=[1, 4, 2, 3], roles=['A', 'B', 'M', 'N'], state='off')
     # k.mux_boards[mux_id].test(activation_time=.4)
-    k.test_mux((1,'A'))
-    
+    # k.test_mux_one_relay((1, 'A'))
+
+
 if within_ohmpi:
     from ohmpi.ohmpi import OhmPi
     # from ohmpi.plots import plot_exec_log
@@ -75,7 +80,7 @@ if within_ohmpi:
     k = OhmPi()
     # A, B, M, N = (32, 29, 31, 30)
     k.reset_mux()
-    k.test_mux(mux_id='mux_03')
+    k.test_mux_one_relay(mux_id='mux_03')
     # k._hw.switch_mux([A, B, M, N], state='on')
     # k._hw.vab_square_wave(12.,1., cycles=2)
     # k._hw.switch_mux([A, B, M, N], state='off')
diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index 60429ff8..1b1bdc6f 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -502,7 +502,7 @@ class OhmPiHardware:
         self.exec_logger.event(f'OhmPiHardware\tswitch_mux\tend\t{datetime.datetime.utcnow()}')
         return status
 
-    def test_mux(self, channel=None, activation_time=1.0):
+    def test_mux_one_relay(self, channel=None, activation_time=1.0): #TODO: is this needed at OhmpiHardware level?
         """Interactive method to test the multiplexer.
 
         Parameters
diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py
index 36590e08..3212666d 100644
--- a/ohmpi/ohmpi.py
+++ b/ohmpi/ohmpi.py
@@ -825,7 +825,7 @@ class OhmPi(object):
         """
         self.reset_mux() # All mux boards should be reset even if we only want to test one otherwise we might create a shortcut
         if mux_id is None:
-            self._hw.test_mux(activation_time=activation_time)
+            self._hw.test_mux_one_relay(activation_time=activation_time)
         else:
             self._hw.mux_boards[mux_id].test(activation_time=activation_time)
 
-- 
GitLab