Merge branch 'master' of https://github.com/szmoore/MCTX3420.git
authorJeremy Tan <[email protected]>
Mon, 14 Oct 2013 07:43:36 +0000 (15:43 +0800)
committerJeremy Tan <[email protected]>
Mon, 14 Oct 2013 07:43:36 +0000 (15:43 +0800)
15 files changed:
server/actuator.c
server/control.c
server/fastcgi.c
server/fastcgi.h
testing/MCTXWeb/public_html/control.html
testing/MCTXWeb/public_html/data-Justin.html [deleted file]
testing/MCTXWeb/public_html/data.html [new file with mode: 0644]
testing/MCTXWeb/public_html/graph.html
testing/MCTXWeb/public_html/help-Justin.html [deleted file]
testing/MCTXWeb/public_html/help.html [new file with mode: 0644]
testing/MCTXWeb/public_html/index.html
testing/MCTXWeb/public_html/pintest.html
testing/MCTXWeb/public_html/static/mctx.graph.js
testing/MCTXWeb/public_html/static/mctx.gui.js
testing/MCTXWeb/public_html/static/style.css

index 3e26e37..ab48d19 100644 (file)
@@ -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
index 0242a3b..d9a7dc6 100644 (file)
@@ -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")) {
index fe461b8..cdaef79 100644 (file)
@@ -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.");
index 269bb94..dd89594 100644 (file)
@@ -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**/
index ecefd5a..f762019 100644 (file)
             <ul>
                <li><a href="index.html"><span>Home</span></a></li>
                <li><a href="control.html"><span>Experiment control</span></a></li>
+               <li><a href="graph.html"><span>Experiment graphs</span></a></li>
+               <li><a href="data.html"><span>Experiment data</span></a></li>
                <li><a href="pintest.html"><span>Pin debugging</span></a></li>
-               <li class="last"><a href="#"><span>Help</span></a></li>
+               <li class="last"><a href="help.html"><span>Help</span></a></li>
             </ul>
             </div>
           </div>
