X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=testing%2FMCTXWeb%2Fpublic_html%2Fstatic%2Fmctx.control.js;h=212f7088b7010f45b9d71e744c1257784e45c1fb;hb=7deca6b4e089e76e279ae84c0aa25728d91e8fd9;hp=1d5c744d6066f433e094c472d93e7a138f8edc07;hpb=8be554d787c35f80ffd91d77dba87543ff9eda6f;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 1d5c744..212f708 100644
--- a/testing/MCTXWeb/public_html/static/mctx.control.js
+++ b/testing/MCTXWeb/public_html/static/mctx.control.js
@@ -21,6 +21,7 @@ function toggleControls(running) {
$("#start-widget").hide();
} else {
$("#start-widget").show();
+ $("#start-widget input").removeAttr("disabled");
$("#experiment-stop").hide();
$("#pressure-widget").hide();
}
@@ -47,6 +48,7 @@ function setSampleRate(id, val, result) {
$.fn.loadSensorList = function (result, input) {
var select = this;
+ select.empty(); //Reset list
$.ajax({
url : mctx.api + 'identify',
@@ -56,7 +58,7 @@ $.fn.loadSensorList = function (result, input) {
return;
}
for (var id in data.sensors) {
- var option = $("", {value : id, text : data.sensors[id]});
+ var option = $("", {value : id, text : data.sensors[id].name});
select.append(option);
}
});
@@ -103,13 +105,15 @@ $.fn.setStatusUpdater = function () {
fail = true;
}
- if (data.control_state_id !== mctx.control.state) {
+ 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;
@@ -130,6 +134,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;
+
if (!experiment || !experiment.match(/^[a-zA-Z0-9_-]+$/)) {
result.text("Experiment names must be composed of alphanumeric characters" +
" or the characters -_-").addClass("fail");
@@ -142,16 +148,44 @@ $.fn.startExperiment = function (group, experiment, force, result) {
data.force = 1;
}
+ //Start the experiment
$.ajax({
url : mctx.control.api,
data : data
}).done(function (data) {
if (!result.checkStatus(data)) {
- return;
+ $(group).removeAttr('disabled');
+ return;
}
- result.html(" ");
- toggleControls(true);
- }).always(function () {
+
+ //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;
+ }
+
+ //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');
});
};
@@ -187,11 +221,11 @@ $.fn.setPressure = function(pressure, result) {
pressure[k] = n;
}
- var set = pressure['set'] + "," + pressure['wait'] + ","
- pressure['size'] + "," + pressure['count'];
- $.ajax({
+ var set = pressure['set'] + "_" + pressure['wait'] + "_" +
+ pressure['step'] + "_" + pressure['count'];
+ return $.ajax({
url : mctx.api + "actuators",
- data : {id : mctx.actuator.pressure_regulator, set : set}
+ data : {name : "pregulator", set : set}
}).done(function (data) {
if (!result.checkStatus(data)) {
return;