diff -r be947a338760 -r 4c2c50f60730 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Wed Jan 15 11:13:39 2020 +0100 +++ b/svghmi/gen_index_xhtml.xslt Fri Jan 17 16:25:45 2020 +0100 @@ -470,7 +470,7 @@ - // Register message reception handler + // Register message reception handler ws.onmessage = function (evt) { @@ -564,9 +564,29 @@ const typedarray_types = { - INT: Int16Array, - - BOOL: Uint8Array + INT: (number) => new Int16Array([number]), + + BOOL: (truth) => new Int16Array([truth]), + + STRING: (str) => { + + // beremiz default string max size is 128 + + str = str.slice(0,128); + + binary = new Uint8Array(str.length + 1); + + binary[0] = str.length; + + for(var i = 0; i < str.length; i++){ + + binary[i+1] = str.charCodeAt(i); + + } + + return binary; + + } /* TODO */ @@ -600,7 +620,7 @@ // artificially subscribe the watchdog widget to "/heartbeat" hmi variable - // Since dispatch directly calls change_hmi_value, + // Since dispatch directly calls change_hmi_value, // PLC will periodically send variable at given frequency @@ -616,7 +636,7 @@ // console.log("Heartbeat" + value); - change_hmi_value(this.indexes[0], "+1"); + change_hmi_value(heartbeat_index, "+1"); } @@ -690,15 +710,15 @@ let iectype = hmitree_types[index]; - let jstype = typedarray_types[iectype]; + let tobinary = typedarray_types[iectype]; send_blob([ new Uint8Array([0]), /* setval = 0 */ - new Uint32Array([index]), - - new jstype([value])]); + new Uint32Array([index]), + + tobinary(value)]); @@ -796,8 +816,6 @@ dispatch_value_to_widget(widget, index, cached_val, cached_val); - - } } @@ -967,6 +985,19 @@ }, + + + + + + + + + + + + + frequency: 5, @@ -996,7 +1027,7 @@ evt => alert('XXX TODO : Edit value')); - + document.getElementById(" ").addEventListener( @@ -1004,7 +1035,7 @@ "click", evt => {let new_val = change_hmi_value(this.indexes[0], " - + "); this.value_elt.textContent = String(new_val);});