From e4d192f05b6e816ceea53ef6371a5fa08a2962ba Mon Sep 17 00:00:00 2001 From: su530201 <olivier.kaufmann@umons.ac.be> Date: Fri, 5 Apr 2024 18:10:30 +0200 Subject: [PATCH] Updates generate_preset_configs, setup_config and configs using mb_2024_1_X --- ..._mb_2024_0_2__1_mux_2024_4roles_dph5005.py | 2 +- ..._mb_2024_0_2__2_mux_2024_2roles_dph5005.py | 2 +- ..._mb_2024_0_2__2_mux_2024_4roles_dph5005.py | 2 +- ..._mb_2024_0_2__3_mux_2024_4roles_dph5005.py | 2 +- .../config_mb_2024_0_2__4_mux_2023_dph5005.py | 2 +- ..._mb_2024_0_2__4_mux_2024_2roles_dph5005.py | 2 +- ..._mb_2024_0_2__4_mux_2024_4roles_dph5005.py | 2 +- configs/config_mb_2024_0_2_dph5005.py | 2 +- configs/config_mb_2024_1_X.py | 116 +++++++++++++ .../config_mb_2024_1_X__1_mux_2024_4roles.py | 127 +++++++++++++++ ..._mb_2024_1_X__1_mux_2024_4roles_dph5005.py | 127 +++++++++++++++ .../config_mb_2024_1_X__2_mux_2024_2roles.py | 137 ++++++++++++++++ ..._mb_2024_1_X__2_mux_2024_2roles_dph5005.py | 137 ++++++++++++++++ .../config_mb_2024_1_X__2_mux_2024_4roles.py | 135 +++++++++++++++ ..._mb_2024_1_X__2_mux_2024_4roles_dph5005.py | 135 +++++++++++++++ .../config_mb_2024_1_X__3_mux_2024_4roles.py | 143 ++++++++++++++++ ..._mb_2024_1_X__3_mux_2024_4roles_dph5005.py | 143 ++++++++++++++++ configs/config_mb_2024_1_X__4_mux_2023.py | 143 ++++++++++++++++ .../config_mb_2024_1_X__4_mux_2023_dph5005.py | 143 ++++++++++++++++ .../config_mb_2024_1_X__4_mux_2024_2roles.py | 154 ++++++++++++++++++ ..._mb_2024_1_X__4_mux_2024_2roles_dph5005.py | 154 ++++++++++++++++++ .../config_mb_2024_1_X__4_mux_2024_4roles.py | 151 +++++++++++++++++ ..._mb_2024_1_X__4_mux_2024_4roles_dph5005.py | 151 +++++++++++++++++ configs/config_mb_2024_1_X_dph5005.py | 116 +++++++++++++ ohmpi/hardware_components/mb_2024_1_X.py | 2 +- ohmpi/utils.py | 37 ++++- setup_config.py | 22 ++- 27 files changed, 2269 insertions(+), 20 deletions(-) create mode 100644 configs/config_mb_2024_1_X.py create mode 100644 configs/config_mb_2024_1_X__1_mux_2024_4roles.py create mode 100644 configs/config_mb_2024_1_X__1_mux_2024_4roles_dph5005.py create mode 100644 configs/config_mb_2024_1_X__2_mux_2024_2roles.py create mode 100644 configs/config_mb_2024_1_X__2_mux_2024_2roles_dph5005.py create mode 100644 configs/config_mb_2024_1_X__2_mux_2024_4roles.py create mode 100644 configs/config_mb_2024_1_X__2_mux_2024_4roles_dph5005.py create mode 100644 configs/config_mb_2024_1_X__3_mux_2024_4roles.py create mode 100644 configs/config_mb_2024_1_X__3_mux_2024_4roles_dph5005.py create mode 100644 configs/config_mb_2024_1_X__4_mux_2023.py create mode 100644 configs/config_mb_2024_1_X__4_mux_2023_dph5005.py create mode 100644 configs/config_mb_2024_1_X__4_mux_2024_2roles.py create mode 100644 configs/config_mb_2024_1_X__4_mux_2024_2roles_dph5005.py create mode 100644 configs/config_mb_2024_1_X__4_mux_2024_4roles.py create mode 100644 configs/config_mb_2024_1_X__4_mux_2024_4roles_dph5005.py create mode 100644 configs/config_mb_2024_1_X_dph5005.py diff --git a/configs/config_mb_2024_0_2__1_mux_2024_4roles_dph5005.py b/configs/config_mb_2024_0_2__1_mux_2024_4roles_dph5005.py index c3fb537e..0842b8ef 100644 --- a/configs/config_mb_2024_0_2__1_mux_2024_4roles_dph5005.py +++ b/configs/config_mb_2024_0_2__1_mux_2024_4roles_dph5005.py @@ -25,7 +25,7 @@ r_shunt = 2. HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi'}, - 'pwr': {'model': 'pwr_dph5005', 'voltage': 3., 'interface_name': 'modbus'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, 'tx': {'model': 'mb_2024_0_2', 'voltage_max': 50., # Maximum voltage supported by the TX board [V] 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] diff --git a/configs/config_mb_2024_0_2__2_mux_2024_2roles_dph5005.py b/configs/config_mb_2024_0_2__2_mux_2024_2roles_dph5005.py index 611b6280..a1921a23 100644 --- a/configs/config_mb_2024_0_2__2_mux_2024_2roles_dph5005.py +++ b/configs/config_mb_2024_0_2__2_mux_2024_2roles_dph5005.py @@ -25,7 +25,7 @@ r_shunt = 2. HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi'}, - 'pwr': {'model': 'pwr_dph5005', 'voltage': 3., 'interface_name': 'modbus'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, 'tx': {'model': 'mb_2024_0_2', 'voltage_max': 50., # Maximum voltage supported by the TX board [V] 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] diff --git a/configs/config_mb_2024_0_2__2_mux_2024_4roles_dph5005.py b/configs/config_mb_2024_0_2__2_mux_2024_4roles_dph5005.py index ab63fb42..c4e013e1 100644 --- a/configs/config_mb_2024_0_2__2_mux_2024_4roles_dph5005.py +++ b/configs/config_mb_2024_0_2__2_mux_2024_4roles_dph5005.py @@ -25,7 +25,7 @@ r_shunt = 2. HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi'}, - 'pwr': {'model': 'pwr_dph5005', 'voltage': 3., 'interface_name': 'modbus'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, 'tx': {'model': 'mb_2024_0_2', 'voltage_max': 50., # Maximum voltage supported by the TX board [V] 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] diff --git a/configs/config_mb_2024_0_2__3_mux_2024_4roles_dph5005.py b/configs/config_mb_2024_0_2__3_mux_2024_4roles_dph5005.py index 04a57854..e0d5ea38 100644 --- a/configs/config_mb_2024_0_2__3_mux_2024_4roles_dph5005.py +++ b/configs/config_mb_2024_0_2__3_mux_2024_4roles_dph5005.py @@ -25,7 +25,7 @@ r_shunt = 2. HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi'}, - 'pwr': {'model': 'pwr_dph5005', 'voltage': 3., 'interface_name': 'modbus'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, 'tx': {'model': 'mb_2024_0_2', 'voltage_max': 50., # Maximum voltage supported by the TX board [V] 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] diff --git a/configs/config_mb_2024_0_2__4_mux_2023_dph5005.py b/configs/config_mb_2024_0_2__4_mux_2023_dph5005.py index 1d2fd7d9..a05c4c6d 100644 --- a/configs/config_mb_2024_0_2__4_mux_2023_dph5005.py +++ b/configs/config_mb_2024_0_2__4_mux_2023_dph5005.py @@ -25,7 +25,7 @@ r_shunt = 2. HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi'}, - 'pwr': {'model': 'pwr_dph5005', 'voltage': 3., 'interface_name': 'modbus'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, 'tx': {'model': 'mb_2024_0_2', 'voltage_max': 50., # Maximum voltage supported by the TX board [V] 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] diff --git a/configs/config_mb_2024_0_2__4_mux_2024_2roles_dph5005.py b/configs/config_mb_2024_0_2__4_mux_2024_2roles_dph5005.py index 72711b9f..ca687bf6 100644 --- a/configs/config_mb_2024_0_2__4_mux_2024_2roles_dph5005.py +++ b/configs/config_mb_2024_0_2__4_mux_2024_2roles_dph5005.py @@ -25,7 +25,7 @@ r_shunt = 2. HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi'}, - 'pwr': {'model': 'pwr_dph5005', 'voltage': 3., 'interface_name': 'modbus'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, 'tx': {'model': 'mb_2024_0_2', 'voltage_max': 50., # Maximum voltage supported by the TX board [V] 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] diff --git a/configs/config_mb_2024_0_2__4_mux_2024_4roles_dph5005.py b/configs/config_mb_2024_0_2__4_mux_2024_4roles_dph5005.py index 34eac8fb..94c4d18d 100644 --- a/configs/config_mb_2024_0_2__4_mux_2024_4roles_dph5005.py +++ b/configs/config_mb_2024_0_2__4_mux_2024_4roles_dph5005.py @@ -25,7 +25,7 @@ r_shunt = 2. HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi'}, - 'pwr': {'model': 'pwr_dph5005', 'voltage': 3., 'interface_name': 'modbus'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, 'tx': {'model': 'mb_2024_0_2', 'voltage_max': 50., # Maximum voltage supported by the TX board [V] 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] diff --git a/configs/config_mb_2024_0_2_dph5005.py b/configs/config_mb_2024_0_2_dph5005.py index bbf1437c..75153676 100644 --- a/configs/config_mb_2024_0_2_dph5005.py +++ b/configs/config_mb_2024_0_2_dph5005.py @@ -25,7 +25,7 @@ r_shunt = 2. HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi'}, - 'pwr': {'model': 'pwr_dph5005', 'voltage': 3., 'interface_name': 'modbus'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, 'tx': {'model': 'mb_2024_0_2', 'voltage_max': 50., # Maximum voltage supported by the TX board [V] 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] diff --git a/configs/config_mb_2024_1_X.py b/configs/config_mb_2024_1_X.py new file mode 100644 index 00000000..014b1257 --- /dev/null +++ b/configs/config_mb_2024_1_X.py @@ -0,0 +1,116 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': {}, + 'default': {} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__1_mux_2024_4roles.py b/configs/config_mb_2024_1_X__1_mux_2024_4roles.py new file mode 100644 index 00000000..6f910345 --- /dev/null +++ b/configs/config_mb_2024_1_X__1_mux_2024_4roles.py @@ -0,0 +1,127 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'electrodes': range(1, 9), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__1_mux_2024_4roles_dph5005.py b/configs/config_mb_2024_1_X__1_mux_2024_4roles_dph5005.py new file mode 100644 index 00000000..06c0d6a6 --- /dev/null +++ b/configs/config_mb_2024_1_X__1_mux_2024_4roles_dph5005.py @@ -0,0 +1,127 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'electrodes': range(1, 9), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__2_mux_2024_2roles.py b/configs/config_mb_2024_1_X__2_mux_2024_2roles.py new file mode 100644 index 00000000..4cfe1ab4 --- /dev/null +++ b/configs/config_mb_2024_1_X__2_mux_2024_2roles.py @@ -0,0 +1,137 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'roles': ['A', 'B'], + 'electrodes': range(1, 17), + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0, + }, + 'mux_02': + {'model': 'mux_2024_0_X', + 'roles': ['M', 'N'], + 'electrodes': range(1, 17), + 'addr1': 'down', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0, + }, + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__2_mux_2024_2roles_dph5005.py b/configs/config_mb_2024_1_X__2_mux_2024_2roles_dph5005.py new file mode 100644 index 00000000..09d7419e --- /dev/null +++ b/configs/config_mb_2024_1_X__2_mux_2024_2roles_dph5005.py @@ -0,0 +1,137 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'roles': ['A', 'B'], + 'electrodes': range(1, 17), + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0, + }, + 'mux_02': + {'model': 'mux_2024_0_X', + 'roles': ['M', 'N'], + 'electrodes': range(1, 17), + 'addr1': 'down', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0, + }, + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__2_mux_2024_4roles.py b/configs/config_mb_2024_1_X__2_mux_2024_4roles.py new file mode 100644 index 00000000..8c2d94ce --- /dev/null +++ b/configs/config_mb_2024_1_X__2_mux_2024_4roles.py @@ -0,0 +1,135 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'electrodes': range(1, 9), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_02': + {'model': 'mux_2024_0_X', + 'electrodes': range(9, 17), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'down', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__2_mux_2024_4roles_dph5005.py b/configs/config_mb_2024_1_X__2_mux_2024_4roles_dph5005.py new file mode 100644 index 00000000..a1f07f1f --- /dev/null +++ b/configs/config_mb_2024_1_X__2_mux_2024_4roles_dph5005.py @@ -0,0 +1,135 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'electrodes': range(1, 9), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_02': + {'model': 'mux_2024_0_X', + 'electrodes': range(9, 17), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'down', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__3_mux_2024_4roles.py b/configs/config_mb_2024_1_X__3_mux_2024_4roles.py new file mode 100644 index 00000000..c1552914 --- /dev/null +++ b/configs/config_mb_2024_1_X__3_mux_2024_4roles.py @@ -0,0 +1,143 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'electrodes': range(1, 9), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_02': + {'model': 'mux_2024_0_X', + 'electrodes': range(9, 17), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'down', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_03': + {'model': 'mux_2024_0_X', + 'electrodes': range(17, 25), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'down', + 'tca_address': None, + 'tca_channel': 0,}, + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__3_mux_2024_4roles_dph5005.py b/configs/config_mb_2024_1_X__3_mux_2024_4roles_dph5005.py new file mode 100644 index 00000000..49355f82 --- /dev/null +++ b/configs/config_mb_2024_1_X__3_mux_2024_4roles_dph5005.py @@ -0,0 +1,143 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'electrodes': range(1, 9), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_02': + {'model': 'mux_2024_0_X', + 'electrodes': range(9, 17), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'down', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_03': + {'model': 'mux_2024_0_X', + 'electrodes': range(17, 25), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'down', + 'tca_address': None, + 'tca_channel': 0,}, + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__4_mux_2023.py b/configs/config_mb_2024_1_X__4_mux_2023.py new file mode 100644 index 00000000..d8fba77a --- /dev/null +++ b/configs/config_mb_2024_1_X__4_mux_2023.py @@ -0,0 +1,143 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_A': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x70, + 'roles': 'A', + 'electrodes': range(1, 65), + }, + 'mux_B': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x71, + 'roles': 'B', + 'electrodes': range(1, 65), + }, + 'mux_M': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x72, + 'roles': 'M', + 'electrodes': range(1, 65), + }, + 'mux_N': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x73, + 'roles': 'N', + 'electrodes': range(1, 65), + } + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__4_mux_2023_dph5005.py b/configs/config_mb_2024_1_X__4_mux_2023_dph5005.py new file mode 100644 index 00000000..3de1a48b --- /dev/null +++ b/configs/config_mb_2024_1_X__4_mux_2023_dph5005.py @@ -0,0 +1,143 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_A': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x70, + 'roles': 'A', + 'electrodes': range(1, 65), + }, + 'mux_B': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x71, + 'roles': 'B', + 'electrodes': range(1, 65), + }, + 'mux_M': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x72, + 'roles': 'M', + 'electrodes': range(1, 65), + }, + 'mux_N': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x73, + 'roles': 'N', + 'electrodes': range(1, 65), + } + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__4_mux_2024_2roles.py b/configs/config_mb_2024_1_X__4_mux_2024_2roles.py new file mode 100644 index 00000000..5a4c490a --- /dev/null +++ b/configs/config_mb_2024_1_X__4_mux_2024_2roles.py @@ -0,0 +1,154 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'roles': ['A', 'B'], + 'electrodes': range(1, 17), + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0, + }, + 'mux_02': + {'model': 'mux_2024_0_X', + 'roles': ['M', 'N'], + 'electrodes': range(1, 17), + 'addr1': 'down', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0, + }, + 'mux_03': + {'model': 'mux_2024_0_X', + 'roles': ['A', 'B'], + 'electrodes': range(17, 33), + 'addr1': 'up', + 'addr2': 'down', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_04': + {'model': 'mux_2024_0_X', + 'roles': ['M', 'N'], + 'electrodes': range(17, 33), + 'addr1': 'down', + 'addr2': 'down', + 'tca_address': None, + 'tca_channel': 0, + } + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__4_mux_2024_2roles_dph5005.py b/configs/config_mb_2024_1_X__4_mux_2024_2roles_dph5005.py new file mode 100644 index 00000000..52598b6c --- /dev/null +++ b/configs/config_mb_2024_1_X__4_mux_2024_2roles_dph5005.py @@ -0,0 +1,154 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'roles': ['A', 'B'], + 'electrodes': range(1, 17), + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0, + }, + 'mux_02': + {'model': 'mux_2024_0_X', + 'roles': ['M', 'N'], + 'electrodes': range(1, 17), + 'addr1': 'down', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0, + }, + 'mux_03': + {'model': 'mux_2024_0_X', + 'roles': ['A', 'B'], + 'electrodes': range(17, 33), + 'addr1': 'up', + 'addr2': 'down', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_04': + {'model': 'mux_2024_0_X', + 'roles': ['M', 'N'], + 'electrodes': range(17, 33), + 'addr1': 'down', + 'addr2': 'down', + 'tca_address': None, + 'tca_channel': 0, + } + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__4_mux_2024_4roles.py b/configs/config_mb_2024_1_X__4_mux_2024_4roles.py new file mode 100644 index 00000000..1fb27eee --- /dev/null +++ b/configs/config_mb_2024_1_X__4_mux_2024_4roles.py @@ -0,0 +1,151 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'electrodes': range(1, 9), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_02': + {'model': 'mux_2024_0_X', + 'electrodes': range(9, 17), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'down', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_03': + {'model': 'mux_2024_0_X', + 'electrodes': range(17, 25), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'down', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_04': + {'model': 'mux_2024_0_X', + 'electrodes': range(25, 33), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'down', + 'addr2': 'down', + 'tca_address': None, + 'tca_channel': 0,}, + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X__4_mux_2024_4roles_dph5005.py b/configs/config_mb_2024_1_X__4_mux_2024_4roles_dph5005.py new file mode 100644 index 00000000..357f11f9 --- /dev/null +++ b/configs/config_mb_2024_1_X__4_mux_2024_4roles_dph5005.py @@ -0,0 +1,151 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': + {'mux_01': + {'model': 'mux_2024_0_X', + 'electrodes': range(1, 9), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_02': + {'model': 'mux_2024_0_X', + 'electrodes': range(9, 17), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'down', + 'addr2': 'up', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_03': + {'model': 'mux_2024_0_X', + 'electrodes': range(17, 25), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'up', + 'addr2': 'down', + 'tca_address': None, + 'tca_channel': 0,}, + 'mux_04': + {'model': 'mux_2024_0_X', + 'electrodes': range(25, 33), + 'roles': ['A', 'B', 'M', 'N'], + 'addr1': 'down', + 'addr2': 'down', + 'tca_address': None, + 'tca_channel': 0,}, + }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/configs/config_mb_2024_1_X_dph5005.py b/configs/config_mb_2024_1_X_dph5005.py new file mode 100644 index 00000000..fdb92dc4 --- /dev/null +++ b/configs/config_mb_2024_1_X_dph5005.py @@ -0,0 +1,116 @@ +import logging +from ohmpi.utils import get_platform +from paho.mqtt.client import MQTTv31 # noqa + +_, on_pi = get_platform() +# DEFINE THE ID OF YOUR OhmPi +ohmpi_id = '0001' if on_pi else 'XXXX' +# DEFINE YOUR MQTT BROKER (DEFAULT: 'localhost') +mqtt_broker = 'localhost' if on_pi else 'NAME_YOUR_BROKER_WHEN_IN_SIMULATION_MODE_HERE' +# DEFINE THE SUFFIX TO ADD TO YOUR LOGS FILES +logging_suffix = '' + +# OhmPi configuration +OHMPI_CONFIG = { + 'id': ohmpi_id, # Unique identifier of the OhmPi board (string) + 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE +} + +r_shunt = 2. + +# default properties of system components that will be +# overwritten by properties defined in each the board dict below. +# if bounds are 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 + +HARDWARE_CONFIG = { + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'}, + 'tx': {'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }, + 'rx': {'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }, + 'mux': {'boards': {}, + 'default': {} + } +} +# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS +# Execution logging configuration +EXEC_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'log_file_logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'exec{logging_suffix}.log', + 'max_bytes': 2097152, + 'backup_count': 30, + 'when': 'd', + 'interval': 1 +} + +# Data logging configuration +DATA_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'file_name': f'data{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# State of Health logging configuration (For a future release) +SOH_LOGGING_CONFIG = { + 'logging_level': logging.INFO, + 'logging_to_console': True, + 'log_file_logging_level': logging.INFO, + 'file_name': f'soh{logging_suffix}.log', + 'max_bytes': 16777216, + 'backup_count': 1024, + 'when': 'd', + 'interval': 1 +} + +# MQTT logging configuration parameters +MQTT_LOGGING_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec', + 'exec_logging_level': EXEC_LOGGING_CONFIG['logging_level'], + 'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data', + 'data_logging_level': DATA_LOGGING_CONFIG['logging_level'], + 'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh', + 'soh_logging_level': SOH_LOGGING_CONFIG['logging_level'] +} + +# MQTT control configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': mqtt_broker, + 'port': 1883, + 'qos': 2, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': {'username': 'mqtt_user', 'password': 'mqtt_password'}, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'{OHMPI_CONFIG["id"]}', + 'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl' +} diff --git a/ohmpi/hardware_components/mb_2024_1_X.py b/ohmpi/hardware_components/mb_2024_1_X.py index 93fd1fd1..fad12d78 100644 --- a/ohmpi/hardware_components/mb_2024_1_X.py +++ b/ohmpi/hardware_components/mb_2024_1_X.py @@ -95,7 +95,6 @@ class Tx(Tx_mb_2024_0_2): def measuring(self, mode="off"): self._measuring = mode - def discharge_pwr(self, latency=None): if self.pwr.voltage_adjustable: if latency is None: @@ -115,6 +114,7 @@ class Tx(Tx_mb_2024_0_2): else: self.exec_logger.debug(f'Pwr discharge not supported by {self.pwr.model}') + class Rx(Rx_mb_2024_0_2): """RX Class""" def __init__(self, **kwargs): diff --git a/ohmpi/utils.py b/ohmpi/utils.py index 6b0d061b..c784e81d 100644 --- a/ohmpi/utils.py +++ b/ohmpi/utils.py @@ -189,7 +189,21 @@ def generate_preset_configs(configs_to_generate=None): 'config_mb_2024_0_2__4_mux_2024_4roles.py', 'config_mb_2024_0_2__4_mux_2024_4roles_dph5005.py', 'config_mb_2024_0_2__4_mux_2024_2roles.py', - 'config_mb_2024_0_2__4_mux_2024_2roles_dph5005.py' + 'config_mb_2024_0_2__4_mux_2024_2roles_dph5005.py', + 'config_mb_2024_1_X.py', 'config_mb_2024_1_X_dph5005.py', + 'config_mb_2024_1_X__4_mux_2023.py', 'config_mb_2024_1_X__4_mux_2023_dph5005.py', + 'config_mb_2024_1_X__1_mux_2024_4roles.py', + 'config_mb_2024_1_X__1_mux_2024_4roles_dph5005.py', + 'config_mb_2024_1_X__2_mux_2024_4roles.py', + 'config_mb_2024_1_X__2_mux_2024_4roles_dph5005.py', + 'config_mb_2024_1_X__2_mux_2024_2roles.py', + 'config_mb_2024_1_X__2_mux_2024_2roles_dph5005.py', + 'config_mb_2024_1_X__3_mux_2024_4roles.py', + 'config_mb_2024_1_X__3_mux_2024_4roles_dph5005.py', + 'config_mb_2024_1_X__4_mux_2024_4roles.py', + 'config_mb_2024_1_X__4_mux_2024_4roles_dph5005.py', + 'config_mb_2024_1_X__4_mux_2024_2roles.py', + 'config_mb_2024_1_X__4_mux_2024_2roles_dph5005.py' ] header = """import logging @@ -223,9 +237,21 @@ HARDWARE_CONFIG = { r_shunt = 2. options = {'pwr': {'battery': """{'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'},""", - 'dph5005': """{'model': 'pwr_dph5005', 'voltage': 3., 'interface_name': 'modbus'},""" + 'dph5005': """{'model': 'pwr_dph5005', 'voltage': 2., 'interface_name': 'modbus'},""" }, - 'mb': {'mb_2024_0_2': {'tx': """{'model': 'mb_2024_0_2', + 'mb': {'mb_2024_1_X': {'tx': """{'model': 'mb_2024_1_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c', + 'vmn_hardware_offset': 2500. + }""", + 'rx': """{'model': 'mb_2024_1_X', + 'latency': 0.010, # latency in seconds in continuous mode + 'sampling_rate': 200, # number of samples per second + 'interface_name': 'i2c', + }"""}, + 'mb_2024_0_2': {'tx': """{'model': 'mb_2024_0_2', 'voltage_max': 50., # Maximum voltage supported by the TX board [V] 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] 'r_shunt': r_shunt, # Shunt resistance in Ohms @@ -351,6 +377,11 @@ HARDWARE_CONFIG = { 'current_max': 3.} }\n}\n""", 'mb_2024_0_2': """\n }, + 'default': {'interface_name': 'i2c_ext', + 'voltage_max': 50., + 'current_max': 3.} + }\n}\n""", + 'mb_2024_1_X': """\n }, 'default': {'interface_name': 'i2c_ext', 'voltage_max': 50., 'current_max': 3.} diff --git a/setup_config.py b/setup_config.py index 764fc1da..6b6d56e4 100644 --- a/setup_config.py +++ b/setup_config.py @@ -5,7 +5,7 @@ check_r_shunt = True check_jumpers_msg = False print('This assistant helps you configure a basic system with a measurement board and from 0 to 4 mux of the same type.' '\nFor more complex configurations including a combination of mux boards with different types or roles, ' - 'please have a look in the configs folder for examples and write your customized configuration file.') + 'please read the docs and explore the configs folder for examples and write your customized configuration file.') mb = None while True: @@ -15,7 +15,7 @@ while True: mb = input('Choose a measurement boards: [v2023/v2024]: ') if mb == 'v2024': - mb = 'v2024_0_2_' + mb = 'v2024_1_X_' # NOTE: used to be set to mb_2024_0_2 by default mux = None while True: @@ -64,9 +64,6 @@ if os.path.exists('configs/' + config): print(f'Your configuration has been set. Your OhmPi id is set to {ohmpi_id}.') print(f'The configuration file is stored in ohmpi/config.py, a backup copy is stored in configs/config_backup.py') print('You should now carefully verify that the configuration file fits your hardware setup.\n') - if pwr != 'battery': - print("It is advised to set a temporary limit on injection voltage while conducting the initial tests." - " To do so, add 'voltage': 2. in the 'pwr' value of the HARDWARE_CONFIG dictionary in ohmpi.config.py") k = 1 if check_r_shunt: print(f'{k}. Check that the value of the shunt resistor value is {r_shunt} Ohm as stated in the config file.') @@ -79,20 +76,29 @@ if os.path.exists('configs/' + config): k += 1 print(f'\n{k}. If you experience problems while starting or operation your OhmPi, analyse the logs and/or try ' f'setting your the loggers "logging_level" to logging.DEBUG.') - k +=1 + k += 1 + print(f'\n{k}. Refer to the documentation for optional tests to conduct before using your instrument.') # print('\n' + '_'*100) # with open('ohmpi/config.py', mode='rt') as f: # for line in f.readlines(): # print(line, end='') # print('\n'+'_'*100) - print('\n'+'*' * 93) + print('\n' + '*' * 93) print('*** You may customize the configuration of your OhmPi by editing the ohmpi/config.py file ***') print('*** The MQTT communication can be encrypted with TLS/SSL but it is not set by default ***') print('*** You should then change the username and password used to connect to the mqtt broker ***') print('*** Make sure you understand what you are doing to avoid damaging to your system ***') print('*' * 93) - + if pwr != 'battery': + print('\n' + '#' * 93) + print('### WARNING - INJECTION VOLTAGE LIMITATION SET! ###') + print('### =========================================== ###') + print('### A limitation has been set on the injection voltage to conduct the initial tests. ###') + print('### To lift this voltage limitation, please edit your ohmpi/config.py (and backup) and ###') + print("### adapt or remove the 'voltage' specification in the 'pwr' ###") + print("### value of the HARDWARE_CONFIG dictionary. ###") + print('\n' + '#' * 93) else: print('The configuration you have selected cannot be set by this tool.\n' 'You probably requested a configuration that makes little sense in most cases.') -- GitLab