|
@@ -27,8 +27,8 @@ var _fqADDRESS = _ADDRESS + ":" + _PORT;
|
|
|
var BG_COLOR = "#f7f7f7";
|
|
var BG_COLOR = "#f7f7f7";
|
|
|
var TEXT_COLOR = "#444444";
|
|
var TEXT_COLOR = "#444444";
|
|
|
|
|
|
|
|
-var DIU_UI_VERSION = "0.1.8";
|
|
|
|
|
-var DIU_UI_VERSION_DATE = "2019-12-10";
|
|
|
|
|
|
|
+var DIU_UI_VERSION = "0.1.9";
|
|
|
|
|
+var DIU_UI_VERSION_DATE = "2020-01-30";
|
|
|
|
|
|
|
|
var g_snd = {
|
|
var g_snd = {
|
|
|
"reject_fare" : "",
|
|
"reject_fare" : "",
|
|
@@ -71,6 +71,7 @@ var g_ctx = {
|
|
|
"current_ui" : "ui_login",
|
|
"current_ui" : "ui_login",
|
|
|
|
|
|
|
|
"ui_change_timeoutid": -1,
|
|
"ui_change_timeoutid": -1,
|
|
|
|
|
+ "ui_watchdog_timeoutid": -1,
|
|
|
|
|
|
|
|
"bulkfare" : "",
|
|
"bulkfare" : "",
|
|
|
"bulkfare_count" : "",
|
|
"bulkfare_count" : "",
|
|
@@ -181,6 +182,30 @@ function _block_status_window(ui_id) {
|
|
|
block_ele.style.y = rect.y;
|
|
block_ele.style.y = rect.y;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function _clear_ui_watchdog() {
|
|
|
|
|
+ if (g_ctx.ui_watchdog_timeoutid >= 0) {
|
|
|
|
|
+ window.clearTimeout(g_ctx.ui_watchdog_timeoutid);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function _set_ui_watchdog(failsafe_ui, _dt) {
|
|
|
|
|
+
|
|
|
|
|
+ // default to 'ui_watchdog' and 5s
|
|
|
|
|
+ //
|
|
|
|
|
+ failsafe_ui = (( typeof failsafe_ui === "undefined") ? "ui_watchdog" : failsafe_ui);
|
|
|
|
|
+ _dt = (( typeof _dt === "undefined") ? 5000 : _dt);
|
|
|
|
|
+
|
|
|
|
|
+ _clear_ui_watchdog();
|
|
|
|
|
+
|
|
|
|
|
+ g_ctx.ui_watchdog_timeoutid = window.setTimeout(
|
|
|
|
|
+ (function(_fsui) {
|
|
|
|
|
+ return function() { console.log("???", _fsui); _switch_ui(_fsui); };
|
|
|
|
|
+ })(failsafe_ui),
|
|
|
|
|
+ _dt);
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
function _switch_ui(to) {
|
|
function _switch_ui(to) {
|
|
|
var ele;
|
|
var ele;
|
|
@@ -322,14 +347,36 @@ function _verify_driver() {
|
|
|
var driver = g_ctx.driver;
|
|
var driver = g_ctx.driver;
|
|
|
var pin = g_ctx.pin;
|
|
var pin = g_ctx.pin;
|
|
|
|
|
|
|
|
|
|
+ // have a fail safe for the verification
|
|
|
|
|
+ //
|
|
|
|
|
+ _set_ui_watchdog();
|
|
|
|
|
+
|
|
|
_api_request("driverlogin", {"driver":driver, "pin":pin}, _verify_driver_ok, _verify_driver_fail);
|
|
_api_request("driverlogin", {"driver":driver, "pin":pin}, _verify_driver_ok, _verify_driver_fail);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function _verify_driver_ok() { _switch_ui("ui_paddle"); }
|
|
|
|
|
-function _verify_driver_fail() { _switch_ui("ui_driverincorrect"); }
|
|
|
|
|
|
|
+function _verify_driver_ok() {
|
|
|
|
|
+ console.log("driver ok");
|
|
|
|
|
+
|
|
|
|
|
+ _clear_ui_watchdog();
|
|
|
|
|
+
|
|
|
|
|
+ _switch_ui("ui_paddle");
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function _verify_driver_fail() {
|
|
|
|
|
+ console.log("driver fail");
|
|
|
|
|
+
|
|
|
|
|
+ _clear_ui_watchdog();
|
|
|
|
|
+
|
|
|
|
|
+ _switch_ui("ui_driverincorrect");
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function _driver_incorrect(inp) {
|
|
function _driver_incorrect(inp) {
|
|
|
|
|
+ console.log("driver incorrect");
|
|
|
|
|
+
|
|
|
|
|
+ _clear_ui_watchdog();
|
|
|
_clear_ui_driver();
|
|
_clear_ui_driver();
|
|
|
|
|
+
|
|
|
_switch_ui("ui_driver");
|
|
_switch_ui("ui_driver");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -410,19 +457,51 @@ function _driver_login(inp) {
|
|
|
function _verify_paddle() {
|
|
function _verify_paddle() {
|
|
|
var paddle = g_ctx.paddle;
|
|
var paddle = g_ctx.paddle;
|
|
|
|
|
|
|
|
|
|
+ // have a fail safe for the verification
|
|
|
|
|
+ //
|
|
|
|
|
+ _set_ui_watchdog();
|
|
|
|
|
+
|
|
|
_api_request("paddleinput", {"paddle":paddle}, _verify_paddle_ack, _verify_paddle_fail);
|
|
_api_request("paddleinput", {"paddle":paddle}, _verify_paddle_ack, _verify_paddle_fail);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function _verify_paddle_ack() { console.log("got ack for push paddle message\n"); }
|
|
|
|
|
-function _verify_paddle_ok() { _switch_ui("ui_main"); }
|
|
|
|
|
-function _verify_paddle_fail() { _switch_ui("ui_paddleunknown"); }
|
|
|
|
|
|
|
+function _verify_paddle_ack() {
|
|
|
|
|
+ console.log("got ack for push paddle message\n");
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function _verify_paddle_ok() {
|
|
|
|
|
+ console.log("verify paddle ok");
|
|
|
|
|
+
|
|
|
|
|
+ _clear_ui_watchdog();
|
|
|
|
|
+
|
|
|
|
|
+ _switch_ui("ui_main");
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function _verify_paddle_fail() {
|
|
|
|
|
+ console.log("verify paddle fail");
|
|
|
|
|
+
|
|
|
|
|
+ _clear_ui_watchdog();
|
|
|
|
|
+
|
|
|
|
|
+ _switch_ui("ui_paddleunknown");
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
function _paddle_unknown(inp) {
|
|
function _paddle_unknown(inp) {
|
|
|
|
|
+
|
|
|
|
|
+ console.log("paddle unknown...");
|
|
|
|
|
+
|
|
|
|
|
+ _clear_ui_watchdog();
|
|
|
_clear_ui_paddle();
|
|
_clear_ui_paddle();
|
|
|
|
|
+
|
|
|
_switch_ui("ui_paddle");
|
|
_switch_ui("ui_paddle");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function _watchdog_tripped(inp) {
|
|
|
|
|
+ console.log("watchdog UI expired!...");
|
|
|
|
|
+ _reset();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
//------------
|
|
//------------
|
|
|
|
|
|
|
|
function _paddle_input(inp) {
|
|
function _paddle_input(inp) {
|
|
@@ -839,6 +918,8 @@ function _main_message_add(msg, bg_color, text_color) {
|
|
|
|
|
|
|
|
function _ws_process(dat) {
|
|
function _ws_process(dat) {
|
|
|
|
|
|
|
|
|
|
+ console.log("_ws_process:", dat);
|
|
|
|
|
+
|
|
|
var tok = dat.split(" ");
|
|
var tok = dat.split(" ");
|
|
|
|
|
|
|
|
if (tok.length < 2) { return; }
|
|
if (tok.length < 2) { return; }
|
|
@@ -872,8 +953,15 @@ function _init_websocket() {
|
|
|
|
|
|
|
|
sock.onopen = function(e) { console.log("open", e); }
|
|
sock.onopen = function(e) { console.log("open", e); }
|
|
|
sock.onmessage = function(e) { _ws_process(e.data); }
|
|
sock.onmessage = function(e) { _ws_process(e.data); }
|
|
|
- sock.onclose = function(e) { console.log("close", e); }
|
|
|
|
|
- sock.onerror = function(e) { console.log("error", e); }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ sock.onclose = function(e) {
|
|
|
|
|
+ console.log("close", e);
|
|
|
|
|
+ setTimeout( function() { _init_websocket(); }, 1000);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ sock.onerror = function(e) {
|
|
|
|
|
+ console.log("error", e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//-------------
|
|
//-------------
|
|
@@ -1091,6 +1179,10 @@ function init() {
|
|
|
|
|
|
|
|
_init_websocket();
|
|
_init_websocket();
|
|
|
|
|
|
|
|
|
|
+ // watchdog
|
|
|
|
|
+ //
|
|
|
|
|
+ document.getElementById('ui_watchdog_btn').onclick = _watchdog_tripped;
|
|
|
|
|
+
|
|
|
// diagnostics
|
|
// diagnostics
|
|
|
//
|
|
//
|
|
|
document.getElementById('ui_diagnostic_mainscreen').onclick = _mainscreen;
|
|
document.getElementById('ui_diagnostic_mainscreen').onclick = _mainscreen;
|
|
@@ -1122,7 +1214,7 @@ function init() {
|
|
|
document.getElementById('ui_login_login').onclick = _login;
|
|
document.getElementById('ui_login_login').onclick = _login;
|
|
|
document.getElementById('ui_login_configuration').onclick = _configuration;
|
|
document.getElementById('ui_login_configuration').onclick = _configuration;
|
|
|
document.getElementById('ui_driverincorrect_btn').onclick = _driver_incorrect;
|
|
document.getElementById('ui_driverincorrect_btn').onclick = _driver_incorrect;
|
|
|
- document.getElementById('ui_paddleunknown_btn').onclick = _paddle_unknown;;
|
|
|
|
|
|
|
+ document.getElementById('ui_paddleunknown_btn').onclick = _paddle_unknown;
|
|
|
|
|
|
|
|
// main menu buttons
|
|
// main menu buttons
|
|
|
//
|
|
//
|