From 787b71dda7f7b934f3cab9a50dc6080cc57dd3ec Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Sun, 30 Apr 2023 16:21:04 +0200
Subject: [PATCH] Fixes bug related to the mux_barrier in hardware system

---
 test_mux_2024.py | 50 ++++++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/test_mux_2024.py b/test_mux_2024.py
index d125f0f2..9d493166 100644
--- a/test_mux_2024.py
+++ b/test_mux_2024.py
@@ -5,31 +5,35 @@ change_config('config_mb_2023_mux_2024.py', verbose=False)
 from OhmPi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG
 from OhmPi.hardware_components import raspberry_pi as controller_module
 
-
+stand_alone_mux = False
+part_of_hardware_system = True
 # Stand alone mux
-MUX_CONFIG['controller'] = controller_module.Controller()
-MUX_CONFIG['id'] = 'mux_1'
-MUX_CONFIG['default_mux_cabling'] = {(i+8, j) : ('mux_1', i) for j in ['A', 'B', 'M', 'N'] for i in range(1,9)}
-mux = Mux(**MUX_CONFIG)
-mux.switch_one(elec=9, role='M', state='on')
-time.sleep(2)
-mux.switch_one(elec=9, role='M', state='off')
-mux.switch({'A': [9], 'B': [12], 'M': [10], 'N': [11]}, state='on')
-time.sleep(8)
-#mux.switch({'A': [1], 'B': [4], 'M': [2], 'N': [3]}, state='off')
-mux.reset()
-mux.test({'A': [9, 10, 11, 12, 13, 14, 15, 16], 'B': [9, 10, 11, 12, 13, 14, 15, 16],
-          'M': [9, 10, 11, 12, 13, 14, 15, 16], 'N': [9, 10, 11, 12, 13, 14, 15, 16]}, activation_time=.1)
+if stand_alone_mux:
+    MUX_CONFIG['controller'] = controller_module.Controller()
+    MUX_CONFIG['id'] = 'mux_1'
+    MUX_CONFIG['default_mux_cabling'] = {(i+8, j) : ('mux_1', i) for j in ['A', 'B', 'M', 'N'] for i in range(1,9)}
+    mux = Mux(**MUX_CONFIG)
+    mux.switch_one(elec=9, role='M', state='on')
+    time.sleep(2)
+    mux.switch_one(elec=9, role='M', state='off')
+    mux.switch({'A': [9], 'B': [12], 'M': [10], 'N': [11]}, state='on')
+    time.sleep(8)
+    #mux.switch({'A': [1], 'B': [4], 'M': [2], 'N': [3]}, state='off')
+    mux.reset()
+    mux.test({'A': [9, 10, 11, 12, 13, 14, 15, 16], 'B': [9, 10, 11, 12, 13, 14, 15, 16],
+              'M': [9, 10, 11, 12, 13, 14, 15, 16], 'N': [9, 10, 11, 12, 13, 14, 15, 16]}, activation_time=.1)
 
 # mux as part of a OhmPiHardware system
-from OhmPi.hardware_system import OhmPiHardware
-print('Starting test of mux as part of a OhmPiHardware system.')
-k = OhmPiHardware()
-k.exec_logger.setLevel(logging.INFO)
+if part_of_hardware_system:
+    from OhmPi.hardware_system import OhmPiHardware
+    print('Starting test of mux as part of a OhmPiHardware system.')
+    k = OhmPiHardware()
+    k.exec_logger.setLevel(logging.INFO)
+
+    # Test mux switching
+    k.reset_mux()
+    k.switch_mux(electrodes=[9,10,11,12], roles=['A', 'B', 'M', 'N'], state='on')
+    time.sleep(1.)
+    k.switch_mux(electrodes=[9,10,11,12], roles=['A', 'B', 'M', 'N'], state='off')
 
-# Test mux switching
-k.reset_mux()
-k.switch_mux(electrodes=[9,10,11,12], roles=['A', 'B', 'M', 'N'], state='on')
-time.sleep(1.)
-k.switch_mux(electrodes=[9,10,11,12], roles=['A', 'B', 'M', 'N'], state='off')
 change_config('config_default.py', verbose=False)
\ No newline at end of file
-- 
GitLab