From 948a6cae9b6194bb448b5a417e92be1388f1b9ad Mon Sep 17 00:00:00 2001 From: jkl <sagitta1618@gmail.com> Date: Sun, 17 Dec 2023 19:46:08 +0100 Subject: [PATCH] Update html interface script to read the chosen config.py --- dev/start_mqtt_html.py | 29 +++++++++++++---------- ohmpi/config.py | 52 +++++++++++++++++++++++++++++------------- 2 files changed, 53 insertions(+), 28 deletions(-) diff --git a/dev/start_mqtt_html.py b/dev/start_mqtt_html.py index 0e7dd6cf..f978ba7d 100644 --- a/dev/start_mqtt_html.py +++ b/dev/start_mqtt_html.py @@ -4,24 +4,29 @@ from ohmpi.utils import change_config # change_config('../configs/config_mb_2023.py', verbose=False) -change_config('../configs/config_mb_2023_4_mux_2023.py', verbose=False) +# change_config('../configs/config_mb_2023_4_mux_2023.py', verbose=False) #change_config('../configs/config_mb_2024_0_2__4_mux_2023_dps5005.py', verbose=False) # start html interface import subprocess -subprocess.Popen(['python', '-m', 'http.server']) +proc = subprocess.Popen(['python', '-m', 'http.server']) # start ohmpi listener -from ohmpi.ohmpi import OhmPi -from ohmpi.config import OHMPI_CONFIG -k = OhmPi(settings=OHMPI_CONFIG['settings']) -import os -k.load_sequence(os.path.join(os.path.dirname(__file__), '../sequences/wenner16.txt')) -k.reset_mux() -#k.run_multiple_sequences(sequence_delay=20, nb_meas=3) +try: + from ohmpi.ohmpi import OhmPi + from ohmpi.config import OHMPI_CONFIG + k = OhmPi(settings=OHMPI_CONFIG['settings']) + import os + k.load_sequence(os.path.join(os.path.dirname(__file__), '../sequences/wenner16.txt')) + k.reset_mux() + #k.run_multiple_sequences(sequence_delay=20, nb_meas=3) -if k.controller is not None: - k.controller.loop_forever() + if k.controller is not None: + k.controller.loop_forever() +except Exception as e: + proc.terminate() + print('ERROR', e) + # restore default config -change_config('../configs/config_default.py', verbose=False) +# change_config('../configs/config_default.py', verbose=False) diff --git a/ohmpi/config.py b/ohmpi/config.py index f3f566ba..d4cad9f9 100644 --- a/ohmpi/config.py +++ b/ohmpi/config.py @@ -1,6 +1,5 @@ import logging from ohmpi.utils import get_platform - from paho.mqtt.client import MQTTv31 # noqa _, on_pi = get_platform() @@ -20,33 +19,54 @@ OHMPI_CONFIG = { r_shunt = 2. HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi'}, - 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, - 'tx': {'model': 'mb_2023_0_X', + 'pwr': {'model': 'pwr_dps5005', 'voltage': 3., '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] 'r_shunt': r_shunt, # Shunt resistance in Ohms 'interface_name': 'i2c' }, - 'rx': {'model': 'mb_2023_0_X', - 'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V - 'sampling_rate': 50., # number of samples per second - 'interface_name': 'i2c', + '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': # default properties given in config are system properties that will be - # overwritten by properties defined in each the board dict below. - # if defined in board specs, values out of specs will be bounded to remain in specs - # omitted properties in config will be set to board specs default values if they exist - {'boards': {}, - 'default': {'interface_name': 'i2c', + 'mux': {'boards': + {'mux_A': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x70, + 'roles': {'A': 'X'}, + 'cabling': {(i, j): ('mux_A', i) for j in ['A'] for i in range(1, 65)}, + 'voltage_max': 12.}, + 'mux_B': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x71, + 'roles': {'B': 'X'}, + 'cabling': {(i, j): ('mux_B', i) for j in ['B'] for i in range(1, 65)}, + 'voltage_max': 12.}, + 'mux_M': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x72, + 'roles': {'M': 'X'}, + 'cabling': {(i, j): ('mux_M', i) for j in ['M'] for i in range(1, 65)}, + 'voltage_max': 12.}, + 'mux_N': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x73, + 'roles': {'N': 'X'}, + 'cabling': {(i, j): ('mux_N', i) for j in ['N'] for i in range(1, 65)}, + '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 # Execution logging configuration EXEC_LOGGING_CONFIG = { - 'logging_level': logging.DEBUG, # TODO: set logging level back to INFO + 'logging_level': logging.INFO, 'log_file_logging_level': logging.DEBUG, 'logging_to_console': True, 'file_name': f'exec{logging_suffix}.log', -- GitLab