Commit 71bf182c authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Renames MQTT topics as subtopics of the ohmpi in config.py; remanes output as...

Renames MQTT topics as subtopics of the ohmpi in config.py; remanes output as sequence in method to load a sequence
Showing with 22 additions and 23 deletions
+22 -23
......@@ -2,7 +2,7 @@ from paho.mqtt.client import MQTTv31
# OhmPi configuration
OHMPI_CONFIG = {
'id': '0001', # Unique identifier of the OhmPi board (string)
'id': '0000', # 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
......@@ -50,7 +50,7 @@ SOH_LOGGING_CONFIG = {
MQTT_LOGGING_CONFIG = {
'hostname': 'ohmpy.umons.ac.be',
'port': 1883,
'qos': 0,
'qos': 1,
'retain': False,
'keepalive': 60,
'will': None,
......@@ -58,9 +58,9 @@ MQTT_LOGGING_CONFIG = {
'tls': None,
'protocol': MQTTv31,
'transport': 'tcp',
'client_id': f'ohmpi_sn_{OHMPI_CONFIG["id"]}',
'control_topic': f'ctrl_ohmpi_sn_{OHMPI_CONFIG["id"]}',
'exec_topic': f'exec_ohmpi_sn_{OHMPI_CONFIG["id"]}',
'data_topic': f'data_ohmpi_sn_{OHMPI_CONFIG["id"]}',
'soh_topic': f'soh_ohmpi_sn_{OHMPI_CONFIG["id"]}'
'client_id': f'{OHMPI_CONFIG["id"]}',
'ctrl_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/ctrl',
'exec_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/exec',
'data_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/data',
'soh_topic': f'ohmpi_{OHMPI_CONFIG["id"]}/soh'
}
......@@ -18,8 +18,6 @@ from termcolor import colored
import threading
from logging_setup import setup_loggers
# from mqtt_setup import mqtt_client_setup
# finish import (done only when class is instantiated as some libs are only available on arm64 platform)
try:
import board # noqa
......@@ -161,7 +159,7 @@ class OhmPi(object):
Parameters
----------
quads : 1D or 2D array
quads : numpy.ndarray
List of quadrupoles of shape nquad x 4 or 1D vector of shape nquad.
Returns
......@@ -219,16 +217,19 @@ class OhmPi(object):
Returns
-------
output : numpy.array
sequence : numpy.array
Array of shape (number quadrupoles * 4).
"""
output = np.loadtxt(filename, delimiter=" ", dtype=int) # load quadrupole file
sequence = np.loadtxt(filename, delimiter=" ", dtype=int) # load quadrupole file
if sequence is not None:
self.exec_logger.debug('Sequence of {:d} quadrupoles read.'.format(sequence.shape[0]))
# locate lines where the electrode index exceeds the maximum number of electrodes
test_index_elec = np.array(np.where(output > self.max_elec))
test_index_elec = np.array(np.where(sequence > self.max_elec))
# locate lines where electrode A == electrode B
test_same_elec = self.find_identical_in_line(output)
test_same_elec = self.find_identical_in_line(sequence)
# if statement with exit cases (TODO rajouter un else if pour le deuxième cas du ticket #2)
if test_index_elec.size != 0:
......@@ -236,17 +237,17 @@ class OhmPi(object):
self.exec_logger.error(f'An electrode index at line {str(test_index_elec[0, i] + 1)} '
f'exceeds the maximum number of electrodes')
# sys.exit(1)
output = None
sequence = None
elif len(test_same_elec) != 0:
for i in range(len(test_same_elec)):
self.exec_logger.error(f'An electrode index A == B detected at line {str(test_same_elec[i] + 1)}')
# sys.exit(1)
output = None
sequence = None
if output is not None:
self.exec_logger.debug('Sequence of {:d} quadrupoles read.'.format(output.shape[0]))
if sequence is not None:
self.exec_logger.info('Sequence of {:d} quadrupoles read.'.format(sequence.shape[0]))
self.sequence = output
self.sequence = sequence
def switch_mux(self, electrode_nr, state, role):
"""Select the right channel for the multiplexer cascade for a given electrode.
......@@ -661,9 +662,7 @@ class OhmPi(object):
self.exec_logger.debug(f'Status: {self.status}')
# mqtt_client, measurement_topic = mqtt_client_setup()
VERSION = '2.0.2'
VERSION = '2.0.3'
print(colored(r' ________________________________' + '\n' +
r'| _ | | | || \/ || ___ \_ _|' + '\n' +
......
......@@ -23,7 +23,7 @@ class MyServer(SimpleHTTPRequestHandler):
# the do_GET() method (if we use the BaseHTTPRequestHandler, we would need to)
# def do_GET(self):
# # normal get for wepages (not so secure!)
# # normal get for webpages (not so secure!)
# print(self.command)
# print(self.headers)
# print(self.request)
......
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