From de4303ddbd05b0a5eba766d9fd34b3292e9e1747 Mon Sep 17 00:00:00 2001 From: su530201 <olivier.kaufmann@umons.ac.be> Date: Thu, 8 Jun 2023 11:46:48 +0200 Subject: [PATCH] Tries to fix "dict has no attr barrier" error --- configs/config_mb_2023_2_mux_2024.py | 48 +++++++++++++++------------- ohmpi/hardware_system.py | 3 +- ohmpi/ohmpi.py | 7 ++-- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/configs/config_mb_2023_2_mux_2024.py b/configs/config_mb_2023_2_mux_2024.py index c2c75104..721b70af 100644 --- a/configs/config_mb_2023_2_mux_2024.py +++ b/configs/config_mb_2023_2_mux_2024.py @@ -20,13 +20,13 @@ OHMPI_CONFIG = { HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi_i2c'}, 'pwr': {'model': 'pwr_batt', 'voltage': 12.}, - 'tx' : {'model': 'ohmpi_card_3_15', + 'tx': {'model': 'ohmpi_card_3_15', 'mcp_board_address': 0x20, 'voltage_max': 12., # Maximum voltage supported by the TX board [V] 'current_max': 4800 / 50 / 2, # Maximum current supported by the TX board [mA] 'r_shunt': 2 # Shunt resistance in Ohms }, - 'rx' : {'model': 'ohmpi_card_3_15', + 'rx': {'model': 'ohmpi_card_3_15', 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V 'sampling_rate': 10., # ms 'nb_samples': 20, # Max value 10 # was named integer before... @@ -34,27 +34,29 @@ HARDWARE_CONFIG = { '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... - {'boards': - {'mux_1': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', - '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_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'}, - 'channels': {(i, j): ('mux_1', i) for j in ['A', 'B', 'M', 'N'] for i in range(1,9)}, - 'voltage_max': 12.}, - 'mux_2': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', - 'tca_address': None, - 'tca_channel': 0, - 'mcp_0': '0x23', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... - 'mcp_1': '0x24', # 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'}, - 'channels': {(i+8, j): ('mux_2', i) for j in ['A', 'B', 'M', 'N'] for i in range(1,9)}, - 'voltage_max': 12.} - }, - 'default': {'voltage_max': 100., 'current_max': 3.}} + {'boards': + {'mux_1': + {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + '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_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'}, + 'channels': {(i, j): ('mux_1', i) for j in ['A', 'B', 'M', 'N'] for i in range(1,9)}, + 'voltage_max': 12.}, + 'mux_2': + {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + 'tca_address': None, + 'tca_channel': 0, + 'mcp_0': '0x23', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... + 'mcp_1': '0x24', # 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'}, + 'channels': {(i+8, j): ('mux_2', i) for j in ['A', 'B', 'M', 'N'] for i in range(1,9)}, + 'voltage_max': 12.} + }, + 'default': {'voltage_max': 100., + 'current_max': 3.} + } } # SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 32dabb01..209ccb76 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -23,6 +23,7 @@ for mux_id, mux_config in HARDWARE_CONFIG['mux']['boards'].items(): MUX_CONFIG[mux_id] = mux_module.MUX_CONFIG MUX_CONFIG[mux_id].update(mux_config) MUX_CONFIG[mux_id].update({'id': mux_id}) + MUX_CONFIG[mux_id].update({'constructor': mux_module.Mux}) mux_boards.append(mux_id) TX_CONFIG = tx_module.TX_CONFIG @@ -77,7 +78,7 @@ class OhmPiHardware: self.tx = kwargs.pop('tx', tx_module.Tx(**HARDWARE_CONFIG['tx'])) if isinstance(self.tx, dict): self.tx = tx_module.Tx(**self.tx) - print(f'tx: {self.tx}, type: {type(self.tx)}') # TODO: Delete me! + print(f'tx.Ctl: {self.tx.ctl}, type: {type(self.tx)}') # TODO: Delete me! self.tx.pwr = self.pwr self._cabling = kwargs.pop('cabling', {}) diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py index ead54bc0..57d9db7a 100644 --- a/ohmpi/ohmpi.py +++ b/ohmpi/ohmpi.py @@ -77,9 +77,10 @@ class OhmPi(object): print(msg) # read in hardware parameters (config.py) - HARDWARE_CONFIG.update({'exec_logger': self.exec_logger, 'data_logger': self.data_logger, - 'soh_logger': self.soh_logger}) - self._hw = OhmPiHardware(**HARDWARE_CONFIG) + # HARDWARE_CONFIG.update({'exec_logger': self.exec_logger, 'data_logger': self.data_logger, + # 'soh_logger': self.soh_logger}) + self._hw = OhmPiHardware(**{'exec_logger': self.exec_logger, 'data_logger': self.data_logger, + 'soh_logger': self.soh_logger}) self.exec_logger.info('Hardware configured...') # default acquisition settings self.settings = { -- GitLab