--- a/svghmi/svghmi.js Sun Nov 20 18:36:13 2022 +0100
+++ b/svghmi/svghmi.js Wed Nov 23 14:18:25 2022 +0100
@@ -525,6 +525,9 @@
? page_name
: page_name + "@" + hmitree_paths[page_index]);
+ // when entering a page, assignments are evaluated
+ new_desc.widgets[0][0].assign();
+
return true;
};
@@ -607,6 +610,7 @@
var reconnect_delay = 0;
var periodic_reconnect_timer;
+var force_reconnect = false;
// Once connection established
function ws_onopen(evt) {
@@ -617,6 +621,7 @@
window.clearTimeout(periodic_reconnect_timer);
}
periodic_reconnect_timer = window.setTimeout(() => {
+ force_reconnect = true;
ws.close();
periodic_reconnect_timer = null;
}, 3600000);
@@ -635,10 +640,16 @@
function ws_onclose(evt) {
console.log("Connection closed. code:"+evt.code+" reason:"+evt.reason+" wasClean:"+evt.wasClean+" Reload in "+reconnect_delay+"ms.");
ws = null;
- // reconect
- // TODO : add visible notification while waiting for reload
+ // Do not attempt to reconnect immediately in case:
+ // - connection was closed by server (PLC stop)
+ // - connection was closed locally with an intention to reconnect
+ if(evt.code=1000 && !force_reconnect){
+ window.alert("Connection closed by server");
+ location.reload();
+ }
window.setTimeout(create_ws, reconnect_delay);
reconnect_delay += 500;
+ force_reconnect = false;
};
var ws_url =