From 96ee691f5103370bded89796e94b61a473f044a3 Mon Sep 17 00:00:00 2001 From: su530201 <olivier.kaufmann@umons.ac.be> Date: Wed, 11 Oct 2023 00:24:33 +0200 Subject: [PATCH] Improve code consistency --- ohmpi/hardware_components/pwr_batt.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ohmpi/hardware_components/pwr_batt.py b/ohmpi/hardware_components/pwr_batt.py index c949675b..205762f2 100644 --- a/ohmpi/hardware_components/pwr_batt.py +++ b/ohmpi/hardware_components/pwr_batt.py @@ -1,16 +1,27 @@ from ohmpi.hardware_components.abstract_hardware_components import PwrAbstract import numpy as np import os +from ohmpi.utils import enforce_specs + +# hardware characteristics and limitations +SPECS = {'model': {'default': os.path.basename(__file__).rstrip('.py')}, + 'voltage': {'default': 12., 'max': 12., 'min': 12.}, + } class Pwr(PwrAbstract): def __init__(self, **kwargs): - kwargs.update({'model': os.path.basename(__file__).rstrip('.py')}) + if 'model' not in kwargs.keys(): + for key in SPECS.keys(): + kwargs = enforce_specs(kwargs, SPECS, key) + subclass_init = False + else: + subclass_init = True voltage = kwargs.pop('voltage', 12.) super().__init__(**kwargs) self.voltage_adjustable = False self._voltage = voltage - self._current_adjustable = False + self.current_adjustable = False self._current = np.nan self._state = 'on' -- GitLab