Commit 44387e59 authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Improve code consistency

Showing with 12 additions and 12 deletions
+12 -12
...@@ -7,9 +7,9 @@ import time ...@@ -7,9 +7,9 @@ import time
import logging import logging
from ohmpi.config import HARDWARE_CONFIG from ohmpi.config import HARDWARE_CONFIG
stand_alone = False # True stand_alone = True
part_of_hardware_system = False part_of_hardware_system = False
within_ohmpi = True within_ohmpi = False
# Stand alone # Stand alone
if stand_alone: if stand_alone:
......
...@@ -74,7 +74,7 @@ class Tx(TxAbstract): ...@@ -74,7 +74,7 @@ class Tx(TxAbstract):
subclass_init = True subclass_init = True
super().__init__(**kwargs) super().__init__(**kwargs)
if not subclass_init: if not subclass_init:
self.exec_logger.event(f'{self.model}\ttx_init\tstart\t{datetime.datetime.utcnow()}') self.exec_logger.event(f'{self.model}\ttx_init\tbegin\t{datetime.datetime.utcnow()}')
assert isinstance(self.connection, I2C) assert isinstance(self.connection, I2C)
kwargs.update({'pwr': kwargs.pop('pwr', SPECS['tx']['compatible_power_sources']['default'])}) kwargs.update({'pwr': kwargs.pop('pwr', SPECS['tx']['compatible_power_sources']['default'])})
if (kwargs['pwr'] != SPECS['tx']['compatible_power_sources']['default'] if (kwargs['pwr'] != SPECS['tx']['compatible_power_sources']['default']
...@@ -221,11 +221,9 @@ class Rx(RxAbstract): ...@@ -221,11 +221,9 @@ class Rx(RxAbstract):
subclass_init = True subclass_init = True
super().__init__(**kwargs) super().__init__(**kwargs)
if not subclass_init: if not subclass_init:
self.exec_logger.event(f'{self.model}\trx_init\tstart\t{datetime.datetime.utcnow()}') self.exec_logger.event(f'{self.model}\trx_init\tbegin\t{datetime.datetime.utcnow()}')
assert isinstance(self.connection, I2C) assert isinstance(self.connection, I2C)
self.exec_logger.event(f'{self.model}\trx_init\tbegin\t{datetime.datetime.utcnow()}')
# ADS1115 for voltage measurement (MN) # ADS1115 for voltage measurement (MN)
self._ads_voltage_address = kwargs['ads_address'] self._ads_voltage_address = kwargs['ads_address']
self._adc_gain = 2/3 self._adc_gain = 2/3
......
...@@ -74,7 +74,7 @@ class Tx(Tx_mb_2023): ...@@ -74,7 +74,7 @@ class Tx(Tx_mb_2023):
subclass_init = True subclass_init = True
super().__init__(**kwargs) super().__init__(**kwargs)
if not subclass_init: if not subclass_init:
self.exec_logger.event(f'{self.model}\ttx_init\tstart\t{datetime.datetime.utcnow()}') self.exec_logger.event(f'{self.model}\ttx_init\tbegin\t{datetime.datetime.utcnow()}')
# Initialize LEDs # Initialize LEDs
self.pin4 = self.mcp_board.get_pin(4) # Ohmpi_run self.pin4 = self.mcp_board.get_pin(4) # Ohmpi_run
self.pin4.direction = Direction.OUTPUT self.pin4.direction = Direction.OUTPUT
...@@ -102,7 +102,7 @@ class Rx(Rx_mb_2023): ...@@ -102,7 +102,7 @@ class Rx(Rx_mb_2023):
subclass_init = True subclass_init = True
super().__init__(**kwargs) super().__init__(**kwargs)
if not subclass_init: if not subclass_init:
self.exec_logger.event(f'{self.model}\trx_init\tstart\t{datetime.datetime.utcnow()}') self.exec_logger.event(f'{self.model}\trx_init\tbegin\t{datetime.datetime.utcnow()}')
# I2C connection to MCP23008, for voltage # I2C connection to MCP23008, for voltage
self.mcp_board = MCP23008(self.connection, address=kwargs['mcp_address']) self.mcp_board = MCP23008(self.connection, address=kwargs['mcp_address'])
# ADS1115 for voltage measurement (MN) # ADS1115 for voltage measurement (MN)
......
...@@ -68,7 +68,7 @@ class Mux(MuxAbstract): ...@@ -68,7 +68,7 @@ class Mux(MuxAbstract):
kwargs.update({'cabling': kwargs.pop('cabling', default_mux_cabling)}) kwargs.update({'cabling': kwargs.pop('cabling', default_mux_cabling)})
super().__init__(**kwargs) super().__init__(**kwargs)
if not subclass_init: if not subclass_init:
self.exec_logger.event(f'{self.model}{self.board_id}\tmux_init\tstart\t{datetime.datetime.utcnow()}') self.exec_logger.event(f'{self.model}{self.board_id}\tmux_init\tbegin\t{datetime.datetime.utcnow()}')
assert isinstance(self.connection, I2C) assert isinstance(self.connection, I2C)
self.exec_logger.debug(f'configuration: {kwargs}') self.exec_logger.debug(f'configuration: {kwargs}')
self._roles = kwargs.pop('roles', None) self._roles = kwargs.pop('roles', None)
......
...@@ -66,7 +66,7 @@ class Mux(MuxAbstract): ...@@ -66,7 +66,7 @@ class Mux(MuxAbstract):
subclass_init = True subclass_init = True
super().__init__(**kwargs) super().__init__(**kwargs)
if not subclass_init: if not subclass_init:
self.exec_logger.event(f'{self.model}{self.board_id}\tmux_init\tstart\t{datetime.datetime.utcnow()}') self.exec_logger.event(f'{self.model}{self.board_id}\tmux_init\tbegin\t{datetime.datetime.utcnow()}')
assert isinstance(self.connection, I2C) assert isinstance(self.connection, I2C)
self.exec_logger.debug(f'configuration: {kwargs}') self.exec_logger.debug(f'configuration: {kwargs}')
tca_address = kwargs.pop('tca_address', None) tca_address = kwargs.pop('tca_address', None)
......
...@@ -5,7 +5,7 @@ import os ...@@ -5,7 +5,7 @@ import os
class Pwr(PwrAbstract): class Pwr(PwrAbstract):
def __init__(self, **kwargs): def __init__(self, **kwargs):
kwargs.update({'board_name': os.path.basename(__file__).rstrip('.py')}) kwargs.update({'model': os.path.basename(__file__).rstrip('.py')})
voltage = kwargs.pop('voltage', 12.) voltage = kwargs.pop('voltage', 12.)
super().__init__(**kwargs) super().__init__(**kwargs)
self.voltage_adjustable = False self.voltage_adjustable = False
......
...@@ -11,6 +11,8 @@ SPECS = {'model': {'default': os.path.basename(__file__).rstrip('.py')}, ...@@ -11,6 +11,8 @@ SPECS = {'model': {'default': os.path.basename(__file__).rstrip('.py')},
'current_max': {'default': 100.}, 'current_max': {'default': 100.},
} }
# TODO: Complete this code... handle modbus connection
class Pwr(PwrAbstract): class Pwr(PwrAbstract):
def __init__(self, **kwargs): def __init__(self, **kwargs):
...@@ -20,9 +22,9 @@ class Pwr(PwrAbstract): ...@@ -20,9 +22,9 @@ class Pwr(PwrAbstract):
subclass_init = False subclass_init = False
else: else:
subclass_init = True subclass_init = True
super().__init__(**kwargs)
if not subclass_init: if not subclass_init:
self.exec_logger.event(f'{self.model}\tpwr_init\tstart\t{datetime.datetime.utcnow()}') self.exec_logger.event(f'{self.model}\tpwr_init\tstart\t{datetime.datetime.utcnow()}')
super().__init__(**kwargs)
# if a controller is passed in kwargs, it will be instantiated # if a controller is passed in kwargs, it will be instantiated
#if self.ctl is None: #if self.ctl is None:
# self.ctl = ctl_module.Ctl(**CTL_CONFIG) # self.ctl = ctl_module.Ctl(**CTL_CONFIG)
......
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