Commit 4b8c4d6e authored by Arnaud WATLET's avatar Arnaud WATLET
Browse files

renames start and stop commands to run_sequence and interrupt in http interface

Showing with 14 additions and 14 deletions
+14 -14
...@@ -91,12 +91,12 @@ class MyServer(SimpleHTTPRequestHandler): ...@@ -91,12 +91,12 @@ class MyServer(SimpleHTTPRequestHandler):
# global ohmpiThread, status, run # global ohmpiThread, status, run
dic = json.loads(self.rfile.read(int(self.headers['Content-Length']))) dic = json.loads(self.rfile.read(int(self.headers['Content-Length'])))
rdic = {} # response dictionary rdic = {} # response dictionary
if dic['cmd'] == 'start': if dic['cmd'] == 'run_sequence':
payload = json.dumps({'cmd_id': cmd_id, 'cmd': 'start'}) payload = json.dumps({'cmd_id': cmd_id, 'cmd': 'run_sequence'})
publish.single(payload=payload, **publisher_config) publish.single(payload=payload, **publisher_config)
elif dic['cmd'] == 'stop': elif dic['cmd'] == 'interrupt':
# ohmpi.stop() # 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) publish.single(payload=payload, **publisher_config)
elif dic['cmd'] == 'getData': elif dic['cmd'] == 'getData':
# get all .csv file in data folder # get all .csv file in data folder
......
...@@ -18,15 +18,15 @@ ...@@ -18,15 +18,15 @@
<h1>OhmPi Acquisition Board</h1> <h1>OhmPi Acquisition Board</h1>
<!-- nb stacks, on-time --> <!-- nb stacks, on-time -->
<button id="update_settingsBtn" type="button" class="btn btn-secondary" data-toggle="modal" data-target="#exampleModal">Settings</button> <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='runBtn' type="button" class="btn btn-primary">Run</button>
<button id='stopBtn' type="button" class="btn btn-warning">Stop</button> <button id='stopBtn' type="button" class="btn btn-warning">Interrupt</button>
<!-- upload button for csv which display the table ABMN --> <!-- upload button for csv which display the table ABMN -->
<button id="removeDataBtn" type="button" class="btn btn-danger">Clear data</button> <button id="removeDataBtn" type="button" class="btn btn-danger">Clear data</button>
<button id="getDataBtn" type="button" class="btn btn-info">Get data</button> <button id="getDataBtn" type="button" class="btn btn-info">Get data</button>
<div class="form-check"> <div class="form-check">
<input id="dataRetrievalCheck" class="form-check-input" type="checkbox" value=""> <input id="dataRetrievalCheck" class="form-check-input" type="checkbox" value="">
<label class="form-check-label" for="dataRetrievalCheck"> <label class="form-check-label" for="dataRetrievalCheck">
Automaticaly get data every 1 second Automaticaly get data every 1 secondStart
</label> </label>
</div> </div>
<div id='output'>Status: idle</div> <div id='output'>Status: idle</div>
...@@ -161,21 +161,21 @@ ...@@ -161,21 +161,21 @@
xhr.send(query) xhr.send(query)
} }
// start button // run button
function startBtnFunc() { function runBtnFunc() {
sendCommand('{"cmd": "start"}', function(x) { sendCommand('{"cmd": "run_sequence"}', function(x) {
console.log(x['status']) console.log(x['status'])
if (x['status'] == 'running') { if (x['status'] == 'running') {
output.innerHTML = 'Status: measuring...' output.innerHTML = 'Status: measuring...'
} }
}) })
} }
let startBtn = document.getElementById('startBtn') let runBtn = document.getElementById('runBtn')
startBtn.addEventListener('click', startBtnFunc) runBtn.addEventListener('click', runBtnFunc)
// stop button // interrupt button
function stopBtnFunc() { function stopBtnFunc() {
sendCommand('{"cmd": "stop"}', function(x) { sendCommand('{"cmd": "interrupt"}', function(x) {
output.innerHTML = 'Status: ' + x['status'] output.innerHTML = 'Status: ' + x['status']
clearInterval(interv) clearInterval(interv)
getData() getData()
......
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