diff --git a/testing/MCTXWeb/public_html/data-Justin.html b/testing/MCTXWeb/public_html/data-Justin.html
deleted file mode 100644 (file)
index 975b538..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-
-<!--Current Experiment section is pretty much working, still working out the previous experiments bit-->
-<!--Basically, the download links and graph links automatically update depending on what is selected in the drop-down menus-->
-<!--Some dodgy javascript is involved but it sort of works-->
-<!--The HTML5 "download" attribute is used to force downloads, but that's not compatible with IE (it just views the files in IE)-->
-<html>
-  <head>
-    <title>MCTX3420 Web Interface</title>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-    <!--[if lte IE 8]>
-      <script language="javascript" type="text/javascript" src="static/excanvas.min.js"></script>
-    <![endif]-->
-    <script type="text/javascript" src="static/jquery-1.10.1.min.js"></script>
-    <script type="text/javascript" src="static/jquery.flot.min.js"></script>
-    <script type="text/javascript" src="static/mctx.gui.js"></script>
-
-    <link rel="stylesheet" type="text/css" href="static/style.css">
-    <link rel="stylesheet" type="text/css" href="static/nav-menu.css">
-    <script type="text/javascript">
-      runBeforeLoad().done(function() {
-        $(document).ready(function() {
-          //Show the content!
-          $("#content").css("display", "block");
-          //Set the welcome bar
-          var name = " " + (mctx.friendlyName ? mctx.friendlyName : "");
-          $("#welcome-container").text("Welcome" + name + "!");
-          $("#logout-container").css("display", "block");
-          //$("#menu-container").populateNavbar();
-
-          $("#logout").click(function() {
-            $("#logout").logout();
-          });
-
-          $("#main_controls").submit(function() {
-            //Validate!
-            return false;
-          });
-
-          $("#errorlog").setErrorLog();
-        });
-      })
-
-      //function to load appropriate graph image depending on drop-down menu
-      function graphLoad(graphid, folder, newgraph) {
-        document.getElementById(graphid).src = folder + "/" + newgraph + ".png";
-      }
-      //function to load appropriate graph image depending on drop-down menu
-      function graphLoad2(graphid, newgraph) {
-        var exp = document.getElementById("expselect").value;
-        document.getElementById(graphid).src = exp + "/" + newgraph + ".png";
-      }
-      //function to create appropriate experiment links depending on drop-down menu
-      function expLoad(expclass, folder, newlink) {
-        var elems = document.getElementsByClassName(expclass);
-        for (i = 0; i < elems.length; i++) {
-          var elem = elems[i];
-          elem.href = folder + "/" + newlink;
-        }
-      }
-      //function to update experiment links links depending on drop-down menu
-      function expLoadTotal(folder) {
-        expLoad('s1', folder, 'strain1');
-        expLoad('s2', folder, 'strain2');
-        expLoad('s3', folder, 'strain3');
-        expLoad('s4', folder, 'strain4');
-        expLoad('p1', folder, 'pressure1');
-        expLoad('p2', folder, 'pressure2');
-        expLoad('d', folder, 'all.zip');
-      }
-    </script>
-  </head>
-
-  <body>
-    <div id="header-wrap">
-      <div id="header">
-        <div id="leftnav">
-          <a href="http://www.uwa.edu.au/" target="_blank">
-            <img alt = "The University of Western Australia"
-                 src="static/uwacrest-text.png">
-          </a>
-          <span id="title">Exploding Cans</span>
-        </div>
-        <div id="rightnav">
-          <span id="welcome-container">
-          </span>
-          <span id="date">
-            <script type="text/javascript">getDate();</script>
-          </span>
-          <div id="logout-container">
-            <form action="#">
-              <div>
-                <input type="button" id="logout" value="Logout">
-              </div>
-            </form>
-          </div>
-        </div>
-        <div class="clear"></div>
-      </div>
-    </div>
-    <!-- End header -->
-
-    <div id="content-wrap">
-      <noscript>
-        <div class="widget centre">
-          <div class="title">JavaScript required</div>
-          This website requires JavaScript to function correctly.
-          Please enable JavaScript to use this site.
-        </div>
-      </noscript>
-
-      <div id="content">
-        <div id="sidebar">
-          <div class="widget">
-            <div class="title">Navigation menu</div>
-            <div class="nav-menu">
-              <ul>
-                <li><a href="index.html"><span>Home</span></a></li>
-                <li><a href="control.html"><span>Experiment control</span></a></li>
-                <li><a href="pintest.html"><span>Pin debugging</span></a></li>
-                <li class="last"><a href="#"><span>Help</span></a></li>
-              </ul>
-            </div>
-          </div>
-          <div class="widget">
-            <div class="title">Help</div>
-
-          </div>
-        </div>
-        <!-- End sidebar -->
-
-        <div id="main">
-          <div class="widget">
-            <div class="title">Experiment Data</div>
-            <b>Current Experiment</b>
-            <table>
-              <tr>
-                <!--I have no idea how we'll end up storing all the experiment data on the Beaglebone so these currently just link to a bunch of dummy files-->
-                <td>View Sensor Data</td>
-                <td></td>
-                <td><a href="current/strain1">Strain 1</a></td>
-                <td><a href="current/strain2">Strain 2</a></td>
-                <td><a href="current/strain3">Strain 3</a></td>
-                <td><a href="current/strain4">Strain 4</a></td>
-                <td><a href="current/pressure1">Pressure 1</a></td>
-                <td><a href="current/pressure2">Pressure 2</a></td>
-              </tr>
-              <tr>
-                <!--uses the download attribute to force downloads, only compatible with some browsers. Other users will just have to right-click and Save File As-->
-                <td>Save Sensor Data</td>
-                <td><a href="current/all.zip" download><input type="button" value="Download All"></a></td>
-                <td><a href="current/strain1" download><input type="button" value="Strain 1"></a></td>
-                <td><a href="current/strain2" download><input type="button" value="Strain 2"></a></td>
-                <td><a href="current/strain3" download><input type="button" value="Strain 3"></a></td>
-                <td><a href="current/strain4" download><input type="button" value="Strain 4"></a></td>
-                <td><a href="current/pressure1" download><input type="button" value="Pressure 1"></a></td>
-                <td><a href="current/pressure1" download><input type="button" value="Pressure 1"></a></td>
-              </tr>
-              <tr>
-                <!--not sure about how exactly we'll be linking to dilatometer or camera data yet-->
-                <td>Dilatometer</td>
-                <td><a href="nowhere" download="nowhere"><input type="button" value="Download Data"></a></td>
-                <td><a href="nowhere">View Data</a></td>
-              </tr>
-              <tr>
-                <td>Camera Data</td>
-                <td><a href="nowhere" download="nowhere"><input type="button" value="Download Data"></a></td>
-                <td><a href="nowhere">View Data</a></td>
-              </tr>
-              <tr>
-
-                <td>Graphs</td>
-                <td>
-                  <form>
-                    <select onChange="graphLoad('g1', 'current', this.value)">
-                      <!--link this to graphs functionality, currently just loads a placeholder image-->
-                      <!--graphs could just plot the data over entire time range of the experiment-->
-                      <option value="nograph">Choose to view</option>
-                      <option value="graph1">Strain 1</option>
-                      <option value="graph2">Strain 2</option>
-                      <option value="graph3">Strain 3</option>
-                      <option value="graph4">Strain 4</option>
-                      <option value="graph5">Pressure 1</option>
-                      <option value="graph6">Pressure 2</option>
-                    </select>
-                  </form>
-
-                </td>
-              </tr>
-            </table>
-            <img src="current/nograph.png" id="g1">
-            <p><b>Previous Experiments</b></p>
-            <table>
-              <tr>
-                <td>Select Experiment</td>
-                <td>
-                  <!--Upon selecting experiment, modify all the download links-->
-                  <!--TODO: prevent downloads of data if no experiment is selected-->
-                  <select id="expselect" onChange="expLoadTotal(this.value)">
-                    <option value="current">Current</option>
-                    <option value="exp1">Experiment 1</option>
-                    <option value="exp2">Experiment 2</option>
-                    <option value="exp3">Experiment 3</option>
-                    <option value="exp4">Experiment 4</option>
-                    <option value="exp5">Experiment 5</option>
-                  </select>
-                </td>
-              </tr>
-              <tr>
-                <td>Experiment Date</td>
-                <!--Lookup the experiment date here for identification purposes-->
-                <td><b>DATE LOOKUP</b></td>
-              </tr>
-              <tr>
-                <td>View Sensor Data</td>
-                <td></td>
-                <td><a href="current/strain1" class="s1">Strain 1</a></td>
-                <td><a href="current/strain2" class="s2">Strain 2</a></td>
-                <td><a href="current/strain3" class="s3">Strain 3</a></td>
-                <td><a href="current/strain4" class="s4">Strain 4</a></td>
-                <td><a href="current/pressure1" class="p1">Pressure 1</a></td>
-                <td><a href="current/pressure2" class="p2">Pressure 2</a></td>
-              </tr>
-              <tr>
-                <td>Save Sensor Data</td>
-                <td><a href="current/all.zip" download class="d"><input type="button" value="Download All"></a></td>
-                <td><a href="current/strain1" download class="s1"><input type="button" value="Strain 1"></a></td>
-                <td><a href="current/strain2" download class="s2"><input type="button" value="Strain 2"></a></td>
-                <td><a href="current/strain3" download class="s3"><input type="button" value="Strain 3"></a></td>
-                <td><a href="current/strain4" download class="s4"><input type="button" value="Strain 4"></a></td>
-                <td><a href="current/pressure1" download class="p1"><input type="button" value="Pressure 1"></a></td>
-                <td><a href="current/pressure2" download class="p2"><input type="button" value="Pressure 1"></a></td>
-              </tr>
-              <tr>
-                <!--not sure about how exactly we'll be linking to dilatometer or camera data yet-->
-                <td>Dilatometer</td>
-                <td><a href="nowhere" download="nowhere"><input type="button" value="Download Data"></a></td>
-                <td><a href="nowhere">View Data</a></td>
-              </tr>
-              <tr>
-                <td>Camera Data</td>
-                <td><a href="nowhere" download="nowhere"><input type="button" value="Download Data"></a></td>
-                <td><a href="nowhere">View Data</a></td>
-              </tr>
-              <tr>
-                <td>Graphs</td>
-                <td>
-                  <form>
-                    <select onChange="graphLoad2('g2', this.value)">
-                      <!--link this to graphs functionality, currently just loads a placeholder image-->
-                      <!--graphs could just plot the data over entire time range of the experiment-->
-                      <option value="nograph">Choose to view</option>
-                      <option value="graph1">Strain 1</option>
-                      <option value="graph2">Strain 2</option>
-                      <option value="graph3">Strain 3</option>
-                      <option value="graph4">Strain 4</option>
-                      <option value="graph5">Pressure 1</option>
-                      <option value="graph6">Pressure 2</option>
-                    </select>
-                  </form>
-                </td>
-              </tr>
-            </table>
-            <img src="current/nograph.png" id="g2">
-          </div>
-        </div>
-        <!-- End main content -->
-      </div>
-    </div>
-  </body>
-</html>
diff --git a/testing/MCTXWeb/public_html/data.html b/testing/MCTXWeb/public_html/data.html
new file mode 100644 (file)
index 0000000..14f54a6
--- /dev/null
@@ -0,0 +1,273 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+
+<!--Current Experiment section is pretty much working, still working out the previous experiments bit-->
+<!--Basically, the download links and graph links automatically update depending on what is selected in the drop-down menus-->
+<!--Some dodgy javascript is involved but it sort of works-->
+<!--The HTML5 "download" attribute is used to force downloads, but that's not compatible with IE (it just views the files in IE)-->
+<html>
+  <head>
+    <title>MCTX3420 Web Interface</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <!--[if lte IE 8]>
+      <script language="javascript" type="text/javascript" src="static/excanvas.min.js"></script>
+    <![endif]-->
+    <script type="text/javascript" src="static/jquery-1.10.1.min.js"></script>
+    <script type="text/javascript" src="static/jquery.flot.min.js"></script>
+    <script type="text/javascript" src="static/mctx.gui.js"></script>
+
+    <link rel="stylesheet" type="text/css" href="static/style.css">
+    <link rel="stylesheet" type="text/css" href="static/nav-menu.css">
+    <script type="text/javascript">
+      runBeforeLoad().done(function() {
+        $(document).ready(function() {
+          //Show the content!
+          $("#content").css("display", "block");
+          //Set the welcome bar
+          var name = " " + (mctx.friendlyName ? mctx.friendlyName : "");
+          $("#welcome-container").text("Welcome" + name + "!");
+          $("#logout-container").css("display", "block");
+          //$("#menu-container").populateNavbar();
+
+          $("#logout").click(function() {
+            $("#logout").logout();
+          });
+
+          $("#main_controls").submit(function() {
+            //Validate!
+            return false;
+          });
+
+          $("#errorlog").setErrorLog();
+        });
+      })
+
+      //function to load appropriate graph image depending on drop-down menu
+      function graphLoad(graphid, folder, newgraph) {
+        document.getElementById(graphid).src = folder + "/" + newgraph + ".png";
+      }
+      //function to load appropriate graph image depending on drop-down menu
+      function graphLoad2(graphid, newgraph) {
+        var exp = document.getElementById("expselect").value;
+        document.getElementById(graphid).src = exp + "/" + newgraph + ".png";
+      }
+      //function to create appropriate experiment links depending on drop-down menu
+      function expLoad(expclass, folder, newlink) {
+        var elems = document.getElementsByClassName(expclass);
+        for (i = 0; i < elems.length; i++) {
+          var elem = elems[i];
+          elem.href = folder + "/" + newlink;
+        }
+      }
+      //function to update experiment links links depending on drop-down menu
+      function expLoadTotal(folder) {
+        expLoad('s1', folder, 'strain1');
+        expLoad('s2', folder, 'strain2');
+        expLoad('s3', folder, 'strain3');
+        expLoad('s4', folder, 'strain4');
+        expLoad('p1', folder, 'pressure1');
+        expLoad('p2', folder, 'pressure2');
+        expLoad('d', folder, 'all.zip');
+      }
+    </script>
+  </head>
+
+  <body>
+    <div id="header-wrap">
+      <div id="header">
+        <div id="leftnav">
+          <a href="http://www.uwa.edu.au/" target="_blank">
+            <img alt = "The University of Western Australia"
+                 src="static/uwacrest-text.png">
+          </a>
+          <span id="title">Exploding Cans</span>
+        </div>
+        <div id="rightnav">
+          <span id="welcome-container">
+          </span>
+          <span id="date">
+            <script type="text/javascript">getDate();</script>
+          </span>
+          <div id="logout-container">
+            <form action="#">
+              <div>
+                <input type="button" id="logout" value="Logout">
+              </div>
+            </form>
+          </div>
+        </div>
+        <div class="clear"></div>
+      </div>
+    </div>
+    <!-- End header -->
+
+    <div id="content-wrap">
+      <noscript>
+        <div class="widget centre">
+          <div class="title">JavaScript required</div>
+          This website requires JavaScript to function correctly.
+          Please enable JavaScript to use this site.
+        </div>
+      </noscript>
+
+      <div id="content">
+        <div id="sidebar">
+          <div class="widget">
+            <div class="title">Navigation menu</div>
+            <div class="nav-menu">
+              <ul>
+                <li><a href="index.html"><span>Home</span></a></li>
+                <li><a href="control.html"><span>Experiment control</span></a></li>
+                <li><a href="graph.html"><span>Experiment graphs</span></a></li>
+                <li><a href="data.html"><span>Experiment data</span></a></li>
+                <li><a href="pintest.html"><span>Pin debugging</span></a></li>
+                <li class="last"><a href="help.html"><span>Help</span></a></li>
+              </ul>
+            </div>
+          </div>
+          <div class="widget">
+            <div class="title">Help</div>
+
+          </div>
+        </div>
+        <!-- End sidebar -->
+
+        <div id="main">
+          <div class="widget">
+            <div class="title">Experiment Data</div>
+            <b>Current Experiment</b>
+            <table>
+              <tr>
+                <!--I have no idea how we'll end up storing all the experiment data on the Beaglebone so these currently just link to a bunch of dummy files-->
+                <td>View Sensor Data</td>
+                <td></td>
+                <td><a href="current/strain1">Strain 1</a></td>
+                <td><a href="current/strain2">Strain 2</a></td>
+                <td><a href="current/strain3">Strain 3</a></td>
+                <td><a href="current/strain4">Strain 4</a></td>
+                <td><a href="current/pressure1">Pressure 1</a></td>
+                <td><a href="current/pressure2">Pressure 2</a></td>
+              </tr>
+              <tr>
+                <!--uses the download attribute to force downloads, only compatible with some browsers. Other users will just have to right-click and Save File As-->
+                <td>Save Sensor Data</td>
+                <td><a href="current/all.zip" download><input type="button" value="Download All"></a></td>
+                <td><a href="current/strain1" download><input type="button" value="Strain 1"></a></td>
+                <td><a href="current/strain2" download><input type="button" value="Strain 2"></a></td>
+                <td><a href="current/strain3" download><input type="button" value="Strain 3"></a></td>
+                <td><a href="current/strain4" download><input type="button" value="Strain 4"></a></td>
+                <td><a href="current/pressure1" download><input type="button" value="Pressure 1"></a></td>
+                <td><a href="current/pressure1" download><input type="button" value="Pressure 1"></a></td>
+              </tr>
+              <tr>
+                <!--not sure about how exactly we'll be linking to dilatometer or camera data yet-->
+                <td>Dilatometer</td>
+                <td><a href="nowhere" download="nowhere"><input type="button" value="Download Data"></a></td>
+                <td><a href="nowhere">View Data</a></td>
+              </tr>
+              <tr>
+                <td>Camera Data</td>
+                <td><a href="nowhere" download="nowhere"><input type="button" value="Download Data"></a></td>
+                <td><a href="nowhere">View Data</a></td>
+              </tr>
+              <tr>
+
+                <td>Graphs</td>
+                <td>
+                  <form>
+                    <select onChange="graphLoad('g1', 'current', this.value)">
+                      <!--link this to graphs functionality, currently just loads a placeholder image-->
+                      <!--graphs could just plot the data over entire time range of the experiment-->
+                      <option value="nograph">Choose to view</option>
+                      <option value="graph1">Strain 1</option>
+                      <option value="graph2">Strain 2</option>
+                      <option value="graph3">Strain 3</option>
+                      <option value="graph4">Strain 4</option>
+                      <option value="graph5">Pressure 1</option>
+                      <option value="graph6">Pressure 2</option>
+                    </select>
+                  </form>
+
+                </td>
+              </tr>
+            </table>
+            <img src="current/nograph.png" id="g1">
+            <p><b>Previous Experiments</b></p>
+            <table>
+              <tr>
+                <td>Select Experiment</td>
+                <td>
+                  <!--Upon selecting experiment, modify all the download links-->
+                  <!--TODO: prevent downloads of data if no experiment is selected-->
+                  <select id="expselect" onChange="expLoadTotal(this.value)">
+                    <option value="current">Current</option>
+                    <option value="exp1">Experiment 1</option>
+                    <option value="exp2">Experiment 2</option>
+                    <option value="exp3">Experiment 3</option>
+                    <option value="exp4">Experiment 4</option>
+                    <option value="exp5">Experiment 5</option>
+                  </select>
+                </td>
+              </tr>
+              <tr>
+                <td>Experiment Date</td>
+                <!--Lookup the experiment date here for identification purposes-->
+                <td><b>DATE LOOKUP</b></td>
+              </tr>
+              <tr>
+                <td>View Sensor Data</td>
+                <td></td>
+                <td><a href="current/strain1" class="s1">Strain 1</a></td>
+                <td><a href="current/strain2" class="s2">Strain 2</a></td>
+                <td><a href="current/strain3" class="s3">Strain 3</a></td>
+                <td><a href="current/strain4" class="s4">Strain 4</a></td>
+                <td><a href="current/pressure1" class="p1">Pressure 1</a></td>
+                <td><a href="current/pressure2" class="p2">Pressure 2</a></td>
+              </tr>
+              <tr>
+                <td>Save Sensor Data</td>
+                <td><a href="current/all.zip" download class="d"><input type="button" value="Download All"></a></td>
+                <td><a href="current/strain1" download class="s1"><input type="button" value="Strain 1"></a></td>
+                <td><a href="current/strain2" download class="s2"><input type="button" value="Strain 2"></a></td>
+                <td><a href="current/strain3" download class="s3"><input type="button" value="Strain 3"></a></td>
+                <td><a href="current/strain4" download class="s4"><input type="button" value="Strain 4"></a></td>
+                <td><a href="current/pressure1" download class="p1"><input type="button" value="Pressure 1"></a></td>
+                <td><a href="current/pressure2" download class="p2"><input type="button" value="Pressure 1"></a></td>
+              </tr>
+              <tr>
+                <!--not sure about how exactly we'll be linking to dilatometer or camera data yet-->
+                <td>Dilatometer</td>
+                <td><a href="nowhere" download="nowhere"><input type="button" value="Download Data"></a></td>
+                <td><a href="nowhere">View Data</a></td>
+              </tr>
+              <tr>
+                <td>Camera Data</td>
+                <td><a href="nowhere" download="nowhere"><input type="button" value="Download Data"></a></td>
+                <td><a href="nowhere">View Data</a></td>
+              </tr>
+              <tr>
+                <td>Graphs</td>
+                <td>
+                  <form>
+                    <select onChange="graphLoad2('g2', this.value)">
+                      <!--link this to graphs functionality, currently just loads a placeholder image-->
+                      <!--graphs could just plot the data over entire time range of the experiment-->
+                      <option value="nograph">Choose to view</option>
+                      <option value="graph1">Strain 1</option>
+                      <option value="graph2">Strain 2</option>
+                      <option value="graph3">Strain 3</option>
+                      <option value="graph4">Strain 4</option>
+                      <option value="graph5">Pressure 1</option>
+                      <option value="graph6">Pressure 2</option>
+                    </select>
+                  </form>
+                </td>
+              </tr>
+            </table>
+            <img src="current/nograph.png" id="g2">
+          </div>
+        </div>
+        <!-- End main content -->
+      </div>
+    </div>
+  </body>
+</html>
index c15d855..137c004 100644 (file)
@@ -4,31 +4,94 @@
     <title>MCTX3420 Web Interface</title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <!--[if lte IE 8]>
