From 4b8c4d6e1a2f32ca9297a80debfb14744c517bf5 Mon Sep 17 00:00:00 2001 From: awatlet <arnaud.watlet@umons.ac.be> Date: Fri, 28 Oct 2022 11:18:24 +0200 Subject: [PATCH] renames start and stop commands to run_sequence and interrupt in http interface --- http_interface.py | 8 ++++---- index.html | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/http_interface.py b/http_interface.py index ab13c81d..ac204375 100644 --- a/http_interface.py +++ b/http_interface.py @@ -91,12 +91,12 @@ class MyServer(SimpleHTTPRequestHandler): # global ohmpiThread, status, run dic = json.loads(self.rfile.read(int(self.headers['Content-Length']))) rdic = {} # response dictionary - if dic['cmd'] == 'start': - payload = json.dumps({'cmd_id': cmd_id, 'cmd': 'start'}) + if dic['cmd'] == 'run_sequence': + payload = json.dumps({'cmd_id': cmd_id, 'cmd': 'run_sequence'}) publish.single(payload=payload, **publisher_config) - elif dic['cmd'] == 'stop': + elif dic['cmd'] == 'interrupt': # ohmpi.stop() - payload = json.dumps({'cmd_id': cmd_id, 'cmd': 'stop'}) + payload = json.dumps({'cmd_id': cmd_id, 'cmd': 'interrupt'}) publish.single(payload=payload, **publisher_config) elif dic['cmd'] == 'getData': # get all .csv file in data folder diff --git a/index.html b/index.html index ee10373b..e76fd112 100644 --- a/index.html +++ b/index.html @@ -18,15 +18,15 @@ <h1>OhmPi Acquisition Board</h1> <!-- nb stacks, on-time --> <button id="update_settingsBtn" type="button" class="btn btn-secondary" data-toggle="modal" data-target="#exampleModal">Settings</button> - <button id='startBtn' type="button" class="btn btn-primary">Start</button> - <button id='stopBtn' type="button" class="btn btn-warning">Stop</button> + <button id='runBtn' type="button" class="btn btn-primary">Run</button> + <button id='stopBtn' type="button" class="btn btn-warning">Interrupt</button> <!-- upload button for csv which display the table ABMN --> <button id="removeDataBtn" type="button" class="btn btn-danger">Clear data</button> <button id="getDataBtn" type="button" class="btn btn-info">Get data</button> <div class="form-check"> <input id="dataRetrievalCheck" class="form-check-input" type="checkbox" value=""> <label class="form-check-label" for="dataRetrievalCheck"> - Automaticaly get data every 1 second + Automaticaly get data every 1 secondStart </label> </div> <div id='output'>Status: idle</div> @@ -161,21 +161,21 @@ xhr.send(query) } - // start button - function startBtnFunc() { - sendCommand('{"cmd": "start"}', function(x) { + // run button + function runBtnFunc() { + sendCommand('{"cmd": "run_sequence"}', function(x) { console.log(x['status']) if (x['status'] == 'running') { output.innerHTML = 'Status: measuring...' } }) } - let startBtn = document.getElementById('startBtn') - startBtn.addEventListener('click', startBtnFunc) + let runBtn = document.getElementById('runBtn') + runBtn.addEventListener('click', runBtnFunc) - // stop button + // interrupt button function stopBtnFunc() { - sendCommand('{"cmd": "stop"}', function(x) { + sendCommand('{"cmd": "interrupt"}', function(x) { output.innerHTML = 'Status: ' + x['status'] clearInterval(interv) getData() -- GitLab