--- a/svghmi/svghmi.js Sat Oct 19 01:23:30 2019 +0200
+++ b/svghmi/svghmi.js Tue Oct 22 17:06:31 2019 +0200
@@ -3,6 +3,8 @@
function dispatch_value(index, value) {
let widgets = subscribers[index];
+ // TODO : value cache
+
if(widgets.size > 0) {
for(let widget of widgets){
let idxidx = widget.indexes.indexOf(index);
@@ -22,6 +24,16 @@
}
};
+function init_widgets() {
+ Object.keys(hmi_widgets).forEach(function(id) {
+ let widget = hmi_widgets[id];
+ let init = widget.init;
+ if(typeof(init) == "function"){
+ return init.call(widget);
+ }
+ });
+};
+
// Open WebSocket to relative "/ws" address
var ws = new WebSocket(window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws'));
ws.binaryType = 'arraybuffer';
@@ -127,9 +139,9 @@
send_blob(delta);
};
-function update_value(index, value) {
+function send_hmi_value(index, value) {
iectype = hmitree_types[index];
- jstype = typedarray_types[iectypes];
+ jstype = typedarray_types[iectype];
send_blob([
new Uint8Array([0]), /* setval = 0 */
new jstype([value])
@@ -137,6 +149,14 @@
};
+function change_hmi_value(index, opstr) {
+ let op = opstr[0];
+ if(op == "=")
+ return send_hmi_value(index, Number(opstr.slice(1)));
+
+ alert('Change '+opstr+" TODO !!! (index :"+index+")");
+}
+
var current_page;
function switch_page(page_name) {
@@ -166,6 +186,7 @@
// Once connection established
ws.onopen = function (evt) {
+ init_widgets();
send_reset();
// show main page
switch_page(default_page);