|
|
@@ -71,6 +71,7 @@ var g_ctx = {
|
|
|
"current_ui" : "ui_login",
|
|
|
|
|
|
"ui_change_timeoutid": -1,
|
|
|
+ "ui_watchdog_timeoutid": -1,
|
|
|
|
|
|
"bulkfare" : "",
|
|
|
"bulkfare_count" : "",
|
|
|
@@ -181,6 +182,30 @@ function _block_status_window(ui_id) {
|
|
|
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) {
|
|
|
var ele;
|
|
|
@@ -322,16 +347,36 @@ function _verify_driver() {
|
|
|
var driver = g_ctx.driver;
|
|
|
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);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-function _verify_driver_ok() { console.log("driver ok"); _switch_ui("ui_paddle"); }
|
|
|
-function _verify_driver_fail() { console.log("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) {
|
|
|
console.log("driver incorrect");
|
|
|
|
|
|
+ _clear_ui_watchdog();
|
|
|
_clear_ui_driver();
|
|
|
+
|
|
|
_switch_ui("ui_driver");
|
|
|
}
|
|
|
|
|
|
@@ -412,22 +457,51 @@ function _driver_login(inp) {
|
|
|
function _verify_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);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-function _verify_paddle_ack() { console.log("got ack for push paddle message\n"); }
|
|
|
-function _verify_paddle_ok() { console.log("verify paddle ok"); _switch_ui("ui_main"); }
|
|
|
-function _verify_paddle_fail() { console.log("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) {
|
|
|
|
|
|
console.log("paddle unknown...");
|
|
|
|
|
|
+ _clear_ui_watchdog();
|
|
|
_clear_ui_paddle();
|
|
|
+
|
|
|
_switch_ui("ui_paddle");
|
|
|
}
|
|
|
|
|
|
+function _watchdog_tripped(inp) {
|
|
|
+ console.log("watchdog UI expired!...");
|
|
|
+ _reset();
|
|
|
+}
|
|
|
+
|
|
|
//------------
|
|
|
|
|
|
function _paddle_input(inp) {
|
|
|
@@ -1105,6 +1179,10 @@ function init() {
|
|
|
|
|
|
_init_websocket();
|
|
|
|
|
|
+ // watchdog
|
|
|
+ //
|
|
|
+ document.getElementById('ui_watchdog_btn').onclick = _watchdog_tripped;
|
|
|
+
|
|
|
// diagnostics
|
|
|
//
|
|
|
document.getElementById('ui_diagnostic_mainscreen').onclick = _mainscreen;
|