-      <script language="javascript" type="text/javascript" src="static/excanvas.min.js"></script>
+    <script language="javascript" type="text/javascript" src="static/excanvas.min.js"></script>
     <![endif]-->
     <script type="text/javascript" src="static/jquery-1.10.1.min.js"></script>
     <script type="text/javascript" src="static/jquery.flot.min.js"></script>
     <script type="text/javascript" src="static/mctx.gui.js"></script>
-        <script type="text/javascript" src="static/mctx.graph.js"></script>
+    <script type="text/javascript" src="static/mctx.graph.js"></script>
     
     <link rel="stylesheet" type="text/css" href="static/style.css">
     <link rel="stylesheet" type="text/css" href="static/nav-menu.css">
     <script type="text/javascript">
-      runBeforeLoad().always(function () {
+      runBeforeLoad().done(function () {
         $(document).ready(function () {
-          $("#graph-controls").setDevices();
-          $("#graph-run").runButton();
-          
+         //Show the content!
+         $("#content").css("display", "block");
+         //Set the welcome bar
+         var name = " " + (mctx.friendlyName ? mctx.friendlyName : "");
+         $("#welcome-container").text("Welcome"+ name + "!");
+         $("#logout-container").css("display", "block");
+         $("#logout").click(function () {
+           $("#logout").logout();
+         });
        });       
-      })
+      }).always(function () {
+        $(document).ready(function () {
+          $("#graph-controls").setDevices();
+          //$("#graph-run").runButton();
+        });
+      });
 
     </script>
   </head>
   
   <body>
-    <div id="header-wrap"></div>
+    <div id="header-wrap">
+      <div id="header">
+        <div id="leftnav">
+          <a href="http://www.uwa.edu.au/" target="_blank">
+            <img alt = "The University of Western Australia"
+            src="static/uwacrest-text.png">
+          </a>
+          <span id="title">Exploding Cans</span>
+        </div>
+        <div id="rightnav">
+          <span id="welcome-container">
+          </span>
+          <span id="date">
+            <script type="text/javascript">getDate();</script>
+          </span>
+          <div id="logout-container">
+            <form action="#">
+              <div>
+                <input type="button" id="logout" value="Logout">
+              </div>
+            </form>
+          </div>
+        </div>
+        <div class="clear"></div>
+      </div>
+    </div>
+    <!-- End header -->
+    
     <div id="content-wrap">
+      <noscript>
+        <div class="widget centre">
+          <div class="title">JavaScript required</div>
+          This website requires JavaScript to function correctly.
+          Please enable JavaScript to use this site.
+        </div>
+      </noscript>
+
       <div id="content">
+        <div id="sidebar">
+          <div class="widget">
+            <div class="title">Navigation menu</div>
+            <div id="sidebar-menu" class="nav-menu">
+            <ul>
+               <li><a href="index.html"><span>Home</span></a></li>
+               <li><a href="control.html"><span>Experiment control</span></a></li>
+               <li><a href="graph.html"><span>Experiment graphs</span></a></li>
+               <li><a href="data.html"><span>Experiment data</span></a></li>
+               <li><a href="pintest.html"><span>Pin debugging</span></a></li>
+               <li class="last"><a href="help.html"><span>Help</span></a></li>
+            </ul>
+            </div>
+          </div>
+        </div>
+        <!-- End sidebar -->
+
         <div id="main">
           <div class="widget">
             <div class="title">Graph</div>
           <div class="widget" id="graph-controls">
               <!--<div class="title">Visualise</div>-->
               <b>X-Axis</b>
-                <form id="xaxis" onChange=$("#graph").setGraph()> <input type="radio" name="xaxis" value="time" id="time" checked="yes">time</input> </form>
+                <form id="xaxis" class="change">
+                  <input type="radio" name="xaxis" alt="time" id="time" checked="checked">
+                  <label for="time">time</label>
+                </form>
                 <b>Y-Axis</b>
-                <form id="yaxis" onChange=$("#graph").setGraph()>  </form>
+                <form id="yaxis" class="change">  </form>
                 <!--b>Right Y-Axis</b>
