From 081a90fe648a5eaff71f026200723a3a1e19697d Mon Sep 17 00:00:00 2001
From: awatlet <arnaud.watlet@umons.ac.be>
Date: Thu, 9 Nov 2023 23:53:31 +0100
Subject: [PATCH] Fixes pwr_switch_on in rs_check

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

diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py
index 62485295..de3c520a 100644
--- a/ohmpi/ohmpi.py
+++ b/ohmpi/ohmpi.py
@@ -784,6 +784,11 @@ class OhmPi(object):
         cmd_id : str, optional
             Unique command identifier
         """
+        # check pwr is on, if not, let's turn it on
+        switch_power_off = False
+        if self._hw.pwr_state == 'off':
+            self._hw.pwr_state = 'on'
+            switch_power_off = True
 
         self._hw.tx.pwr.voltage = float(tx_volt)
 
@@ -866,7 +871,10 @@ class OhmPi(object):
             self.switch_mux_off(quad)
 
         self.status = 'idle'
-
+        
+        # if power was off before measurement, let's turn if off
+        if switch_power_off:
+            self._hw.pwr_state = 'off'
     #
     #         # TODO if interrupted, we would need to restore the values
     #         # TODO or we offer the possibility in 'run_measurement' to have rs_check each time?
-- 
GitLab