diff --git a/config.py b/config.py index e8e74a6d170091a404a4273c3a2331661f1b3809..de61e9c5e8b56bfef517ba5d4c985717973df4e6 100644 --- a/config.py +++ b/config.py @@ -20,7 +20,7 @@ OHMPI_CONFIG = { CONTROL_CONFIG = { 'tcp_port': 5555, - 'interface': 'http_interface.py' # 'mqtt_interface' + 'interface': 'mqtt_interface.py' # 'mqtt_interface' } # Execution logging configuration EXEC_LOGGING_CONFIG = { diff --git a/index.html b/index.html index f55d5d9d2580c9685af550e1dc12828bb21e3ac1..ee10373ba50e0f40cc12c95a2e7f94e15db2b7f6 100644 --- a/index.html +++ b/index.html @@ -142,11 +142,7 @@ // 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) @@ -167,11 +163,7 @@ // 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...' @@ -183,11 +175,7 @@ // stop button function stopBtnFunc() { -<<<<<<< HEAD sendCommand('{"cmd": "stop"}', function(x) { -======= - sendCommand('{"command": "stop"}', function(x) { ->>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a output.innerHTML = 'Status: ' + x['status'] clearInterval(interv) getData() @@ -209,17 +197,10 @@ // 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 }) } @@ -370,11 +351,7 @@ // 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'], @@ -399,11 +376,7 @@ // 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) { @@ -524,11 +497,7 @@ // 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') @@ -539,11 +508,7 @@ // shutdown Pi function shutdownBtnFunc() { -<<<<<<< HEAD sendCommand('{"cmd": "shutdown"}', function(x) { -======= - sendCommand('{"command": "shutdown"}', function(x) { ->>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a console.log('shuting down...') }) } @@ -552,11 +517,7 @@ // restart Pi function restartBtnFunc() { -<<<<<<< HEAD sendCommand('{"cmd": "restart"}', function(x) { -======= - sendCommand('{"command": "restart"}', function(x) { ->>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a console.log('rebooting...') }) } @@ -565,11 +526,7 @@ // invert data // function invertBtnFunc() { -<<<<<<< HEAD // sendCommand('{"cmd": "invert"}', function(x) { -======= - // sendCommand('{"command": "invert"}', function(x) { ->>>>>>> a52ac9e5e0984f701ed4e4c3a437d7ae4cf0673a // console.log('inversion results', x) // }) // } @@ -578,11 +535,7 @@ // 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 fe6e1f4a9bea0dc1bf2b7b5524d25adba6fc9472..443fec4a7d7316f1bc9a8e262ee0e48210a3f802 100644 --- a/mqtt_interface.py +++ b/mqtt_interface.py @@ -11,7 +11,6 @@ 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 diff --git a/run.sh b/run.sh index 277fafc2181d217d1085ec8f1f282e501569ec68..20e920502eca97449578502248296edbee2805f9 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,6 @@ #!bin/bash -source ./ohmpy/bin/activate +cd /home/pi/OhmPi + +source /home/pi/OhmPi/ohmpy/bin/activate python ohmpi.py