-                <form id="y2axis" onChange=$("#graph").setGraph()> <input type="radio" name="y2axis" value="none" id="none" checked="yes">none</input></form>-->
+                <form id="y2axis" onChange=$("#graph").setGraph()> <input type="radio" name="y2axis" value="none" id="none" checked="yes">none</form>-->
 
                 <div> 
-                  <form id="time_range" onChange=$("#graph").setGraph()>
+                  <form id="time_range" class="change">
                     <p> 
-                        Time of Last Update <input type="text" value="" id="current_time" disabled></input>
-                        Start Time <input type="text" value="" id="start_time"></input> 
-                        End Time <input type="text" value="" id="end_time"></input>
+                        Time of Last Update <input type="text" value="" id="current_time" disabled>
+                        Start Time <input type="text" value="" id="start_time"> 
+                        End Time <input type="text" value="" id="end_time">
                     </p>
                 </form>
                 </div>
-                <input type="button" value="Run" id="graph-run" onClick=$("#graph-run").runButton()></input>
-                <input type="button" value="Open New Graph" disabled></input>
-                <input type="button" value="Save Graph Image" disabled></input>
-                <input type="button" value="Dump Raw Data" disabled></input>
+                <input type="button" value="Run" id="graph-run" onClick="$('#graph-run').runButton()">
+                <input type="button" value="Open New Graph" disabled>
+                <input type="button" value="Save Graph Image" disabled>
+                <input type="button" value="Dump Raw Data" disabled>
             </div>
         
         <!-- TODO: Put this on its own page? 
           <div class="widget">
               <div class="title">Controls</div>
               <form id="controls">
-                <p>Mode: <input type="radio" name="mode" value="normal">Normal</input>
-                      <input type="radio" name="mode" value="explode">EXPLODE!</input> </p>
-                Filename: <input type="text"> </input>
-                <input type="button" value="Stop" id="stopstart"></input>
-                <input type="button" value="Pause" id="runpause"></input>
-                <input type="button" value="Load"></input>
-               --> 
-                
+                <p>Mode: <input type="radio" name="mode" value="normal">Normal
+                      <input type="radio" name="mode" value="explode">EXPLODE! </p>
+                Filename: <input type="text"> 
+                <input type="button" value="Stop" id="stopstart">
+                <input type="button" value="Pause" id="runpause">
+                <input type="button" value="Load">
               </form>
           </div>
+          -->
         </div>
-      </div>
+    </div>
+      <!-- End main content -->
     </div>
   </body>
