author | Edouard Tisserant |
Tue, 17 Mar 2020 13:16:01 +0100 | |
branch | svghmi |
changeset 2878 | bec552270ad1 |
parent 2877 | 682bce953795 |
child 2879 | 58e6a91dc37f |
permissions | -rw-r--r-- |
2753
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
1 |
include yslt_noindent.yml2 |
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2763
diff
changeset
|
2 |
|
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2763
diff
changeset
|
3 |
// overrides yslt's output function to set CDATA |
2798
ddb2c4668a6b
SVGHMI : many details about communication implemented in JS, with side effects.
Edouard Tisserant
parents:
2797
diff
changeset
|
4 |
decl output(method, cdata-section-elements="xhtml:script"); |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
5 |
|
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
6 |
in xsl decl labels(*ptr, name="defs_by_labels") alias call-template { |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
7 |
with "hmi_element", "$hmi_element"; |
2810
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
8 |
with "labels"{text *ptr}; |
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
9 |
}; |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
10 |
|
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
11 |
in xsl decl optional_labels(*ptr, name="defs_by_labels") alias call-template { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
12 |
with "hmi_element", "$hmi_element"; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
13 |
with "labels"{text *ptr}; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
14 |
with "mandatory","'no'"; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
15 |
}; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
16 |
|
2840
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
17 |
in xsl decl svgtmpl(match, xmlns="http://www.w3.org/2000/svg") alias template; |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
18 |
in xsl decl svgfunc(name, xmlns="http://www.w3.org/2000/svg") alias template; |
2840
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
19 |
|
2873
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
20 |
!debug_output_calls = [] |
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
21 |
|
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
22 |
istylesheet |
2753
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
23 |
/* From Inkscape */ |
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
24 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
25 |
xmlns:cc="http://creativecommons.org/ns#" |
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
26 |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
27 |
xmlns:svg="http://www.w3.org/2000/svg" |
2838
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
28 |
xmlns:xlink="http://www.w3.org/1999/xlink" |
2753
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
29 |
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
30 |
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
2798
ddb2c4668a6b
SVGHMI : many details about communication implemented in JS, with side effects.
Edouard Tisserant
parents:
2797
diff
changeset
|
31 |
xmlns:xhtml="http://www.w3.org/1999/xhtml" |
2753
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
32 |
|
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
33 |
/* Our namespace to invoke python code */ |
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
34 |
xmlns:ns="beremiz" |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
35 |
extension-element-prefixes="ns func exsl regexp str dyn" |
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
36 |
exclude-result-prefixes="ns str regexp exsl func dyn" { |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
37 |
|
2790
8fab1886ebec
SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents:
2789
diff
changeset
|
38 |
|
2877
682bce953795
SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents:
2876
diff
changeset
|
39 |
include hmi_tree.ysl2 |
682bce953795
SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents:
2876
diff
changeset
|
40 |
|
682bce953795
SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents:
2876
diff
changeset
|
41 |
include geometry.ysl2 |
682bce953795
SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents:
2876
diff
changeset
|
42 |
|
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
43 |
const "svg_root_id", "/svg:svg/@id"; |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
44 |
const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]"; |
2794
c10069a02ed0
SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents:
2793
diff
changeset
|
45 |
|
2877
682bce953795
SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents:
2876
diff
changeset
|
46 |
include detachable_pages.ysl2 |
2853 | 47 |
|
2878 | 48 |
include inline_svg.ysl2 |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
49 |
|
2853 | 50 |
template "/" { |
2793
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
51 |
comment > Made with SVGHMI. https://beremiz.org |
2873
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
52 |
|
022db76c3bff
SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2872
diff
changeset
|
53 |
// use python to call all debug output from included definitions |
2874
b67af0b8dc72
SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2873
diff
changeset
|
54 |
// '&bug' is a workaround for pyPEG that choke on yml2 python results not parsing to a single call |
b67af0b8dc72
SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2873
diff
changeset
|
55 |
!"&bug {"+"\n".join(["comment {\n| \n| %s:\n call \"%s\";\n| \n}"%(n,n) for n in debug_output_calls]) +"}"! |
b67af0b8dc72
SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2873
diff
changeset
|
56 |
|
2840
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
57 |
html xmlns="http://www.w3.org/1999/xhtml" |
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
58 |
xmlns:svg="http://www.w3.org/2000/svg" |
e588f25e6c74
SVGHMI: Better and less verbose SVG namespace handling in XSLT transform
Edouard Tisserant
parents:
2839
diff
changeset
|
59 |
xmlns:xlink="http://www.w3.org/1999/xlink" { |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
60 |
head; |
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
61 |
body style="margin:0;overflow:hidden;" { |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
62 |
copy "$result_svg"; |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
63 |
script{ |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
64 |
call "scripts"; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
65 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
66 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
67 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
68 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
69 |
|
2810
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
70 |
/* |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
71 |
Parses: |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
72 |
"HMI:WidgetType:param1:param2@path1@path2" |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
73 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
74 |
Into: |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
75 |
widget type="WidgetType" { |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
76 |
arg value="param1"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
77 |
arg value="param2"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
78 |
path value="path1"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
79 |
path value="path2"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
80 |
} |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
81 |
*/ |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
82 |
|
2793
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
83 |
|
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
84 |
function "scripts" |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
85 |
{ |
2799
f5da343b9b63
SVGHMI: Many fixes. Subscriptions to HMItree seems to be working, and dispatch function is called in JS with good data. Bidirectional communication now really working.
Edouard Tisserant
parents:
2798
diff
changeset
|
86 |
| //(function(){ |
2798
ddb2c4668a6b
SVGHMI : many details about communication implemented in JS, with side effects.
Edouard Tisserant
parents:
2797
diff
changeset
|
87 |
| |
2847
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
88 |
| id = idstr => document.getElementById(idstr); |
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
89 |
| |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
90 |
| var hmi_hash = [«$hmitree/@hash»]; |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
91 |
|
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
92 |
/* TODO re-enable |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
93 |
|| |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
94 |
function evaluate_js_from_descriptions() { |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
95 |
var Page; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
96 |
var Input; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
97 |
var Display; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
98 |
var res = []; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
99 |
|| |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
100 |
const "midmark" > \n«$mark» |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
101 |
apply """//*[contains(child::svg:desc, $midmark) or \ |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
102 |
starts-with(child::svg:desc, $mark)]""",2 |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
103 |
mode="code_from_descs"; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
104 |
|| |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
105 |
return res; |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
106 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
107 |
|| |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
108 |
*/ |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
109 |
|
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
110 |
| var hmi_widgets = { |
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
111 |
foreach "$hmi_elements" { |
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
112 |
const "widget", "func:parselabel(@inkscape:label)/widget"; |
2856
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
113 |
const "eltid","@id"; |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
114 |
| "«@id»": { |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
115 |
| type: "«$widget/@type»", |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
116 |
| args: [ |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
117 |
foreach "$widget/arg" |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
118 |
| "«@value»"`if "position()!=last()" > ,` |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
119 |
| ], |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
120 |
| indexes: [ |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
121 |
foreach "$widget/path" { |
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
122 |
choose { |
2869
d9eb50c015d1
SVGHMI: take care of path given in HMI:Page and HMI:Jump, but do not apply subscription offset for now. Intermediate commit in a "working" state.
Edouard Tisserant
parents:
2868
diff
changeset
|
123 |
when "not(@index)" { |
d9eb50c015d1
SVGHMI: take care of path given in HMI:Page and HMI:Jump, but do not apply subscription offset for now. Intermediate commit in a "working" state.
Edouard Tisserant
parents:
2868
diff
changeset
|
124 |
warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree |
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
125 |
} |
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
126 |
otherwise { |
2869
d9eb50c015d1
SVGHMI: take care of path given in HMI:Page and HMI:Jump, but do not apply subscription offset for now. Intermediate commit in a "working" state.
Edouard Tisserant
parents:
2868
diff
changeset
|
127 |
| «@index»`if "position()!=last()" > ,` |
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
128 |
} |
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
129 |
} |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
130 |
} |
2855 | 131 |
| ], |
132 |
| element: id("«@id»"), |
|
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
133 |
apply "$widget", mode="widget_defs" with "hmi_element","."; |
2855 | 134 |
| }`if "position()!=last()" > ,` |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
135 |
} |
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
136 |
| } |
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
137 |
| |
2822
9101a72a1da0
SVGHMI: added a watchdog. To ensure that the whole chain is checked, watchdog use a periodic echo of a hearteat variable. JS client code systematically register /HEARTBEAT at 1s update freq, and reacts on updates of /HEARTBEAT by systematically incrementing it. C code catch /HEARTBEAT update and feeds python-implemented watchdog. For now, watchdog does nothing when tiggered
Edouard Tisserant
parents:
2814
diff
changeset
|
138 |
| var heartbeat_index = «$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index»; |
9101a72a1da0
SVGHMI: added a watchdog. To ensure that the whole chain is checked, watchdog use a periodic echo of a hearteat variable. JS client code systematically register /HEARTBEAT at 1s update freq, and reacts on updates of /HEARTBEAT by systematically incrementing it. C code catch /HEARTBEAT update and feeds python-implemented watchdog. For now, watchdog does nothing when tiggered
Edouard Tisserant
parents:
2814
diff
changeset
|
139 |
| |
2798
ddb2c4668a6b
SVGHMI : many details about communication implemented in JS, with side effects.
Edouard Tisserant
parents:
2797
diff
changeset
|
140 |
| var hmitree_types = [ |
ddb2c4668a6b
SVGHMI : many details about communication implemented in JS, with side effects.
Edouard Tisserant
parents:
2797
diff
changeset
|
141 |
|
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
142 |
foreach "$indexed_hmitree/*" { |
2849
bb89a2fbb4e0
SVGHMI: re-indenting
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2848
diff
changeset
|
143 |
| /* «@index» «@hmipath» */ "«substring(local-name(), 5)»"`if "position()!=last()" > ,` |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
144 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
145 |
|
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
146 |
| ] |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
147 |
| |
2843
94696b3f69fb
SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents:
2842
diff
changeset
|
148 |
|
2847
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
149 |
| var detachable_elements = { |
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
150 |
foreach "$detachable_elements"{ |
2850
e38654ec6281
SVGHMI: detach/re-attach elements required by pages on page switch
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2849
diff
changeset
|
151 |
| "«@id»":[id("«@id»"), id("«../@id»")]`if "position()!=last()" > ,` |
2847
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
152 |
} |
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
153 |
| } |
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
154 |
|
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
155 |
| |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
156 |
| var page_desc = { |
2877
682bce953795
SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents:
2876
diff
changeset
|
157 |
apply "$hmi_pages", mode="page_desc"; |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
158 |
| } |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
159 |
|
2795 | 160 |
| |
161 |
| var default_page = "«$default_page»"; |
|
2847
dffade5c83d3
SVGHMI: fix some JS + add generation of detachable elements, to be continued
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2846
diff
changeset
|
162 |
| var svg_root = id("«$svg_root_id»"); |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
163 |
include text svghmi.js |
2799
f5da343b9b63
SVGHMI: Many fixes. Subscriptions to HMItree seems to be working, and dispatch function is called in JS with good data. Bidirectional communication now really working.
Edouard Tisserant
parents:
2798
diff
changeset
|
164 |
| //})(); |
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
165 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
166 |
|
2810
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
167 |
// template "*", mode="code_from_descs" { |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
168 |
// || |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
169 |
// { |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
170 |
// var path, role, name, priv; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
171 |
// var id = "«@id»"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
172 |
// || |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
173 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
174 |
// /* if label is used, use it as default name */ |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
175 |
// if "@inkscape:label" |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
176 |
// |> name = "«@inkscape:label»"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
177 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
178 |
// | /* -------------- */ |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
179 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
180 |
// // this breaks indent, but fixing indent could break string literals |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
181 |
// value "substring-after(svg:desc, $mark)"; |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
182 |
// // nobody reads generated code anyhow... |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
183 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
184 |
// || |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
185 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
186 |
// /* -------------- */ |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
187 |
// res.push({ |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
188 |
// path:path, |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
189 |
// role:role, |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
190 |
// name:name, |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
191 |
// priv:priv |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
192 |
// }) |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
193 |
// } |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
194 |
// || |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
195 |
// } |
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
196 |
|
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
197 |
|
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
198 |
|
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
199 |
function "defs_by_labels" { |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
200 |
param "labels","''"; |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
201 |
param "mandatory","'yes'"; |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
202 |
param "hmi_element"; |
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
203 |
const "widget_type","@type"; |
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
204 |
foreach "str:split($labels)" { |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
205 |
const "name","."; |
2854
c7d5f46cc306
SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents:
2853
diff
changeset
|
206 |
const "elt_id","$result_svg_ns//*[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]/@id"; |
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
207 |
choose { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
208 |
when "not($elt_id)" { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
209 |
if "$mandatory='yes'" { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
210 |
// TODO FIXME error > «$widget_type» widget must have a «$name» element |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
211 |
warning > «$widget_type» widget must have a «$name» element |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
212 |
} |
2853 | 213 |
// otherwise produce nothing |
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
214 |
} |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
215 |
otherwise { |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
216 |
| «$name»_elt: id("«$elt_id»"), |
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
217 |
} |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
218 |
} |
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
219 |
} |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
220 |
} |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
221 |
|
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
222 |
|
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
223 |
template "widget[@type='Display']", mode="widget_defs" { |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
224 |
param "hmi_element"; |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
225 |
| frequency: 5, |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
226 |
| dispatch: function(value) { |
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
227 |
choose { |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
228 |
when "$hmi_element[self::svg:text]"{ |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
229 |
// TODO : care about <tspan> ? |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
230 |
| this.element.textContent = String(value); |
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
231 |
} |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
232 |
otherwise { |
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
233 |
warning > Display widget as a group not implemented |
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
234 |
} |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
235 |
} |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
236 |
| }, |
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
237 |
|
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
238 |
} |
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
239 |
template "widget[@type='Meter']", mode="widget_defs" { |
2807 | 240 |
param "hmi_element"; |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
241 |
| frequency: 10, |
2856
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
242 |
labels("needle range"); |
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
243 |
optional_labels("value min max"); |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
244 |
| dispatch: function(value) { |
2856
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
245 |
| if(this.value_elt) |
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
246 |
| this.value_elt.textContent = String(value); |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
247 |
| let [min,max,totallength] = this.range; |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
248 |
| let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min))); |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
249 |
| let tip = this.range_elt.getPointAtLength(length); |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
250 |
| this.needle_elt.setAttribute('d', "M "+this.origin.x+","+this.origin.y+" "+tip.x+","+tip.y); |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
251 |
| }, |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
252 |
| origin: undefined, |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
253 |
| range: undefined, |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
254 |
| init: function() { |
2857
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
255 |
| let min = this.min_elt ? |
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
256 |
| Number(this.min_elt.textContent) : |
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
257 |
| this.args.length >= 1 ? this.args[0] : 0; |
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
258 |
| let max = this.max_elt ? |
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
259 |
| Number(this.max_elt.textContent) : |
a5c781b2f8f9
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2856
diff
changeset
|
260 |
| this.args.length >= 2 ? this.args[1] : 100; |
2856
1b529ba018ad
SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2855
diff
changeset
|
261 |
| this.range = [min, max, this.range_elt.getTotalLength()] |
2852
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
262 |
| this.origin = this.needle_elt.getPointAtLength(0); |
f7349ca820c9
SVGHMI: completely fixed indentation of generated widget description. Lets try to keep it as-is until we can use yslt indentation.
Edouard Tisserant
parents:
2851
diff
changeset
|
263 |
| }, |
2807 | 264 |
} |
265 |
||
2829
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
266 |
def "func:escape_quotes" { |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
267 |
param "txt"; |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
268 |
// have to use a python string to enter escaped quote |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
269 |
const "frst", !"substring-before($txt,'\"')"!; |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
270 |
const "frstln", "string-length($frst)"; |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
271 |
choose { |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
272 |
when "$frstln > 0 and string-length($txt) > $frstln" { |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
273 |
result !"concat($frst,'\\\"',func:escape_quotes(substring-after($txt,'\"')))"!; |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
274 |
} |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
275 |
otherwise { |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
276 |
result "$txt"; |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
277 |
} |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
278 |
} |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
279 |
} |
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
280 |
|
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
281 |
template "widget[@type='Input']", mode="widget_defs" { |
2801
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
282 |
param "hmi_element"; |
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
283 |
const "value_elt" { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
284 |
optional_labels("value"); |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
285 |
} |
2861
84c16ece8e10
SVGHMI: fixed repeated error when Input widget is missing 'value' element
Edouard Tisserant
parents:
2858
diff
changeset
|
286 |
const "have_value","string-length($value_elt)>0"; |
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
287 |
value "$value_elt"; |
2861
84c16ece8e10
SVGHMI: fixed repeated error when Input widget is missing 'value' element
Edouard Tisserant
parents:
2858
diff
changeset
|
288 |
if "$have_value" |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
289 |
| frequency: 5, |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
290 |
|
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
291 |
| dispatch: function(value) { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
292 |
|
2861
84c16ece8e10
SVGHMI: fixed repeated error when Input widget is missing 'value' element
Edouard Tisserant
parents:
2858
diff
changeset
|
293 |
if "$have_value" |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
294 |
| this.value_elt.textContent = String(value); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
295 |
|
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
296 |
| }, |
2801
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
297 |
const "edit_elt_id","$hmi_element/*[@inkscape:label='edit'][1]/@id"; |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
298 |
| init: function() { |
2801
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
299 |
if "$edit_elt_id" { |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
300 |
| id("«$edit_elt_id»").addEventListener( |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
301 |
| "click", |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
302 |
| evt => alert('XXX TODO : Edit value')); |
2801
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
303 |
} |
2829
4c2c50f60730
SVGHMI : HMI_STRING now also supported from HMI to PLC
Edouard Tisserant
parents:
2822
diff
changeset
|
304 |
foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" { |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
305 |
| id("«@id»").addEventListener( |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
306 |
| "click", |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
307 |
| evt => {let new_val = change_hmi_value(this.indexes[0], "«func:escape_quotes(@inkscape:label)»"); |
2861
84c16ece8e10
SVGHMI: fixed repeated error when Input widget is missing 'value' element
Edouard Tisserant
parents:
2858
diff
changeset
|
308 |
if "$have_value"{ |
84c16ece8e10
SVGHMI: fixed repeated error when Input widget is missing 'value' element
Edouard Tisserant
parents:
2858
diff
changeset
|
309 |
| this.value_elt.textContent = String(new_val); |
84c16ece8e10
SVGHMI: fixed repeated error when Input widget is missing 'value' element
Edouard Tisserant
parents:
2858
diff
changeset
|
310 |
} |
84c16ece8e10
SVGHMI: fixed repeated error when Input widget is missing 'value' element
Edouard Tisserant
parents:
2858
diff
changeset
|
311 |
| }); |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
312 |
/* TODO gray out value until refreshed */ |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
313 |
} |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
314 |
| }, |
2801
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
315 |
} |
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
316 |
template "widget[@type='Button']", mode="widget_defs" { |
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
317 |
} |
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
318 |
template "widget[@type='Toggle']", mode="widget_defs" { |
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
319 |
| frequency: 5, |
390acff12755
SVGHMI: Added init call to all widgets at startup to bind events. More features in Input widget : Edit and Change buttons. WIP HMI->PLC value update, incoherent data detected in C part on update.
Edouard Tisserant
parents:
2800
diff
changeset
|
320 |
} |
2839
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
321 |
template "widget[@type='Switch']", mode="widget_defs" { |
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
322 |
param "hmi_element"; |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
323 |
| frequency: 5, |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
324 |
| dispatch: function(value) { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
325 |
| for(let choice of this.choices){ |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
326 |
| if(value != choice.value){ |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
327 |
| choice.elt.setAttribute("style", "display:none"); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
328 |
| } else { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
329 |
| choice.elt.setAttribute("style", choice.style); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
330 |
| } |
2839
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
331 |
| } |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
332 |
| }, |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
333 |
| init: function() { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
334 |
| // Hello Switch |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
335 |
| }, |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
336 |
| choices: [ |
2839
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
337 |
const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+)(#.*)?$'"!; |
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
338 |
foreach "$hmi_element/*[regexp:test(@inkscape:label,$regex)]" { |
f4dd234faa11
SVGHMI: Added mostly untested switch widget
Edouard Tisserant
parents:
2838
diff
changeset
|
339 |
const "literal", "regexp:match(@inkscape:label,$regex)[2]"; |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
340 |
| { |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
341 |
| elt:id("«@id»"), |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
342 |
| style:"«@style»", |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
343 |
| value:«$literal» |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
344 |
| }`if "position()!=last()" > ,` |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
345 |
} |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
346 |
| ], |
2800
68cee1366b9c
SVGHMI: dispatching data to minimalist "Display" text widget.
Edouard Tisserant
parents:
2799
diff
changeset
|
347 |
} |
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
348 |
template "widget[@type='Jump']", mode="widget_defs" { |
2838
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
349 |
param "hmi_element"; |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
350 |
| on_click: function(evt) { |
2869
d9eb50c015d1
SVGHMI: take care of path given in HMI:Page and HMI:Jump, but do not apply subscription offset for now. Intermediate commit in a "working" state.
Edouard Tisserant
parents:
2868
diff
changeset
|
351 |
| switch_page(this.args[0], this.indexes[0]); |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
352 |
| }, |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
353 |
| init: function() { |
2838
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
354 |
/* registering event this way doies not "click" through svg:use |
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
355 |
| this.element.onclick = evt => switch_page(this.args[0]); |
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
356 |
event must be registered by adding attribute to element instead |
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
357 |
TODO : generalize mouse event handling by global event capture + getElementsAtPoint() |
459bf80d3f46
SVGHMI: HMI:Page can now be a svg:g group or a svg:use clone, and included/linked widget are included in page. HMI:Jump was updated to be clickable through svg:use, to be generalized.
Edouard Tisserant
parents:
2837
diff
changeset
|
358 |
*/ |
2851
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
359 |
| this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)"); |
8d15c6238e62
SVGHMI: re-indent generated JS
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2850
diff
changeset
|
360 |
| }, |
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
361 |
} |
2753
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
362 |
} |