From f136b26687c29bfde0339730edb7c537345a14c7 Mon Sep 17 00:00:00 2001 From: awatlet <arnaud.watlet@umons.ac.be> Date: Thu, 12 Oct 2023 12:31:49 +0200 Subject: [PATCH] Adds pwr_state on tx to switch dps on and off --- ohmpi/hardware_components/mb_2023_0_X.py | 2 +- ohmpi/hardware_components/mb_2024_0_2.py | 48 ++++++++++++------------ ohmpi/hardware_system.py | 4 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ohmpi/hardware_components/mb_2023_0_X.py b/ohmpi/hardware_components/mb_2023_0_X.py index 5216c77a..2f68994f 100644 --- a/ohmpi/hardware_components/mb_2023_0_X.py +++ b/ohmpi/hardware_components/mb_2023_0_X.py @@ -241,7 +241,7 @@ class Rx(RxAbstract): self.exec_logger.event(f'{self.model}\trx_init\tend\t{datetime.datetime.utcnow()}') @property - def gain(self): + def gain(self): #TODO: should be in abstract_hardware_components return self._adc_gain @gain.setter diff --git a/ohmpi/hardware_components/mb_2024_0_2.py b/ohmpi/hardware_components/mb_2024_0_2.py index 8b890d89..970067d3 100644 --- a/ohmpi/hardware_components/mb_2024_0_2.py +++ b/ohmpi/hardware_components/mb_2024_0_2.py @@ -99,30 +99,30 @@ class Tx(Tx_mb_2023): Tx_mb_2023.inject(self, polarity=polarity, injection_duration=injection_duration) self.pin6.value = False - # @property - # def pwr_state(self): - # return self._pwr_state - # - # @pwr_state.setter - # def pwr_state(self, state, latency=4.): - # """Switches pwr on or off. - # - # Parameters - # ---------- - # state : str - # 'on', 'off' - # """ - # if state == 'on': - # self.pin2.value = True - # self.pin3.value = True - # self.exec_logger.debug(f'Switching DPS on') - # self._pwr_state = 'on' - # time.sleep(latency) # from pwr specs - # elif state == 'off': - # self.pin2.value = False - # self.pin3.value = False - # self.exec_logger.debug(f'Switching DPS off') - # self._pwr_state = 'off' + @property + def pwr_state(self): + return self._pwr_state + + @pwr_state.setter + def pwr_state(self, state, latency=4.): + """Switches pwr on or off. + + Parameters + ---------- + state : str + 'on', 'off' + """ + if state == 'on': + self.pin2.value = True + self.pin3.value = True + self.exec_logger.debug(f'Switching DPS on') + self._pwr_state = 'on' + time.sleep(latency) # from pwr specs + elif state == 'off': + self.pin2.value = False + self.pin3.value = False + self.exec_logger.debug(f'Switching DPS off') + self._pwr_state = 'off' class Rx(Rx_mb_2023): diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index d828cb15..c89b1c26 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -446,13 +446,13 @@ class OhmPiHardware: if not append: self._clear_values() if self.tx.pwr_state == 'off': - self.tx.pwr_state('on') + self.tx.pwr_state = 'on' switch_pwr_off = True for i in range(n_pulses): self._vab_pulse(vab=vab, duration=durations[i], sampling_rate=sampling_rate, polarity=polarities[i], append=True) if switch_pwr_off: - self.tx.pwr_state('off') + self.tx.pwr_state = 'off' def switch_mux(self, electrodes, roles=None, state='off', **kwargs): """Switches on multiplexer relays for given quadrupole. -- GitLab