From: Jeremy Tan Date: Mon, 14 Oct 2013 07:43:36 +0000 (+0800) Subject: Merge branch 'master' of https://github.com/szmoore/MCTX3420.git X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=725ecf0f529c604ce67da5d281a95ba9e8b68e36;hp=85a4ea3366eaf09950957e416a2e12c8e4270f92;p=matches%2FMCTX3420.git Merge branch 'master' of https://github.com/szmoore/MCTX3420.git --- diff --git a/server/actuator.c b/server/actuator.c index 3e26e37..ab48d19 100644 --- a/server/actuator.c +++ b/server/actuator.c @@ -336,7 +336,7 @@ void Actuator_Handler(FCGIContext * context, char * params) FCGI_RejectJSON(context, "No id or name supplied"); return; } - else if (id < 0 || id >= ACTUATORS_MAX) + else if (id < 0 || id >= g_num_actuators) { FCGI_RejectJSON(context, "Invalid Actuator id"); return; @@ -364,7 +364,7 @@ void Actuator_Handler(FCGIContext * context, char * params) // If the user doesn't provide all 4 values, the Actuator will get set *once* using the first of the provided values // (see Actuator_Loop) // Not really a problem if n = 1, but maybe generate a warning for 2 <= n < 4 ? - Log(LOGDEBUG, "Only provided %d values (expect %d) for Actuator setting", n); + Log(LOGDEBUG, "Only provided %d values (expect %d) for Actuator setting", n, 4); } // SANITY CHECKS if (c.stepwait < 0 || c.steps < 0 || (a->sanity != NULL && !a->sanity(a->user_id, c.start))) @@ -373,7 +373,6 @@ void Actuator_Handler(FCGIContext * context, char * params) return; } Actuator_SetControl(a, &c); - } // Begin response diff --git a/server/control.c b/server/control.c index 0242a3b..d9a7dc6 100644 --- a/server/control.c +++ b/server/control.c @@ -38,18 +38,17 @@ void Control_Handler(FCGIContext *context, char *params) { ControlModes desired_mode; - // Login/auth now handled entirely in fastcgi.c and login.c //TODO: Need to not have the ability for any user to stop someone else' experiment... // (achieve by storing the username of the person running the current experiment, even when they log out?) // (Our program should only realisitically support a single experiment at a time, so that should be sufficient) - FCGIValue values[4] = { + FCGIValue values[3] = { {"action", &action, FCGI_REQUIRED(FCGI_STRING_T)}, {"force", &force, FCGI_BOOL_T}, {"name", &name, FCGI_STRING_T} }; - if (!FCGI_ParseRequest(context, params, values, 4)) + if (!FCGI_ParseRequest(context, params, values, 3)) return; if (!strcmp(action, "emergency")) { diff --git a/server/fastcgi.c b/server/fastcgi.c index fe461b8..cdaef79 100644 --- a/server/fastcgi.c +++ b/server/fastcgi.c @@ -510,15 +510,9 @@ void * FCGI_RequestLoop (void *data) //if (module_handler != Login_Handler && module_handler != IdentifyHandler) if (false) // Testing { - if (cookie[0] == '\0') - { - FCGI_RejectJSONEx(&context, STATUS_UNAUTHORIZED, "Please login."); - continue; - } - if (!FCGI_HasControl(&context, cookie)) { - FCGI_RejectJSON(&context, "Invalid control key."); + FCGI_RejectJSON(&context, "Please login. Invalid control key."); continue; } @@ -533,9 +527,6 @@ void * FCGI_RequestLoop (void *data) { FCGI_RejectJSON(&context, "Unhandled module"); } - - - } Log(LOGDEBUG, "Thread exiting."); diff --git a/server/fastcgi.h b/server/fastcgi.h index 269bb94..dd89594 100644 --- a/server/fastcgi.h +++ b/server/fastcgi.h @@ -46,6 +46,8 @@ typedef struct time_t control_timestamp; /**A SHA-1 hash that is the control key, determining who is logged in**/ char control_key[41]; + /**Determines if the user is an admin or not**/ + bool is_admin; /**The IPv4 address of the logged-in user**/ char control_ip[16]; /**A friendly name for the logged-in user. Max length 30**/ diff --git a/testing/MCTXWeb/public_html/control.html b/testing/MCTXWeb/public_html/control.html index ecefd5a..f762019 100644 --- a/testing/MCTXWeb/public_html/control.html +++ b/testing/MCTXWeb/public_html/control.html @@ -86,8 +86,10 @@ diff --git a/testing/MCTXWeb/public_html/data-Justin.html b/testing/MCTXWeb/public_html/data-Justin.html deleted file mode 100644 index 975b538..0000000 --- a/testing/MCTXWeb/public_html/data-Justin.html +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - - - - MCTX3420 Web Interface - - - - - - - - - - - - -
- -
- - -
- - -
- - - -
-
-
Experiment Data
- Current Experiment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
View Sensor DataStrain 1Strain 2Strain 3Strain 4Pressure 1Pressure 2
Save Sensor Data
DilatometerView Data
Camera DataView Data
Graphs -
- -
- -
- -

