--- a/svghmi/svghmi.js Wed Dec 18 13:31:22 2019 +0100
+++ b/svghmi/svghmi.js Fri Jan 10 13:15:07 2020 +0100
@@ -115,6 +115,19 @@
// hmitree indexed array of Sets of widgets objects
var subscribers = hmitree_types.map(_ignored => new Set());
+// artificially subscribe the watchdog widget to "/heartbeat" hmi variable
+// Since dispatch directly calls change_hmi_value,
+// PLC will periodically send variable at given frequency
+subscribers[heartbeat_index].add({
+ /* type: "Watchdog", */
+ frequency: 1,
+ indexes: [heartbeat_index],
+ dispatch: function(value) {
+ console.log("Heartbeat" + value);
+ change_hmi_value(this.indexes[0], "+1");
+ }
+});
+
function update_subscriptions() {
let delta = [];
for(let index = 0; index < subscribers.length; index++){
@@ -123,6 +136,7 @@
// periods are in ms
let previous_period = subscriptions[index];
+ // subscribing with a zero period is unsubscribing
let new_period = 0;
if(widgets.size > 0) {
let maxfreq = 0;