# HG changeset patch
# User Edouard Tisserant
# Date 1692351500 -7200
# Node ID efe0b5b21842dece64c5298eb343e1681f383951
# Parent 65969628e9204e10a1512836612790b4d3b037f0
SVGHMI: add support of all IEC61131 interger types.
- add HMI_*INT types
- fix sprintf.js with big int (64b)
- extend svghmi_real test project
diff -r 65969628e920 -r efe0b5b21842 svghmi/gen_index_xhtml.xslt
--- a/svghmi/gen_index_xhtml.xslt Fri Mar 10 09:13:29 2023 +0100
+++ b/svghmi/gen_index_xhtml.xslt Fri Aug 18 11:38:20 2023 +0200
@@ -2170,8 +2170,6 @@
this.incoming[index] = undefined;
- // TODO: add timestamp argument to dispatch, so that defered data do not appear wrong on graphs
-
this.lastdispatch[index] = Date.now();
this.do_dispatch(new_val, old_val, index);
@@ -9273,8 +9271,6 @@
- console.log("dispatch(",value,oldval, index, time);
-
// naive local buffer impl.
// data is updated only when graph is visible
@@ -10985,9 +10981,19 @@
- if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) {
-
- throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))
+ if (re.numeric_arg.test(ph.type)){
+
+ let argtype = typeof arg;
+
+ if ( argtype !== 'bigint') {
+
+ if ( argtype !== 'number' && isNaN(arg) ) {
+
+ throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))
+
+ }
+
+ }
}
@@ -11481,13 +11487,27 @@
const dvgetters = {
- INT: (dv,offset) => [dv.getInt16(offset, true), 2],
-
- BOOL: (dv,offset) => [dv.getInt8(offset, true), 1],
-
- NODE: (dv,offset) => [dv.getInt8(offset, true), 1],
-
- REAL: (dv,offset) => [dv.getFloat32(offset, true), 4],
+ SINT: (dv,offset) => [dv.getInt8(offset, true), 1],
+
+ INT: (dv,offset) => [dv.getInt16(offset, true), 2],
+
+ DINT: (dv,offset) => [dv.getInt32(offset, true), 4],
+
+ LINT: (dv,offset) => [dv.getBigInt64(offset, true), 8],
+
+ USINT: (dv,offset) => [dv.getUint8(offset, true), 1],
+
+ UINT: (dv,offset) => [dv.getUint16(offset, true), 2],
+
+ UDINT: (dv,offset) => [dv.getUint32(offset, true), 4],
+
+ ULINT: (dv,offset) => [dv.getBigUint64(offset, true), 8],
+
+ BOOL: (dv,offset) => [dv.getInt8(offset, true), 1],
+
+ NODE: (dv,offset) => [dv.getInt8(offset, true), 1],
+
+ REAL: (dv,offset) => [dv.getFloat32(offset, true), 4],
STRING: (dv, offset) => {
@@ -11717,8 +11737,22 @@
const typedarray_types = {
+ SINT: (number) => new Int8Array([number]),
+
INT: (number) => new Int16Array([number]),
+ DINT: (number) => new Int32Array([number]),
+
+ LINT: (number) => new Int64Array([number]),
+
+ USINT: (number) => new Uint8Array([number]),
+
+ UINT: (number) => new Uint16Array([number]),
+
+ UDINT: (number) => new Uint32Array([number]),
+
+ ULINT: (number) => new Uint64Array([number]),
+
BOOL: (truth) => new Int8Array([truth]),
NODE: (truth) => new Int8Array([truth]),
diff -r 65969628e920 -r efe0b5b21842 svghmi/hmi_tree.py
--- a/svghmi/hmi_tree.py Fri Mar 10 09:13:29 2023 +0100
+++ b/svghmi/hmi_tree.py Fri Aug 18 11:38:20 2023 +0200
@@ -17,7 +17,15 @@
HMI_TYPES_DESC = {
"HMI_NODE":{},
"HMI_STRING":{},
+ "HMI_SINT":{},
"HMI_INT":{},
+ "HMI_DINT":{},
+ "HMI_LINT":{},
+ "HMI_DINT":{},
+ "HMI_USINT":{},
+ "HMI_UINT":{},
+ "HMI_UDINT":{},
+ "HMI_ULINT":{},
"HMI_BOOL":{},
"HMI_REAL":{}
}
diff -r 65969628e920 -r efe0b5b21842 svghmi/pous.xml
--- a/svghmi/pous.xml Fri Mar 10 09:13:29 2023 +0100
+++ b/svghmi/pous.xml Fri Aug 18 11:38:20 2023 +0200
@@ -16,11 +16,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 65969628e920 -r efe0b5b21842 svghmi/sprintf.js
--- a/svghmi/sprintf.js Fri Mar 10 09:13:29 2023 +0100
+++ b/svghmi/sprintf.js Fri Aug 18 11:38:20 2023 +0200
@@ -59,8 +59,13 @@
arg = arg()
}
- if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) {
- throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))
+ if (re.numeric_arg.test(ph.type)){
+ let argtype = typeof arg;
+ if ( argtype !== 'bigint') {
+ if ( argtype !== 'number' && isNaN(arg) ) {
+ throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))
+ }
+ }
}
if (re.number.test(ph.type)) {
diff -r 65969628e920 -r efe0b5b21842 svghmi/svghmi.js
--- a/svghmi/svghmi.js Fri Mar 10 09:13:29 2023 +0100
+++ b/svghmi/svghmi.js Fri Aug 18 11:38:20 2023 +0200
@@ -24,10 +24,17 @@
var has_watchdog = window.location.hash == "#watchdog";
const dvgetters = {
- INT: (dv,offset) => [dv.getInt16(offset, true), 2],
- BOOL: (dv,offset) => [dv.getInt8(offset, true), 1],
- NODE: (dv,offset) => [dv.getInt8(offset, true), 1],
- REAL: (dv,offset) => [dv.getFloat32(offset, true), 4],
+ SINT: (dv,offset) => [dv.getInt8(offset, true), 1],
+ INT: (dv,offset) => [dv.getInt16(offset, true), 2],
+ DINT: (dv,offset) => [dv.getInt32(offset, true), 4],
+ LINT: (dv,offset) => [dv.getBigInt64(offset, true), 8],
+ USINT: (dv,offset) => [dv.getUint8(offset, true), 1],
+ UINT: (dv,offset) => [dv.getUint16(offset, true), 2],
+ UDINT: (dv,offset) => [dv.getUint32(offset, true), 4],
+ ULINT: (dv,offset) => [dv.getBigUint64(offset, true), 8],
+ BOOL: (dv,offset) => [dv.getInt8(offset, true), 1],
+ NODE: (dv,offset) => [dv.getInt8(offset, true), 1],
+ REAL: (dv,offset) => [dv.getFloat32(offset, true), 4],
STRING: (dv, offset) => {
const size = dv.getInt8(offset);
return [
@@ -142,7 +149,14 @@
};
const typedarray_types = {
+ SINT: (number) => new Int8Array([number]),
INT: (number) => new Int16Array([number]),
+ DINT: (number) => new Int32Array([number]),
+ LINT: (number) => new Int64Array([number]),
+ USINT: (number) => new Uint8Array([number]),
+ UINT: (number) => new Uint16Array([number]),
+ UDINT: (number) => new Uint32Array([number]),
+ ULINT: (number) => new Uint64Array([number]),
BOOL: (truth) => new Int8Array([truth]),
NODE: (truth) => new Int8Array([truth]),
REAL: (number) => new Float32Array([number]),
diff -r 65969628e920 -r efe0b5b21842 tests/projects/svghmi_real/plc.xml
--- a/tests/projects/svghmi_real/plc.xml Fri Mar 10 09:13:29 2023 +0100
+++ b/tests/projects/svghmi_real/plc.xml Fri Aug 18 11:38:20 2023 +0200
@@ -1,7 +1,7 @@
-
+
@@ -27,53 +27,334 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
var0
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ var1
+
+
+
-
-
-
-
-
-
- var1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ var2
+
+
+
+
+
+
+
+
+
+
+ var3
+
+
+
+
+
+
+
+
+
+
+ var4
+
+
+
+
+
+
+
+
+
+
+ var5
+
+
+
+
+
+
+
+
+
+
+ var6
+
+
+
+
+
+
+
+
+
+
+ var7
+
+
+
+
+
+
+
+
+
+
+ var8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 65969628e920 -r efe0b5b21842 tests/projects/svghmi_real/svghmi_0@svghmi/svghmi.svg
--- a/tests/projects/svghmi_real/svghmi_0@svghmi/svghmi.svg Fri Mar 10 09:13:29 2023 +0100
+++ b/tests/projects/svghmi_real/svghmi_0@svghmi/svghmi.svg Fri Aug 18 11:38:20 2023 +0200
@@ -25,7 +25,7 @@
image/svg+xml
-
+
@@ -59,14 +59,14 @@
inkscape:current-layer="hmi0"
showgrid="false"
units="px"
- inkscape:zoom="0.64"
- inkscape:cx="106.50649"
- inkscape:cy="372.66049"
- inkscape:window-width="1600"
- inkscape:window-height="836"
- inkscape:window-x="1600"
+ inkscape:zoom="0.90509668"
+ inkscape:cx="672.72033"
+ inkscape:cy="359.05499"
+ inkscape:window-width="1850"
+ inkscape:window-height="1036"
+ inkscape:window-x="0"
inkscape:window-y="27"
- inkscape:window-maximized="0"
+ inkscape:window-maximized="1"
showguides="true"
inkscape:guide-bbox="true"
inkscape:snap-global="true"
@@ -381,13 +381,13 @@
+ transform="translate(220,-480)">
1234
+ transform="translate(-474.79908,-17.189114)">
-1
-10
+ transform="translate(531.20092,-17.189114)">
+ transform="translate(291.2009,-17.189114)">
+.1
+ transform="translate(-380,60)">
%.2f
- %d
-
-
+ transform="translate(20,60)">
temp: %.2f℃
ratio: %.2f%%
padded: %'04d
this way, %d and %.3f are together
+ sodipodi:role="line">Multiple variable display: var1 %d and var0 %.3f
+
+ REAL
+ SINT
+ INT
+ DINT
+ LINT
+ USINT
+ UINT
+ UDINT
+ ULINT
+
+ %d
+
+
+ %d
+
+
+ %d
+
+
+ %d
+
+
+ %d
+
+
+ %d
+
+
+ %d
+
+
+ %d
+
+
+
+ 1234
+
+
+ -1
+
+
+
+ -10
+
+
+
+ +1
+
+
+
+ +10
+