Commit 34627e51 authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Investigates reading times

Showing with 16 additions and 5 deletions
+16 -5
......@@ -51,6 +51,10 @@ class PwrAbstract(ABC):
self._current_adjustable = kwargs.pop('current_adjustable', False)
self._current = np.nan
self._state = 'off'
self._current_min = kwargs.pop('current_min', 0.)
self._current_max = kwargs.pop('current_max', 0.)
self._current_min = kwargs.pop('voltage_min', 0.)
self._voltage_max = kwargs.pop('voltage_max', 0.)
@property
@abstractmethod
......@@ -63,6 +67,7 @@ class PwrAbstract(ABC):
def current(self, value, **kwargs):
# add actions to set the DPS current
pass
@abstractmethod
def turn_off(self):
self.exec_logger.debug(f'Switching {self.board_name} off')
......@@ -86,6 +91,7 @@ class PwrAbstract(ABC):
if not self.voltage_adjustable:
self.exec_logger.warning(f'Voltage cannot be set on {self.board_name}...')
else:
assert self._voltage_min < value < self._voltage_max
# add actions to set the DPS voltage
self._voltage = value
......@@ -211,6 +217,7 @@ class MuxAbstract(ABC):
time.sleep(activation_time)
self.exec_logger.debug('Test finished.')
class TxAbstract(ABC):
def __init__(self, **kwargs):
self.board_name = kwargs.pop('board_name', 'unknown TX hardware')
......@@ -266,6 +273,7 @@ class TxAbstract(ABC):
@inj_time.setter
def inj_time(self, value):
assert isinstance(value, float)
assert value > 0.
self._inj_time = value
@property
......
from ohmpi.ohmpi.config import HARDWARE_CONFIG
from ohmpi.config import HARDWARE_CONFIG
import os
from ohmpi.hardware_components import MuxAbstract
MUX_CONFIG = HARDWARE_CONFIG['mux'].pop('default', {})
class Mux(MuxAbstract):
def __init__(self, **kwargs):
kwargs.update({'board_name': os.path.basename(__file__).rstrip('.py')})
......
import importlib
from ohmpi.ohmpi.config import HARDWARE_CONFIG
from ohmpi.config import HARDWARE_CONFIG
import adafruit_ads1x15.ads1115 as ads # noqa
from adafruit_ads1x15.analog_in import AnalogIn # noqa
from adafruit_mcp230xx.mcp23008 import MCP23008 # noqa
......
......@@ -2,6 +2,7 @@ from ohmpi.hardware_components.abstract_hardware_components import PwrAbstract
import numpy as np
import os
class Pwr(PwrAbstract):
def __init__(self, **kwargs):
kwargs.update({'board_name': os.path.basename(__file__).rstrip('.py')})
......@@ -11,7 +12,7 @@ class Pwr(PwrAbstract):
self._voltage = voltage
self._current_adjustable = False
self._current = np.nan
self._state = 'on'
@property
def current(self):
......
......@@ -162,7 +162,7 @@ class OhmPiHardware:
else:
_readings = self.readings.tolist()
sample = 0
self.tx_sync.wait()
self.tx_sync.wait() #
if not append or self._start_time is None:
self._start_time = datetime.datetime.utcnow()
while self.tx_sync.is_set():
......@@ -171,7 +171,8 @@ class OhmPiHardware:
self.rx.voltage])
sample += 1
sleep_time = self._start_time + datetime.timedelta(seconds=sample * sampling_rate / 1000) - lap
time.sleep(np.max([0.001, sleep_time.total_seconds()]))
time.sleep(np.max([0., sleep_time.total_seconds()])) # TODO set readings to nan if sleep time <0 and skip the sample (sample +=1)
self.exec_logger.warning(f'pulse {self._pulse}: elapsed time {(lap-self._start_time).total_seconds()} s') # TODO: Set to debug level
self.readings = np.array(_readings)
self._pulse += 1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment