소스 검색

wip

* further progress in application startup at boot
clementinecomputing 6 년 전
부모
커밋
43c42e26a7
4개의 변경된 파일219개의 추가작업 그리고 18개의 파일을 삭제
  1. 41 9
      busunit/DIUv2/html/index-ORG.html
  2. 172 8
      busunit/DIUv2/html/js/diu_ui-ORG.js
  3. 3 1
      busunit/scripts/connection_tether-ssh.sh
  4. 3 0
      busunit/scripts/rc.local

+ 41 - 9
busunit/DIUv2/html/index-ORG.html

@@ -8,7 +8,7 @@
 
 
   </head>
   </head>
 
 
-  <body>
+  <body id='body'>
 
 
     <!-- ************************* -->
     <!-- ************************* -->
     <!-- ******            ******* -->
     <!-- ******            ******* -->
@@ -37,23 +37,55 @@
         <button class='invisiblock' id='ui_login_blockwindow'> </button>
         <button class='invisiblock' id='ui_login_blockwindow'> </button>
 
 
 <textarea class='statuslogin' type='textarea' id='ui_login_status' rows='12' cols='80' disabled readonly>
 <textarea class='statuslogin' type='textarea' id='ui_login_status' rows='12' cols='80' disabled readonly>
-Tunnel: YES   GPRS: YES   Eq# 9998  #Msg: 0
-Last Token Read (00): ""
-GPS: NO / Stale
+Tunnel: . GPRS: . Eq# . #Msg: .
+Last Token Read (.): ""
+GPS: .
 
 
 Package    Version        Installed
 Package    Version        Installed
-config     20190730v403   11/05/2019 02:36:43
-firmware   1.11           07/30/2019 16:33:08
 
 
-IMEI = 356136074279052
-IMSI = 310260877138191
-ETH0 = 00:80:66:10:E8:8A
 </textarea>
 </textarea>
 
 
       </div>
       </div>
 
 
     </div>
     </div>
 
 
+    <!-- ************************** -->
+    <!-- ******             ******* -->
+    <!-- ****** Diagnostics ******* -->
+    <!-- ******             ******* -->
+    <!-- ************************** -->
+
+
+    <div id='ui_diagnostic' style='display:none;' >
+
+      <br>
+
+      <div class='pure-g row'>
+
+        <div class='pure-u-1-3 col'> <button class='bdropinp bkeyw' id='ui_diagnostic_mainscreen'>Main Screen</button> </div>
+        <div class='pure-u-1-3 col'> <button class='bdropinp bkeyw' id='ui_diagnostic_reset'>Reset</button> </div>
+        <div class='pure-u-1-3 col'> <button class='bdropinp bkeyw' id='ui_diagnostic_reboot'>Reboot</button> </div>
+
+      </div>
+
+      <br>
+      <br>
+      <br>
+
+      <div class='pure-g'>
+
+        <button class='invisiblock' id='ui_diagnostic_window'> </button>
+
+<textarea class='statuslogin' type='textarea' id='ui_diagnostic_view' rows='12' cols='80' disabled readonly>
+Diagnostic window...
+</textarea>
+
+      </div>
+
+    </div>
+
+
+
     <!-- ************************* -->
     <!-- ************************* -->
     <!-- ******            ******* -->
     <!-- ******            ******* -->
     <!-- ******   Driver   ******* -->
     <!-- ******   Driver   ******* -->

+ 172 - 8
busunit/DIUv2/html/js/diu_ui-ORG.js

@@ -252,7 +252,6 @@ function _login() {
 }
 }
 
 
 //------------
 //------------
