From 6a1e5e710916026ad747ca7f19187e6d8f656d76 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Sun, 30 Apr 2023 12:42:30 +0200
Subject: [PATCH] Separates test_measure from Hardware system mux test -> moves
 mux tests to test_mux_2024

---
 test_measure_with_ohmpi_card_3_15.py |  6 ------
 test_mux_2024.py                     | 21 ++++++++++++++++++++-
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/test_measure_with_ohmpi_card_3_15.py b/test_measure_with_ohmpi_card_3_15.py
index 6c012876..e9251e5b 100644
--- a/test_measure_with_ohmpi_card_3_15.py
+++ b/test_measure_with_ohmpi_card_3_15.py
@@ -10,10 +10,6 @@ from OhmPi.hardware_system import OhmPiHardware
 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')
-
 # Test _vab_pulse:
 print('Testing positive _vab_pulse')
 k._vab_pulse(vab=12, length=1., sampling_rate=k.rx.sampling_rate, polarity=1)
@@ -55,7 +51,5 @@ r = [np.abs((k.pulses[i]['polarity']*k.pulses[i]['vmn']-k.sp)/k.pulses[i]['iab']
 for i in range(len(r)):
     print(f'Mean resistance with sp correction for pulse{i}: {np.mean(r[i]):.3f} Ohms, Dev. {100*np.std(r[i])/np.mean(r[i]):.1f} %')
 
-k.switch_mux(electrodes=[9,10,11,12], roles=['A', 'B', 'M', 'N'], state='off')
-k.reset_mux()
 change_config('config_default.py', verbose=False)
 
diff --git a/test_mux_2024.py b/test_mux_2024.py
index 0b166f67..fe159104 100644
--- a/test_mux_2024.py
+++ b/test_mux_2024.py
@@ -1,9 +1,12 @@
 import time
 from utils import change_config
+import logging
 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
 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)}
@@ -17,4 +20,20 @@ time.sleep(8)
 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]})
-change_config('config_default.py', verbose=False)
+
+# mux as part of a OhmPiHardware system
+
+from utils import change_config
+change_config('config_mb_2023_mux_2024.py', verbose=False)
+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')
+change_config('config_default.py', verbose=False)
\ No newline at end of file
-- 
GitLab