Previous Experiments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select Experiment - - - -
Experiment DateDATE LOOKUP
View Sensor DataStrain 1Strain 2Strain 3Strain 4Pressure 1Pressure 2
Save Sensor Data
DilatometerView Data
Camera DataView Data
Graphs -
- -
-
- -
-
- -
-
- - diff --git a/testing/MCTXWeb/public_html/data.html b/testing/MCTXWeb/public_html/data.html new file mode 100644 index 0000000..14f54a6 --- /dev/null +++ b/testing/MCTXWeb/public_html/data.html @@ -0,0 +1,273 @@ + + + + + + + + + MCTX3420 Web Interface + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + + +
+
+
Experiment Data
+ Current Experiment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
View Sensor DataStrain 1Strain 2Strain 3Strain 4Pressure 1Pressure 2
Save Sensor Data
DilatometerView Data
Camera DataView Data
Graphs +
+ +
+ +
+ +

Previous Experiments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Select Experiment + + + +
Experiment DateDATE LOOKUP
View Sensor DataStrain 1Strain 2Strain 3Strain 4Pressure 1Pressure 2
Save Sensor Data
DilatometerView Data
Camera DataView Data
Graphs +
+ +
+
+ +
+
+ +
+
+ + diff --git a/testing/MCTXWeb/public_html/graph.html b/testing/MCTXWeb/public_html/graph.html index c15d855..137c004 100644 --- a/testing/MCTXWeb/public_html/graph.html +++ b/testing/MCTXWeb/public_html/graph.html @@ -4,31 +4,94 @@ MCTX3420 Web Interface - + -
+
+ +
+ +
+ +
+ + +
Graph
@@ -39,43 +102,46 @@
X-Axis -
time
+
+ + +
Y-Axis -
+
+
none
-->
-
+

- Time of Last Update - Start Time - End Time + Time of Last Update + Start Time + End Time

- - - - + + + +
- +

Mode: Normal + EXPLODE!

+ Filename: + + +
+ -->
-
+
+ - + \ No newline at end of file diff --git a/testing/MCTXWeb/public_html/help-Justin.html b/testing/MCTXWeb/public_html/help-Justin.html deleted file mode 100644 index acf23a9..0000000 --- a/testing/MCTXWeb/public_html/help-Justin.html +++ /dev/null @@ -1,186 +0,0 @@ - - - - MCTX3420 Web Interface - - - - - - - - - - -
- -
- - -
-
- - - -
-
-
Getting Started
-

Welcome to the MCTX3420 project documentation! On this page, you will find help on how to use the project software, - as well as information about the various hardware components.

-

For a basic introduction to using the experiment, see 'Tutorials'. - System overview provides a general overview of the experiment's hardware, while - Using the web interface provides a tutorial on using the the project software. - For detailed information about the experiment hardware, see the 'Hardware' section. For detailed information about the project software, - see the 'Software' section.

-
Tutorials
- -
Hardware
- -
Software
- -
- -
-
Project Wiki
-

All of the project's help documentation is stored in its GitHub wiki. This git repository also - stores all of the software code for the project; to access the project code files, visit this link.