-</html>
+</html>
\ 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 (file)
index acf23a9..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-  <head>
-    <title>MCTX3420 Web Interface</title>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-    <script type="text/javascript" src="static/jquery-1.10.1.min.js"></script>
-    <script type="text/javascript" src="static/mctx.gui.js"></script>
-
-    <link rel="stylesheet" type="text/css" href="static/style.css">
-    <link rel="stylesheet" type="text/css" href="static/nav-menu.css">
-    <script type="text/javascript">
-      runBeforeLoad().done(function() {
-        $(document).ready(function() {
-          //Show the content!
-          $("#content").css("display", "block");
-          //Set the welcome bar
-          var name = " " + (mctx.friendlyName ? mctx.friendlyName : "");
-          $("#welcome-container").text("Welcome" + name + "!");
-          $("#logout-container").css("display", "block");
-          //$("#menu-container").populateNavbar();
-
-          $("#logout").click(function() {
-            $("#logout").logout();
-          });
-
-          $("#main_controls").submit(function() {
-            //Validate!
-            return false;
-          });
-
-          $("#errorlog").setErrorLog();
-        });
-      })
-
-    </script>
-  </head>
-
-  <body>
-    <div id="header-wrap">
-      <div id="header">
-        <div id="leftnav">
-          <a href="http://www.uwa.edu.au/" target="_blank">
-            <img alt = "The University of Western Australia"
-                 src="static/uwacrest-text.png">
-          </a>
-          <span id="title">Exploding Cans</span>
-        </div>
-        <div id="rightnav">
-          <span id="welcome-container">
-          </span>
-          <span id="date">
-            <script type="text/javascript">getDate();</script>
-          </span>
-          <div id="logout-container">
-            <form action="#">
-              <div>
-                <input type="button" id="logout" value="Logout">
-              </div>
-            </form>
-          </div>
-        </div>
-        <div class="clear"></div>
-      </div>
-    </div>
-    <!-- End header -->
-
-    <div id="content-wrap">
-      <div id="content">
-        <div id="sidebar">
-          <div class="widget">
-            <div class="title">Navigation menu</div>
-            <div class="nav-menu">
-              <ul>
-                <li><a href="index.html"><span>Home</span></a></li>
-                <li><a href="control.html"><span>Experiment control</span></a></li>
-                <li><a href="pintest.html"><span>Pin debugging</span></a></li>
-                <li class="last"><a href="#"><span>Help</span></a></li>
-              </ul>
-            </div>
-          </div>
-          <div class="widget justify">
-            <div class="title">Tutorials</div>
-            <p class="justify">For general information on using the MCTX project web interface (i.e. this webpage!) see the <b>'Tutorials'</b> section.
-              This will guide you through setting up, running and analysing an experiment with basic tutorials and explanation of the possible options.</p>
-          </div>
-          <div class="widget justify">
-            <div class="title">Experiment Hardware</div>
-            <p class="justify">For detailed technical information about the experiment hardware, including system diagrams, datasheets and run-downs of the components,
-              see the <b>'Hardware'</b> section.</p>
-          </div>
-          <div class="widget justify">
-            <div class="title">Experiment Software</div>
-            <p class="justify">For detailed technical information about the experiment software, including explanations of its structure, functions and so on, see the
-              <b>'Software'</b> section. Actual code can be accessed on the project's GitHub: <a href="https://github.com/szmoore/MCTX3420">MCTX3420</a>.</p>
-          </div>
-          <div class="widget justify">
-            <div class="title">Contact</div>
-            <p class="justify">If you would like more information about the project or require additional assistance, please contact:</p>
-            <p><b>Adrian Keating</b></p>
-            <p><b>Adam Wittek</b></p>
-          </div>
-        </div>
-        <!-- End sidebar -->
-
-        <div id="main">
-          <div class="widget">
-            <div class="title">Getting Started</div>
-            <p class="justify">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.</p>
-            <p class="justify">For a basic introduction to using the experiment, see <b>'Tutorials'</b>.
-              <a href="https://github.com/szmoore/MCTX3420/wiki/System-Overview" target="_blank">System overview</a> provides a general overview of the experiment's hardware, while
-              <a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Web-Interface" target="_blank">Using the web interface</a> provides a tutorial on using the the project software.
-              For detailed information about the experiment hardware, see the <b>'Hardware'</b> section. For detailed information about the project software,
-              see the <b>'Software'</b> section.</p>
-            <div class="sub-title">Tutorials</div>
-            <ul>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/System-Overview" target="_blank">System overview</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Web-Interface" target="_blank">Using the web interface</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Run-an-Experiment" target="_blank">Running an experiment</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-View-Old-Experiments" target="_blank">Viewing previous experiments</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Data-Processing" target="_blank">Data processing</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/System-Safety" target="_blank">System safety</a></li>
-            </ul>
-            <div class="sub-title">Hardware</div>
-            <ul>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/System-Overview" target="_blank">System overview</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Electronics" target="_blank">Electronics</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-BeagleBone" target="_blank">BeagleBone</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Pneumatics" target="_blank">Pneumatics</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Sensors" target="_blank">Sensors</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Mounting" target="_blank">Mounting</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Case" target="_blank">Case</a></li>
-            </ul>
-            <div class="sub-title">Software</div>
-            <ul>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Overview" target="_blank">Software overview</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Browser-Interface" target="_blank">Browser interface</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Server-API" target="_blank">Server API</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Server-Code" target="_blank">Server code</a>
-                <ul>
-                  <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Data-Handling" target="_blank">Data handling</a></li>
-                  <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Sensors-&amp;-Actuators" target="_blank">Sensors and actuators</a></li>
-                  <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Pin-Access" target="_blank">Pin access</a></li>
-                  <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Image-Processing" target="_blank">Image processing</a></li>
-                </ul>
-              </li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Terminology" target="_blank">Terminology</a></li>
-            </ul>
-          </div>
-
-          <div class="widget">
-            <div class="title">Project Wiki</div>
-            <p>All of the project's help documentation is stored in its <a href="https://github.com/szmoore/MCTX3420/wiki" target="_blank">GitHub wiki.</a> This git repository also
-              stores all of the software code for the project; to access the project code files, visit <a href="https://github.com/szmoore/MCTX3420" target="_blank">this link</a>.</p>
-            <p>The following is a list of pages on the GitHub wiki (all of which can be accessed via the categories above):<p>
-            <ul>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Data-Processing" target="_blank">Getting Started: Data Processing</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Run-an-Experiment" target="_blank">Getting Started: Run an Experiment</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-View-Old-Experiments" target="_blank">Getting Started: View Old Experiments</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Web-Interface" target="_blank">Getting Started: Web Interface</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-BeagleBone" target="_blank">Hardware: BeagleBone</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Case" target="_blank">Hardware: Case</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Electronics" target="_blank">Hardware: Electronics</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Mounting" target="_blank">Hardware: Mounting</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Pneumatics" target="_blank">Hardware: Pneumatics</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Sensors" target="_blank">Hardware: Sensors</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki" target="_blank">Home</a>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Browser-Interface" target="_blank">Software: Browser Interface</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Data-Handling" target="_blank">Software: Data Handling</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Image-Processing" target="_blank">Software: Image Processing</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Overview" target="_blank">Software: Overview</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Pin-Access" target="_blank">Software: Pin Access</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Sensors-&amp;-Actuators" target="_blank">Software: Sensors &amp; Actuators</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Server-API" target="_blank">Software: Server API</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Server-Code" target="_blank">Software: Server Code</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Terminology" target="_blank">Software: Terminology</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/System-Overview" target="_blank">System Overview</a></li>
-              <li><a href="https://github.com/szmoore/MCTX3420/wiki/System-Safety" target="_blank">System Safety</a></li>
-            </ul>
-          </div>
-        </div>
-        <!-- End main content -->
-      </div>
-    </div>
-  </body>
-</html>
diff --git a/testing/MCTXWeb/public_html/help.html b/testing/MCTXWeb/public_html/help.html
new file mode 100644 (file)
index 0000000..cad8b0a
--- /dev/null
@@ -0,0 +1,188 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+  <head>
+    <title>MCTX3420 Web Interface</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <script type="text/javascript" src="static/jquery-1.10.1.min.js"></script>
+    <script type="text/javascript" src="static/mctx.gui.js"></script>
+
+    <link rel="stylesheet" type="text/css" href="static/style.css">
+    <link rel="stylesheet" type="text/css" href="static/nav-menu.css">
+    <script type="text/javascript">
+      runBeforeLoad().done(function() {
+        $(document).ready(function() {
+          //Show the content!
+          $("#content").css("display", "block");
+          //Set the welcome bar
+          var name = " " + (mctx.friendlyName ? mctx.friendlyName : "");
+          $("#welcome-container").text("Welcome" + name + "!");
+          $("#logout-container").css("display", "block");
+          //$("#menu-container").populateNavbar();
+
+          $("#logout").click(function() {
+            $("#logout").logout();
+          });
+
+          $("#main_controls").submit(function() {
+            //Validate!
+            return false;
+          });
+
+          $("#errorlog").setErrorLog();
+        });
+      })
+
+    </script>
+  </head>
+
+  <body>
+    <div id="header-wrap">
+      <div id="header">
+        <div id="leftnav">
+          <a href="http://www.uwa.edu.au/" target="_blank">
+            <img alt = "The University of Western Australia"
+                 src="static/uwacrest-text.png">
+          </a>
+          <span id="title">Exploding Cans</span>
+        </div>
+        <div id="rightnav">
+          <span id="welcome-container">
+          </span>
+          <span id="date">
+            <script type="text/javascript">getDate();</script>
+          </span>
+          <div id="logout-container">
+            <form action="#">
+              <div>
+                <input type="button" id="logout" value="Logout">
+              </div>
+            </form>
+          </div>
+        </div>
+        <div class="clear"></div>
+      </div>
+    </div>
+    <!-- End header -->
+
+    <div id="content-wrap">
+      <div id="content">
+        <div id="sidebar">
+          <div class="widget">
+            <div class="title">Navigation menu</div>
+            <div class="nav-menu">
+              <ul>
+                <li><a href="index.html"><span>Home</span></a></li>
+                <li><a href="control.html"><span>Experiment control</span></a></li>
+                <li><a href="graph.html"><span>Experiment graphs</span></a></li>
+                <li><a href="data.html"><span>Experiment data</span></a></li>
+                <li><a href="pintest.html"><span>Pin debugging</span></a></li>
+                <li class="last"><a href="help.html"><span>Help</span></a></li>
+              </ul>
+            </div>
+          </div>
+          <div class="widget justify">
+            <div class="title">Tutorials</div>
+            <p class="justify">For general information on using the MCTX project web interface (i.e. this webpage!) see the <b>'Tutorials'</b> section.
+              This will guide you through setting up, running and analysing an experiment with basic tutorials and explanation of the possible options.</p>
+          </div>
+          <div class="widget justify">
+            <div class="title">Experiment Hardware</div>
+            <p class="justify">For detailed technical information about the experiment hardware, including system diagrams, datasheets and run-downs of the components,
+              see the <b>'Hardware'</b> section.</p>
+          </div>
+          <div class="widget justify">
+            <div class="title">Experiment Software</div>
+            <p class="justify">For detailed technical information about the experiment software, including explanations of its structure, functions and so on, see the
+              <b>'Software'</b> section. Actual code can be accessed on the project's GitHub: <a href="https://github.com/szmoore/MCTX3420">MCTX3420</a>.</p>
+          </div>
+          <div class="widget justify">
+            <div class="title">Contact</div>
+            <p class="justify">If you would like more information about the project or require additional assistance, please contact:</p>
+            <p><b>Adrian Keating</b></p>
+            <p><b>Adam Wittek</b></p>
+          </div>
+        </div>
+        <!-- End sidebar -->
+
+        <div id="main">
+          <div class="widget">
+            <div class="title">Getting Started</div>
+            <p class="justify">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.</p>
+            <p class="justify">For a basic introduction to using the experiment, see <b>'Tutorials'</b>.
+              <a href="https://github.com/szmoore/MCTX3420/wiki/System-Overview" target="_blank">System overview</a> provides a general overview of the experiment's hardware, while
+              <a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Web-Interface" target="_blank">Using the web interface</a> provides a tutorial on using the the project software.
+              For detailed information about the experiment hardware, see the <b>'Hardware'</b> section. For detailed information about the project software,
+              see the <b>'Software'</b> section.</p>
+            <div class="sub-title">Tutorials</div>
+            <ul>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/System-Overview" target="_blank">System overview</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Web-Interface" target="_blank">Using the web interface</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Run-an-Experiment" target="_blank">Running an experiment</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-View-Old-Experiments" target="_blank">Viewing previous experiments</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Data-Processing" target="_blank">Data processing</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/System-Safety" target="_blank">System safety</a></li>
+            </ul>
+            <div class="sub-title">Hardware</div>
+            <ul>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/System-Overview" target="_blank">System overview</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Electronics" target="_blank">Electronics</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-BeagleBone" target="_blank">BeagleBone</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Pneumatics" target="_blank">Pneumatics</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Sensors" target="_blank">Sensors</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Mounting" target="_blank">Mounting</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Case" target="_blank">Case</a></li>
+            </ul>
+            <div class="sub-title">Software</div>
+            <ul>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Overview" target="_blank">Software overview</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Browser-Interface" target="_blank">Browser interface</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Server-API" target="_blank">Server API</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Server-Code" target="_blank">Server code</a>
+                <ul>
+                  <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Data-Handling" target="_blank">Data handling</a></li>
+                  <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Sensors-&amp;-Actuators" target="_blank">Sensors and actuators</a></li>
+                  <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Pin-Access" target="_blank">Pin access</a></li>
+                  <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Image-Processing" target="_blank">Image processing</a></li>
+                </ul>
+              </li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Terminology" target="_blank">Terminology</a></li>
+            </ul>
+          </div>
+
+          <div class="widget">
+            <div class="title">Project Wiki</div>
+            <p>All of the project's help documentation is stored in its <a href="https://github.com/szmoore/MCTX3420/wiki" target="_blank">GitHub wiki.</a> This git repository also
+              stores all of the software code for the project; to access the project code files, visit <a href="https://github.com/szmoore/MCTX3420" target="_blank">this link</a>.</p>
+            <p>The following is a list of pages on the GitHub wiki (all of which can be accessed via the categories above):<p>
+            <ul>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Data-Processing" target="_blank">Getting Started: Data Processing</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Run-an-Experiment" target="_blank">Getting Started: Run an Experiment</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-View-Old-Experiments" target="_blank">Getting Started: View Old Experiments</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Getting-Started:-Web-Interface" target="_blank">Getting Started: Web Interface</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-BeagleBone" target="_blank">Hardware: BeagleBone</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Case" target="_blank">Hardware: Case</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Electronics" target="_blank">Hardware: Electronics</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Mounting" target="_blank">Hardware: Mounting</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Pneumatics" target="_blank">Hardware: Pneumatics</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Hardware:-Sensors" target="_blank">Hardware: Sensors</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki" target="_blank">Home</a>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Browser-Interface" target="_blank">Software: Browser Interface</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Data-Handling" target="_blank">Software: Data Handling</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Image-Processing" target="_blank">Software: Image Processing</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Overview" target="_blank">Software: Overview</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Pin-Access" target="_blank">Software: Pin Access</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Sensors-&amp;-Actuators" target="_blank">Software: Sensors &amp; Actuators</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Server-API" target="_blank">Software: Server API</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Server-Code" target="_blank">Software: Server Code</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/Software:-Terminology" target="_blank">Software: Terminology</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/System-Overview" target="_blank">System Overview</a></li>
+              <li><a href="https://github.com/szmoore/MCTX3420/wiki/System-Safety" target="_blank">System Safety</a></li>
+            </ul>
+          </div>
+        </div>
+        <!-- End main content -->
+      </div>
+    </div>
+  </body>
+</html>
index 4ffacec..77c7f75 100644 (file)
            $("#logout").logout();
          });
        });       
-      })
+      }).always(function () {
+        $(document).ready(function () {
+          //$("#sidebar-menu").populateNavMenu();
+        });
+      });
 
     </script>
   </head>
         <div id="sidebar">
           <div class="widget">
             <div class="title">Navigation menu</div>
-            <div class="nav-menu">
+            <div id="sidebar-menu" class="nav-menu">
             <ul>
                <li><a href="index.html"><span>Home</span></a></li>
                <li><a href="control.html"><span>Experiment control</span></a></li>
