Commit f338d93c authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Updates config files

Showing with 106 additions and 480 deletions
+106 -480
import logging import logging
from ohmpi.utils import get_platform from ohmpi.utils import get_platform
from paho.mqtt.client import MQTTv31 from paho.mqtt.client import MQTTv31 # noqa
_, on_pi = get_platform() _, on_pi = get_platform()
# DEFINE THE ID OF YOUR OhmPi # DEFINE THE ID OF YOUR OhmPi
...@@ -17,22 +17,38 @@ OHMPI_CONFIG = { ...@@ -17,22 +17,38 @@ OHMPI_CONFIG = {
'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE
} }
r_shunt = 2.
HARDWARE_CONFIG = { HARDWARE_CONFIG = {
'ctl': {'model' : 'dummy_ctl' 'ctl': {'model': 'raspberry_pi'},
}, 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'},
'tx' : {'model' : 'dummy_tx', 'tx': {'model': 'mb_2024_0_2',
'current_max': 4800 / 50 / 2, # Maximum current mA 'voltage_max': 50., # Maximum voltage supported by the TX board [V]
'r_shunt': 2, # Shunt resistance in Ohms 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A]
'low_battery': 12. # Volts 'r_shunt': r_shunt, # Shunt resistance in Ohms
'interface_name': 'i2c'
}, },
'rx' : {'model': 'dummy_rx', 'rx': {'model': 'mb_2024_0_2',
'latency': 0.010, # latency in seconds in continuous mode
'sampling_rate': 50, # number of samples per second
'interface_name': 'i2c'
}, },
'mux': {'model' : 'dummy_mux', 'mux': {'boards':
'max_elec': 64, {'mux_00':
'voltage_max' : 100, {'model': 'mux_2024_0_X',
'current_max' : 3 'tca_address': None,
'tca_channel': 0,
'addr2': 'down',
'addr1': 'down',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i+0, j): ('mux_00', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 12.}
},
'default': {'interface_name': 'i2c_ext',
'voltage_max': 100.,
'current_max': 3.}
} }
} }
# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS # SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS
# Execution logging configuration # Execution logging configuration
EXEC_LOGGING_CONFIG = { EXEC_LOGGING_CONFIG = {
......
import logging
from ohmpi.utils import get_platform
from paho.mqtt.client import MQTTv31
_, 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)
# 'R_shunt': 2, # Shunt resistance in Ohms
# 'Imax': 4800 / 50 / 2, # Maximum current
# 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V
# 'nb_samples': 20, # Max value 10 # was named integer before...
# 'version': 2, # Is this still needed?
# 'max_elec': 64,
# 'board_addresses': {'A': 0x73, 'B': 0x72, 'M': 0x71, 'N': 0x70}, # CHECK IF YOUR BOARDS HAVE THESE ADDRESSES
'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE
# 'board_version': 'mb.2023.0.0',#,'22.10',
# 'mcp_board_address': 0x20
} # TODO: add a dictionary with INA models and associated gain values
HARDWARE_CONFIG = {
'ctl': {'model' : 'dummy_ctl'
},
'pwr' : {'model': 'dummy_pwr'},
'tx' : {'model' : 'dummy_tx',
'current_max': 4800 / 50 / 2, # Maximum current
'R_shunt': 2 # Shunt resistance in Ohms
},
'rx' : {'model': 'dummy_rx',
},
'mux': {'model' : 'dummy_mux',
'max_elec': 64,
'voltage_max' : 100,
'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.DEBUG,
'logging_to_console': True,
'file_name': f'exec{logging_suffix}.log',
'max_bytes': 262144,
'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,
'log_file_logging_level': logging.DEBUG,
'logging_to_console': True,
'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': logging.DEBUG,
'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'
}
import logging import logging
from ohmpi.utils import get_platform from ohmpi.utils import get_platform
from paho.mqtt.client import MQTTv31 from paho.mqtt.client import MQTTv31 # noqa
_, on_pi = get_platform() _, on_pi = get_platform()
# DEFINE THE ID OF YOUR OhmPi # DEFINE THE ID OF YOUR OhmPi
...@@ -43,8 +43,6 @@ HARDWARE_CONFIG = { ...@@ -43,8 +43,6 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'up', 'addr2': 'up',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, '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)}, 'cabling': {(i + 8, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 50.}, 'voltage_max': 50.},
...@@ -54,8 +52,6 @@ HARDWARE_CONFIG = { ...@@ -54,8 +52,6 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'down', 'addr2': 'down',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i + 16, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'cabling': {(i + 16, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 50.}, 'voltage_max': 50.},
......
...@@ -21,51 +21,51 @@ r_shunt = 2. ...@@ -21,51 +21,51 @@ r_shunt = 2.
HARDWARE_CONFIG = { HARDWARE_CONFIG = {
'ctl': {'model': 'raspberry_pi'}, 'ctl': {'model': 'raspberry_pi'},
'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'},
'tx': {'model': 'mb_2023_0_X', 'tx': {'model': 'mb_2023_0_X',
'voltage_max': 50., # Maximum voltage supported by the TX board [V] '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] '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 'r_shunt': r_shunt, # Shunt resistance in Ohms
'interface_name': 'i2c' 'interface_name': 'i2c'
}, },
'rx': {'model': 'mb_2023_0_X', 'rx': {'model': 'mb_2023_0_X',
'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V 'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V
'sampling_rate': 50., # number of samples per second 'sampling_rate': 50., # number of samples per second
'interface_name': 'i2c', 'interface_name': 'i2c',
}, },
'mux': # default properties given in config are system properties that will be 'mux': # default properties given in config are system properties that will be
# overwritten by properties defined in each the board dict below. # 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 # 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 # omitted properties in config will be set to board specs default values if they exist
{'boards': {'boards':
{'mux_A': {'mux_A':
{'model': 'mux_2023_0_X', {'model': 'mux_2023_0_X',
'mux_tca_address': 0x70, 'mux_tca_address': 0x70,
'roles': {'A': 'X'}, 'roles': {'A': 'X'},
'cabling': {(i, j): ('mux_A', i) for j in ['A'] for i in range(1, 65)}, 'cabling': {(i, j): ('mux_A', i) for j in ['A'] for i in range(1, 65)},
'voltage_max': 12.}, 'voltage_max': 12.},
'mux_B': 'mux_B':
{'model': 'mux_2023_0_X', {'model': 'mux_2023_0_X',
'mux_tca_address': 0x71, 'mux_tca_address': 0x71,
'roles': {'B': 'X'}, 'roles': {'B': 'X'},
'cabling': {(i, j): ('mux_B', i) for j in ['B'] for i in range(1, 65)}, 'cabling': {(i, j): ('mux_B', i) for j in ['B'] for i in range(1, 65)},
'voltage_max': 12.}, 'voltage_max': 12.},
'mux_M': 'mux_M':
{'model': 'mux_2023_0_X', {'model': 'mux_2023_0_X',
'mux_tca_address': 0x72, 'mux_tca_address': 0x72,
'roles': {'M': 'X'}, 'roles': {'M': 'X'},
'cabling': {(i, j): ('mux_M', i) for j in ['M'] for i in range(1, 65)}, 'cabling': {(i, j): ('mux_M', i) for j in ['M'] for i in range(1, 65)},
'voltage_max': 12.}, 'voltage_max': 12.},
'mux_N': 'mux_N':
{'model': 'mux_2023_0_X', {'model': 'mux_2023_0_X',
'mux_tca_address': 0x73, 'mux_tca_address': 0x73,
'roles': {'N': 'X'}, 'roles': {'N': 'X'},
'cabling': {(i, j): ('mux_N', i) for j in ['N'] for i in range(1, 65)}, 'cabling': {(i, j): ('mux_N', i) for j in ['N'] for i in range(1, 65)},
'voltage_max': 12.}, 'voltage_max': 12.},
}, },
'default': {'interface_name': 'i2c', 'default': {'interface_name': 'i2c',
'voltage_max': 12., 'voltage_max': 12.,
'current_max': 3.} 'current_max': 3.}
} }
} }
# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS # SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS
......
...@@ -38,19 +38,15 @@ HARDWARE_CONFIG = { ...@@ -38,19 +38,15 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'up', 'addr2': 'up',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, '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)}, 'cabling': {(i+8, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 12.}, 'voltage_max': 12.},
'mux_03': 'mux_03':
{'model': 'mux_2024_0_X', {'model': 'mux_2024_0_X',
'tca_address': None, 'tca_address': None,
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'down', 'addr2': 'down',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i+24, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'cabling': {(i+24, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 12.}, 'voltage_max': 12.},
......
...@@ -42,8 +42,6 @@ HARDWARE_CONFIG = { ...@@ -42,8 +42,6 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'up', 'addr2': 'up',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, '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)}, 'cabling': {(i+8, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 50.}, 'voltage_max': 50.},
...@@ -53,8 +51,6 @@ HARDWARE_CONFIG = { ...@@ -53,8 +51,6 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'down', 'addr2': 'down',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i+16, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'cabling': {(i+16, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 50.}, 'voltage_max': 50.},
......
...@@ -39,8 +39,8 @@ HARDWARE_CONFIG = { ...@@ -39,8 +39,8 @@ HARDWARE_CONFIG = {
{'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01',
'tca_address': None, 'tca_address': None,
'tca_channel': 0, '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... 'addr2': 'up',
'mcp_1': '0x23', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user...) 'addr1': 'up',
'roles': {'A': 'X', 'B': 'Y'}, 'roles': {'A': 'X', 'B': 'Y'},
'voltage_max': 12. 'voltage_max': 12.
}}, }},
......
...@@ -18,33 +18,34 @@ OHMPI_CONFIG = { ...@@ -18,33 +18,34 @@ OHMPI_CONFIG = {
} }
HARDWARE_CONFIG = { HARDWARE_CONFIG = {
'ctl': {'model' : 'raspberry_pi'}, 'ctl': {'model': 'raspberry_pi'},
'pwr': {'model' : 'pwr_batt', 'voltage': 12.}, 'pwr': {'model': 'pwr_batt', 'voltage': 12.},
'tx' : {'model' : 'mb_2023_0_X', 'tx': {'model': 'mb_2023_0_X',
'mcp_board_address': 0x20, 'mcp_board_address': 0x20,
'voltage_max': 12., # Maximum voltage supported by the TX board [V] 'voltage_max': 12., # Maximum voltage supported by the TX board [V]
'current_max': 4800 / 50 / 2, # Maximum current supported by the TX board [mA] 'current_max': 4800 / 50 / 2, # Maximum current supported by the TX board [mA]
'r_shunt': 2 # Shunt resistance in Ohms 'r_shunt': 2 # Shunt resistance in Ohms
}, },
'rx' : {'model': 'mb_2023_0_X', 'rx': {'model': 'mb_2023_0_X',
'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V
'sampling_rate': 100., # Hz 'sampling_rate': 100., # Hz
'nb_samples': 20, # Max value 10 # was named integer before... 'nb_samples': 20, # Max value 10 # was named integer before...
}, },
'mux': # default properties are system properties that will be 'mux': # default properties are system properties that will be
# overwritten by board properties defined at the board level within the board model file # 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... # both will be overwritten by properties specified in the board dict below. Use with caution...
{'boards': {'boards':
{'mux_1': {'mux_1':
{'model' : 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01',
'tca_address': None, 'tca_address': None,
'tca_channel': 0, '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... 'addr2': 'up',
'mcp_1': '0x23', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user...) 'addr1': 'up',
'roles': {'M': 'X', 'N': 'Y'}, 'roles': {'M': 'X', 'N': 'Y'},
'voltage_max': 12. 'voltage_max': 12.
}}, }
'default': {'voltage_max': 100., 'current_max': 3.}} },
'default': {'voltage_max': 100., 'current_max': 3.}}
} }
# SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS # SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS
......
import logging
from ohmpi.utils import get_platform
from paho.mqtt.client import MQTTv31
_, 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
}
HARDWARE_CONFIG = {
'ctl': {'model' : 'raspberry_pi'},
'pwr': {'model' : 'DPS_5005',
'voltage_adjustable': True},
'tx' : {'model' : 'mb_2024_rev_0_0',
'mcp_board_address': 0x20,
'current_max': 4800 / 50 / 2, # Maximum current
'r_shunt': 2 # Shunt resistance in Ohms
},
'rx' : {'model': 'mb_2024_rev_0_0',
'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V
'nb_samples': 20, # Max value 10 # was named integer before...
},
'mux': {'model' : 'ohmpi_i2c_mux64_v1.01',
'max_elec': 64,
'board_addresses': {'A': 0x73, 'B': 0x72, 'M': 0x71, 'N': 0x70}, # CHECK IF YOUR BOARDS HAVE THESE ADDRESSES
'voltage_max': 100,
'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.DEBUG,
'logging_to_console': True,
'file_name': f'exec{logging_suffix}.log',
'max_bytes': 262144,
'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.DEBUG,
'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': logging.DEBUG,
'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'
}
...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = { ...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = {
'interface_name': 'i2c' 'interface_name': 'i2c'
}, },
'rx': {'model': 'mb_2024_0_2', 'rx': {'model': 'mb_2024_0_2',
'coef_p2': 1.00, # slope for conversion for ADS, measurement in V/V
'latency': 0.010, # latency in seconds in continuous mode 'latency': 0.010, # latency in seconds in continuous mode
'sampling_rate': 50, # number of samples per second 'sampling_rate': 50, # number of samples per second
'interface_name': 'i2c' 'interface_name': 'i2c'
......
...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = { ...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = {
'interface_name': 'i2c' 'interface_name': 'i2c'
}, },
'rx': {'model': 'mb_2024_0_2', 'rx': {'model': 'mb_2024_0_2',
'coef_p2': 1.00, # slope for conversion for ADS, measurement in V/V
'latency': 0.010, # latency in seconds in continuous mode 'latency': 0.010, # latency in seconds in continuous mode
'sampling_rate': 50, # number of samples per second 'sampling_rate': 50, # number of samples per second
'interface_name': 'i2c' 'interface_name': 'i2c'
...@@ -39,8 +38,6 @@ HARDWARE_CONFIG = { ...@@ -39,8 +38,6 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'down', 'addr2': 'down',
'addr1': 'down', 'addr1': 'down',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i+0, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'cabling': {(i+0, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 12.} 'voltage_max': 12.}
......
...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = { ...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = {
'interface_name': 'i2c' 'interface_name': 'i2c'
}, },
'rx': {'model': 'mb_2024_0_2', 'rx': {'model': 'mb_2024_0_2',
'coef_p2': 1.00, # slope for conversion for ADS, measurement in V/V
'latency': 0.010, # latency in seconds in continuous mode 'latency': 0.010, # latency in seconds in continuous mode
'sampling_rate': 50, # number of samples per second 'sampling_rate': 50, # number of samples per second
'interface_name': 'i2c' 'interface_name': 'i2c'
...@@ -39,8 +38,6 @@ HARDWARE_CONFIG = { ...@@ -39,8 +38,6 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'down', 'addr2': 'down',
'addr1': 'down', 'addr1': 'down',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i+0, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'cabling': {(i+0, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 12.} 'voltage_max': 12.}
......
...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = { ...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = {
'interface_name': 'i2c' 'interface_name': 'i2c'
}, },
'rx': {'model': 'mb_2024_0_2', 'rx': {'model': 'mb_2024_0_2',
'coef_p2': 1.00, # slope for conversion for ADS, measurement in V/V
'latency': 0.010, # latency in seconds in continuous mode 'latency': 0.010, # latency in seconds in continuous mode
'sampling_rate': 50, # number of samples per second 'sampling_rate': 50, # number of samples per second
'interface_name': 'i2c' 'interface_name': 'i2c'
...@@ -39,8 +38,6 @@ HARDWARE_CONFIG = { ...@@ -39,8 +38,6 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'up', 'addr2': 'up',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i+0, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'cabling': {(i+0, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 12.}, 'voltage_max': 12.},
......
...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = { ...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = {
'interface_name': 'i2c' 'interface_name': 'i2c'
}, },
'rx': {'model': 'mb_2024_0_2', 'rx': {'model': 'mb_2024_0_2',
'coef_p2': 1.00, # slope for conversion for ADS, measurement in V/V
'latency': 0.010, # latency in seconds in continuous mode 'latency': 0.010, # latency in seconds in continuous mode
'sampling_rate': 50, # number of samples per second 'sampling_rate': 50, # number of samples per second
'interface_name': 'i2c' 'interface_name': 'i2c'
...@@ -39,19 +38,15 @@ HARDWARE_CONFIG = { ...@@ -39,19 +38,15 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'up', 'addr2': 'up',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, '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)}, 'cabling': {(i+8, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 50.}, 'voltage_max': 50.},
'mux_03': 'mux_03':
{'model': 'mux_2024_0_X', {'model': 'mux_2024_0_X',
'tca_address': None, 'tca_address': None,
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'down', 'addr2': 'down',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i+16, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'cabling': {(i+16, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 50.}, 'voltage_max': 50.},
......
...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = { ...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = {
'interface_name': 'i2c' 'interface_name': 'i2c'
}, },
'rx': {'model': 'mb_2024_0_2', 'rx': {'model': 'mb_2024_0_2',
'coef_p2': 1.00, # slope for conversion for ADS, measurement in V/V
'latency': 0.010, # latency in seconds in continuous mode 'latency': 0.010, # latency in seconds in continuous mode
'sampling_rate': 50, # number of samples per second 'sampling_rate': 50, # number of samples per second
'interface_name': 'i2c' 'interface_name': 'i2c'
...@@ -67,8 +66,6 @@ HARDWARE_CONFIG = { ...@@ -67,8 +66,6 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'up', 'addr2': 'up',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i+65+8, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'cabling': {(i+65+8, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 12.}, 'voltage_max': 12.},
...@@ -78,8 +75,6 @@ HARDWARE_CONFIG = { ...@@ -78,8 +75,6 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'down', 'addr2': 'down',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i+65+24, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'cabling': {(i+65+24, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 12.}, 'voltage_max': 12.},
......
...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = { ...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = {
'interface_name': 'i2c' 'interface_name': 'i2c'
}, },
'rx': {'model': 'mb_2024_0_2', 'rx': {'model': 'mb_2024_0_2',
'coef_p2': 1.00, # slope for conversion for ADS, measurement in V/V
'latency': 0.010, # latency in seconds in continuous mode 'latency': 0.010, # latency in seconds in continuous mode
'sampling_rate': 50, # number of samples per second 'sampling_rate': 50, # number of samples per second
'interface_name': 'i2c' 'interface_name': 'i2c'
......
...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = { ...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = {
'vmn_hardware_offset': 2501. 'vmn_hardware_offset': 2501.
}, },
'rx': {'model': 'mb_2024_0_2', 'rx': {'model': 'mb_2024_0_2',
'coef_p2': 1.00, # slope for conversion for ADS, measurement in V/V
'latency': 0.010, # latency in seconds in continuous mode 'latency': 0.010, # latency in seconds in continuous mode
'sampling_rate': 50, # number of samples per second 'sampling_rate': 50, # number of samples per second
'interface_name': 'i2c' 'interface_name': 'i2c'
...@@ -39,19 +38,15 @@ HARDWARE_CONFIG = { ...@@ -39,19 +38,15 @@ HARDWARE_CONFIG = {
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'up', 'addr2': 'up',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, '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)}, 'cabling': {(i+8, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 50.}, 'voltage_max': 50.},
'mux_03': 'mux_03':
{'model': 'mux_2024_0_X', {'model': 'mux_2024_0_X',
'tca_address': None, 'tca_address': None,
'tca_channel': 0, 'tca_channel': 0,
'addr2': 'down', 'addr2': 'down',
'addr1': 'up', 'addr1': 'up',
# 'mcp_0': '0x26',
# 'mcp_1': '0x27',
'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'}, 'roles': {'A': 'X', 'B': 'Y', 'M': 'XX', 'N': 'YY'},
'cabling': {(i+24, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'cabling': {(i+24, j): ('mux_03', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)},
'voltage_max': 50.}, 'voltage_max': 50.},
......
...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = { ...@@ -27,7 +27,6 @@ HARDWARE_CONFIG = {
'interface_name': 'i2c' 'interface_name': 'i2c'
}, },
'rx': {'model': 'mb_2024_0_2', 'rx': {'model': 'mb_2024_0_2',
'coef_p2': 1.00, # slope for conversion for ADS, measurement in V/V
'latency': 0.010, # latency in seconds in continuous mode 'latency': 0.010, # latency in seconds in continuous mode
'sampling_rate': 50, # number of samples per second 'sampling_rate': 50, # number of samples per second
'interface_name': 'i2c' 'interface_name': 'i2c'
...@@ -57,7 +56,7 @@ HARDWARE_CONFIG = { ...@@ -57,7 +56,7 @@ HARDWARE_CONFIG = {
'roles': {'N': 'X'}, 'roles': {'N': 'X'},
'cabling': {(i, j): ('mux_N', i) for j in ['N'] for i in range(1, 65)}, 'cabling': {(i, j): ('mux_N', i) for j in ['N'] for i in range(1, 65)},
'voltage_max': 12.}, 'voltage_max': 12.},
'mux_A2': 'mux_A2':
{'model': 'mux_2023_0_X', {'model': 'mux_2023_0_X',
'mux_tca_address': 0x74, 'mux_tca_address': 0x74,
'roles': {'A': 'X'}, 'roles': {'A': 'X'},
......
import logging
from ohmpi.utils import get_platform
from paho.mqtt.client import MQTTv31
_, 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
}
HARDWARE_CONFIG = {
'ctl': {'model' : 'raspberry_pi'},
'tx' : {'model' : 'mb_2023_0_X',
'mcp_board_address': 0x20,
'current_max': 4800 / 50 / 2, # Maximum current
'r_shunt': 2 # Shunt resistance in Ohms
},
'rx' : {'model': 'mb_2023_0_X',
'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V
'sampling_rate': 100., # Hz
'nb_samples': 20, # Max value 10 # was named integer before...
},
'mux': {'model' : 'dummy_mux', # 'ohmpi_i2c_mux64_v1.01',
'max_elec': 64,
'board_addresses': {'A': 0x73, 'B': 0x72, 'M': 0x71, 'N': 0x70}, # CHECK IF YOUR BOARDS HAVE THESE ADDRESSES
'voltage_max': 100,
'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.DEBUG,
'logging_to_console': True,
'file_name': f'exec{logging_suffix}.log',
'max_bytes': 262144,
'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,
'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': logging.DEBUG,
'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'
}
# import sys
# sys.path.extend(['/home/su530201/PycharmProjects/OhmPi'])
from ohmpi.hardware_components.dummy_tx import Tx
from ohmpi.hardware_components.dummy_rx import Rx
from ohmpi.logging_setup import create_stdout_logger
exec_logger = create_stdout_logger(name='exec')
soh_logger = create_stdout_logger(name='soh')
print('\nCreating TX...')
tx = Tx(exec_logger=exec_logger, soh_logger=soh_logger)
print('\nCreating RX...')
rx = Rx(exec_logger=exec_logger, soh_logger=soh_logger)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment