From 5722136270c48ab35be63879b572a93de9b5bf33 Mon Sep 17 00:00:00 2001 From: su530201 <olivier.kaufmann@umons.ac.be> Date: Sun, 8 May 2022 12:41:53 +0200 Subject: [PATCH] Updates the config.py settings for controller and upgrades ohmpi version --- config.py | 18 +++++++++++++++++- data/readme.txt | 1 - ohmpi.py | 18 ++++++++++-------- 3 files changed, 27 insertions(+), 10 deletions(-) delete mode 100644 data/readme.txt diff --git a/config.py b/config.py index 90f74494..355d61bf 100644 --- a/config.py +++ b/config.py @@ -59,8 +59,24 @@ MQTT_LOGGING_CONFIG = { 'protocol': MQTTv31, 'transport': 'tcp', 'client_id': f'ohmpi_sn_{OHMPI_CONFIG["id"]}', - 'control_topic': f'ctrl_ohmpi_sn_{OHMPI_CONFIG["id"]}', + 'ctrl_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"]}' } + +# MQTT command configuration parameters +MQTT_CONTROL_CONFIG = { + 'hostname': 'ohmpy.umons.ac.be', + 'port': 1883, + 'qos': 0, + 'retain': False, + 'keepalive': 60, + 'will': None, + 'auth': None, + 'tls': None, + 'protocol': MQTTv31, + 'transport': 'tcp', + 'client_id': f'ohmpi_sn_{OHMPI_CONFIG["id"]}', + 'cmd_topic': f'cmd_ohmpi_sn_{OHMPI_CONFIG["id"]}' +} \ No newline at end of file diff --git a/data/readme.txt b/data/readme.txt deleted file mode 100644 index f311a0ee..00000000 --- a/data/readme.txt +++ /dev/null @@ -1 +0,0 @@ -In this folder will be logged all measurements done with the OhmPi as .csv. diff --git a/ohmpi.py b/ohmpi.py index 44450d34..90efae8c 100644 --- a/ohmpi.py +++ b/ohmpi.py @@ -137,7 +137,7 @@ class OhmPi(object): self.exec_logger.debug('Acquisition parameters updated: ' + str(self.pardict)) def _read_hardware_parameters(self): - """Read hardware parameters from settings.py. + """Read hardware parameters from config.py """ from config import OHMPI_CONFIG self.id = OHMPI_CONFIG['id'] # ID of the OhmPi @@ -161,7 +161,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 @@ -195,7 +195,11 @@ class OhmPi(object): @staticmethod def get_platform(): - """Get platform name and check if it is a raspberry pi""" + """Get platform name and check if it is a raspberry pi + Returns + ======= + str, bool + name of the platform on which the code is running, boolean that is true if the platform is a raspberry pi""" platform = 'unknown' on_pi = False @@ -219,7 +223,7 @@ class OhmPi(object): Returns ------- - output : numpy.array + output : numpy.ndarray Array of shape (number quadrupoles * 4). """ output = np.loadtxt(filename, delimiter=" ", dtype=int) # load quadrupole file @@ -455,7 +459,7 @@ class OhmPi(object): sum_ps = sum_ps + vmn1 # TODO get battery voltage and warn if battery is running low - + # TODO send a message on SOH stating the battery level end_calc = time.time() # TODO I am not sure I understand the computation below @@ -661,9 +665,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.1.0' print(colored(r' ________________________________' + '\n' + r'| _ | | | || \/ || ___ \_ _|' + '\n' + -- GitLab