+               <li><a href="graph.html"><span>Experiment graphs</span></a></li>
+               <li><a href="data.html"><span>Experiment data</span></a></li>
                <li><a href="pintest.html"><span>Pin debugging</span></a></li>
-               <li class="last"><a href="#"><span>Help</span></a></li>
+               <li class="last"><a href="help.html"><span>Help</span></a></li>
             </ul>
             </div>
           </div>
index fbc9411..0944617 100644 (file)
             <ul>
                <li><a href="index.html"><span>Home</span></a></li>
                <li><a href="control.html"><span>Experiment control</span></a></li>
+               <li><a href="graph.html"><span>Experiment graphs</span></a></li>
+               <li><a href="data.html"><span>Experiment data</span></a></li>
                <li><a href="pintest.html"><span>Pin debugging</span></a></li>
-               <li class="last"><a href="#"><span>Help</span></a></li>
+               <li class="last"><a href="help.html"><span>Help</span></a></li>
             </ul>
             </div>
           </div>
index f71b52a..687db84 100644 (file)
@@ -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 += "<i> Sensors </i>"
-  var checked = "checked";
-  if (!check_first)
-    checked = "";
-  $.each(mctx.sensors, function(key, val) {
-    formhtml += "<input type=\""+input_type+"\" value=\""+val+"\" id=\"sensors\" name=\""+formname+"\""+checked+">" + val + "</input>";
-    checked = "";
-  });
- // formhtml += "<i> Actuators </i>"
-  $.each(mctx.actuators, function(key, val) {
-    formhtml += "<input type=\""+input_type+"\" value=\""+val+"\" id=\"actuators\" name=\""+formname+"\""+checked+">" + val + "</input>";
-    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 = $("<input/>", attributes);
+      var label = $("<label/>", {'for' : prefix + '_' + val, 'text' : val}); 
+      entry.prop("checked", check_first);
+      check_first = false;
+      container.append(entry).append(label);
+    });
+  }
+  
+  apply(mctx.sensors, 'sensors');
+  apply(mctx.actuators, 'actuators');
 };
 
 /**
@@ -71,99 +76,61 @@ $.fn.deployDevices = function(input_type, check_first) {
  * @returns itself (Is this right?)
  */
 $.fn.setDevices = function() {
-       // Query for sensors and actuators
-  var sensor_curtime = 0;
-  var actuator_curtime = 0;
-  return $.when(
-       $.ajax({url : mctx.api + "?sensors"}).done(function(data) {
-               mctx.sensors = $.extend(mctx.sensors, data.sensors);
-      sensor_curtime = data.running_time;
-    }),
-    $.ajax({url : mctx.api + "?actuators"}).done(function(data) {
-      mctx.actuators = $.extend(mctx.actuators, data.actuators);
-      actuator_curtime = data.running_time;
-    })
-  ).then(function() {
-    $("#xaxis").deployDevices("radio", false);
-    $("#yaxis").deployDevices("checkbox", true);
-    var c = Math.max(actuator_curtime, sensor_curtime);
-    $("input[name=current_time]", "#time_range").val(c);
-    
+  // Query for sensors and actuators
+  return $.ajax({
+    url : mctx.api + 'identify', 
+    data : {'sensors' : 1, 'actuators' : 1}
+  }).done(function (data) {
+    mctx.sensors = $.extend(mctx.sensors, data.sensors);
+    mctx.actuators = $.extend(mctx.actuators, data.actuators);
     
+    //Always set the 'time' option to be checked
+    $("#xaxis input").prop('checked', true);  
+    $("#xaxis").deployDevices("radio", false, 'xaxis');
+    $("#yaxis").deployDevices("checkbox", true, 'yaxis');
+    $("#current_time").val(data.running_time);
+    //Add event listeners for when the inputs are changed
+    $(".change input").change(function () {
+      $("#graph").setGraph();
+    });
   });
 };
 
-
-
-
-/**
- * Sets the graphs to graph stuff.
- * @returns {$.fn}
- */
-$.fn.setGraph = function () {
-  clearTimeout(mctx.graph.timer);
-  var sensor_url = mctx.api + "sensors";
-  var actuator_url = mctx.api + "actuators";
-
-  var updateData = function(json, data) {
-    for (var i = 0; i < json.data.length; ++i)
-      data.push(json.data[i]);
-    return data;
-  };
-  var graphdiv = this;
-
-
-  // Determine which actuator/sensors to plot
-  var xaxis = $("input[name=xaxis]:checked", "#xaxis");
-  var yaxis = $("input[name=yaxis]:checked", "#yaxis");
-  var start_time = $("#start_time").val();
-  var end_time = $("#end_time").val();
-  if (!$.isNumeric(start_time)) {
-    start_time = null;
+function graphUpdater() {
+  var urls = {
+    'sensors' : mctx.graph.api.sensors,
+    'actuators' : mctx.graph.api.actuators
   }
-  if (!$.isNumeric(end_time)) {
-    end_time = null;
-  }
-
-  var devices = {};
-  xaxis.each(function() {
-    devices[$(this).val()] = {};
-    devices[$(this).val()]["url"] = mctx.api + $(this).attr("id");
-    devices[$(this).val()]["data"] = [];
-    devices[$(this).val()]["start_time"] = start_time;
-    devices[$(this).val()]["end_time"] = end_time;
-  });
-  yaxis.each(function() {
-    devices[$(this).val()] = {};
-    devices[$(this).val()]["url"] = mctx.api + $(this).attr("id");
-    devices[$(this).val()]["data"] = [];
-    devices[$(this).val()]["start_time"] = start_time;
-    devices[$(this).val()]["end_time"] = end_time;
-  });
-
+  
   var updater = function () {
     var time_limit = 20;
     var responses = [];
     var ctime =  $("#current_time");
     
+    var xaxis = mctx.graph.xaxis;
+    var yaxis = mctx.graph.yaxis;
+    var start_time = mctx.graph.start_time;
+    var end_time = mctx.graph.end_time;
+    var devices = mctx.graph.devices;
+    
+    if (xaxis.size() < 1 || yaxis.size() < 1) {
+      mctx.graph.running = false;
+      return;
+    }
     
     $.each(devices, function(key, val) {
-      if (devices[key].url === sensor_url || devices[key].url === actuator_url) {
-       // alert("AJAX");
-        //alert(key);
-        //alert(devices[key].url);
-        parameters = {name : key};
+      if (val.urltype in urls) {
+        var parameters = {id : val.id};
         if (start_time != null) {
-          //alert("start_time = " + start_time);
-          parameters = $.extend(parameters, {start_time : start_time});
+          parameters.start_time = start_time;
         }
-        if (end_time != null)
-          parameters = $.extend(parameters, {end_time : end_time});
-        responses.push($.ajax({url : devices[key].url, data : parameters}).done(function(json) {
+        if (end_time != null) {
+          parameters.end_time = end_time;
+        }
+        responses.push($.ajax({url : urls[val.urltype], data : parameters})
+        .done(function(json) {
           //alert("Hi from " + json.name);
-          var dev = devices[json.name].data;
+          var dev = val.data;
           for (var i = 0; i < json.data.length; ++i) {
             if (dev.length <= 0 || json.data[i][0] > dev[dev.length-1][0]) {
               dev.push(json.data[i]);
@@ -177,17 +144,15 @@ $.fn.setGraph = function () {
 
     //... When the response is received, then() will happen (I think?)
     $.when.apply(this, responses).then(function () {
-      
       var plot_data = [];
       yaxis.each(function() {
         //alert("Add " + $(this).val() + " to plot");
-        if (xaxis.val() === "time") {
+        if (xaxis.attr("alt") === "time") {
           //alert("Against time");
-          plot_data.push(devices[$(this).val()].data);
-        }
-        else {
+          plot_data.push(devices[$(this).attr("alt")].data);
+        } else {
           var result = []
-          dataMerge(devices[xaxis.val()].data, devices[$(this).val()].data, result);
+          dataMerge(devices[xaxis.attr("alt")].data, devices[$(this).attr("alt")].data, result);
           /*
           var astr = "[";
           for (var i = 0; i < result.length; ++i)
@@ -199,14 +164,64 @@ $.fn.setGraph = function () {
         }
       });
       
-      //alert(plot_data + "");
-      //alert("Plot happened");
       $.plot("#graph", plot_data);
-      mctx.graph.timer = setTimeout(updater, 1000);
-    }, function () {alert("Graph crashed");});
+      if (mctx.graph.running) {
+        mctx.graph.timer = setTimeout(updater, 1000);
+      }
+    }, function () {mctx.graph.running=false; alert("Graph crashed");});
   };
   
+  mctx.graph.running = true;
   updater();
+  return this;
+}
+
+/**
+ * Sets the graphs to graph stuff.
+ * @returns {$.fn}
+ */
+$.fn.setGraph = function () {
+  // Determine which actuator/sensors to plot
+  var xaxis = $("#xaxis input[name=xaxis]:checked");
+  var yaxis = $("#yaxis input[name=yaxis]:checked");
+  if (xaxis.size() < 1 || yaxis.size() < 1) {
+    //nothing to plot...
+    return;
+  }
+  
+  var start_time = $("#start_time").val();
+  var end_time = $("#end_time").val();
+  if (!$.isNumeric(start_time)) {
+    start_time = null;
+  }
+  if (!$.isNumeric(end_time)) {
+    end_time = null;
+  }
+
+  var devices = {};
+  var populateDict = function () {
+    var dict = {};
+    dict['urltype'] = $(this).attr("class");
+    dict['id'] = $(this).attr("value");
+    dict['data'] = [];
+    dict['start_time'] = start_time;
+    dict['end_time'] = end_time;
+    devices[$(this).attr("alt")] = dict;
+  };
+  xaxis.each(populateDict);
+  yaxis.each(populateDict);
+  
+  mctx.graph.xaxis = xaxis;
+  mctx.graph.yaxis = yaxis;
+  mctx.graph.start_time = start_time;
+  mctx.graph.end_time = end_time;
+  mctx.graph.devices = devices;
+  
+  if (!mctx.graph.running) {
+    $("#graph-run").val("Pause");
+    graphUpdater();
+  }
+  
   return this;
 };
 
@@ -217,6 +232,7 @@ $.fn.runButton = function() {
     $(this).val("Pause");
   }
   else {
+    mctx.graph.running = false;
     clearTimeout(mctx.graph.timer);
     $(this).val("Run");
   }
index 773fa23..c609ef5 100644 (file)
@@ -1,12 +1,12 @@
 /**
- * MCTX3420 2013 GUI stuff.
- * Coding style:
- *  - Always end statements with semicolons
- *  - Egyptian brackets are highly recommended (*cough*).
- *  - Don't use synchronous stuff - hook events into callbacks
- *  - $.fn functions should return either themselves or some useful object
- *    to allow for chaining of method calls
- */
+* MCTX3420 2013 GUI stuff.
+* Coding style:
+*  - Always end statements with semicolons
+*  - Egyptian brackets are highly recommended (*cough*).
+*  - Don't use synchronous stuff - hook events into callbacks
+*  - $.fn functions should return either themselves or some useful object
+*    to allow for chaining of method calls
+*/
 
 mctx = {};
 //Don't use this in the final version
@@ -18,33 +18,40 @@ mctx.expected_api_version = 0;
 mctx.has_control = false;
 mctx.debug = true;
 
+mctx.menu = [
+    {'text' : 'Home', href : mctx.location + 'index.html'},
+    {'text' : 'Experiment control', href : mctx.location + 'control.html'},
+    {'text' : 'Pin debugging', href : mctx.location + 'pintest.html'},
+    {'text' : 'Help', href : mctx.location + 'help.html'}
+];
+
 mctx.statusCodes = {
-  STATUS_OK : 1
+    STATUS_OK : 1
 };
 
 mctx.statusCodesDescription = {
-  "1" : "Ok",
-  "-1" : "General error",
-  "-2" : "Unauthorized",
-  "-3" : "Not running",
-  "-4" : "Already exists"
+    "1" : "Ok",
+    "-1" : "General error",
+    "-2" : "Unauthorized",
+    "-3" : "Not running",
+    "-4" : "Already exists"
 };
 
 mctx.sensors = {
-  0 : {name : "Strain gauge 1"},
-  1 : {name : "Strain gauge 2"},
-  2 : {name : "Strain gauge 3"},
-  3 : {name : "Strain gauge 4"},
-  4 : {name : "Pressure sensor 1"},
-  5 : {name : "Pressure sensor 2"},
-  6 : {name : "Pressure sensor 3"}
+    0 : {name : "Strain gauge 1"},
+    1 : {name : "Strain gauge 2"},
+    2 : {name : "Strain gauge 3"},
+    3 : {name : "Strain gauge 4"},
+    4 : {name : "Pressure sensor 1"},
+    5 : {name : "Pressure sensor 2"},
+    6 : {name : "Pressure sensor 3"}
 };
 
 mctx.actuators = {
-  0 : {name : "Solenoid 1"},
-  1 : {name : "Solenoid 2"},
-  2 : {name : "Solenoid 3"},
-  3 : {name : "Pressure regulator"}
+    0 : {name : "Solenoid 1"},
+    1 : {name : "Solenoid 2"},
+    2 : {name : "Solenoid 3"},
+    3 : {name : "Pressure regulator"}
 };
 
 mctx.strain_gauges = {};
@@ -52,257 +59,231 @@ mctx.strain_gauges.ids = [0, 1, 2, 3];
 mctx.strain_gauges.time_limit = 20;
 
 /**
- * Logs a message if mctx.debug is enabled. This function takes
- * a variable number of arguments and passes them 
- * to alert or console.log (based on browser support).
- * @returns {undefined}
- */
+* Logs a message if mctx.debug is enabled. This function takes
+* a variable number of arguments and passes them 
+* to alert or console.log (based on browser support).
+* @returns {undefined}
+*/
 function debugLog () {
-  if (mctx.debug) {
-    if (typeof console === "undefined" || typeof console.log === "undefined") {
-      for (var i = 0; i < arguments.length; i++) {
-        alert(arguments[i]);
-      }
-    } else {
-      console.log.apply(this, arguments);
+    if (mctx.debug) {
+        if (typeof console === "undefined" || typeof console.log === "undefined") {
+            for (var i = 0; i < arguments.length; i++) {
+                alert(arguments[i]);
+            }
+        } else {
+            console.log.apply(this, arguments);
+        }
     }
-  }
 }
 
 /**
- * Writes the current date to wherever it's called.
- */
+* Writes the current date to wherever it's called.
+*/
 function getDate() {
-       document.write((new Date()).toDateString());
+    document.write((new Date()).toDateString());
 }
 
 /**
- * Should be run before the load of any GUI page.
- * To hook events to be called after this function runs,
- * use the 'always' method, e.g runBeforeLoad().always(function() {my stuff});
- * @param {type} isLoginPage
- * @returns The return value of calling $.ajax
- */
+* Should be run before the load of any GUI page.
+* To hook events to be called after this function runs,
+* use the 'always' method, e.g runBeforeLoad().always(function() {my stuff});
+* @param {type} isLoginPage
+* @returns The return value of calling $.ajax
+*/
 function runBeforeLoad(isLoginPage) {
-  return $.ajax({
-    url : mctx.api + "identify"
-  }).done(function (data) {
-    if (data.logged_in && isLoginPage) {
-      if (mctx.debug) {
-        debugLog("Redirect disabled!");
-      } else {
-        window.location = mctx.location;
-      }
-    } else if (!data.logged_in && !isLoginPage) {
-      if (mctx.debug) {
-        debugLog("Redirect disabled!");
-      } else {
-        //Note: this only clears the nameless cookie
-        document.cookie = ""; 
-        window.location = mctx.location + "login.html";
-      }
-    } else {
-      mctx.friendlyName = data.friendly_name;
-    }
-  }).fail(function (jqHXR) {
-    if (mctx.debug) {
-      debugLog("Failed to ident server. Is API running?")
-    } else if (!isLoginPage) {
-      window.location = mctx.location + "login.html";
-    }
-  });
+    return $.ajax({
+        url : mctx.api + "identify"
+    }).done(function (data) {
+        if (data.logged_in && isLoginPage) {
+            if (mctx.debug) {
+                debugLog("Redirect disabled!");
+            } else {
+                window.location = mctx.location;
+            }
+        } else if (!data.logged_in && !isLoginPage) {
+            if (mctx.debug) {
+                debugLog("Redirect disabled!");
+            } else {
+                //Note: this only clears the nameless cookie
+                document.cookie = ""; 
+                window.location = mctx.location + "login.html";
+            }
+        } else {
+            mctx.friendlyName = data.friendly_name;
+        }
+    }).fail(function (jqHXR) {
+        if (mctx.debug) {
+            debugLog("Failed to ident server. Is API running?")
+        } else if (!isLoginPage) {
+            window.location = mctx.location + "login.html";
+        }
+    }).always(function () {
+        
+    });
 }
 
 /**
- * Populates a submenu of the navigation bar
- * @param {string} header The header
- * @param {object} items An object representing the submenu items
- * @param {function} translator A function that translates an object item
- *                              into a text and href.
- * @returns {$.fn} Itself
- */
-$.fn.populateSubmenu = function(header, items, translator) {
-  var submenuHeader = $("<li/>").append($("<a/>", {text : header, href : "#"}));
-  var submenu = $("<ul/>", {"class" : "submenu"});
-  
-  for (var item in items) {
-    var info = translator(item, items);
-    submenu.append($("<li/>").append(
-          $("<a/>", {text : info.text, 
-                     href : info.href, target : "_blank"})
-    ));
-  }
-  
-  this.append(submenuHeader.append(submenu));
-  return this;
-};
-
-/** 
- * Populates the navigation bar
+ * Populates the navigation menu.
  */
-$.fn.populateNavbar = function () {
-  var menu = $("<ul/>", {"class" : "menu"});
-  var sensorTranslator = function(item, items) {
-    var href = mctx.api + "sensors?start_time=0&format=tsv&id=" + item;
-    return {text : items[item].name, href : href};
-  };
-  var actuatorTranslator = function(item, items) {
-    var href = mctx.api + "actuators?start_time=0&format=tsv&id=" + item;
-    return {text : items[item].name, href : href};
-  };
-  
-  menu.populateSubmenu("Sensor data", mctx.sensors, sensorTranslator);
-  menu.populateSubmenu("Actuator data", mctx.actuators, actuatorTranslator);
-  menu.appendTo(this);
-  return this;
+$.fn.populateNavMenu = function() {
+    var root = $("<ul/>")
+    for (var i = 0; i < mctx.menu.length; i++) {
+        var item = mctx.menu[i];
+        var entry = $("<li/>").append(
+            $("<a/>", {text : item.text, href: item.href})
+        );
+        root.append(entry);
+    }
+    $(this).append(root);
+    return this;
 }
 
 /**
- * Sets the camera autoupdater
- * Obsolete?
- * @returns {$.fn}
- */
+* Sets the camera autoupdater
+* Obsolete?
+* @returns {$.fn}
+*/
 $.fn.setCamera = function () {
-  var url = mctx.api + "image";  //http://beaglebone/api/image
-  var update = true;
+    var url = mctx.api + "image";  //http://beaglebone/api/image
+    var update = true;
 
-  //Stop updating if we can't retrieve an image!
-  this.error(function() {
-    update = false;
-  });
-  
-  var parent = this;
-  
-  var updater = function() {
-    if (!update) {
-      alert("Cam fail");
-      parent.attr("src", "");
-      return;
-    }
-    
-    parent.attr("src", url + "#" + (new Date()).getTime());
-    
-    setTimeout(updater, 1000);
-  };
-  
-  updater();
-  return this;
+    //Stop updating if we can't retrieve an image!
+    this.error(function() {
+        update = false;
+    });
+
+    var parent = this;
+
+    var updater = function() {
+        if (!update) {
+            alert("Cam fail");
+            parent.attr("src", "");
+            return;
+        }
+        
+        parent.attr("src", url + "#" + (new Date()).getTime());
+        
+        setTimeout(updater, 10000);
+    };
+
+    updater();
+    return this;
 };
 
 /**
- * Sets the strain graphs to graph stuff. Obsolete?
- * @returns {$.fn}
- */
+* Sets the strain graphs to graph stuff. Obsolete?
+* @returns {$.fn}
+*/
 $.fn.setStrainGraphs = function () {
-  var sensor_url = mctx.api + "sensors";
-  var graphdiv = this;
-  
-  var updater = function () {
-    var time_limit = mctx.strain_gauges.time_limit;
-    var responses = new Array(mctx.strain_gauges.ids.length);
-    
-    for (var i = 0; i < mctx.strain_gauges.ids.length; i++) {
-      var parameters = {id : i, start_time: -time_limit};
-      responses[i] = $.ajax({url : sensor_url, data : parameters});
-    }
-    
-    $.when.apply(this, responses).then(function () {
-      var data = new Array(arguments.length);
-      for (var i = 0; i < arguments.length; i++) {
-        var raw_data = arguments[i][0].data;
-        var pruned_data = [];
-        var step = ~~(raw_data.length/100);
-        for (var j = 0; j < raw_data.length; j += step)
-          pruned_data.push(raw_data[j]); 
-        data[i] = pruned_data;
-      }
-      $.plot(graphdiv, data);
-      setTimeout(updater, 500);
-    }, function () {debugLog("It crashed");});
-  };
-  
-  updater();
-  return this;
+    var sensor_url = mctx.api + "sensors";
+    var graphdiv = this;
+
+    var updater = function () {
+        var time_limit = mctx.strain_gauges.time_limit;
+        var responses = new Array(mctx.strain_gauges.ids.length);
+        
+        for (var i = 0; i < mctx.strain_gauges.ids.length; i++) {
+            var parameters = {id : i, start_time: -time_limit};
+            responses[i] = $.ajax({url : sensor_url, data : parameters});
+        }
+        
+        $.when.apply(this, responses).then(function () {
+            var data = new Array(arguments.length);
+            for (var i = 0; i < arguments.length; i++) {
+                var raw_data = arguments[i][0].data;
+                var pruned_data = [];
+                var step = ~~(raw_data.length/100);
+                for (var j = 0; j < raw_data.length; j += step)
+                pruned_data.push(raw_data[j]); 
+                data[i] = pruned_data;
+            }
+            $.plot(graphdiv, data);
+            setTimeout(updater, 1000);
+        }, function () {debugLog("It crashed");});
+    };
+
+    updater();
+    return this;
 };
 
 /**
- * Performs a login attempt.
- * @returns The AJAX object of the login request */
+* Performs a login attempt.
+* @returns The AJAX object of the login request */
 $.fn.login = function () {
-  var username = this.find("input[name='username']").val();
-  var password = this.find("input[name='pass']").val();
-  var out = this.find("#result");
-  var redirect = function () {
-    window.location.href = mctx.location;
-  };
-  
-  out.removeAttr("class");
-  out.text("Logging in...");
-  
-  return $.ajax({
-    url : mctx.api + "bind",
-    data : {user: username, pass : password}
-  }).done(function (data) {
-    if (data.status < 0) {
-      mctx.has_control = false;
-      out.attr("class", "fail");
-      out.text("Login failed: " + data.description);
-    } else {
-      //todo: error check
-      mctx.has_control = true;
-      out.attr("class", "pass");
-      out.text("Login ok!");
-      setTimeout(redirect, 800);      
-    }
-  }).fail(function (jqXHR) {
-    mctx.has_control = false;
-    out.attr("class", "fail");
-    out.text("Login request failed - connection issues.")
-  });
+    var username = this.find("input[name='username']").val();
+    var password = this.find("input[name='pass']").val();
+    var out = this.find("#result");
+    var redirect = function () {
+        window.location.href = mctx.location;
+    };
+
+    out.removeAttr("class");
+    out.text("Logging in...");
+
+    return $.ajax({
+        url : mctx.api + "bind",
+        data : {user: username, pass : password}
+    }).done(function (data) {
+        if (data.status < 0) {
+            mctx.has_control = false;
+            out.attr("class", "fail");
+            out.text("Login failed: " + data.description);
+        } else {
+            //todo: error check
+            mctx.has_control = true;
+            out.attr("class", "pass");
+            out.text("Login ok!");
+            setTimeout(redirect, 800);      
+        }
+    }).fail(function (jqXHR) {
+        mctx.has_control = false;
+        out.attr("class", "fail");
+        out.text("Login request failed - connection issues.")
+    });
 };
 
 /**
- * Performs a logout request. The nameless cookie is
- * always cleared and the browser redirected to the login page,
- * independent of whether or not logout succeeded.
- * @returns  The AJAX object of the logout request.
- */
+* Performs a logout request. The nameless cookie is
+* always cleared and the browser redirected to the login page,
+* independent of whether or not logout succeeded.
+* @returns  The AJAX object of the logout request.
+*/
 $.fn.logout = function () {
-  return $.ajax({
-    url : mctx.api + "unbind"
-  }).always(function () {
-    //Note: this only clears the nameless cookie
-    document.cookie = ""; 
-    window.location = mctx.location + "login.html";
-  });
+    return $.ajax({
+        url : mctx.api + "unbind"
+    }).always(function () {
+        //Note: this only clears the nameless cookie
+        document.cookie = ""; 
+        window.location = mctx.location + "login.html";
+    });
 };
 
 /**
- * Sets the error log to continuously update.
- * @returns itself */
+* Sets the error log to continuously update.
+* @returns itself */
 $.fn.setErrorLog = function () {
-  var url = mctx.api + "errorlog";
-  var outdiv = this;
-  
-  var updater = function () {
-    $.ajax({url : url}).done(function (data) {
-      outdiv.text(data);
-      outdiv.scrollTop(
-        outdiv[0].scrollHeight - outdiv.height()
-      );
-      setTimeout(updater, 2000);
-    }).fail(function (jqXHR) {
-      if (jqXHR.status === 502 || jqXHR.status === 0) {
-        outdiv.text("Failed to retrieve the error log.");
-      }
-      setTimeout(updater, 4000);
-    });
-  };
-  
-  updater();
-  return this;
+    var url = mctx.api + "errorlog";
+    var outdiv = this;
+
+    var updater = function () {
+        $.ajax({url : url}).done(function (data) {
+            outdiv.text(data);
+            outdiv.scrollTop(
+            outdiv[0].scrollHeight - outdiv.height()
+            );
+            setTimeout(updater, 3000);
+        }).fail(function (jqXHR) {
+            if (jqXHR.status === 502 || jqXHR.status === 0) {
+                outdiv.text("Failed to retrieve the error log.");
+            }
+            setTimeout(updater, 10000); //poll at slower rate
+        });
+    };
+
+    updater();
+    return this;
 };
 
 $(document).ajaxError(function (event, jqXHR) {
-  //console.log("AJAX query failed with: " + jqXHR.status + " (" + jqXHR.statusText + ")");
+    //console.log("AJAX query failed with: " + jqXHR.status + " (" + jqXHR.statusText + ")");
 });
\ No newline at end of file
index e9a8623..2b23426 100644 (file)
@@ -196,7 +196,7 @@ input[type="text"]:focus, input[type="password"]:focus {
 
 #sidebar{
   float: left;
-  max-width: 26%;
+  width: 240px;
 }
 
 #sidebar .title {
@@ -246,22 +246,11 @@ input[type="text"]:focus, input[type="password"]:focus {
 
 .plot {
        box-sizing: border-box;
-       width: 850px;
-       height: 450px;
+       width: auto;
+       height: 300px;
        padding: 20px 15px 15px 15px;
        margin: 15px auto 30px auto;
        border: 1px solid #ddd;
-       background: #fff;
-       background: linear-gradient(#f6f6f6 0, #fff 50px);
-       background: -o-linear-gradient(#f6f6f6 0, #fff 50px);
-       background: -ms-linear-gradient(#f6f6f6 0, #fff 50px);
-       background: -moz-linear-gradient(#f6f6f6 0, #fff 50px);
-       background: -webkit-linear-gradient(#f6f6f6 0, #fff 50px);
-       box-shadow: 0 3px 10px rgba(0,0,0,0.15);
-       -o-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
-       -ms-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
-       -moz-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
-       -webkit-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
        font-size:20px;
 }
 

UCC git Repository :: git.ucc.asn.au