diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..411f65872b6b5acccde4445192ad665579f627b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +data/* +**/.ipynb_notebooks/** +data.zip +__pycache__ +Ohmpi_4elec_mqtt.py +ohmpy/* +logs/* +sequence.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..f2e6e93d68a55eaefb2e97cae411327e4b70ef3e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,21 @@ +image: python:3.9-bullseye +# This file is a template, and might need editing before it works on your project. +# Full project: https://gitlab.com/pages/plain-html +pages: + stage: deploy + script: + - apt-get update + - apt-get install --assume-yes pandoc + - pip install numpy pandas termcolor paho-mqtt # top import of Ohmpi.py + - pip install sphinx numpydoc sphinx_rtd_theme pandoc recommonmark + - cd doc + - make html + # also make latex? pdf? + - cd .. + - mv doc/build/html/ public/ + - ls public/ + artifacts: + paths: + - public/ + only: + - master diff --git a/index.html b/index.html index ee10373ba50e0f40cc12c95a2e7f94e15db2b7f6..f55d5d9d2580c9685af550e1dc12828bb21e3ac1 100644 --- a/index.html +++ b/index.html @@ -142,7 +142,11 @@ // useful functions function sendCommand(query, callback=null) { +<<<<<<< HEAD // dic in the form: {'cmd': X, ...} as JSON +======= + // dic in the form: {'command': X, ...} as JSON +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a if (callback == null) { function callback(x) { console.log('default callback:', x) @@ -163,7 +167,11 @@ // start button function startBtnFunc() { +<<<<<<< HEAD sendCommand('{"cmd": "start"}', function(x) { +======= + sendCommand('{"command": "start"}', function(x) { +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a console.log(x['status']) if (x['status'] == 'running') { output.innerHTML = 'Status: measuring...' @@ -175,7 +183,11 @@ // stop button function stopBtnFunc() { +<<<<<<< HEAD sendCommand('{"cmd": "stop"}', function(x) { +======= + sendCommand('{"command": "stop"}', function(x) { +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a output.innerHTML = 'Status: ' + x['status'] clearInterval(interv) getData() @@ -197,10 +209,17 @@ // define callback to send settigs to Pi function configCallback() { sendCommand(JSON.stringify({ +<<<<<<< HEAD 'cmd': 'update_settings', 'config': formVals }), function(x) { console.log('update_settings', x) +======= + 'command': 'setConfig', + 'config': formVals + }), function(x) { + console.log('setconfig:', x) +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a }) } @@ -351,7 +370,11 @@ // run RS check function rsBtnFunc() { +<<<<<<< HEAD sendCommand('{"cmd": "rsCheck"}', function (res) { +======= + sendCommand('{"command": "rsCheck"}', function (res) { +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a // update the bar plot rsdata.push({ x: res['data']['AB'], @@ -376,7 +399,11 @@ // getData function getData() { sendCommand(JSON.stringify({ +<<<<<<< HEAD 'cmd': 'getData', +======= + 'command': 'getData', +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a 'surveyNames': Object.keys(data).slice(0, -1) // last survey is often partial so we download it again }), function(ddic) { @@ -497,7 +524,11 @@ // remove data function removeDataBtnFunc() { +<<<<<<< HEAD sendCommand('{"cmd": "removeData"}',function(x) { +======= + sendCommand('{"command": "removeData"}',function(x) { +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a data = {} output.innerHTML = 'Status: ' + x['status'] + ' (all data cleared)' console.log('all data removed') @@ -508,7 +539,11 @@ // shutdown Pi function shutdownBtnFunc() { +<<<<<<< HEAD sendCommand('{"cmd": "shutdown"}', function(x) { +======= + sendCommand('{"command": "shutdown"}', function(x) { +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a console.log('shuting down...') }) } @@ -517,7 +552,11 @@ // restart Pi function restartBtnFunc() { +<<<<<<< HEAD sendCommand('{"cmd": "restart"}', function(x) { +======= + sendCommand('{"command": "restart"}', function(x) { +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a console.log('rebooting...') }) } @@ -526,7 +565,11 @@ // invert data // function invertBtnFunc() { +<<<<<<< HEAD // sendCommand('{"cmd": "invert"}', function(x) { +======= + // sendCommand('{"command": "invert"}', function(x) { +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a // console.log('inversion results', x) // }) // } @@ -535,7 +578,11 @@ // download data function downloadBtnFunc() { +<<<<<<< HEAD sendCommand('{"cmd": "download"}', function(x) { +======= + sendCommand('{"command": "download"}', function(x) { +>>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a let dwl = document.getElementById('download') dwl.setAttribute('href', serverUrl + '/data.zip') dwl.setAttribute('download', 'data.zip') diff --git a/mqtt_interface.py b/mqtt_interface.py index ed5837aed44fd5f7323fe53c2d7ee74e23147529..fe6e1f4a9bea0dc1bf2b7b5524d25adba6fc9472 100644 --- a/mqtt_interface.py +++ b/mqtt_interface.py @@ -11,6 +11,7 @@ def on_message(client, userdata, message): # Send the command print(f'Sending command {message.payload.decode("utf-8")}') +<<<<<<< HEAD socket.send(message.payload) # Get the reply @@ -50,3 +51,4 @@ if broker_connected: else: print("Unable to connect to broker") exit(1) + diff --git a/mqtt_logger.py b/mqtt_logger.py index 73106af168209f5ac1a9b037c30fa5a2c3e78a12..02f1c041a7c01cac984f900e59fedace065467d3 100644 --- a/mqtt_logger.py +++ b/mqtt_logger.py @@ -59,3 +59,4 @@ class MQTTHandler(logging.Handler): protocol=self.protocol, transport=self.transport) except Exception as e: print(e) + diff --git a/ohmpi.py b/ohmpi.py index c066a368d3db88fff869218c3377ffcecde4ba61..824138a4a19cef5cb8cb3fb997ab792f03368b54 100644 --- a/ohmpi.py +++ b/ohmpi.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ created on January 6, 2020. -Update May 2022 +Updates May 2022, Oct 2022. Ohmpi.py is a program to control a low-cost and open hardware resistivity meter OhmPi that has been developed by Rémi CLEMENT (INRAE),Vivien DUBOIS (INRAE), Hélène GUYARD (IGE), Nicolas FORQUET (INRAE), Yannick FARGIER (IFSTTAR) Olivier KAUFMANN (UMONS) and Guillaume BLANCHY (ILVO). @@ -10,7 +10,6 @@ Olivier KAUFMANN (UMONS) and Guillaume BLANCHY (ILVO). import os import io import json -# import subprocess import numpy as np import csv @@ -707,8 +706,6 @@ class OhmPi(object): reply = {'cmd_id': cmd_id, 'status': status} reply = json.dumps(reply) self.exec_logger.debug(f'Execution report: {reply}') - # self.exec_logger.debug(reply) - # reply = bytes(reply, 'utf-8') reply = reply.encode('utf-8') socket.send(reply) except zmq.ZMQError as e: diff --git a/run.sh b/run.sh index 14ddf4c1ff4d38277d872bc1ddfc3bced63253e9..277fafc2181d217d1085ec8f1f282e501569ec68 100755 --- a/run.sh +++ b/run.sh @@ -1,5 +1,4 @@ #!bin/bash -cd /home/pi/OhmPi -source "/home/pi/OhmPi/ohmpy/bin/activate" -python --version -python /home/pi/OhmPi/ohmpi.py + +source ./ohmpy/bin/activate +python ohmpi.py