Commit 948a6cae authored by Guillaume Blanchy's avatar Guillaume Blanchy
Browse files

Update html interface script to read the chosen config.py

Showing with 53 additions and 28 deletions
+53 -28
...@@ -4,24 +4,29 @@ ...@@ -4,24 +4,29 @@
from ohmpi.utils import change_config from ohmpi.utils import change_config
# change_config('../configs/config_mb_2023.py', verbose=False) # 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) #change_config('../configs/config_mb_2024_0_2__4_mux_2023_dps5005.py', verbose=False)
# start html interface # start html interface
import subprocess import subprocess
subprocess.Popen(['python', '-m', 'http.server']) proc = subprocess.Popen(['python', '-m', 'http.server'])
# start ohmpi listener # start ohmpi listener
from ohmpi.ohmpi import OhmPi try:
from ohmpi.config import OHMPI_CONFIG from ohmpi.ohmpi import OhmPi
k = OhmPi(settings=OHMPI_CONFIG['settings']) from ohmpi.config import OHMPI_CONFIG
import os k = OhmPi(settings=OHMPI_CONFIG['settings'])
k.load_sequence(os.path.join(os.path.dirname(__file__), '../sequences/wenner16.txt')) import os
k.reset_mux() k.load_sequence(os.path.join(os.path.dirname(__file__), '../sequences/wenner16.txt'))
#k.run_multiple_sequences(sequence_delay=20, nb_meas=3) k.reset_mux()
#k.run_multiple_sequences(sequence_delay=20, nb_meas=3)
if k.controller is not None: if k.controller is not None:
k.controller.loop_forever() k.controller.loop_forever()
except Exception as e:
proc.terminate()
print('ERROR', e)
# restore default config # restore default config
change_config('../configs/config_default.py', verbose=False) # change_config('../configs/config_default.py', verbose=False)
import logging import logging
from ohmpi.utils import get_platform from ohmpi.utils import get_platform
from paho.mqtt.client import MQTTv31 # noqa from paho.mqtt.client import MQTTv31 # noqa
_, on_pi = get_platform() _, on_pi = get_platform()
...@@ -20,33 +19,54 @@ OHMPI_CONFIG = { ...@@ -20,33 +19,54 @@ OHMPI_CONFIG = {
r_shunt = 2. 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_dps5005', 'voltage': 3., 'interface_name': 'modbus'},
'tx': {'model': 'mb_2023_0_X', 'tx': {'model': 'mb_2024_0_2',
'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_2024_0_2',
'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V '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'
}, },
'mux': # default properties given in config are system properties that will be 'mux': {'boards':
# overwritten by properties defined in each the board dict below. {'mux_A':
# if defined in board specs, values out of specs will be bounded to remain in specs {'model': 'mux_2023_0_X',
# omitted properties in config will be set to board specs default values if they exist 'mux_tca_address': 0x70,
{'boards': {}, 'roles': {'A': 'X'},
'default': {'interface_name': 'i2c', '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., 'voltage_max': 100.,
'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
# Execution logging configuration # Execution logging configuration
EXEC_LOGGING_CONFIG = { EXEC_LOGGING_CONFIG = {
'logging_level': logging.DEBUG, # TODO: set logging level back to INFO 'logging_level': logging.INFO,
'log_file_logging_level': logging.DEBUG, 'log_file_logging_level': logging.DEBUG,
'logging_to_console': True, 'logging_to_console': True,
'file_name': f'exec{logging_suffix}.log', 'file_name': f'exec{logging_suffix}.log',
......
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