Commit dd4b281d authored by Guillaume Blanchy's avatar Guillaume Blanchy
Browse files

Update UI

Showing with 48 additions and 41 deletions
+48 -41
...@@ -3,15 +3,25 @@ ...@@ -3,15 +3,25 @@
# to message from the MQTT broker # to message from the MQTT broker
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
import subprocess
subprocess.Popen(['python', '-m', 'http.server'])
# start ohmpi listener
from ohmpi.ohmpi import OhmPi from ohmpi.ohmpi import OhmPi
from ohmpi.config import OHMPI_CONFIG from ohmpi.config import OHMPI_CONFIG
ohmpi = OhmPi(settings=OHMPI_CONFIG['settings']) k = OhmPi(settings=OHMPI_CONFIG['settings'])
if ohmpi.controller is not None: import os
ohmpi.controller.loop_forever() 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()
# restore default config # restore default config
change_config('../configs/config_default.py', verbose=False) change_config('../configs/config_default.py', verbose=False)
...@@ -85,10 +85,10 @@ if within_ohmpi: ...@@ -85,10 +85,10 @@ if within_ohmpi:
print('Starting test with OhmPi.') print('Starting test with OhmPi.')
k = OhmPi() k = OhmPi()
# k.get_data() # k.get_data()
k.load_sequence(os.path.join(os.path.dirname(__file__), '../sequences/wenner.txt')) # k.load_sequence(os.path.join(os.path.dirname(__file__), '../sequences/wenner16.txt'))
k.reset_mux() # k.reset_mux()
# k.run_multiple_sequences(sequence_delay=20, nb_meas=3) # k.run_multiple_sequences(sequence_delay=20, nb_meas=3)
k.run_sequence(injection_duration=0.2) # k.run_sequence(injection_duration=0.2)
# k.rs_check(tx_volt=4) # k.rs_check(tx_volt=4)
# k.test_mux(mux_id=None, activation_time=0.2) # k.test_mux(mux_id=None, activation_time=0.2)
# k._hw.switch_mux([A, B, M, N], state='on') # k._hw.switch_mux([A, B, M, N], state='on')
...@@ -103,11 +103,11 @@ if within_ohmpi: ...@@ -103,11 +103,11 @@ if within_ohmpi:
# k._hw.switch_mux([A, B, M, N], state='off') # k._hw.switch_mux([A, B, M, N], state='off')
# print(f'OhmPiHardware Resistance: {k._hw.last_rho :.2f} ohm, dev. {k._hw.last_dev:.2f} %, rx bias: {k._hw.rx._bias:.2f} mV') # print(f'OhmPiHardware Resistance: {k._hw.last_rho :.2f} ohm, dev. {k._hw.last_dev:.2f} %, rx bias: {k._hw.rx._bias:.2f} mV')
# k._hw._plot_readings() # k._hw._plot_readings()
# A, B, M, N = (16, 13, 15, 14) A, B, M, N = (17, 20, 18, 19)
# A, B, M, N = (1, 4, 2, 3) # A, B, M, N = (1, 4, 2, 3)
# d = k.run_measurement([A, B, M, N], injection_duration=0.5, nb_stack=2, duty_cycle=0.5) d = k.run_measurement([A, B, M, N], injection_duration=0.5, nb_stack=2, duty_cycle=0.5)
# print(d) print(d)
# k._hw._plot_readings() k._hw._plot_readings()
# print(f'OhmPiHardware: Resistance: {k._hw.last_resistance() :.2f} ohm, dev. {k._hw.last_dev():.2f} %, sp: {k._hw.sp:.2f} mV, rx bias: {k._hw.rx._bias:.2f} mV') # print(f'OhmPiHardware: Resistance: {k._hw.last_resistance() :.2f} ohm, dev. {k._hw.last_dev():.2f} %, sp: {k._hw.sp:.2f} mV, rx bias: {k._hw.rx._bias:.2f} mV')
# print(f'OhmPi: Resistance: {d["R [ohm]"] :.2f} ohm, dev. {d["R_std [%]"]:.2f} %, rx bias: {k._hw.rx._bias:.2f} mV') # print(f'OhmPi: Resistance: {d["R [ohm]"] :.2f} ohm, dev. {d["R_std [%]"]:.2f} %, rx bias: {k._hw.rx._bias:.2f} mV')
# k._hw._plot_readings(save_fig=False) # k._hw._plot_readings(save_fig=False)
......
...@@ -220,6 +220,12 @@ mosquitto_sub -h raspberrypi.local -t ohmpi_0001/ctrl ...@@ -220,6 +220,12 @@ mosquitto_sub -h raspberrypi.local -t ohmpi_0001/ctrl
// process data // process data
msg = payload // for accessing the variable from the console msg = payload // for accessing the variable from the console
console.log('DATA LOG:', payload) console.log('DATA LOG:', payload)
// replace NaN values by null to make them acceptable for json parser
payload = payload.replace(/\bNaN\b/g, "null");
payload = payload.replace(/\bnan\b/g, "null");
// parse to json
let ddic = JSON.parse(payload.split('INFO:')[1]) let ddic = JSON.parse(payload.split('INFO:')[1])
// RS check data // RS check data
...@@ -516,7 +522,6 @@ mosquitto_sub -h raspberrypi.local -t ohmpi_0001/ctrl ...@@ -516,7 +522,6 @@ mosquitto_sub -h raspberrypi.local -t ohmpi_0001/ctrl
// xpos.push((Math.min(ab, mn) + dist/2)*elec_spacing) // xpos.push((Math.min(ab, mn) + dist/2)*elec_spacing)
// ypos.push(- (Math.sqrt(2)/2*dist)*elec_spacing) // ypos.push(- (Math.sqrt(2)/2*dist)*elec_spacing)
} }
console.log('========', app, xpos, ypos)
// update the trace and redraw the figure // update the trace and redraw the figure
trace['x'] = xpos trace['x'] = xpos
trace['y'] = ypos trace['y'] = ypos
...@@ -825,6 +830,10 @@ mosquitto_sub -h raspberrypi.local -t ohmpi_0001/ctrl ...@@ -825,6 +830,10 @@ mosquitto_sub -h raspberrypi.local -t ohmpi_0001/ctrl
output.innerHTML = 'Status: ' + x['status'] + ' (all data cleared)' output.innerHTML = 'Status: ' + x['status'] + ' (all data cleared)'
console.log('all data removed') console.log('all data removed')
}) })
data = {}
quads = []
getData()
document.getElementById('quadSelect').innerHTML = ''
} }
let removeDataBtn = document.getElementById('removeDataBtn') let removeDataBtn = document.getElementById('removeDataBtn')
removeDataBtn.addEventListener('click', removeDataBtnFunc) removeDataBtn.addEventListener('click', removeDataBtnFunc)
......
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
_, on_pi = get_platform() _, on_pi = get_platform()
# DEFINE THE ID OF YOUR OhmPi # DEFINE THE ID OF YOUR OhmPi
...@@ -17,36 +17,26 @@ OHMPI_CONFIG = { ...@@ -17,36 +17,26 @@ 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': 'raspberry_pi'}, 'ctl': {'model' : 'dummy_ctl'
'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, },
'tx': {'model': 'mb_2023_0_X', 'tx' : {'model' : 'dummy_tx',
'voltage_max': 50., # Maximum voltage supported by the TX board [V] 'current_max': 4800 / 50 / 2, # Maximum current mA
'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] 'r_shunt': 2, # Shunt resistance in Ohms
'r_shunt': r_shunt, # Shunt resistance in Ohms 'low_battery': 12. # Volts
'interface_name': 'i2c'
}, },
'rx': {'model': 'mb_2023_0_X', 'rx' : {'model': 'dummy_rx',
'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V
'sampling_rate': 50., # number of samples per second
'interface_name': 'i2c',
}, },
'mux': # default properties given in config are system properties that will be 'mux': {'model' : 'dummy_mux',
# overwritten by properties defined in each the board dict below. 'max_elec': 64,
# if defined in board specs, values out of specs will be bounded to remain in specs 'voltage_max' : 100,
# omitted properties in config will be set to board specs default values if they exist 'current_max' : 3
{'boards': {}, }
'default': {'interface_name': 'i2c',
'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 = {
'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',
...@@ -70,8 +60,8 @@ DATA_LOGGING_CONFIG = { ...@@ -70,8 +60,8 @@ DATA_LOGGING_CONFIG = {
# State of Health logging configuration (For a future release) # State of Health logging configuration (For a future release)
SOH_LOGGING_CONFIG = { SOH_LOGGING_CONFIG = {
'logging_level': logging.INFO, 'logging_level': logging.INFO,
'logging_to_console': True,
'log_file_logging_level': logging.DEBUG, 'log_file_logging_level': logging.DEBUG,
'logging_to_console': True,
'file_name': f'soh{logging_suffix}.log', 'file_name': f'soh{logging_suffix}.log',
'max_bytes': 16777216, 'max_bytes': 16777216,
'backup_count': 1024, 'backup_count': 1024,
......
export PYTHONPATH=`pwd` export PYTHONPATH=`pwd`
source $PYTHONPATH/ohmpy/bin/activate source $PYTHONPATH/ohmpy/bin/activate
python dev/start_mqtt_html.py & # run ohmpi.py to capture the commands python dev/start_mqtt_html.py
python -m http.server # run web GUI
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