X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=testing%2FMCTXWeb%2Fpublic_html%2Fstatic%2Fmctx.control.js;h=d3b5348eeb9e563368d00711b06471a654c3403e;hb=7e9d726ccd53626251e56b92c8eec47772bfe0f9;hp=cf6762994ef038e57e0c2a233acc262d4efbf2d6;hpb=fc0dc3b827eeff91373db42a78a098200cbf8fa6;p=matches%2FMCTX3420.git diff --git a/testing/MCTXWeb/public_html/static/mctx.control.js b/testing/MCTXWeb/public_html/static/mctx.control.js index cf67629..d3b5348 100644 --- a/testing/MCTXWeb/public_html/static/mctx.control.js +++ b/testing/MCTXWeb/public_html/static/mctx.control.js @@ -5,13 +5,228 @@ mctx.control = {}; mctx.control.api = mctx.api + 'control' +mctx.control.states = { + start : 0, + pause : 1, + resume : 2, + stop : 3, + emergency : 4 +}; +mctx.control.state = null; -$(document).ready(function () { +function toggleControls(running) { + if (running) { + $("#experiment-stop").show(); + $("#pressure-widget").show(); + $("#start-widget").hide(); + } else { + $("#start-widget").show(); + $("#experiment-stop").hide(); + $("#pressure-widget").hide(); + } +} + +function setSampleRate(id, val, result) { + var n = Number(val); + if (isNaN(n) || n < 0) { + result.text("You must give positive numeric values.").addClass("fail"); + return; + } + $.ajax({ - url : mctx.control.api, - data : {'action' : 'identify'} - }).done(function () { + url : mctx.api + 'sensors', + data : {id : id, sample_s : n} + }).done(function(data) { + if (!result.checkStatus(data)) { + return; + } + + result.text("Set ok!").removeClass("fail").addClass("pass"); + }); +}; + +$.fn.loadSensorList = function (result, input) { + var select = this; + select.empty(); //Reset list + + $.ajax({ + url : mctx.api + 'identify', + data : {'sensors' : 1} + }).done(function(data) { + if (!result.checkStatus(data)) { + return; + } + for (var id in data.sensors) { + var option = $("