-//------------
 
 
 
 
 function _verify_driver() {
 function _verify_driver() {
@@ -531,11 +530,16 @@ function _cb_status(inp) {
 
 
   var m = g_ctx.diu_status;
   var m = g_ctx.diu_status;
   if (g_ctx.current_ui === "ui_login") {
   if (g_ctx.current_ui === "ui_login") {
+
+    has_tunn = ((m["tunnel"] == '1') ? 'YES' : 'NO');
+    has_gprs = ((m["gprs"] == '1') ? 'YES' : 'NO');
+    has_gps = ((m["gps"] == '1') ? 'YES' : 'NO');
+
     var ele = document.getElementById("ui_login_status");
     var ele = document.getElementById("ui_login_status");
     var str = "";
     var str = "";
-    str += "Tunnel: " + m["tunnel"] + "  GPRS: " + m["gprs"] + "  Eq#: " + m["equipno"] + "  #Msg: " + m["nmsg"] + "\n";
+    str += "Tunnel: " + has_tunn + "  GPRS: " + has_gprs + "  Eq#: " + m["equipno"] + "  #Msg: " + m["nmsg"] + "\n";
     str += "Last Token Read (" + m["last_token"] + ")\n";
     str += "Last Token Read (" + m["last_token"] + ")\n";
-    str += "GPS: " + m["gps"] + "\n";
+    str += "GPS: " + has_gps + "\n";
     str += "\n";
     str += "\n";
     //      012345678012345678901234567890
     //      012345678012345678901234567890
     str += "Package   Version   Installed\n";
     str += "Package   Version   Installed\n";
@@ -594,8 +598,6 @@ function _main_message_replace(msg, bg_color, text_color) {
 
 
   g_ctx.status_text = lines.join("\n");
   g_ctx.status_text = lines.join("\n");
   ele.innerHTML = g_ctx.status_text;
   ele.innerHTML = g_ctx.status_text;
-
-  console.log(">>replace:", msg);
 }
 }
 
 
 function _main_message_add(msg, bg_color, text_color) {
 function _main_message_add(msg, bg_color, text_color) {
@@ -619,8 +621,6 @@ function _main_message_add(msg, bg_color, text_color) {
 
 
   g_ctx.status_text = lines.join("\n");
   g_ctx.status_text = lines.join("\n");
   ele.innerHTML = g_ctx.status_text;
   ele.innerHTML = g_ctx.status_text;
-
-  console.log(">>add:", msg);
 }
 }
 
 
 
 
@@ -666,12 +666,173 @@ function _init_websocket() {
   sock.onerror = function(e) { console.log("error", e); }
   sock.onerror = function(e) { console.log("error", e); }
 }
 }
 
 
+//-------------
+
+var ui_pattern = {
+  "state" : "idle",
+  "lastX" : 0,
+  "lastY" : 0,
+  "curX" : 0,
+  "curY" : 0
+};
+
+function ui_pattern_mousedown(ev) {
+  var ele = document.getElementById("body");
+  var rect = ele.getBoundingClientRect();
+
+  var x = ev["x"];
+  var y = ev["y"];
+
+  var width = rect.width;
+  var height = rect.height;
+
+  if (ui_pattern.state == "idle") {
+    if (y < (height/4)) {
+      ui_pattern.state = "square_0";
+    }
+    else {
+      ui_pattern.state = "idle"
+    }
+
+  }
+
+  else if (ui_pattern.state == "square_0") {
+    if (x > (3*width/4)) {
+      ui_pattern.state = "square_1";
+    }
+    else {
+      ui_pattern.state = "idle"
+    }
+  }
+
+  else if (ui_pattern.state == "square_1") {
+    if (y > (3*height/4)) {
+      ui_pattern.state = "square_2";
+    }
+    else {
+      ui_pattern.state = "idle"
+    }
+  }
+
+  else if (ui_pattern.state == "square_2") {
+    if (x < (width/4)) {
+      _switch_ui("ui_diagnostic");
+    }
+    ui_pattern.state = "idle"
+  }
+
+  return false;
+
+
+  if (ui_pattern.state == "idle") {
+
+    if ((x < (width/4)) && (y < (height/4))) {
+      ui_pattern.state = "cross_0_start";
+    }
+    else {
+      ui_pattern.state = "idle"
+    }
+
+  }
+  else if (ui_pattern.state == "cross_0_end") {
+
+    if ((x > (3*width/4)) && (y < (height/4))) {
+      ui_pattern.state = "cross_1_start";
+    }
+    else {
+      ui_pattern.state = "idle"
+    }
+
+  }
+  else {
+    ui_pattern.state = "idle";
+  }
+
+  return false;
+}
+
+function ui_pattern_mouseup(ev) {
+  return false;
+
+  var ele = document.getElementById("body");
+  var rect = ele.getBoundingClientRect();
+
+  var x = ev["x"];
+  var y = ev["y"];
+
+  var width = rect.width;
+  var height = rect.height;
+
+  if (ui_pattern.state == "cross_0_start") {
+
+    if ((x > (3*width/4)) && (y > (3*height/4))) {
+      ui_pattern.state = "cross_0_end";
+    }
+    else {
+      ui_pattern.state = "idle"
+    }
+
+  }
+  else if (ui_pattern.state == "cross_1_start") {
+
+    if ((x < (width/4)) && (y > (3*height/4))) {
+      _switch_ui("ui_diagnostic");
+    }
+
+    ui_pattern.state = "idle";
+
+  }
+  else {
+    ui_pattern.state = "idle";
+  }
+
+  return false;
+}
+
+//------------
+
+function _mainscreen() {
+  _switch_ui('ui_login');
+  g_ctx.driver_login_state = "driver";
+  _clear_ui_driver();
+  _clear_ui_paddle();
+}
+
+function _reset() {
+
+
+
+  _switch_ui('ui_login');
+  g_ctx.driver_login_state = "driver";
+  _clear_ui_driver();
+  _clear_ui_paddle();
+
+  location.reload(true);
+
+}
+
+function _reboot() {
+  _switch_ui('ui_login');
+  g_ctx.driver_login_state = "driver";
+  _clear_ui_driver();
+  _clear_ui_paddle();
+}
+
+//------------
+
+
 //-------------
 //-------------
 
 
 function init() {
 function init() {
 
 
   _init_websocket();
   _init_websocket();
 
 
+  // diagnostics
+  //
+  document.getElementById('ui_diagnostic_mainscreen').onclick = _mainscreen;
+  document.getElementById('ui_diagnostic_reset').onclick = _reset;
+  document.getElementById('ui_diagnostic_reboot').onclick = _reboot;
+
   // login
   // login
   //
   //
   document.getElementById('ui_login_login').onclick = _login;
   document.getElementById('ui_login_login').onclick = _login;
@@ -832,7 +993,6 @@ function init() {
   // set interval to check status every 1 second
   // set interval to check status every 1 second
   //
   //
   var x = window.setInterval(function() { _api_request("status", {}, _cb_status, _cb_status_err); }, 1000);
   var x = window.setInterval(function() { _api_request("status", {}, _cb_status, _cb_status_err); }, 1000);
-  console.log(">>>", x);
 
 
   // try and reduce textarea highlighting, drag and drop/copy pasting,
   // try and reduce textarea highlighting, drag and drop/copy pasting,
   // and other bad behavor.
   // and other bad behavor.
@@ -877,6 +1037,10 @@ function init() {
   block_ele.style.y = rect.y;
   block_ele.style.y = rect.y;
 
 
 
 
+  ele = document.getElementById("body");
+  ele.onmousedown = ui_pattern_mousedown;
+  ele.onmouseup = ui_pattern_mouseup;
+
 }
 }
 
 
 init();
 init();

+ 3 - 1
busunit/scripts/connection_tether-ssh.sh

@@ -18,7 +18,9 @@
 # along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
 # along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
 #
 #
 
 
-. $HOME/bin/common_values.sh 
+export BASEDIR="/home/bus"
+
+. $BASEDIR/bin/common_values.sh
 
 
 # Do this once at boot time, but do it again after a tunnel abort request...
 # Do this once at boot time, but do it again after a tunnel abort request...
 #
 #

+ 3 - 0
busunit/scripts/rc.local

@@ -23,4 +23,7 @@
 /home/bus/bin/setup-serial.py 2>&1 >> /tmp/init.log
 /home/bus/bin/setup-serial.py 2>&1 >> /tmp/init.log
 /home/bus/bin/get_net_ids.sh 2>&1 >> /tmp/init.log
 /home/bus/bin/get_net_ids.sh 2>&1 >> /tmp/init.log
 
 
+/home/bus/bin/connection_tether.sh 2>&1 >> /tmp/tether.log &
+/home/bus/bin/update_loop.sh 2>&1 >> /tmp/run.log &
+
 exit 0
 exit 0