diff -r 68cee1366b9c -r 390acff12755 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Sat Oct 19 01:23:30 2019 +0200 +++ b/svghmi/gen_index_xhtml.xslt Tue Oct 22 17:06:31 2019 +0200 @@ -326,6 +326,10 @@ + // TODO : value cache + + + if(widgets.size > 0) { for(let widget of widgets){ @@ -364,6 +368,26 @@ + 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')); @@ -582,11 +606,11 @@ - 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([ @@ -602,6 +626,22 @@ + 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; @@ -660,6 +700,8 @@ ws.onopen = function (evt) { + init_widgets(); + send_reset(); // show main page @@ -773,18 +815,73 @@ - Display widget as a group not implemented + + Display widget as a group not implemented + }, - frequency: 10, + frequency: 10, + + frequency: 5, + + + + + Input widget must have a text element + + + value_elt: document.getElementById(" + + "), + + dispatch: function(value) { + + this.value_elt.textContent = String(value); + + }, + + + init: function() { + + + document.getElementById(" + + ").addEventListener( + + "click", + + evt => alert('XXX TODO : Edit value')); + + + + document.getElementById(" + + ").addEventListener( + + "click", + + evt => change_hmi_value(this.indexes[0], " + + ")); + + + }, + + + + frequency: 5, + + frequency: 5, + +