diff --git a/configs/config_mb_2023_3_mux_2024.py b/configs/config_mb_2023_3_mux_2024.py index 93622b6dfab04f84e7f9b515c1ef0de970eaeeec..27e3e534b157bc062bccf0bd8e1db8749bab849f 100644 --- a/configs/config_mb_2023_3_mux_2024.py +++ b/configs/config_mb_2023_3_mux_2024.py @@ -23,36 +23,39 @@ HARDWARE_CONFIG = { 'tx': {'model': 'mb_2023_0_X', 'voltage_max': 12., # Maximum voltage supported by the TX board [V] 'adc_voltage_max': 4800., # Maximum voltage read by the current ADC on the TX board [mA] - 'r_shunt': 2. # Shunt resistance in Ohms + 'r_shunt': 2., # Shunt resistance in Ohms + 'interface_name': 'i2c', }, 'rx': {'model': 'mb_2023_0_X', - 'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V - 'sampling_rate': 50. # number of samples per second + 'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V + 'sampling_rate': 50., # number of samples per second + 'interface_name': 'i2c', }, - 'mux': # default properties are system properties that will be - # overwritten by board properties defined at the board level within the board model file - # both will be overwritten by properties specified in the board dict below. Use with caution... + 'mux': # default properties given in config are system properties that will be + # overwritten by properties defined in each the board dict below. + # if defined in board specs, values out of specs will be bounded to remain in specs + # omitted properties in config will be set to board specs default values if they exist {'boards': {'mux_02': - {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', 'tca_address': None, 'tca_channel': 0, - 'mcp_0': '0x22', # TODO: Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... + 'mcp_0': '0x22', # TODO: Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user...) 'mcp_1': '0x23', # TODO: Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user...) 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'cabling': {(i+8, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'voltage_max': 12.}, 'mux_00': - {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', 'tca_address': None, 'tca_channel': 0, - 'mcp_0': '0x24', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... + 'mcp_0': '0x24', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user...) 'mcp_1': '0x25', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user...) 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'cabling': {(i+16, j): ('mux_00', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'voltage_max': 12.}, 'mux_04': - {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', 'tca_address': None, 'tca_channel': 0, 'mcp_0': '0x26', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... diff --git a/ohmpi/hardware_components/mux_2024_0_X.py b/ohmpi/hardware_components/mux_2024_0_X.py index 48fed4101b90252702ce5430689585ea7d392a81..54158a4344140b76f66fdb7c30bbed630b57c36f 100644 --- a/ohmpi/hardware_components/mux_2024_0_X.py +++ b/ohmpi/hardware_components/mux_2024_0_X.py @@ -5,7 +5,7 @@ from ohmpi.hardware_components import MuxAbstract import adafruit_tca9548a # noqa from adafruit_mcp230xx.mcp23017 import MCP23017 # noqa from digitalio import Direction # noqa -from busio import I2C +from busio import I2C # noqa # import time # hardware characteristics and limitations diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 841f42a0428df029a10e7a3090c0e36740973f52..8ad5a27c6d3974d47e4732eacad9ef963e710f41 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -28,14 +28,12 @@ for k, v in MUX_CONFIG.items(): for k2, v2 in MUX_DEFAULT.items(): MUX_CONFIG[k].update({k2: MUX_CONFIG[k].pop(k2, v2)}) -TX_CONFIG = HARDWARE_CONFIG['tx'] # NOTE: is TX_CONFIG needed or should we use HARDWARE_CONFIX['tx']? -print(HARDWARE_CONFIG['tx']) +TX_CONFIG = HARDWARE_CONFIG['tx'] for k, v in tx_module.SPECS['tx'].items(): try: TX_CONFIG.update({k: TX_CONFIG.pop(k, v['default'])}) except: print(f'Cannot set value {v} in TX_CONFIG[{k}]') -print(HARDWARE_CONFIG['tx']) RX_CONFIG = HARDWARE_CONFIG['rx'] for k, v in rx_module.SPECS['rx'].items(): @@ -80,7 +78,11 @@ class OhmPiHardware: HARDWARE_CONFIG['rx'].pop('model') HARDWARE_CONFIG['rx'].update(**HARDWARE_CONFIG['rx']) - HARDWARE_CONFIG['rx'].update({'ctl': HARDWARE_CONFIG['rx'].pop('ctl', self.ctl)}) + HARDWARE_CONFIG['rx'].update({'connection': HARDWARE_CONFIG['rx'].pop('connection', + self.ctl.interfaces[ + HARDWARE_CONFIG['rx'].pop( + 'interface_name', 'i2c')])}) + #HARDWARE_CONFIG['rx'].update({'connection': HARDWARE_CONFIG['rx'].pop('connection', self.ctl)}) if isinstance(HARDWARE_CONFIG['rx']['ctl'], dict): ctl_mod = HARDWARE_CONFIG['rx']['ctl'].pop('model', self.ctl) if isinstance(ctl_mod, str): @@ -103,7 +105,12 @@ class OhmPiHardware: HARDWARE_CONFIG['tx'].pop('model') HARDWARE_CONFIG['tx'].update(**HARDWARE_CONFIG['tx']) HARDWARE_CONFIG['tx'].update({'tx_sync': self.tx_sync}) - HARDWARE_CONFIG['tx'].update({'ctl': self.ctl}) + #HARDWARE_CONFIG['tx'].update({'ctl': self.ctl}) + HARDWARE_CONFIG['tx'].update({'connection': HARDWARE_CONFIG['tx'].pop('connection', + self.ctl.interfaces[ + HARDWARE_CONFIG['tx'].pop( + 'interface_name', 'i2c')])}) + HARDWARE_CONFIG['tx'].update({'exec_logger': self.exec_logger, 'data_logger': self.data_logger, 'soh_logger': self.soh_logger}) self.tx = kwargs.pop('tx', tx_module.Tx(**HARDWARE_CONFIG['tx'])) @@ -119,23 +126,16 @@ class OhmPiHardware: mux_config.update({'ctl': mux_config.pop('ctl', self.ctl)}) mux_module = importlib.import_module(f'ohmpi.hardware_components.{mux_config["model"]}') - if isinstance(mux_config['ctl'], dict): ### TODO: is this needed? + if isinstance(mux_config['ctl'], dict): mux_ctl_module = importlib.import_module(f'ohmpi.hardware_components.{mux_config["ctl"]["model"]}') mux_config['ctl'] = mux_ctl_module.Ctl(**mux_config['ctl']) # (**self.ctl) assert issubclass(type(mux_config['ctl']), CtlAbstract) - mux_config.update({ - mux_config.pop('connection', mux_config['ctl'].interfaces[mux_config.pop('interface_name', 'i2c')])}) + mux_config.update({mux_config.pop('connection', + mux_config['ctl'].interfaces[mux_config.pop('interface_name', 'i2c')])}) mux_config['id'] = mux_id self.mux_boards[mux_id] = mux_module.Mux(**mux_config) - # self.mux_boards = kwargs.pop('mux', {'mux_1': mux_module.Mux(id='mux_1', - # exec_logger=self.exec_logger, - # data_logger=self.data_logger, - # soh_logger=self.soh_logger, - # ctl=self.ctl, - # cabling=self._cabling)}) - self.mux_barrier = Barrier(len(self.mux_boards) + 1) self._cabling = {} for mux_id, mux in self.mux_boards.items():