X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=testing%2FMCTXWeb%2Fpublic_html%2Fstatic%2Fmctx.control.js;h=f414a82fc327dd88fec5d67c1aee328945808bed;hb=88497ad20dbc7b92041ad5d441b26e2bfc0775a5;hp=de45e6161405c8c512adcf4e9015e2cde49dd9a2;hpb=edb6df04611c10dca29799a1e08096bd4ca28303;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 de45e61..f414a82 100644 --- a/testing/MCTXWeb/public_html/static/mctx.control.js +++ b/testing/MCTXWeb/public_html/static/mctx.control.js @@ -47,7 +47,7 @@ function setSampleRate(id, val, result) { $.fn.loadSensorList = function (result, input) { var select = this; - select.empty(); //Reset list + select.empty(); //Reset list $.ajax({ url : mctx.api + 'identify', @@ -104,15 +104,15 @@ $.fn.setStatusUpdater = function () { fail = true; } - if (data.control_state_id !== mctx.control.state) { - //Set logic for sensor sample rate thing + if (data.control_state_id !== mctx.control.state) { + //Set logic for sensor sample rate thing $("#sensor-select").loadSensorList($("#samplerate-result")); toggleControls(running); $(result).text(text); if (fail) { - $(result).parent().addClass("fail"); + $(result).parent().addClass("fail").removeClass("pass"); } else { - $(result).parent().addClass("pass"); + $(result).parent().addClass("pass").removeClass("fail"); } mctx.control.state = data.control_state_id; @@ -132,8 +132,8 @@ $.fn.setStatusUpdater = function () { $.fn.startExperiment = function (group, experiment, force, result) { $(group).attr('disabled', 'disabled'); - - var can_number = ($(this).attr("name") === "start_strain") ? 0 : 1; + + var can_number = ($(this).attr("name") === "start_strain") ? 0 : 1; if (!experiment || !experiment.match(/^[a-zA-Z0-9_-]+$/)) { result.text("Experiment names must be composed of alphanumeric characters" + @@ -146,40 +146,43 @@ $.fn.startExperiment = function (group, experiment, force, result) { if (force) { data.force = 1; } - + //Start the experiment $.ajax({ url : mctx.control.api, data : data }).done(function (data) { if (!result.checkStatus(data)) { + $(group).removeAttr('disabled'); + return; + } + + //Select the can + $.ajax({ + url : mctx.api + "actuators", + data : {name : "can_select", set : can_number} + }).done(function (data) { + if (!result.checkStatus(data)) { + $(group).removeAttr('disabled'); return; - } - - //Select the can - $.ajax({ - url : mctx.api + "actuators", - data : {name : "can_select", set : can_number} - }).done(function (data) { - if (!result.checkStatus(data)) { - return; - } - - //Enable the can - $.ajax({ - url : mctx.api + 'actuators', - data : {name : "can_enable", set : 1} - }).done(function (data) { - if (!result.checkStatus(data)) { - return; - } - result.html(" "); - toggleControls(true); - }).always(function () { - $(group).removeAttr('disabled'); - }); - }).fail(function () { - $(group).removeAttr('disabled'); + } + + //Enable the can + $.ajax({ + url : mctx.api + 'actuators', + data : {name : "can_enable", set : 1} + }).done(function (data) { + if (!result.checkStatus(data)) { + $(group).removeAttr('disabled'); + return; + } + result.html(" "); + toggleControls(true); + }).fail(function () { + $(group).removeAttr('disabled'); + }); + }).fail(function () { + $(group).removeAttr('disabled'); }); }).fail(function () { $(group).removeAttr('disabled'); @@ -219,7 +222,7 @@ $.fn.setPressure = function(pressure, result) { var set = pressure['set'] + "_" + pressure['wait'] + "_" + pressure['step'] + "_" + pressure['count']; - $.ajax({ + return $.ajax({ url : mctx.api + "actuators", data : {name : "pregulator", set : set} }).done(function (data) {