equal
deleted
inserted
replaced
522 } |
522 } |
523 |
523 |
524 apply_hmi_value(current_page_var_index, page_index == undefined |
524 apply_hmi_value(current_page_var_index, page_index == undefined |
525 ? page_name |
525 ? page_name |
526 : page_name + "@" + hmitree_paths[page_index]); |
526 : page_name + "@" + hmitree_paths[page_index]); |
|
527 |
|
528 // when entering a page, assignments are evaluated |
|
529 new_desc.widgets[0][0].assign(); |
527 |
530 |
528 return true; |
531 return true; |
529 }; |
532 }; |
530 |
533 |
531 function switch_visible_page(page_name) { |
534 function switch_visible_page(page_name) { |
605 // show main page |
608 // show main page |
606 switch_page(default_page); |
609 switch_page(default_page); |
607 |
610 |
608 var reconnect_delay = 0; |
611 var reconnect_delay = 0; |
609 var periodic_reconnect_timer; |
612 var periodic_reconnect_timer; |
|
613 var force_reconnect = false; |
610 |
614 |
611 // Once connection established |
615 // Once connection established |
612 function ws_onopen(evt) { |
616 function ws_onopen(evt) { |
613 // Work around memory leak with websocket on QtWebEngine |
617 // Work around memory leak with websocket on QtWebEngine |
614 // reconnect every hour to force deallocate websocket garbage |
618 // reconnect every hour to force deallocate websocket garbage |
615 if(window.navigator.userAgent.includes("QtWebEngine")){ |
619 if(window.navigator.userAgent.includes("QtWebEngine")){ |
616 if(periodic_reconnect_timer){ |
620 if(periodic_reconnect_timer){ |
617 window.clearTimeout(periodic_reconnect_timer); |
621 window.clearTimeout(periodic_reconnect_timer); |
618 } |
622 } |
619 periodic_reconnect_timer = window.setTimeout(() => { |
623 periodic_reconnect_timer = window.setTimeout(() => { |
|
624 force_reconnect = true; |
620 ws.close(); |
625 ws.close(); |
621 periodic_reconnect_timer = null; |
626 periodic_reconnect_timer = null; |
622 }, 3600000); |
627 }, 3600000); |
623 } |
628 } |
624 |
629 |
633 }; |
638 }; |
634 |
639 |
635 function ws_onclose(evt) { |
640 function ws_onclose(evt) { |
636 console.log("Connection closed. code:"+evt.code+" reason:"+evt.reason+" wasClean:"+evt.wasClean+" Reload in "+reconnect_delay+"ms."); |
641 console.log("Connection closed. code:"+evt.code+" reason:"+evt.reason+" wasClean:"+evt.wasClean+" Reload in "+reconnect_delay+"ms."); |
637 ws = null; |
642 ws = null; |
638 // reconect |
643 // Do not attempt to reconnect immediately in case: |
639 // TODO : add visible notification while waiting for reload |
644 // - connection was closed by server (PLC stop) |
|
645 // - connection was closed locally with an intention to reconnect |
|
646 if(evt.code=1000 && !force_reconnect){ |
|
647 window.alert("Connection closed by server"); |
|
648 location.reload(); |
|
649 } |
640 window.setTimeout(create_ws, reconnect_delay); |
650 window.setTimeout(create_ws, reconnect_delay); |
641 reconnect_delay += 500; |
651 reconnect_delay += 500; |
|
652 force_reconnect = false; |
642 }; |
653 }; |
643 |
654 |
644 var ws_url = |
655 var ws_url = |
645 window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws') |
656 window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws') |
646 + '?mode=' + (has_watchdog ? "watchdog" : "multiclient"); |
657 + '?mode=' + (has_watchdog ? "watchdog" : "multiclient"); |