From 365febc313d14412cca2ad0c1402012a35a08a9c Mon Sep 17 00:00:00 2001
From: awatlet <arnaud.watlet@umons.ac.be>
Date: Tue, 14 Nov 2023 12:24:01 +0100
Subject: [PATCH] Fixes rs_check

---
 ohmpi/hardware_system.py | 9 +++++++++
 ohmpi/ohmpi.py           | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index a4d1a9e6..03a5e220 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -587,6 +587,7 @@ class OhmPiHardware:
         """
         self.exec_logger.event(f'OhmPiHardware\tvab_square_wave\tbegin\t{datetime.datetime.utcnow()}')
         switch_pwr_off, switch_tx_pwr_off = False, False
+        # switches tx pwr on if needed (relays switching dps on and off)
         if self.pwr_state == 'off':
             self.pwr_state = 'on'
             switch_tx_pwr_off = True
@@ -623,6 +624,9 @@ class OhmPiHardware:
                 self.tx.voltage = vab
         else:
             vab = self.tx.voltage
+
+        # switches dps pwr on if needed
+        switch_pwr_off = False
         if self.tx.pwr.pwr_state == 'off':
             self.tx.pwr.pwr_state = 'on'
             switch_pwr_off = True
@@ -638,6 +642,8 @@ class OhmPiHardware:
             self.tx.pwr.pwr_state = 'off'
     def _vab_pulses(self, vab, durations, sampling_rate, polarities=None, append=False):
         switch_pwr_off, switch_tx_pwr_off = False, False
+
+        # switches tx pwr on if needed (relays switching dps on and off)
         if self.pwr_state == 'off':
             self.pwr_state = 'on'
             switch_pwr_off = True
@@ -647,9 +653,12 @@ class OhmPiHardware:
             self.tx.voltage = vab
         else:
             vab = self.tx.voltage
+
+        # switches dps pwr on if needed
         if self.tx.pwr.pwr_state == 'off':
             self.tx.pwr.pwr_state = 'on'
             switch_pwr_off = True
+
         if sampling_rate is None:
             sampling_rate = RX_CONFIG['sampling_rate']
         if polarities is not None:
diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py
index bd66fe3f..c25164ea 100644
--- a/ohmpi/ohmpi.py
+++ b/ohmpi/ohmpi.py
@@ -822,7 +822,7 @@ class OhmPi(object):
         if self._hw.pwr.pwr_state == 'off':
             self._hw.pwr.pwr_state = 'on'
             switch_pwr_off = True
-            
+
         # measure all quad of the RS sequence
         for i in range(0, quads.shape[0]):
             quad = quads[i, :]  # quadrupole
-- 
GitLab