-

The following is a list of pages on the GitHub wiki (all of which can be accessed via the categories above):

-

-
-
- -
-
- - diff --git a/testing/MCTXWeb/public_html/help.html b/testing/MCTXWeb/public_html/help.html new file mode 100644 index 0000000..cad8b0a --- /dev/null +++ b/testing/MCTXWeb/public_html/help.html @@ -0,0 +1,188 @@ + + + + MCTX3420 Web Interface + + + + + + + + + + +
+ +
+ + +
+
+ + + +
+
+
Getting Started
+

Welcome to the MCTX3420 project documentation! On this page, you will find help on how to use the project software, + as well as information about the various hardware components.

+

For a basic introduction to using the experiment, see 'Tutorials'. + System overview provides a general overview of the experiment's hardware, while + Using the web interface provides a tutorial on using the the project software. + For detailed information about the experiment hardware, see the 'Hardware' section. For detailed information about the project software, + see the 'Software' section.

+
Tutorials
+ +
Hardware
+ +
Software
+ +
+ +
+
Project Wiki
+

All of the project's help documentation is stored in its GitHub wiki. This git repository also + stores all of the software code for the project; to access the project code files, visit this link.

+

The following is a list of pages on the GitHub wiki (all of which can be accessed via the categories above):

+

+
+
+ +
+
+ + diff --git a/testing/MCTXWeb/public_html/index.html b/testing/MCTXWeb/public_html/index.html index 4ffacec..77c7f75 100644 --- a/testing/MCTXWeb/public_html/index.html +++ b/testing/MCTXWeb/public_html/index.html @@ -21,7 +21,11 @@ $("#logout").logout(); }); }); - }) + }).always(function () { + $(document).ready(function () { + //$("#sidebar-menu").populateNavMenu(); + }); + }); @@ -68,12 +72,14 @@ diff --git a/testing/MCTXWeb/public_html/static/mctx.graph.js b/testing/MCTXWeb/public_html/static/mctx.graph.js index f71b52a..687db84 100644 --- a/testing/MCTXWeb/public_html/static/mctx.graph.js +++ b/testing/MCTXWeb/public_html/static/mctx.graph.js @@ -14,6 +14,7 @@ mctx.actuators = {}; mctx.graph.dependent = null; mctx.graph.independent = null; mctx.graph.timer = null; +mctx.graph.running = false; /** * Helper - Calculate pairs of (dependent, independent) values @@ -22,12 +23,11 @@ mctx.graph.timer = null; * @returns result */ function dataMerge(dependent, independent, result) { - var j = 0; for (var i = 0; i < dependent.length-1; ++i) { var start = dependent[i][0]; var end = dependent[i+1][0]; - var average = 0; var n = 0; + var average = 0, n = 0; for (; j < independent.length; ++j) { if (independent[j][0] < start) continue; @@ -39,31 +39,36 @@ function dataMerge(dependent, independent, result) { if (n > 0) { average /= n; result.push([dependent[i][1], average]); - } + } } return result; } /** * Helper function adds the sensors and actuators to a form + * @param input_type is it a radio? or is it a checkbox? + * @param check_first determines whether the first item is checked or not + * @param group which group this input belongs to (name field) */ -$.fn.deployDevices = function(input_type, check_first) { - var formhtml = $(this).html(); - var formname = $(this).attr("id"); - // formhtml += " Sensors " - var checked = "checked"; - if (!check_first) - checked = ""; - $.each(mctx.sensors, function(key, val) { - formhtml += "" + val + ""; - checked = ""; - }); - // formhtml += " Actuators " - $.each(mctx.actuators, function(key, val) { - formhtml += "" + val + ""; - checked = ""; - }); - $(this).html(formhtml); +$.fn.deployDevices = function(input_type, check_first, group) { + var container = this; + var apply = function(dict, prefix) { + $.each(dict, function(key, val) { + var attributes = { + 'type' : input_type, 'value' : key, 'alt' : val, + 'class' : prefix, 'name' : group, + 'id' : prefix + '_' + val //Unique id (name mangling) + }; + var entry = $("", attributes); + var label = $("