From 4a179297d85fa93ef9f3655aab90dc8204f57cc8 Mon Sep 17 00:00:00 2001 From: awatlet <arnaud.watlet@umons.ac.be> Date: Sun, 15 Oct 2023 22:03:30 +0200 Subject: [PATCH] Adds pwr_latency as pwr and tx variables --- ohmpi/hardware_components/mb_2024_0_2.py | 7 +++++-- ohmpi/hardware_components/pwr_dps5005.py | 6 ++++-- ohmpi/hardware_system.py | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ohmpi/hardware_components/mb_2024_0_2.py b/ohmpi/hardware_components/mb_2024_0_2.py index 5f8f4fb1..7fde18bb 100644 --- a/ohmpi/hardware_components/mb_2024_0_2.py +++ b/ohmpi/hardware_components/mb_2024_0_2.py @@ -34,6 +34,7 @@ SPECS = {'rx': {'model': {'default': os.path.basename(__file__).rstrip('.py')}, 'r_shunt': {'min': 0., 'default': 2.}, 'activation_delay': {'default': 0.010}, # Max turn on time of OMRON G5LE-1 5VDC relays 'release_delay': {'default': 0.005}, # Max turn off time of OMRON G5LE-1 5VDC relays = 1ms + 'pwr_latency': {'default': 4.} }} # TODO: move low_battery spec in pwr @@ -76,6 +77,8 @@ class Tx(Tx_mb_2023): super().__init__(**kwargs) if not subclass_init: self.exec_logger.event(f'{self.model}\ttx_init\tbegin\t{datetime.datetime.utcnow()}') + self._pwr_latency = kwargs['pwr_latency'] + # Initialize LEDs self.pin4 = self.mcp_board.get_pin(4) # Ohmpi_run self.pin4.direction = Direction.OUTPUT @@ -104,7 +107,7 @@ class Tx(Tx_mb_2023): return self._pwr_state @pwr_state.setter - def pwr_state(self, state, latency=4.): + def pwr_state(self, state): """Switches pwr on or off. Parameters @@ -117,7 +120,7 @@ class Tx(Tx_mb_2023): self.pin3.value = True self.exec_logger.debug(f'Switching DPS on') self._pwr_state = 'on' - time.sleep(latency) # from pwr specs + time.sleep(self._pwr_latency) # from pwr specs elif state == 'off': self.pin2.value = False self.pin3.value = False diff --git a/ohmpi/hardware_components/pwr_dps5005.py b/ohmpi/hardware_components/pwr_dps5005.py index 691fc396..04f077ee 100644 --- a/ohmpi/hardware_components/pwr_dps5005.py +++ b/ohmpi/hardware_components/pwr_dps5005.py @@ -14,6 +14,7 @@ SPECS = {'model': {'default': os.path.basename(__file__).rstrip('.py')}, 'current_max': {'default': 100.}, 'current_adjustable': {'default': False}, 'voltage_adjustable': {'default': True} + 'pwr_latency':{'default': .3} } # TODO: Complete this code... handle modbus connection @@ -41,6 +42,7 @@ class Pwr(PwrAbstract): self.current_adjustable = False self._current = np.nan self._pwr_state = 'off' + self._pwr_latency = kwargs['pwr_latency'] if not subclass_init: self.exec_logger.event(f'{self.model}\tpwr_init\tend\t{datetime.datetime.utcnow()}') @@ -82,7 +84,7 @@ class Pwr(PwrAbstract): return self._pwr_state @pwr_state.setter - def pwr_state(self, state, latency=.3): + def pwr_state(self, state): """Switches pwr on or off. Parameters @@ -94,7 +96,7 @@ class Pwr(PwrAbstract): self.connection.write_register(0x09, 1) self._pwr_state = 'on' self.exec_logger.debug(f'{self.model} is on') - time.sleep(latency) # from pwr specs + time.sleep(self._pwr_latency) # from pwr specs elif state == 'off': self.connection.write_register(0x09, 0) diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 991035c7..214b55d4 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -436,6 +436,7 @@ class OhmPiHardware: self.tx.pwr.pwr_state = 'off' if switch_tx_pwr_off: self.tx.pwr_state = 'off' + def _vab_pulse(self, vab=None, duration=1., sampling_rate=None, polarity=1, append=False): """ Gets VMN and IAB from a single voltage pulse """ -- GitLab