1 <?xml version="1.0"?> |
1 <?xml version="1.0"?> |
2 <xsl:stylesheet xmlns:ns="beremiz" xmlns:definitions="definitions" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:func="http://exslt.org/functions" xmlns:epilogue="epilogue" xmlns:preamble="preamble" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:svg="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:str="http://exslt.org/strings" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:declarations="declarations" xmlns:debug="debug" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0"> |
2 <xsl:stylesheet xmlns:ns="beremiz" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:exsl="http://exslt.org/common" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:preamble="preamble" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:svg="http://www.w3.org/2000/svg" xmlns:debug="debug" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:definitions="definitions" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:cc="http://creativecommons.org/ns#" xmlns:declarations="declarations" xmlns:func="http://exslt.org/functions" xmlns:str="http://exslt.org/strings" xmlns:epilogue="epilogue" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions"> |
3 <xsl:output method="xml" cdata-section-elements="xhtml:script"/> |
3 <xsl:output cdata-section-elements="xhtml:script" method="xml"/> |
4 <xsl:variable name="svg" select="/svg:svg"/> |
4 <xsl:variable select="/svg:svg" name="svg"/> |
5 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
5 <xsl:variable select="//svg:*[starts-with(@inkscape:label, 'HMI:')]" name="hmi_elements"/> |
6 <xsl:variable name="hmitree" select="ns:GetHMITree()"/> |
6 <xsl:variable select="ns:GetHMITree()" name="hmitree"/> |
7 <xsl:variable name="_categories"> |
7 <xsl:variable name="_categories"> |
8 <noindex> |
8 <noindex> |
9 <xsl:text>HMI_PLC_STATUS</xsl:text> |
9 <xsl:text>HMI_PLC_STATUS</xsl:text> |
10 </noindex> |
10 </noindex> |
11 <noindex> |
11 <noindex> |
12 <xsl:text>HMI_CURRENT_PAGE</xsl:text> |
12 <xsl:text>HMI_CURRENT_PAGE</xsl:text> |
13 </noindex> |
13 </noindex> |
14 </xsl:variable> |
14 </xsl:variable> |
15 <xsl:variable name="categories" select="exsl:node-set($_categories)"/> |
15 <xsl:variable select="exsl:node-set($_categories)" name="categories"/> |
16 <xsl:variable name="_indexed_hmitree"> |
16 <xsl:variable name="_indexed_hmitree"> |
17 <xsl:apply-templates mode="index" select="$hmitree"/> |
17 <xsl:apply-templates mode="index" select="$hmitree"/> |
18 </xsl:variable> |
18 </xsl:variable> |
19 <xsl:variable name="indexed_hmitree" select="exsl:node-set($_indexed_hmitree)"/> |
19 <xsl:variable select="exsl:node-set($_indexed_hmitree)" name="indexed_hmitree"/> |
20 <preamble:hmi-tree/> |
20 <preamble:hmi-tree/> |
21 <xsl:template match="preamble:hmi-tree"> |
21 <xsl:template match="preamble:hmi-tree"> |
22 <xsl:text> |
22 <xsl:text> |
23 </xsl:text> |
23 </xsl:text> |
24 <xsl:text>/* </xsl:text> |
24 <xsl:text>/* </xsl:text> |
94 <xsl:for-each select="@*"> |
94 <xsl:for-each select="@*"> |
95 <xsl:copy/> |
95 <xsl:copy/> |
96 </xsl:for-each> |
96 </xsl:for-each> |
97 </xsl:copy> |
97 </xsl:copy> |
98 <xsl:apply-templates mode="index" select="*[1]"> |
98 <xsl:apply-templates mode="index" select="*[1]"> |
99 <xsl:with-param name="index" select="$index + 1"/> |
99 <xsl:with-param select="$index + 1" name="index"/> |
100 <xsl:with-param name="parentpath"> |
100 <xsl:with-param name="parentpath"> |
101 <xsl:value-of select="$path"/> |
101 <xsl:value-of select="$path"/> |
102 </xsl:with-param> |
102 </xsl:with-param> |
103 </xsl:apply-templates> |
103 </xsl:apply-templates> |
104 </xsl:when> |
104 </xsl:when> |
105 <xsl:otherwise> |
105 <xsl:otherwise> |
106 <xsl:apply-templates mode="index" select="*[1]"> |
106 <xsl:apply-templates mode="index" select="*[1]"> |
107 <xsl:with-param name="index" select="$index"/> |
107 <xsl:with-param select="$index" name="index"/> |
108 <xsl:with-param name="parentpath"> |
108 <xsl:with-param name="parentpath"> |
109 <xsl:value-of select="$path"/> |
109 <xsl:value-of select="$path"/> |
110 </xsl:with-param> |
110 </xsl:with-param> |
111 </xsl:apply-templates> |
111 </xsl:apply-templates> |
112 </xsl:otherwise> |
112 </xsl:otherwise> |
113 </xsl:choose> |
113 </xsl:choose> |
114 </xsl:variable> |
114 </xsl:variable> |
115 <xsl:copy-of select="$content"/> |
115 <xsl:copy-of select="$content"/> |
116 <xsl:apply-templates mode="index" select="following-sibling::*[1]"> |
116 <xsl:apply-templates mode="index" select="following-sibling::*[1]"> |
117 <xsl:with-param name="index" select="$index + count(exsl:node-set($content)/*)"/> |
117 <xsl:with-param select="$index + count(exsl:node-set($content)/*)" name="index"/> |
118 <xsl:with-param name="parentpath"> |
118 <xsl:with-param name="parentpath"> |
119 <xsl:value-of select="$parentpath"/> |
119 <xsl:value-of select="$parentpath"/> |
120 </xsl:with-param> |
120 </xsl:with-param> |
121 </xsl:apply-templates> |
121 </xsl:apply-templates> |
122 </xsl:template> |
122 </xsl:template> |
123 <xsl:template mode="parselabel" match="*"> |
123 <xsl:template mode="parselabel" match="*"> |
124 <xsl:variable name="label" select="@inkscape:label"/> |
124 <xsl:variable select="@inkscape:label" name="label"/> |
125 <xsl:variable name="description" select="substring-after($label,'HMI:')"/> |
125 <xsl:variable select="substring-after($label,'HMI:')" name="description"/> |
126 <xsl:variable name="_args" select="substring-before($description,'@')"/> |
126 <xsl:variable select="substring-before($description,'@')" name="_args"/> |
127 <xsl:variable name="args"> |
127 <xsl:variable name="args"> |
128 <xsl:choose> |
128 <xsl:choose> |
129 <xsl:when test="$_args"> |
129 <xsl:when test="$_args"> |
130 <xsl:value-of select="$_args"/> |
130 <xsl:value-of select="$_args"/> |
131 </xsl:when> |
131 </xsl:when> |
132 <xsl:otherwise> |
132 <xsl:otherwise> |
133 <xsl:value-of select="$description"/> |
133 <xsl:value-of select="$description"/> |
134 </xsl:otherwise> |
134 </xsl:otherwise> |
135 </xsl:choose> |
135 </xsl:choose> |
136 </xsl:variable> |
136 </xsl:variable> |
137 <xsl:variable name="_type" select="substring-before($args,':')"/> |
137 <xsl:variable select="substring-before($args,':')" name="_type"/> |
138 <xsl:variable name="type"> |
138 <xsl:variable name="type"> |
139 <xsl:choose> |
139 <xsl:choose> |
140 <xsl:when test="$_type"> |
140 <xsl:when test="$_type"> |
141 <xsl:value-of select="$_type"/> |
141 <xsl:value-of select="$_type"/> |
142 </xsl:when> |
142 </xsl:when> |
158 <xsl:attribute name="value"> |
158 <xsl:attribute name="value"> |
159 <xsl:value-of select="."/> |
159 <xsl:value-of select="."/> |
160 </xsl:attribute> |
160 </xsl:attribute> |
161 </arg> |
161 </arg> |
162 </xsl:for-each> |
162 </xsl:for-each> |
163 <xsl:variable name="paths" select="substring-after($description,'@')"/> |
163 <xsl:variable select="substring-after($description,'@')" name="paths"/> |
164 <xsl:for-each select="str:split($paths, '@')"> |
164 <xsl:for-each select="str:split($paths, '@')"> |
165 <xsl:if test="string-length(.) > 0"> |
165 <xsl:if test="string-length(.) > 0"> |
166 <path> |
166 <path> |
167 <xsl:attribute name="value"> |
167 <xsl:attribute name="value"> |
168 <xsl:value-of select="."/> |
168 <xsl:value-of select="."/> |
169 </xsl:attribute> |
169 </xsl:attribute> |
170 <xsl:variable name="path" select="."/> |
170 <xsl:variable select="." name="path"/> |
171 <xsl:variable name="item" select="$indexed_hmitree/*[@hmipath = $path]"/> |
171 <xsl:variable select="$indexed_hmitree/*[@hmipath = $path]" name="item"/> |
172 <xsl:choose> |
172 <xsl:choose> |
173 <xsl:when test="count($item) = 1"> |
173 <xsl:when test="count($item) = 1"> |
174 <xsl:attribute name="index"> |
174 <xsl:attribute name="index"> |
175 <xsl:value-of select="$item/@index"/> |
175 <xsl:value-of select="$item/@index"/> |
176 </xsl:attribute> |
176 </xsl:attribute> |
213 <func:result select="string-length($ancest) > 0 and starts-with($descend,$ancest)"/> |
213 <func:result select="string-length($ancest) > 0 and starts-with($descend,$ancest)"/> |
214 </func:function> |
214 </func:function> |
215 <func:function name="func:same_class_paths"> |
215 <func:function name="func:same_class_paths"> |
216 <xsl:param name="a"/> |
216 <xsl:param name="a"/> |
217 <xsl:param name="b"/> |
217 <xsl:param name="b"/> |
218 <xsl:variable name="class_a" select="$indexed_hmitree/*[@hmipath = $a]/@class"/> |
218 <xsl:variable select="$indexed_hmitree/*[@hmipath = $a]/@class" name="class_a"/> |
219 <xsl:variable name="class_b" select="$indexed_hmitree/*[@hmipath = $b]/@class"/> |
219 <xsl:variable select="$indexed_hmitree/*[@hmipath = $b]/@class" name="class_b"/> |
220 <func:result select="$class_a and $class_b and $class_a = $class_b"/> |
220 <func:result select="$class_a and $class_b and $class_a = $class_b"/> |
221 </func:function> |
221 </func:function> |
222 <xsl:template mode="testtree" match="*"> |
222 <xsl:template mode="testtree" match="*"> |
223 <xsl:param name="indent" select="''"/> |
223 <xsl:param select="''" name="indent"/> |
224 <xsl:value-of select="$indent"/> |
224 <xsl:value-of select="$indent"/> |
225 <xsl:text> </xsl:text> |
225 <xsl:text> </xsl:text> |
226 <xsl:value-of select="local-name()"/> |
226 <xsl:value-of select="local-name()"/> |
227 <xsl:text> </xsl:text> |
227 <xsl:text> </xsl:text> |
228 <xsl:for-each select="@*"> |
228 <xsl:for-each select="@*"> |
322 </xsl:choose> |
322 </xsl:choose> |
323 </func:function> |
323 </func:function> |
324 <func:function name="func:intersect"> |
324 <func:function name="func:intersect"> |
325 <xsl:param name="a"/> |
325 <xsl:param name="a"/> |
326 <xsl:param name="b"/> |
326 <xsl:param name="b"/> |
327 <xsl:variable name="x_intersect" select="func:intersect_1d($a/@x, $a/@x+$a/@w, $b/@x, $b/@x+$b/@w)"/> |
327 <xsl:variable select="func:intersect_1d($a/@x, $a/@x+$a/@w, $b/@x, $b/@x+$b/@w)" name="x_intersect"/> |
328 <xsl:choose> |
328 <xsl:choose> |
329 <xsl:when test="$x_intersect != 0"> |
329 <xsl:when test="$x_intersect != 0"> |
330 <xsl:variable name="y_intersect" select="func:intersect_1d($a/@y, $a/@y+$a/@h, $b/@y, $b/@y+$b/@h)"/> |
330 <xsl:variable select="func:intersect_1d($a/@y, $a/@y+$a/@h, $b/@y, $b/@y+$b/@h)" name="y_intersect"/> |
331 <func:result select="$x_intersect * $y_intersect"/> |
331 <func:result select="$x_intersect * $y_intersect"/> |
332 </xsl:when> |
332 </xsl:when> |
333 <xsl:otherwise> |
333 <xsl:otherwise> |
334 <func:result select="0"/> |
334 <func:result select="0"/> |
335 </xsl:otherwise> |
335 </xsl:otherwise> |
336 </xsl:choose> |
336 </xsl:choose> |
337 </func:function> |
337 </func:function> |
338 <func:function name="func:overlapping_geometry"> |
338 <func:function name="func:overlapping_geometry"> |
339 <xsl:param name="elt"/> |
339 <xsl:param name="elt"/> |
340 <xsl:variable name="groups" select="/svg:svg | //svg:g"/> |
340 <xsl:variable select="/svg:svg | //svg:g" name="groups"/> |
341 <xsl:variable name="g" select="$geometry[@Id = $elt/@id]"/> |
341 <xsl:variable select="$geometry[@Id = $elt/@id]" name="g"/> |
342 <xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/> |
342 <xsl:variable select="$geometry[@Id != $elt/@id]" name="candidates"/> |
343 <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or (not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]"/> |
343 <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or (not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]"/> |
344 </func:function> |
344 </func:function> |
345 <xsl:variable name="hmi_pages_descs" select="$parsed_widgets/widget[@type = 'Page']"/> |
345 <xsl:variable select="$parsed_widgets/widget[@type = 'Page']" name="hmi_pages_descs"/> |
346 <xsl:variable name="hmi_pages" select="$hmi_elements[@id = $hmi_pages_descs/@id]"/> |
346 <xsl:variable select="$hmi_elements[@id = $hmi_pages_descs/@id]" name="hmi_pages"/> |
347 <xsl:variable name="default_page"> |
347 <xsl:variable name="default_page"> |
348 <xsl:choose> |
348 <xsl:choose> |
349 <xsl:when test="count($hmi_pages) > 1"> |
349 <xsl:when test="count($hmi_pages) > 1"> |
350 <xsl:choose> |
350 <xsl:choose> |
351 <xsl:when test="$hmi_pages_descs/arg[1]/@value = 'Home'"> |
351 <xsl:when test="$hmi_pages_descs/arg[1]/@value = 'Home'"> |
415 <xsl:otherwise> |
415 <xsl:otherwise> |
416 <func:result select="/.."/> |
416 <func:result select="/.."/> |
417 </xsl:otherwise> |
417 </xsl:otherwise> |
418 </xsl:choose> |
418 </xsl:choose> |
419 </func:function> |
419 </func:function> |
420 <xsl:variable name="required_elements" select="//svg:defs/descendant-or-self::svg:* | func:required_elements($hmi_pages | $keypads)/ancestor-or-self::svg:*"/> |
420 <xsl:variable select="//svg:defs/descendant-or-self::svg:* | func:required_elements($hmi_pages | $keypads)/ancestor-or-self::svg:*" name="required_elements"/> |
421 <xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/> |
421 <xsl:variable select="//svg:*[not(@id = $required_elements/@id)]" name="discardable_elements"/> |
422 <func:function name="func:sumarized_elements"> |
422 <func:function name="func:sumarized_elements"> |
423 <xsl:param name="elements"/> |
423 <xsl:param name="elements"/> |
424 <xsl:variable name="short_list" select="$elements[not(ancestor::*/@id = $elements/@id)]"/> |
424 <xsl:variable select="$elements[not(ancestor::*/@id = $elements/@id)]" name="short_list"/> |
425 <xsl:variable name="filled_groups" select="$short_list/parent::svg:*[ not(descendant::*[ not(self::svg:g) and not(@id = $discardable_elements/@id) and not(@id = $short_list/descendant-or-self::*[not(self::svg:g)]/@id) ])]"/> |
425 <xsl:variable select="$short_list/parent::svg:*[ not(descendant::*[ not(self::svg:g) and not(@id = $discardable_elements/@id) and not(@id = $short_list/descendant-or-self::*[not(self::svg:g)]/@id) ])]" name="filled_groups"/> |
426 <xsl:variable name="groups_to_add" select="$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"/> |
426 <xsl:variable select="$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]" name="groups_to_add"/> |
427 <func:result select="$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"/> |
427 <func:result select="$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"/> |
428 </func:function> |
428 </func:function> |
429 <func:function name="func:detachable_elements"> |
429 <func:function name="func:detachable_elements"> |
430 <xsl:param name="pages"/> |
430 <xsl:param name="pages"/> |
431 <xsl:choose> |
431 <xsl:choose> |
470 <xsl:text>} |
470 <xsl:text>} |
471 </xsl:text> |
471 </xsl:text> |
472 <xsl:text> |
472 <xsl:text> |
473 </xsl:text> |
473 </xsl:text> |
474 </xsl:template> |
474 </xsl:template> |
475 <xsl:variable name="forEach_widgets_ids" select="$parsed_widgets/widget[@type = 'ForEach']/@id"/> |
475 <xsl:variable select="$parsed_widgets/widget[@type = 'ForEach']/@id" name="forEach_widgets_ids"/> |
476 <xsl:variable name="forEach_widgets" select="$hmi_elements[@id = $forEach_widgets_ids]"/> |
476 <xsl:variable select="$hmi_elements[@id = $forEach_widgets_ids]" name="forEach_widgets"/> |
477 <xsl:variable name="in_forEach_widget_ids" select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]/@id"/> |
477 <xsl:variable select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]/@id" name="in_forEach_widget_ids"/> |
478 <xsl:template mode="page_desc" match="svg:*"> |
478 <xsl:template mode="page_desc" match="svg:*"> |
479 <xsl:variable name="desc" select="func:widget(@id)"/> |
479 <xsl:variable select="func:widget(@id)" name="desc"/> |
480 <xsl:variable name="page" select="."/> |
480 <xsl:variable select="." name="page"/> |
481 <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/> |
481 <xsl:variable select="$geometry[@Id = $page/@id]" name="p"/> |
482 <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/> |
482 <xsl:variable select="func:all_related_elements($page)" name="page_all_elements"/> |
483 <xsl:variable name="all_page_widgets" select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]"/> |
483 <xsl:variable select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]" name="all_page_widgets"/> |
484 <xsl:variable name="page_managed_widgets" select="$all_page_widgets[not(@id=$in_forEach_widget_ids)]"/> |
484 <xsl:variable select="$all_page_widgets[not(@id=$in_forEach_widget_ids)]" name="page_managed_widgets"/> |
485 <xsl:variable name="page_relative_widgets" select="$page_managed_widgets[func:is_descendant_path(func:widget(@id)/path/@value, $desc/path/@value)]"/> |
485 <xsl:variable select="$page_managed_widgets[func:is_descendant_path(func:widget(@id)/path/@value, $desc/path/@value)]" name="page_relative_widgets"/> |
486 <xsl:variable name="required_detachables" select="func:sumarized_elements($page_all_elements)/ ancestor-or-self::*[@id = $detachable_elements/@id]"/> |
486 <xsl:variable select="func:sumarized_elements($page_all_elements)/ ancestor-or-self::*[@id = $detachable_elements/@id]" name="required_detachables"/> |
487 <xsl:text> "</xsl:text> |
487 <xsl:text> "</xsl:text> |
488 <xsl:value-of select="$desc/arg[1]/@value"/> |
488 <xsl:value-of select="$desc/arg[1]/@value"/> |
489 <xsl:text>": { |
489 <xsl:text>": { |
490 </xsl:text> |
490 </xsl:text> |
491 <xsl:text> bbox: [</xsl:text> |
491 <xsl:text> bbox: [</xsl:text> |
668 <xsl:template mode="inline_svg" match="sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']"> |
668 <xsl:template mode="inline_svg" match="sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']"> |
669 <xsl:message terminate="yes"> |
669 <xsl:message terminate="yes"> |
670 <xsl:text>All units must be set to "px" in Inkscape's document properties</xsl:text> |
670 <xsl:text>All units must be set to "px" in Inkscape's document properties</xsl:text> |
671 </xsl:message> |
671 </xsl:message> |
672 </xsl:template> |
672 </xsl:template> |
673 <xsl:variable name="hmi_lists_descs" select="$parsed_widgets/widget[@type = 'List']"/> |
673 <xsl:variable select="$parsed_widgets/widget[@type = 'List']" name="hmi_lists_descs"/> |
674 <xsl:variable name="hmi_lists" select="$hmi_elements[@id = $hmi_lists_descs/@id]"/> |
674 <xsl:variable select="$hmi_elements[@id = $hmi_lists_descs/@id]" name="hmi_lists"/> |
675 <xsl:variable name="targets_not_to_unlink" select="$hmi_elements[@id = $hmi_lists/@id]/descendant::svg:*"/> |
675 <xsl:variable select="$hmi_lists/descendant-or-self::svg:*" name="targets_not_to_unlink"/> |
676 <xsl:variable name="to_unlink" select="$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use"/> |
676 <xsl:variable select="$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use" name="to_unlink"/> |
677 <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="svg:use"> |
677 <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="svg:use"> |
678 <xsl:variable name="targetid" select="substring-after(@xlink:href,'#')"/> |
678 <xsl:param name="seed"/> |
|
679 <xsl:variable select="substring-after(@xlink:href,'#')" name="targetid"/> |
679 <xsl:choose> |
680 <xsl:choose> |
680 <xsl:when test="@id = $to_unlink/@id and not($targetid = $targets_not_to_unlink/@id)"> |
681 <xsl:when test="@id = $to_unlink/@id and not($targetid = $targets_not_to_unlink/@id)"> |
681 <xsl:call-template name="unlink_clone"> |
682 <xsl:call-template name="unlink_clone"> |
682 <xsl:with-param name="targetid" select="$targetid"/> |
683 <xsl:with-param select="$targetid" name="targetid"/> |
|
684 <xsl:with-param select="$seed" name="seed"/> |
683 </xsl:call-template> |
685 </xsl:call-template> |
684 </xsl:when> |
686 </xsl:when> |
685 <xsl:otherwise> |
687 <xsl:otherwise> |
686 <xsl:copy> |
688 <xsl:copy> |
687 <xsl:apply-templates mode="inline_svg" select="@* | node()"/> |
689 <xsl:apply-templates mode="inline_svg" select="@* | node()"/> |
703 <xsl:text>x</xsl:text> |
705 <xsl:text>x</xsl:text> |
704 </name> |
706 </name> |
705 <name> |
707 <name> |
706 <xsl:text>y</xsl:text> |
708 <xsl:text>y</xsl:text> |
707 </name> |
709 </name> |
|
710 <name> |
|
711 <xsl:text>id</xsl:text> |
|
712 </name> |
708 </xsl:variable> |
713 </xsl:variable> |
709 <xsl:variable name="excluded_use_attrs" select="exsl:node-set($_excluded_use_attrs)"/> |
714 <xsl:variable select="exsl:node-set($_excluded_use_attrs)" name="excluded_use_attrs"/> |
710 <xsl:variable name="_merge_use_attrs"> |
715 <xsl:variable name="_merge_use_attrs"> |
711 <name> |
716 <name> |
712 <xsl:text>transform</xsl:text> |
717 <xsl:text>transform</xsl:text> |
713 </name> |
718 </name> |
714 <name> |
719 <name> |
715 <xsl:text>style</xsl:text> |
720 <xsl:text>style</xsl:text> |
716 </name> |
721 </name> |
717 </xsl:variable> |
722 </xsl:variable> |
718 <xsl:variable name="merge_use_attrs" select="exsl:node-set($_merge_use_attrs)"/> |
723 <xsl:variable select="exsl:node-set($_merge_use_attrs)" name="merge_use_attrs"/> |
719 <xsl:template xmlns="http://www.w3.org/2000/svg" name="unlink_clone"> |
724 <xsl:template xmlns="http://www.w3.org/2000/svg" name="unlink_clone"> |
720 <xsl:param name="targetid"/> |
725 <xsl:param name="targetid"/> |
721 <xsl:variable name="target" select="//svg:*[@id = $targetid]"/> |
726 <xsl:param name="seed"/> |
|
727 <xsl:variable select="//svg:*[@id = $targetid]" name="target"/> |
|
728 <xsl:variable select="concat($seed, @id)" name="seeded_id"/> |
722 <g> |
729 <g> |
|
730 <xsl:attribute name="id"> |
|
731 <xsl:value-of select="$seeded_id"/> |
|
732 </xsl:attribute> |
723 <xsl:choose> |
733 <xsl:choose> |
724 <xsl:when test="$target[self::svg:g]"> |
734 <xsl:when test="$target[self::svg:g]"> |
725 <xsl:for-each select="@*[not(local-name() = $excluded_use_attrs/name | $merge_use_attrs)]"> |
735 <xsl:for-each select="@*[not(local-name() = $excluded_use_attrs/name | $merge_use_attrs)]"> |
726 <xsl:attribute name="{name()}"> |
736 <xsl:attribute name="{name()}"> |
727 <xsl:value-of select="."/> |
737 <xsl:value-of select="."/> |
1320 </xsl:text> |
1334 </xsl:text> |
1321 <xsl:text> |
1335 <xsl:text> |
1322 </xsl:text> |
1336 </xsl:text> |
1323 </xsl:template> |
1337 </xsl:template> |
1324 <xsl:template name="defs_by_labels"> |
1338 <xsl:template name="defs_by_labels"> |
1325 <xsl:param name="labels" select="''"/> |
1339 <xsl:param select="''" name="labels"/> |
1326 <xsl:param name="mandatory" select="'yes'"/> |
1340 <xsl:param select="'yes'" name="mandatory"/> |
1327 <xsl:param name="subelements" select="/.."/> |
1341 <xsl:param select="/.." name="subelements"/> |
1328 <xsl:param name="hmi_element"/> |
1342 <xsl:param name="hmi_element"/> |
1329 <xsl:variable name="widget_type" select="@type"/> |
1343 <xsl:variable select="@type" name="widget_type"/> |
1330 <xsl:for-each select="str:split($labels)"> |
1344 <xsl:for-each select="str:split($labels)"> |
1331 <xsl:variable name="name" select="."/> |
1345 <xsl:variable select="." name="name"/> |
1332 <xsl:variable name="elt" select="$result_svg_ns//*[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]"/> |
1346 <xsl:variable select="$result_svg_ns//*[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]" name="elt"/> |
1333 <xsl:choose> |
1347 <xsl:choose> |
1334 <xsl:when test="not($elt/@id)"> |
1348 <xsl:when test="not($elt/@id)"> |
1335 <xsl:if test="$mandatory='yes'"> |
1349 <xsl:if test="$mandatory='yes'"> |
1336 <xsl:message terminate="yes"> |
1350 <xsl:message terminate="yes"> |
1337 <xsl:value-of select="$widget_type"/> |
1351 <xsl:value-of select="$widget_type"/> |
1506 </xsl:text> |
1520 </xsl:text> |
1507 </xsl:template> |
1521 </xsl:template> |
1508 <xsl:template mode="widget_defs" match="widget[@type='Button']"> |
1522 <xsl:template mode="widget_defs" match="widget[@type='Button']"> |
1509 <xsl:param name="hmi_element"/> |
1523 <xsl:param name="hmi_element"/> |
1510 <xsl:call-template name="defs_by_labels"> |
1524 <xsl:call-template name="defs_by_labels"> |
1511 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
1525 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
1512 <xsl:with-param name="labels"> |
1526 <xsl:with-param name="labels"> |
1513 <xsl:text>active inactive</xsl:text> |
1527 <xsl:text>active inactive</xsl:text> |
1514 </xsl:with-param> |
1528 </xsl:with-param> |
1515 <xsl:with-param name="mandatory" select="'no'"/> |
1529 <xsl:with-param select="'no'" name="mandatory"/> |
1516 </xsl:call-template> |
1530 </xsl:call-template> |
1517 <xsl:text> |
1531 <xsl:text> |
|
1532 </xsl:text> |
|
1533 </xsl:template> |
|
1534 <xsl:template mode="widget_class" match="widget[@type='CircularBar']"> |
|
1535 <xsl:text>class CircularBarWidget extends Widget{ |
|
1536 </xsl:text> |
|
1537 <xsl:text> frequency = 10; |
|
1538 </xsl:text> |
|
1539 <xsl:text> range = undefined; |
|
1540 </xsl:text> |
|
1541 <xsl:text> |
|
1542 </xsl:text> |
|
1543 <xsl:text> dispatch(value) { |
|
1544 </xsl:text> |
|
1545 <xsl:text> if(this.value_elt) |
|
1546 </xsl:text> |
|
1547 <xsl:text> this.value_elt.textContent = String(value); |
|
1548 </xsl:text> |
|
1549 <xsl:text> let [min,max,start,end] = this.range; |
|
1550 </xsl:text> |
|
1551 <xsl:text> let [cx,cy] = this.center; |
|
1552 </xsl:text> |
|
1553 <xsl:text> let [rx,ry] = this.proportions; |
|
1554 </xsl:text> |
|
1555 <xsl:text> let tip = start + (end-start)*Number(value)/(max-min); |
|
1556 </xsl:text> |
|
1557 <xsl:text> let size = 0; |
|
1558 </xsl:text> |
|
1559 <xsl:text> if (tip-start > Math.PI) { |
|
1560 </xsl:text> |
|
1561 <xsl:text> size = 1; |
|
1562 </xsl:text> |
|
1563 <xsl:text> } else { |
|
1564 </xsl:text> |
|
1565 <xsl:text> size = 0; |
|
1566 </xsl:text> |
|
1567 <xsl:text> } |
|
1568 </xsl:text> |
|
1569 <xsl:text> this.path_elt.setAttribute('d', "M "+(cx+rx*Math.cos(start))+","+(cy+ry*Math.sin(start))+" A "+rx+","+ry+" 0 "+size+" 1 "+(cx+rx*Math.cos(tip))+","+(cy+ry*Math.sin(tip))); |
|
1570 </xsl:text> |
|
1571 <xsl:text> } |
|
1572 </xsl:text> |
|
1573 <xsl:text> |
|
1574 </xsl:text> |
|
1575 <xsl:text> init() { |
|
1576 </xsl:text> |
|
1577 <xsl:text> let start = Number(this.path_elt.getAttribute('sodipodi:start')); |
|
1578 </xsl:text> |
|
1579 <xsl:text> let end = Number(this.path_elt.getAttribute('sodipodi:end')); |
|
1580 </xsl:text> |
|
1581 <xsl:text> let cx = Number(this.path_elt.getAttribute('sodipodi:cx')); |
|
1582 </xsl:text> |
|
1583 <xsl:text> let cy = Number(this.path_elt.getAttribute('sodipodi:cy')); |
|
1584 </xsl:text> |
|
1585 <xsl:text> let rx = Number(this.path_elt.getAttribute('sodipodi:rx')); |
|
1586 </xsl:text> |
|
1587 <xsl:text> let ry = Number(this.path_elt.getAttribute('sodipodi:ry')); |
|
1588 </xsl:text> |
|
1589 <xsl:text> if (ry == 0) { |
|
1590 </xsl:text> |
|
1591 <xsl:text> ry = rx; |
|
1592 </xsl:text> |
|
1593 <xsl:text> } |
|
1594 </xsl:text> |
|
1595 <xsl:text> if (start > end) { |
|
1596 </xsl:text> |
|
1597 <xsl:text> end = end + 2*Math.PI; |
|
1598 </xsl:text> |
|
1599 <xsl:text> } |
|
1600 </xsl:text> |
|
1601 <xsl:text> let min = this.min_elt ? |
|
1602 </xsl:text> |
|
1603 <xsl:text> Number(this.min_elt.textContent) : |
|
1604 </xsl:text> |
|
1605 <xsl:text> this.args.length >= 1 ? this.args[0] : 0; |
|
1606 </xsl:text> |
|
1607 <xsl:text> let max = this.max_elt ? |
|
1608 </xsl:text> |
|
1609 <xsl:text> Number(this.max_elt.textContent) : |
|
1610 </xsl:text> |
|
1611 <xsl:text> this.args.length >= 2 ? this.args[1] : 100; |
|
1612 </xsl:text> |
|
1613 <xsl:text> this.range = [min, max, start, end]; |
|
1614 </xsl:text> |
|
1615 <xsl:text> this.center = [cx, cy]; |
|
1616 </xsl:text> |
|
1617 <xsl:text> this.proportions = [rx, ry]; |
|
1618 </xsl:text> |
|
1619 <xsl:text> } |
|
1620 </xsl:text> |
|
1621 <xsl:text>} |
1518 </xsl:text> |
1622 </xsl:text> |
1519 </xsl:template> |
1623 </xsl:template> |
1520 <xsl:template mode="widget_defs" match="widget[@type='CircularBar']"> |
1624 <xsl:template mode="widget_defs" match="widget[@type='CircularBar']"> |
1521 <xsl:param name="hmi_element"/> |
1625 <xsl:param name="hmi_element"/> |
1522 <xsl:text>frequency: 10, |
|
1523 </xsl:text> |
|
1524 <xsl:call-template name="defs_by_labels"> |
1626 <xsl:call-template name="defs_by_labels"> |
1525 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
1627 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
1526 <xsl:with-param name="labels"> |
1628 <xsl:with-param name="labels"> |
1527 <xsl:text>path</xsl:text> |
1629 <xsl:text>path</xsl:text> |
1528 </xsl:with-param> |
1630 </xsl:with-param> |
1529 </xsl:call-template> |
1631 </xsl:call-template> |
1530 <xsl:call-template name="defs_by_labels"> |
1632 <xsl:call-template name="defs_by_labels"> |
1531 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
1633 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
1532 <xsl:with-param name="labels"> |
1634 <xsl:with-param name="labels"> |
1533 <xsl:text>value min max</xsl:text> |
1635 <xsl:text>value min max</xsl:text> |
1534 </xsl:with-param> |
1636 </xsl:with-param> |
1535 <xsl:with-param name="mandatory" select="'no'"/> |
1637 <xsl:with-param select="'no'" name="mandatory"/> |
1536 </xsl:call-template> |
1638 </xsl:call-template> |
1537 <xsl:text>dispatch: function(value) { |
1639 <xsl:text> |
1538 </xsl:text> |
|
1539 <xsl:text> if(this.value_elt) |
|
1540 </xsl:text> |
|
1541 <xsl:text> this.value_elt.textContent = String(value); |
|
1542 </xsl:text> |
|
1543 <xsl:text> let [min,max,start,end] = this.range; |
|
1544 </xsl:text> |
|
1545 <xsl:text> let [cx,cy] = this.center; |
|
1546 </xsl:text> |
|
1547 <xsl:text> let [rx,ry] = this.proportions; |
|
1548 </xsl:text> |
|
1549 <xsl:text> let tip = start + (end-start)*Number(value)/(max-min); |
|
1550 </xsl:text> |
|
1551 <xsl:text> let size = 0; |
|
1552 </xsl:text> |
|
1553 <xsl:text> if (tip-start > Math.PI) { |
|
1554 </xsl:text> |
|
1555 <xsl:text> size = 1; |
|
1556 </xsl:text> |
|
1557 <xsl:text> } else { |
|
1558 </xsl:text> |
|
1559 <xsl:text> size = 0; |
|
1560 </xsl:text> |
|
1561 <xsl:text> } |
|
1562 </xsl:text> |
|
1563 <xsl:text> this.path_elt.setAttribute('d', "M "+(cx+rx*Math.cos(start))+","+(cy+ry*Math.sin(start))+" A "+rx+","+ry+" 0 "+size+" 1 "+(cx+rx*Math.cos(tip))+","+(cy+ry*Math.sin(tip))); |
|
1564 </xsl:text> |
|
1565 <xsl:text>}, |
|
1566 </xsl:text> |
|
1567 <xsl:text>range: undefined, |
|
1568 </xsl:text> |
|
1569 <xsl:text>init: function() { |
|
1570 </xsl:text> |
|
1571 <xsl:text> let start = Number(this.path_elt.getAttribute('sodipodi:start')); |
|
1572 </xsl:text> |
|
1573 <xsl:text> let end = Number(this.path_elt.getAttribute('sodipodi:end')); |
|
1574 </xsl:text> |
|
1575 <xsl:text> let cx = Number(this.path_elt.getAttribute('sodipodi:cx')); |
|
1576 </xsl:text> |
|
1577 <xsl:text> let cy = Number(this.path_elt.getAttribute('sodipodi:cy')); |
|
1578 </xsl:text> |
|
1579 <xsl:text> let rx = Number(this.path_elt.getAttribute('sodipodi:rx')); |
|
1580 </xsl:text> |
|
1581 <xsl:text> let ry = Number(this.path_elt.getAttribute('sodipodi:ry')); |
|
1582 </xsl:text> |
|
1583 <xsl:text> if (ry == 0) { |
|
1584 </xsl:text> |
|
1585 <xsl:text> ry = rx; |
|
1586 </xsl:text> |
|
1587 <xsl:text> } |
|
1588 </xsl:text> |
|
1589 <xsl:text> if (start > end) { |
|
1590 </xsl:text> |
|
1591 <xsl:text> end = end + 2*Math.PI; |
|
1592 </xsl:text> |
|
1593 <xsl:text> } |
|
1594 </xsl:text> |
|
1595 <xsl:text> let min = this.min_elt ? |
|
1596 </xsl:text> |
|
1597 <xsl:text> Number(this.min_elt.textContent) : |
|
1598 </xsl:text> |
|
1599 <xsl:text> this.args.length >= 1 ? this.args[0] : 0; |
|
1600 </xsl:text> |
|
1601 <xsl:text> let max = this.max_elt ? |
|
1602 </xsl:text> |
|
1603 <xsl:text> Number(this.max_elt.textContent) : |
|
1604 </xsl:text> |
|
1605 <xsl:text> this.args.length >= 2 ? this.args[1] : 100; |
|
1606 </xsl:text> |
|
1607 <xsl:text> this.range = [min, max, start, end]; |
|
1608 </xsl:text> |
|
1609 <xsl:text> this.center = [cx, cy]; |
|
1610 </xsl:text> |
|
1611 <xsl:text> this.proportions = [rx, ry]; |
|
1612 </xsl:text> |
|
1613 <xsl:text>}, |
|
1614 </xsl:text> |
1640 </xsl:text> |
1615 </xsl:template> |
1641 </xsl:template> |
1616 <xsl:template mode="widget_class" match="widget[@type='CircularSlider']"> |
1642 <xsl:template mode="widget_class" match="widget[@type='CircularSlider']"> |
1617 <xsl:text>class CircularSliderWidget extends Widget{ |
1643 <xsl:text>class CircularSliderWidget extends Widget{ |
1618 </xsl:text> |
1644 </xsl:text> |
1622 </xsl:text> |
1648 </xsl:text> |
1623 <xsl:text> circle = undefined; |
1649 <xsl:text> circle = undefined; |
1624 </xsl:text> |
1650 </xsl:text> |
1625 <xsl:text> handle_pos = undefined; |
1651 <xsl:text> handle_pos = undefined; |
1626 </xsl:text> |
1652 </xsl:text> |
|
1653 <xsl:text> svg_dist = undefined; |
|
1654 </xsl:text> |
1627 <xsl:text> drag = false; |
1655 <xsl:text> drag = false; |
1628 </xsl:text> |
1656 </xsl:text> |
1629 <xsl:text> enTimer = false; |
1657 <xsl:text> enTimer = false; |
1630 </xsl:text> |
1658 </xsl:text> |
|
1659 <xsl:text> last_drag = false; |
|
1660 </xsl:text> |
1631 <xsl:text> |
1661 <xsl:text> |
1632 </xsl:text> |
1662 </xsl:text> |
1633 <xsl:text> dispatch(value) { |
1663 <xsl:text> dispatch(value) { |
1634 </xsl:text> |
1664 </xsl:text> |
1635 <xsl:text> if(!this.drag){ |
1665 <xsl:text> if(this.value_elt) |
1636 </xsl:text> |
1666 </xsl:text> |
1637 <xsl:text> if(this.value_elt) |
1667 <xsl:text> this.value_elt.textContent = String(value); |
1638 </xsl:text> |
1668 </xsl:text> |
1639 <xsl:text> this.value_elt.textContent = String(value); |
1669 <xsl:text> |
1640 </xsl:text> |
1670 </xsl:text> |
1641 <xsl:text> |
1671 <xsl:text> this.update_DOM(value, this.handle_elt); |
1642 </xsl:text> |
1672 </xsl:text> |
1643 <xsl:text> this.handle_position(value); |
1673 <xsl:text> } |
|
1674 </xsl:text> |
|
1675 <xsl:text> |
|
1676 </xsl:text> |
|
1677 <xsl:text> update_DOM(value, elt){ |
|
1678 </xsl:text> |
|
1679 <xsl:text> let [min,max,totalDistance] = this.range; |
|
1680 </xsl:text> |
|
1681 <xsl:text> let length = Math.max(0,Math.min((totalDistance),(Number(value)-min)/(max-min)*(totalDistance))); |
|
1682 </xsl:text> |
|
1683 <xsl:text> let tip = this.range_elt.getPointAtLength(length); |
|
1684 </xsl:text> |
|
1685 <xsl:text> elt.setAttribute('transform',"translate("+(tip.x-this.handle_pos.x)+","+(tip.y-this.handle_pos.y)+")"); |
|
1686 </xsl:text> |
|
1687 <xsl:text> |
|
1688 </xsl:text> |
|
1689 <xsl:text> if(this.setpoint_elt != undefined){ |
|
1690 </xsl:text> |
|
1691 <xsl:text> if(this.last_drag!= this.drag){ |
|
1692 </xsl:text> |
|
1693 <xsl:text> if(this.drag){ |
|
1694 </xsl:text> |
|
1695 <xsl:text> this.setpoint_elt.setAttribute("style", this.setpoint_style); |
|
1696 </xsl:text> |
|
1697 <xsl:text> }else{ |
|
1698 </xsl:text> |
|
1699 <xsl:text> this.setpoint_elt.setAttribute("style", "display:none"); |
|
1700 </xsl:text> |
|
1701 <xsl:text> } |
|
1702 </xsl:text> |
|
1703 <xsl:text> this.last_drag = this.drag; |
|
1704 </xsl:text> |
|
1705 <xsl:text> } |
1644 </xsl:text> |
1706 </xsl:text> |
1645 <xsl:text> } |
1707 <xsl:text> } |
1646 </xsl:text> |
1708 </xsl:text> |
1647 <xsl:text> } |
1709 <xsl:text> } |
1648 </xsl:text> |
1710 </xsl:text> |
1649 <xsl:text> |
1711 <xsl:text> |
1650 </xsl:text> |
1712 </xsl:text> |
1651 <xsl:text> handle_position(value){ |
|
1652 </xsl:text> |
|
1653 <xsl:text> let [min,max,totalDistance] = this.range; |
|
1654 </xsl:text> |
|
1655 <xsl:text> let length = Math.max(0,Math.min((totalDistance),(Number(value)-min)/(max-min)*(totalDistance))); |
|
1656 </xsl:text> |
|
1657 <xsl:text> let tip = this.range_elt.getPointAtLength(length); |
|
1658 </xsl:text> |
|
1659 <xsl:text> this.handle_elt.setAttribute('transform',"translate("+(tip.x-this.handle_pos.x)+","+(tip.y-this.handle_pos.y)+")"); |
|
1660 </xsl:text> |
|
1661 <xsl:text> } |
|
1662 </xsl:text> |
|
1663 <xsl:text> |
|
1664 </xsl:text> |
|
1665 <xsl:text> on_release(evt) { |
1713 <xsl:text> on_release(evt) { |
1666 </xsl:text> |
1714 </xsl:text> |
|
1715 <xsl:text> window.removeEventListener("touchmove", this.on_bound_drag, true); |
|
1716 </xsl:text> |
|
1717 <xsl:text> window.removeEventListener("mousemove", this.on_bound_drag, true); |
|
1718 </xsl:text> |
|
1719 <xsl:text> |
|
1720 </xsl:text> |
|
1721 <xsl:text> window.removeEventListener("mouseup", this.bound_on_release, true) |
|
1722 </xsl:text> |
|
1723 <xsl:text> window.removeEventListener("touchend", this.bound_on_release, true); |
|
1724 </xsl:text> |
|
1725 <xsl:text> window.removeEventListener("touchcancel", this.bound_on_release, true); |
|
1726 </xsl:text> |
1667 <xsl:text> if(this.drag){ |
1727 <xsl:text> if(this.drag){ |
1668 </xsl:text> |
1728 </xsl:text> |
1669 <xsl:text> this.drag = false; |
1729 <xsl:text> this.drag = false; |
1670 </xsl:text> |
1730 </xsl:text> |
1671 <xsl:text> } |
1731 <xsl:text> } |
1672 </xsl:text> |
1732 </xsl:text> |
|
1733 <xsl:text> this.update_position(evt); |
|
1734 </xsl:text> |
|
1735 <xsl:text> } |
|
1736 </xsl:text> |
|
1737 <xsl:text> |
|
1738 </xsl:text> |
|
1739 <xsl:text> on_drag(evt){ |
|
1740 </xsl:text> |
|
1741 <xsl:text> if(this.enTimer && this.drag){ |
|
1742 </xsl:text> |
|
1743 <xsl:text> this.update_position(evt); |
|
1744 </xsl:text> |
|
1745 <xsl:text> //reset timer |
|
1746 </xsl:text> |
|
1747 <xsl:text> this.enTimer = false; |
|
1748 </xsl:text> |
|
1749 <xsl:text> setTimeout("{hmi_widgets['"+this.element_id+"'].enTimer = true;}", 100); |
|
1750 </xsl:text> |
|
1751 <xsl:text> } |
|
1752 </xsl:text> |
1673 <xsl:text> } |
1753 <xsl:text> } |
1674 </xsl:text> |
1754 </xsl:text> |
1675 <xsl:text> |
1755 <xsl:text> |
1676 </xsl:text> |
1756 </xsl:text> |
1677 <xsl:text> update_position(evt){ |
1757 <xsl:text> update_position(evt){ |
1760 </xsl:text> |
1840 </xsl:text> |
1761 <xsl:text> //get handle distance from mouse position |
1841 <xsl:text> //get handle distance from mouse position |
1762 </xsl:text> |
1842 </xsl:text> |
1763 <xsl:text> if(fi<fiEnd){ |
1843 <xsl:text> if(fi<fiEnd){ |
1764 </xsl:text> |
1844 </xsl:text> |
1765 <xsl:text> svg_dist=(fi)/(fiEnd)*(this.range[1]-this.range[0]); |
1845 <xsl:text> this.svg_dist=(fi)/(fiEnd)*(this.range[1]-this.range[0]); |
1766 </xsl:text> |
1846 </xsl:text> |
1767 <xsl:text> } |
1847 <xsl:text> } |
1768 </xsl:text> |
1848 </xsl:text> |
1769 <xsl:text> else if(fiEnd<fi && fi<fiEnd+minMax){ |
1849 <xsl:text> else if(fiEnd<fi && fi<fiEnd+minMax){ |
1770 </xsl:text> |
1850 </xsl:text> |
1771 <xsl:text> svg_dist = this.range[1]; |
1851 <xsl:text> this.svg_dist = this.range[1]; |
1772 </xsl:text> |
1852 </xsl:text> |
1773 <xsl:text> } |
1853 <xsl:text> } |
1774 </xsl:text> |
1854 </xsl:text> |
1775 <xsl:text> else{ |
1855 <xsl:text> else{ |
1776 </xsl:text> |
1856 </xsl:text> |
1777 <xsl:text> svg_dist = this.range[0]; |
1857 <xsl:text> this.svg_dist = this.range[0]; |
1778 </xsl:text> |
1858 </xsl:text> |
1779 <xsl:text> } |
1859 <xsl:text> } |
1780 </xsl:text> |
1860 </xsl:text> |
1781 <xsl:text> |
1861 <xsl:text> |
1782 </xsl:text> |
1862 </xsl:text> |
1783 <xsl:text> //redraw handle --TODO is it fast enough if I just call change_hmi_value??? |
1863 <xsl:text> |
1784 </xsl:text> |
1864 </xsl:text> |
1785 <xsl:text> this.handle_position(svg_dist); |
1865 <xsl:text> this.apply_hmi_value(0, Math.ceil(this.svg_dist)); |
1786 </xsl:text> |
1866 </xsl:text> |
1787 <xsl:text> if(this.value_elt) |
1867 <xsl:text> |
1788 </xsl:text> |
1868 </xsl:text> |
1789 <xsl:text> this.value_elt.textContent = String(Math.ceil(svg_dist)); |
1869 <xsl:text> // update ghost cursor |
1790 </xsl:text> |
1870 </xsl:text> |
1791 <xsl:text> this.apply_hmi_value(0, Math.ceil(svg_dist)); |
1871 <xsl:text> if(this.setpoint_elt != undefined){ |
1792 </xsl:text> |
1872 </xsl:text> |
1793 <xsl:text> |
1873 <xsl:text> this.request_animate(); |
1794 </xsl:text> |
1874 </xsl:text> |
1795 <xsl:text> //reset timer |
1875 <xsl:text> } |
1796 </xsl:text> |
|
1797 <xsl:text> this.enTimer = false; |
|
1798 </xsl:text> |
|
1799 <xsl:text> setTimeout("{hmi_widgets['"+this.element_id+"'].enTimer = true;}", 100); |
|
1800 </xsl:text> |
1876 </xsl:text> |
1801 <xsl:text> } |
1877 <xsl:text> } |
1802 </xsl:text> |
1878 </xsl:text> |
1803 <xsl:text> |
1879 <xsl:text> |
1804 </xsl:text> |
1880 </xsl:text> |
1805 <xsl:text> } |
1881 <xsl:text> } |
1806 </xsl:text> |
1882 </xsl:text> |
1807 <xsl:text> |
1883 <xsl:text> |
1808 </xsl:text> |
1884 </xsl:text> |
|
1885 <xsl:text> animate(){ |
|
1886 </xsl:text> |
|
1887 <xsl:text> this.update_DOM(this.svg_dist, this.setpoint_elt); |
|
1888 </xsl:text> |
|
1889 <xsl:text> } |
|
1890 </xsl:text> |
|
1891 <xsl:text> |
|
1892 </xsl:text> |
1809 <xsl:text> on_select(evt){ |
1893 <xsl:text> on_select(evt){ |
1810 </xsl:text> |
1894 </xsl:text> |
1811 <xsl:text> this.drag = true; |
1895 <xsl:text> this.drag = true; |
1812 </xsl:text> |
1896 </xsl:text> |
1813 <xsl:text> this.enTimer = true; |
1897 <xsl:text> this.enTimer = true; |
1814 </xsl:text> |
1898 </xsl:text> |
|
1899 <xsl:text> window.addEventListener("touchmove", this.on_bound_drag, true); |
|
1900 </xsl:text> |
|
1901 <xsl:text> window.addEventListener("mousemove", this.on_bound_drag, true); |
|
1902 </xsl:text> |
|
1903 <xsl:text> |
|
1904 </xsl:text> |
|
1905 <xsl:text> window.addEventListener("mouseup", this.bound_on_release, true) |
|
1906 </xsl:text> |
|
1907 <xsl:text> window.addEventListener("touchend", this.bound_on_release, true); |
|
1908 </xsl:text> |
|
1909 <xsl:text> window.addEventListener("touchcancel", this.bound_on_release, true); |
|
1910 </xsl:text> |
1815 <xsl:text> this.update_position(evt); |
1911 <xsl:text> this.update_position(evt); |
1816 </xsl:text> |
1912 </xsl:text> |
1817 <xsl:text> } |
1913 <xsl:text> } |
1818 </xsl:text> |
1914 </xsl:text> |
1819 <xsl:text> |
1915 <xsl:text> |
1878 </xsl:text> |
1974 </xsl:text> |
1879 <xsl:text> this.circle = [cX, cY,fiStart,fiEnd,minMax,cPos.x,cPos.y,cPos.width,cPos.height]; |
1975 <xsl:text> this.circle = [cX, cY,fiStart,fiEnd,minMax,cPos.x,cPos.y,cPos.width,cPos.height]; |
1880 </xsl:text> |
1976 </xsl:text> |
1881 <xsl:text> |
1977 <xsl:text> |
1882 </xsl:text> |
1978 </xsl:text> |
|
1979 <xsl:text> //bind functions |
|
1980 </xsl:text> |
|
1981 <xsl:text> this.bound_on_select = this.on_select.bind(this); |
|
1982 </xsl:text> |
|
1983 <xsl:text> this.bound_on_release = this.on_release.bind(this); |
|
1984 </xsl:text> |
|
1985 <xsl:text> this.on_bound_drag = this.on_drag.bind(this); |
|
1986 </xsl:text> |
|
1987 <xsl:text> |
|
1988 </xsl:text> |
1883 <xsl:text> //init events |
1989 <xsl:text> //init events |
1884 </xsl:text> |
1990 </xsl:text> |
1885 <xsl:text> this.handle_elt.addEventListener("touchstart", hmi_widgets[this.element_id].on_select.bind(this)); |
1991 <xsl:text> this.element.addEventListener("mousedown", this.bound_on_select); |
1886 </xsl:text> |
1992 </xsl:text> |
1887 <xsl:text> this.handle_elt.addEventListener("mousedown", hmi_widgets[this.element_id].on_select.bind(this)); |
1993 <xsl:text> this.element.addEventListener("touchstart", this.bound_on_select); |
1888 </xsl:text> |
1994 </xsl:text> |
1889 <xsl:text> this.element.addEventListener("mousedown", hmi_widgets[this.element_id].on_select.bind(this)); |
1995 <xsl:text> |
|
1996 </xsl:text> |
|
1997 <xsl:text> if(this.setpoint_elt != undefined){ |
|
1998 </xsl:text> |
|
1999 <xsl:text> this.setpoint_style = this.setpoint_elt.getAttribute("style"); |
|
2000 </xsl:text> |
|
2001 <xsl:text> this.setpoint_elt.setAttribute("style", "display:none"); |
|
2002 </xsl:text> |
|
2003 <xsl:text> } |
|
2004 </xsl:text> |
|
2005 <xsl:text> |
1890 </xsl:text> |
2006 </xsl:text> |
1891 <xsl:text> |
2007 <xsl:text> |
1892 </xsl:text> |
2008 </xsl:text> |
1893 <xsl:text> window.addEventListener("touchmove", hmi_widgets[this.element_id].update_position.bind(this)); |
2009 <xsl:text> window.addEventListener("touchmove", hmi_widgets[this.element_id].update_position.bind(this)); |
1894 </xsl:text> |
2010 </xsl:text> |
1910 </xsl:text> |
2026 </xsl:text> |
1911 </xsl:template> |
2027 </xsl:template> |
1912 <xsl:template mode="widget_defs" match="widget[@type='CircularSlider']"> |
2028 <xsl:template mode="widget_defs" match="widget[@type='CircularSlider']"> |
1913 <xsl:param name="hmi_element"/> |
2029 <xsl:param name="hmi_element"/> |
1914 <xsl:call-template name="defs_by_labels"> |
2030 <xsl:call-template name="defs_by_labels"> |
1915 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
2031 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
1916 <xsl:with-param name="labels"> |
2032 <xsl:with-param name="labels"> |
1917 <xsl:text>handle range</xsl:text> |
2033 <xsl:text>handle range</xsl:text> |
1918 </xsl:with-param> |
2034 </xsl:with-param> |
1919 </xsl:call-template> |
2035 </xsl:call-template> |
1920 <xsl:call-template name="defs_by_labels"> |
2036 <xsl:call-template name="defs_by_labels"> |
1921 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
2037 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
1922 <xsl:with-param name="labels"> |
2038 <xsl:with-param name="labels"> |
1923 <xsl:text>value min max</xsl:text> |
2039 <xsl:text>value min max</xsl:text> |
1924 </xsl:with-param> |
2040 </xsl:with-param> |
1925 <xsl:with-param name="mandatory" select="'no'"/> |
2041 <xsl:with-param select="'no'" name="mandatory"/> |
1926 </xsl:call-template> |
2042 </xsl:call-template> |
1927 <xsl:text> |
2043 <xsl:text> |
1928 </xsl:text> |
2044 </xsl:text> |
1929 </xsl:template> |
2045 </xsl:template> |
1930 <xsl:template mode="widget_class" match="widget[@type='Display']"> |
2046 <xsl:template mode="widget_class" match="widget[@type='Display']"> |
2978 <xsl:text>ForEach widget </xsl:text> |
3094 <xsl:text>ForEach widget </xsl:text> |
2979 <xsl:value-of select="$hmi_element/@id"/> |
3095 <xsl:value-of select="$hmi_element/@id"/> |
2980 <xsl:text> must have one argument given : a class name.</xsl:text> |
3096 <xsl:text> must have one argument given : a class name.</xsl:text> |
2981 </xsl:message> |
3097 </xsl:message> |
2982 </xsl:if> |
3098 </xsl:if> |
2983 <xsl:variable name="class" select="arg[1]/@value"/> |
3099 <xsl:variable select="arg[1]/@value" name="class"/> |
2984 <xsl:variable name="base_path" select="path/@value"/> |
3100 <xsl:variable select="path/@value" name="base_path"/> |
2985 <xsl:variable name="hmi_index_base" select="$indexed_hmitree/*[@hmipath = $base_path]"/> |
3101 <xsl:variable select="$indexed_hmitree/*[@hmipath = $base_path]" name="hmi_index_base"/> |
2986 <xsl:variable name="hmi_tree_base" select="$hmitree/descendant-or-self::*[@path = $hmi_index_base/@path]"/> |
3102 <xsl:variable select="$hmitree/descendant-or-self::*[@path = $hmi_index_base/@path]" name="hmi_tree_base"/> |
2987 <xsl:variable name="hmi_tree_items" select="$hmi_tree_base/*[@class = $class]"/> |
3103 <xsl:variable select="$hmi_tree_base/*[@class = $class]" name="hmi_tree_items"/> |
2988 <xsl:variable name="hmi_index_items" select="$indexed_hmitree/*[@path = $hmi_tree_items/@path]"/> |
3104 <xsl:variable select="$indexed_hmitree/*[@path = $hmi_tree_items/@path]" name="hmi_index_items"/> |
2989 <xsl:variable name="items_paths" select="$hmi_index_items/@hmipath"/> |
3105 <xsl:variable select="$hmi_index_items/@hmipath" name="items_paths"/> |
2990 <xsl:text> index_pool: [ |
3106 <xsl:text> index_pool: [ |
2991 </xsl:text> |
3107 </xsl:text> |
2992 <xsl:for-each select="$hmi_index_items"> |
3108 <xsl:for-each select="$hmi_index_items"> |
2993 <xsl:text> </xsl:text> |
3109 <xsl:text> </xsl:text> |
2994 <xsl:value-of select="@index"/> |
3110 <xsl:value-of select="@index"/> |
3000 </xsl:for-each> |
3116 </xsl:for-each> |
3001 <xsl:text> ], |
3117 <xsl:text> ], |
3002 </xsl:text> |
3118 </xsl:text> |
3003 <xsl:text> init: function() { |
3119 <xsl:text> init: function() { |
3004 </xsl:text> |
3120 </xsl:text> |
3005 <xsl:variable name="prefix" select="concat($class,':')"/> |
3121 <xsl:variable select="concat($class,':')" name="prefix"/> |
3006 <xsl:variable name="buttons_regex" select="concat('^',$prefix,'[+\-][0-9]+')"/> |
3122 <xsl:variable select="concat('^',$prefix,'[+\-][0-9]+')" name="buttons_regex"/> |
3007 <xsl:variable name="buttons" select="$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]"/> |
3123 <xsl:variable select="$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]" name="buttons"/> |
3008 <xsl:for-each select="$buttons"> |
3124 <xsl:for-each select="$buttons"> |
3009 <xsl:variable name="op" select="substring-after(@inkscape:label, $prefix)"/> |
3125 <xsl:variable select="substring-after(@inkscape:label, $prefix)" name="op"/> |
3010 <xsl:text> id("</xsl:text> |
3126 <xsl:text> id("</xsl:text> |
3011 <xsl:value-of select="@id"/> |
3127 <xsl:value-of select="@id"/> |
3012 <xsl:text>").setAttribute("onclick", "hmi_widgets['</xsl:text> |
3128 <xsl:text>").setAttribute("onclick", "hmi_widgets['</xsl:text> |
3013 <xsl:value-of select="$hmi_element/@id"/> |
3129 <xsl:value-of select="$hmi_element/@id"/> |
3014 <xsl:text>'].on_click('</xsl:text> |
3130 <xsl:text>'].on_click('</xsl:text> |
3018 </xsl:for-each> |
3134 </xsl:for-each> |
3019 <xsl:text> |
3135 <xsl:text> |
3020 </xsl:text> |
3136 </xsl:text> |
3021 <xsl:text> this.items = [ |
3137 <xsl:text> this.items = [ |
3022 </xsl:text> |
3138 </xsl:text> |
3023 <xsl:variable name="items_regex" select="concat('^',$prefix,'[0-9]+')"/> |
3139 <xsl:variable select="concat('^',$prefix,'[0-9]+')" name="items_regex"/> |
3024 <xsl:variable name="unordered_items" select="$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]"/> |
3140 <xsl:variable select="$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]" name="unordered_items"/> |
3025 <xsl:for-each select="$unordered_items"> |
3141 <xsl:for-each select="$unordered_items"> |
3026 <xsl:variable name="elt_label" select="concat($prefix, string(position()))"/> |
3142 <xsl:variable select="concat($prefix, string(position()))" name="elt_label"/> |
3027 <xsl:variable name="elt" select="$unordered_items[@inkscape:label = $elt_label]"/> |
3143 <xsl:variable select="$unordered_items[@inkscape:label = $elt_label]" name="elt"/> |
3028 <xsl:variable name="pos" select="position()"/> |
3144 <xsl:variable select="position()" name="pos"/> |
3029 <xsl:variable name="item_path" select="$items_paths[$pos]"/> |
3145 <xsl:variable select="$items_paths[$pos]" name="item_path"/> |
3030 <xsl:text> [ /* item="</xsl:text> |
3146 <xsl:text> [ /* item="</xsl:text> |
3031 <xsl:value-of select="$elt_label"/> |
3147 <xsl:value-of select="$elt_label"/> |
3032 <xsl:text>" path="</xsl:text> |
3148 <xsl:text>" path="</xsl:text> |
3033 <xsl:value-of select="$item_path"/> |
3149 <xsl:value-of select="$item_path"/> |
3034 <xsl:text>" */ |
3150 <xsl:text>" */ |
3215 </xsl:text> |
3331 </xsl:text> |
3216 </xsl:template> |
3332 </xsl:template> |
3217 <xsl:template mode="widget_defs" match="widget[@type='Input']"> |
3333 <xsl:template mode="widget_defs" match="widget[@type='Input']"> |
3218 <xsl:param name="hmi_element"/> |
3334 <xsl:param name="hmi_element"/> |
3219 <xsl:call-template name="defs_by_labels"> |
3335 <xsl:call-template name="defs_by_labels"> |
3220 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
3336 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
3221 <xsl:with-param name="labels"> |
3337 <xsl:with-param name="labels"> |
3222 <xsl:text>key_pos</xsl:text> |
3338 <xsl:text>key_pos</xsl:text> |
3223 </xsl:with-param> |
3339 </xsl:with-param> |
3224 <xsl:with-param name="mandatory" select="'no'"/> |
3340 <xsl:with-param select="'no'" name="mandatory"/> |
3225 </xsl:call-template> |
3341 </xsl:call-template> |
3226 <xsl:variable name="value_elt"> |
3342 <xsl:variable name="value_elt"> |
3227 <xsl:call-template name="defs_by_labels"> |
3343 <xsl:call-template name="defs_by_labels"> |
3228 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
3344 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
3229 <xsl:with-param name="labels"> |
3345 <xsl:with-param name="labels"> |
3230 <xsl:text>value</xsl:text> |
3346 <xsl:text>value</xsl:text> |
3231 </xsl:with-param> |
3347 </xsl:with-param> |
3232 <xsl:with-param name="mandatory" select="'no'"/> |
3348 <xsl:with-param select="'no'" name="mandatory"/> |
3233 </xsl:call-template> |
3349 </xsl:call-template> |
3234 </xsl:variable> |
3350 </xsl:variable> |
3235 <xsl:variable name="have_value" select="string-length($value_elt)>0"/> |
3351 <xsl:variable select="string-length($value_elt)>0" name="have_value"/> |
3236 <xsl:value-of select="$value_elt"/> |
3352 <xsl:value-of select="$value_elt"/> |
3237 <xsl:if test="$have_value"> |
3353 <xsl:if test="$have_value"> |
3238 <xsl:text> frequency: 5, |
3354 <xsl:text> frequency: 5, |
3239 </xsl:text> |
3355 </xsl:text> |
3240 </xsl:if> |
3356 </xsl:if> |
3363 <xsl:text>JsonTable Widget can't contain element of type </xsl:text> |
3479 <xsl:text>JsonTable Widget can't contain element of type </xsl:text> |
3364 <xsl:value-of select="local-name()"/> |
3480 <xsl:value-of select="local-name()"/> |
3365 <xsl:text>.</xsl:text> |
3481 <xsl:text>.</xsl:text> |
3366 </xsl:message> |
3482 </xsl:message> |
3367 </xsl:template> |
3483 </xsl:template> |
|
3484 <xsl:variable select="$parsed_widgets/widget[@type = 'TextStyleList']" name="hmi_textstylelists_descs"/> |
|
3485 <xsl:variable select="$hmi_elements[@id = $hmi_textstylelists_descs/@id]" name="hmi_textstylelists"/> |
3368 <xsl:template mode="json_table_elt_render" match="svg:use"> |
3486 <xsl:template mode="json_table_elt_render" match="svg:use"> |
3369 <xsl:param name="value_expr"/> |
3487 <xsl:param name="value_expr"/> |
3370 <xsl:variable name="targetid" select="substring-after(@xlink:href,'#')"/> |
3488 <xsl:variable select="substring-after(@xlink:href,'#')" name="targetid"/> |
3371 <xsl:variable name="from_list" select="$hmi_lists[(@id | */@id) = $targetid]"/> |
3489 <xsl:variable select="$hmi_lists[(@id | */@id) = $targetid]" name="from_list"/> |
3372 <xsl:if test="count($from_list) = 0"> |
3490 <xsl:variable select="$hmi_textstylelists[(@id | */@id) = $targetid]" name="from_textstylelist"/> |
3373 <xsl:message terminate="yes"> |
3491 <xsl:choose> |
3374 <xsl:text>Clones (svg:use) in JsonTable Widget must point to a valid HMI:List widget or HMI:List item. Reference "</xsl:text> |
3492 <xsl:when test="count($from_list) > 0"> |
3375 <xsl:value-of select="@xlink:href"/> |
3493 <xsl:text> id("</xsl:text> |
3376 <xsl:text>" is not valid.</xsl:text> |
3494 <xsl:value-of select="@id"/> |
3377 </xsl:message> |
3495 <xsl:text>").setAttribute("xlink:href", |
3378 </xsl:if> |
3496 </xsl:text> |
3379 <xsl:text> id("</xsl:text> |
3497 <xsl:text> "#"+hmi_widgets["</xsl:text> |
3380 <xsl:value-of select="@id"/> |
3498 <xsl:value-of select="$from_list/@id"/> |
3381 <xsl:text>").setAttribute("xlink:href", |
3499 <xsl:text>"].items[</xsl:text> |
3382 </xsl:text> |
3500 <xsl:value-of select="$value_expr"/> |
3383 <xsl:text> "#"+hmi_widgets["</xsl:text> |
3501 <xsl:text>]); |
3384 <xsl:value-of select="$from_list/@id"/> |
3502 </xsl:text> |
3385 <xsl:text>"].items[</xsl:text> |
3503 </xsl:when> |
3386 <xsl:value-of select="$value_expr"/> |
3504 <xsl:when test="count($from_textstylelist) > 0"> |
3387 <xsl:text>]); |
3505 <xsl:text> console.log("from_textsylelist","</xsl:text> |
3388 </xsl:text> |
3506 <xsl:value-of select="@id"/> |
|
3507 <xsl:text>", "</xsl:text> |
|
3508 <xsl:value-of select="$value_expr"/> |
|
3509 <xsl:text>", </xsl:text> |
|
3510 <xsl:value-of select="$value_expr"/> |
|
3511 <xsl:text>, |
|
3512 </xsl:text> |
|
3513 <xsl:text> hmi_widgets["</xsl:text> |
|
3514 <xsl:value-of select="$from_textstylelist/@id"/> |
|
3515 <xsl:text>"].items[</xsl:text> |
|
3516 <xsl:value-of select="$value_expr"/> |
|
3517 <xsl:text>]); |
|
3518 </xsl:text> |
|
3519 </xsl:when> |
|
3520 <xsl:otherwise> |
|
3521 <xsl:message terminate="no"> |
|
3522 <xsl:text>Clones (svg:use) in JsonTable Widget must point to a valid HMI:List or HMI:TextStyleList widget or item. Reference "</xsl:text> |
|
3523 <xsl:value-of select="@xlink:href"/> |
|
3524 <xsl:text>" is not valid and will not be updated.</xsl:text> |
|
3525 </xsl:message> |
|
3526 </xsl:otherwise> |
|
3527 </xsl:choose> |
3389 </xsl:template> |
3528 </xsl:template> |
3390 <xsl:template mode="json_table_elt_render" match="svg:text"> |
3529 <xsl:template mode="json_table_elt_render" match="svg:text"> |
3391 <xsl:param name="value_expr"/> |
3530 <xsl:param name="value_expr"/> |
3392 <xsl:text> id("</xsl:text> |
3531 <xsl:text> id("</xsl:text> |
3393 <xsl:value-of select="@id"/> |
3532 <xsl:value-of select="@id"/> |
3399 <xsl:template mode="json_table_render" match="svg:*"> |
3538 <xsl:template mode="json_table_render" match="svg:*"> |
3400 <xsl:param name="objname"/> |
3539 <xsl:param name="objname"/> |
3401 <xsl:apply-templates mode="json_table_elt_render" select="."> |
3540 <xsl:apply-templates mode="json_table_elt_render" select="."> |
3402 <xsl:with-param name="value_expr"> |
3541 <xsl:with-param name="value_expr"> |
3403 <xsl:value-of select="$objname"/> |
3542 <xsl:value-of select="$objname"/> |
3404 <xsl:value-of select="@inkscape:label"/> |
3543 <xsl:value-of select="substring-before(@inkscape:label, ' ')"/> |
3405 </xsl:with-param> |
3544 </xsl:with-param> |
3406 </xsl:apply-templates> |
3545 </xsl:apply-templates> |
3407 </xsl:template> |
3546 </xsl:template> |
3408 <xsl:template mode="json_table_render" match="svg:g"> |
3547 <xsl:template mode="json_table_render" match="svg:g"> |
3409 <xsl:param name="objname"/> |
3548 <xsl:param name="objname"/> |
3410 <xsl:text> let obj_</xsl:text> |
3549 <xsl:text> let obj_</xsl:text> |
3411 <xsl:value-of select="@id"/> |
3550 <xsl:value-of select="@id"/> |
3412 <xsl:text> = </xsl:text> |
3551 <xsl:text> = </xsl:text> |
3413 <xsl:value-of select="$objname"/> |
3552 <xsl:value-of select="$objname"/> |
3414 <xsl:value-of select="@inkscape:label"/> |
3553 <xsl:value-of select="substring-before(@inkscape:label, ' ')"/> |
3415 <xsl:text>; |
3554 <xsl:text>; |
3416 </xsl:text> |
3555 </xsl:text> |
3417 <xsl:apply-templates mode="json_table_render" select="*[@inkscape:label]"> |
3556 <xsl:apply-templates mode="json_table_render" select="*[@inkscape:label]"> |
3418 <xsl:with-param name="objname"> |
3557 <xsl:with-param name="objname"> |
3419 <xsl:text>obj_</xsl:text> |
3558 <xsl:text>obj_</xsl:text> |
3422 </xsl:apply-templates> |
3561 </xsl:apply-templates> |
3423 </xsl:template> |
3562 </xsl:template> |
3424 <xsl:template mode="widget_defs" match="widget[@type='JsonTable']"> |
3563 <xsl:template mode="widget_defs" match="widget[@type='JsonTable']"> |
3425 <xsl:param name="hmi_element"/> |
3564 <xsl:param name="hmi_element"/> |
3426 <xsl:call-template name="defs_by_labels"> |
3565 <xsl:call-template name="defs_by_labels"> |
3427 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
3566 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
3428 <xsl:with-param name="labels"> |
3567 <xsl:with-param name="labels"> |
3429 <xsl:text>data</xsl:text> |
3568 <xsl:text>data</xsl:text> |
3430 </xsl:with-param> |
3569 </xsl:with-param> |
3431 </xsl:call-template> |
3570 </xsl:call-template> |
3432 <xsl:call-template name="defs_by_labels"> |
3571 <xsl:call-template name="defs_by_labels"> |
3433 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
3572 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
3434 <xsl:with-param name="labels"> |
3573 <xsl:with-param name="labels"> |
3435 <xsl:text>forward backward cursor</xsl:text> |
3574 <xsl:text>forward backward cursor</xsl:text> |
3436 </xsl:with-param> |
3575 </xsl:with-param> |
3437 <xsl:with-param name="mandatory" select="'no'"/> |
3576 <xsl:with-param select="'no'" name="mandatory"/> |
3438 </xsl:call-template> |
3577 </xsl:call-template> |
3439 <xsl:variable name="data_elt" select="$result_svg_ns//*[@id = $hmi_element/@id]/*[@inkscape:label = 'data']"/> |
3578 <xsl:variable select="$result_svg_ns//*[@id = $hmi_element/@id]/*[@inkscape:label = 'data']" name="data_elt"/> |
3440 <xsl:text> spread_json_data: function(jdata) { |
3579 <xsl:text> spread_json_data: function(jdata) { |
3441 </xsl:text> |
3580 </xsl:text> |
3442 <xsl:apply-templates mode="json_table_render" select="$data_elt/*"> |
3581 <xsl:apply-templates mode="json_table_render" select="$data_elt/*"> |
3443 <xsl:with-param name="objname" select="'jdata'"/> |
3582 <xsl:with-param select="'jdata'" name="objname"/> |
3444 </xsl:apply-templates> |
3583 </xsl:apply-templates> |
3445 <xsl:text> } |
3584 <xsl:text> } |
3446 </xsl:text> |
3585 </xsl:text> |
3447 </xsl:template> |
3586 </xsl:template> |
3448 <xsl:template name="jump_widget_activity"> |
3587 <xsl:template name="jump_widget_activity"> |
3449 <xsl:param name="hmi_element"/> |
3588 <xsl:param name="hmi_element"/> |
3450 <xsl:call-template name="defs_by_labels"> |
3589 <xsl:call-template name="defs_by_labels"> |
3451 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
3590 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
3452 <xsl:with-param name="labels"> |
3591 <xsl:with-param name="labels"> |
3453 <xsl:text>active inactive</xsl:text> |
3592 <xsl:text>active inactive</xsl:text> |
3454 </xsl:with-param> |
3593 </xsl:with-param> |
3455 <xsl:with-param name="mandatory" select="'no'"/> |
3594 <xsl:with-param select="'no'" name="mandatory"/> |
3456 </xsl:call-template> |
3595 </xsl:call-template> |
3457 </xsl:template> |
3596 </xsl:template> |
3458 <xsl:template name="jump_widget_disability"> |
3597 <xsl:template name="jump_widget_disability"> |
3459 <xsl:param name="hmi_element"/> |
3598 <xsl:param name="hmi_element"/> |
3460 <xsl:call-template name="defs_by_labels"> |
3599 <xsl:call-template name="defs_by_labels"> |
3461 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
3600 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
3462 <xsl:with-param name="labels"> |
3601 <xsl:with-param name="labels"> |
3463 <xsl:text>disabled</xsl:text> |
3602 <xsl:text>disabled</xsl:text> |
3464 </xsl:with-param> |
3603 </xsl:with-param> |
3465 <xsl:with-param name="mandatory" select="'no'"/> |
3604 <xsl:with-param select="'no'" name="mandatory"/> |
3466 </xsl:call-template> |
3605 </xsl:call-template> |
3467 </xsl:template> |
3606 </xsl:template> |
3468 <xsl:template mode="widget_defs" match="widget[@type='Jump']"> |
3607 <xsl:template mode="widget_defs" match="widget[@type='Jump']"> |
3469 <xsl:param name="hmi_element"/> |
3608 <xsl:param name="hmi_element"/> |
3470 <xsl:variable name="activity"> |
3609 <xsl:variable name="activity"> |
3471 <xsl:call-template name="jump_widget_activity"> |
3610 <xsl:call-template name="jump_widget_activity"> |
3472 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
3611 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
3473 </xsl:call-template> |
3612 </xsl:call-template> |
3474 </xsl:variable> |
3613 </xsl:variable> |
3475 <xsl:variable name="have_activity" select="string-length($activity)>0"/> |
3614 <xsl:variable select="string-length($activity)>0" name="have_activity"/> |
3476 <xsl:value-of select="$activity"/> |
3615 <xsl:value-of select="$activity"/> |
3477 <xsl:variable name="disability"> |
3616 <xsl:variable name="disability"> |
3478 <xsl:call-template name="jump_widget_disability"> |
3617 <xsl:call-template name="jump_widget_disability"> |
3479 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
3618 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
3480 </xsl:call-template> |
3619 </xsl:call-template> |
3481 </xsl:variable> |
3620 </xsl:variable> |
3482 <xsl:variable name="have_disability" select="$have_activity and string-length($disability)>0"/> |
3621 <xsl:variable select="$have_activity and string-length($disability)>0" name="have_disability"/> |
3483 <xsl:value-of select="$disability"/> |
3622 <xsl:value-of select="$disability"/> |
3484 <xsl:if test="$have_activity"> |
3623 <xsl:if test="$have_activity"> |
3485 <xsl:text> active: false, |
3624 <xsl:text> active: false, |
3486 </xsl:text> |
3625 </xsl:text> |
3487 <xsl:if test="$have_disability"> |
3626 <xsl:if test="$have_disability"> |
3705 <xsl:template mode="widget_class" match="widget[@type='Keypad']"> |
3844 <xsl:template mode="widget_class" match="widget[@type='Keypad']"> |
3706 <xsl:text>class KeypadWidget extends Widget{ |
3845 <xsl:text>class KeypadWidget extends Widget{ |
3707 </xsl:text> |
3846 </xsl:text> |
3708 <xsl:text> moving = undefined; |
3847 <xsl:text> moving = undefined; |
3709 </xsl:text> |
3848 </xsl:text> |
3710 <xsl:text> enTimer = undefined; |
3849 <xsl:text> click = undefined; |
3711 </xsl:text> |
3850 </xsl:text> |
3712 <xsl:text> offset = undefined; |
3851 <xsl:text> offset = undefined; |
3713 </xsl:text> |
3852 </xsl:text> |
3714 <xsl:text> |
3853 <xsl:text> |
3715 </xsl:text> |
3854 </xsl:text> |
3716 <xsl:text> on_position_click(evt) { |
3855 <xsl:text> on_position_click(evt) { |
3717 </xsl:text> |
3856 </xsl:text> |
3718 <xsl:text> this.moving = true; |
3857 <xsl:text> this.moving = true; |
3719 </xsl:text> |
3858 </xsl:text> |
3720 <xsl:text> this.enTimer = true; |
3859 <xsl:text> |
|
3860 </xsl:text> |
|
3861 <xsl:text> // chatch window events |
|
3862 </xsl:text> |
|
3863 <xsl:text> window.addEventListener("touchmove", this.bound_on_drag, true); |
|
3864 </xsl:text> |
|
3865 <xsl:text> window.addEventListener("mousemove", this.bound_on_drag, true); |
|
3866 </xsl:text> |
|
3867 <xsl:text> |
|
3868 </xsl:text> |
|
3869 <xsl:text> window.addEventListener("mouseup", this.bound_on_release, true) |
|
3870 </xsl:text> |
|
3871 <xsl:text> window.addEventListener("touchend", this.bound_on_release, true); |
|
3872 </xsl:text> |
|
3873 <xsl:text> window.addEventListener("touchcancel", this.bound_on_release, true); |
3721 </xsl:text> |
3874 </xsl:text> |
3722 <xsl:text> |
3875 <xsl:text> |
3723 </xsl:text> |
3876 </xsl:text> |
3724 <xsl:text> // get click position offset from widget x,y and save it to variable |
3877 <xsl:text> // get click position offset from widget x,y and save it to variable |
3725 </xsl:text> |
3878 </xsl:text> |
3749 </xsl:text> |
3902 </xsl:text> |
3750 <xsl:text> } |
3903 <xsl:text> } |
3751 </xsl:text> |
3904 </xsl:text> |
3752 <xsl:text> |
3905 <xsl:text> |
3753 </xsl:text> |
3906 </xsl:text> |
3754 <xsl:text> off_position_click(evt) { |
3907 <xsl:text> on_release(evt) { |
|
3908 </xsl:text> |
|
3909 <xsl:text> //relase binds |
|
3910 </xsl:text> |
|
3911 <xsl:text> window.removeEventListener("touchmove", this.bound_on_drag, true); |
|
3912 </xsl:text> |
|
3913 <xsl:text> window.removeEventListener("mousemove", this.bound_on_drag, true); |
|
3914 </xsl:text> |
|
3915 <xsl:text> |
|
3916 </xsl:text> |
|
3917 <xsl:text> window.removeEventListener("mouseup", this.bound_on_release, true) |
|
3918 </xsl:text> |
|
3919 <xsl:text> window.removeEventListener("touchend", this.bound_on_release, true); |
|
3920 </xsl:text> |
|
3921 <xsl:text> window.removeEventListener("touchcancel", this.bound_on_release, true); |
|
3922 </xsl:text> |
|
3923 <xsl:text> |
3755 </xsl:text> |
3924 </xsl:text> |
3756 <xsl:text> if(this.moving) |
3925 <xsl:text> if(this.moving) |
3757 </xsl:text> |
3926 </xsl:text> |
3758 <xsl:text> this.moving = false; |
3927 <xsl:text> this.moving = false; |
3759 </xsl:text> |
3928 </xsl:text> |
3760 <xsl:text> } |
3929 <xsl:text> } |
3761 </xsl:text> |
3930 </xsl:text> |
3762 <xsl:text> |
3931 <xsl:text> |
3763 </xsl:text> |
3932 </xsl:text> |
3764 <xsl:text> on_move(evt) { |
3933 <xsl:text> on_drag(evt) { |
3765 </xsl:text> |
3934 </xsl:text> |
3766 <xsl:text> if(this.moving && this.enTimer){ |
3935 <xsl:text> if(this.moving) |
3767 </xsl:text> |
3936 </xsl:text> |
3768 <xsl:text> //get keyboard pos in html |
3937 <xsl:text> //get mouse coordinates |
3769 </xsl:text> |
3938 </xsl:text> |
3770 <xsl:text> let [eltid, tmpgrp] = current_modal; |
3939 <xsl:text> var clickX = undefined; |
3771 </xsl:text> |
3940 </xsl:text> |
3772 <xsl:text> let [xcoord,ycoord] = this.coordinates; |
3941 <xsl:text> var clickY = undefined; |
3773 </xsl:text> |
3942 </xsl:text> |
3774 <xsl:text> let [xdest,ydest,svgWidth,svgHeight] = page_desc[current_visible_page].bbox; |
3943 <xsl:text> if (evt.type == "touchmove"){ |
3775 </xsl:text> |
3944 </xsl:text> |
3776 <xsl:text> |
3945 <xsl:text> clickX = Math.ceil(evt.touches[0].clientX); |
3777 </xsl:text> |
3946 </xsl:text> |
3778 <xsl:text> //get mouse coordinates |
3947 <xsl:text> clickY = Math.ceil(evt.touches[0].clientY); |
3779 </xsl:text> |
3948 </xsl:text> |
3780 <xsl:text> var clickX = undefined; |
3949 <xsl:text> } |
3781 </xsl:text> |
3950 </xsl:text> |
3782 <xsl:text> var clickY = undefined; |
3951 <xsl:text> else{ |
3783 </xsl:text> |
3952 </xsl:text> |
3784 <xsl:text> if (evt.type == "touchmove"){ |
3953 <xsl:text> clickX = evt.pageX; |
3785 </xsl:text> |
3954 </xsl:text> |
3786 <xsl:text> clickX = Math.ceil(evt.touches[0].clientX); |
3955 <xsl:text> clickY = evt.pageY; |
3787 </xsl:text> |
3956 </xsl:text> |
3788 <xsl:text> clickY = Math.ceil(evt.touches[0].clientY); |
3957 <xsl:text> } |
3789 </xsl:text> |
3958 </xsl:text> |
3790 <xsl:text> } |
3959 <xsl:text> this.click = [clickX,clickY] |
3791 </xsl:text> |
3960 </xsl:text> |
3792 <xsl:text> else{ |
3961 <xsl:text> |
3793 </xsl:text> |
3962 </xsl:text> |
3794 <xsl:text> clickX = evt.pageX; |
3963 <xsl:text> //requeset redraw |
3795 </xsl:text> |
3964 </xsl:text> |
3796 <xsl:text> clickY = evt.pageY; |
3965 <xsl:text> this.request_animate(); |
3797 </xsl:text> |
3966 </xsl:text> |
3798 <xsl:text> } |
3967 <xsl:text> } |
3799 </xsl:text> |
3968 </xsl:text> |
3800 <xsl:text> |
3969 <xsl:text> |
3801 </xsl:text> |
3970 </xsl:text> |
3802 <xsl:text> //translate keyboard position |
3971 <xsl:text> animate(){ |
3803 </xsl:text> |
3972 </xsl:text> |
3804 <xsl:text> let mouseX = ((clickX-this.offset[0])/window.innerWidth)*svgWidth; |
3973 <xsl:text> //get keyboard pos in html |
3805 </xsl:text> |
3974 </xsl:text> |
3806 <xsl:text> let mouseY = ((clickY-this.offset[1])/window.innerHeight)*svgHeight; |
3975 <xsl:text> let [eltid, tmpgrp] = current_modal; |
3807 </xsl:text> |
3976 </xsl:text> |
3808 <xsl:text> tmpgrp.setAttribute("transform","translate("+String(xdest-xcoord+mouseX)+","+String(ydest-ycoord+mouseY)+")"); |
3977 <xsl:text> let [xcoord,ycoord] = this.coordinates; |
3809 </xsl:text> |
3978 </xsl:text> |
3810 <xsl:text> |
3979 <xsl:text> let [clickX,clickY] = this.click; |
3811 </xsl:text> |
3980 </xsl:text> |
3812 <xsl:text> //reset timer |
3981 <xsl:text> let [xdest,ydest,svgWidth,svgHeight] = page_desc[current_visible_page].bbox; |
3813 </xsl:text> |
3982 </xsl:text> |
3814 <xsl:text> this.enTimer = false; |
3983 <xsl:text> |
3815 </xsl:text> |
3984 </xsl:text> |
3816 <xsl:text> setTimeout("{hmi_widgets['"+this.element_id+"'].enTimer = true;}", 100); |
3985 <xsl:text> //translate keyboard position |
3817 </xsl:text> |
3986 </xsl:text> |
3818 <xsl:text> } |
3987 <xsl:text> let mouseX = ((clickX-this.offset[0])/window.innerWidth)*svgWidth; |
3819 </xsl:text> |
3988 </xsl:text> |
3820 <xsl:text> |
3989 <xsl:text> let mouseY = ((clickY-this.offset[1])/window.innerHeight)*svgHeight; |
|
3990 </xsl:text> |
|
3991 <xsl:text> tmpgrp.setAttribute("transform","translate("+String(xdest-xcoord+mouseX)+","+String(ydest-ycoord+mouseY)+")"); |
3821 </xsl:text> |
3992 </xsl:text> |
3822 <xsl:text> } |
3993 <xsl:text> } |
3823 </xsl:text> |
3994 </xsl:text> |
3824 <xsl:text> |
3995 <xsl:text> |
3825 </xsl:text> |
3996 </xsl:text> |
3995 </xsl:text> |
4166 </xsl:text> |
3996 </xsl:template> |
4167 </xsl:template> |
3997 <xsl:template mode="widget_defs" match="widget[@type='Keypad']"> |
4168 <xsl:template mode="widget_defs" match="widget[@type='Keypad']"> |
3998 <xsl:param name="hmi_element"/> |
4169 <xsl:param name="hmi_element"/> |
3999 <xsl:call-template name="defs_by_labels"> |
4170 <xsl:call-template name="defs_by_labels"> |
4000 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
4171 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
4001 <xsl:with-param name="labels"> |
4172 <xsl:with-param name="labels"> |
4002 <xsl:text>Esc Enter BackSpace Keys Info Value</xsl:text> |
4173 <xsl:text>Esc Enter BackSpace Keys Info Value</xsl:text> |
4003 </xsl:with-param> |
4174 </xsl:with-param> |
4004 </xsl:call-template> |
4175 </xsl:call-template> |
4005 <xsl:call-template name="defs_by_labels"> |
4176 <xsl:call-template name="defs_by_labels"> |
4006 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
4177 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
4007 <xsl:with-param name="labels"> |
4178 <xsl:with-param name="labels"> |
4008 <xsl:text>Sign Space NumDot position</xsl:text> |
4179 <xsl:text>Sign Space NumDot position</xsl:text> |
4009 </xsl:with-param> |
4180 </xsl:with-param> |
4010 <xsl:with-param name="mandatory" select="'no'"/> |
4181 <xsl:with-param select="'no'" name="mandatory"/> |
4011 </xsl:call-template> |
4182 </xsl:call-template> |
4012 <xsl:call-template name="defs_by_labels"> |
4183 <xsl:call-template name="defs_by_labels"> |
4013 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
4184 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
4014 <xsl:with-param name="labels"> |
4185 <xsl:with-param name="labels"> |
4015 <xsl:text>CapsLock Shift</xsl:text> |
4186 <xsl:text>CapsLock Shift</xsl:text> |
4016 </xsl:with-param> |
4187 </xsl:with-param> |
4017 <xsl:with-param name="mandatory" select="'no'"/> |
4188 <xsl:with-param select="'no'" name="mandatory"/> |
4018 <xsl:with-param name="subelements" select="'active inactive'"/> |
4189 <xsl:with-param select="'active inactive'" name="subelements"/> |
4019 </xsl:call-template> |
4190 </xsl:call-template> |
4020 <xsl:text> init: function() { |
4191 <xsl:text> init: function() { |
4021 </xsl:text> |
4192 </xsl:text> |
4022 <xsl:for-each select="$hmi_element/*[@inkscape:label = 'Keys']/*"> |
4193 <xsl:for-each select="$hmi_element/*[@inkscape:label = 'Keys']/*"> |
4023 <xsl:text> id("</xsl:text> |
4194 <xsl:text> id("</xsl:text> |
4043 <xsl:text>_click()"); |
4214 <xsl:text>_click()"); |
4044 </xsl:text> |
4215 </xsl:text> |
4045 </xsl:for-each> |
4216 </xsl:for-each> |
4046 <xsl:text> if(this.position_elt){ |
4217 <xsl:text> if(this.position_elt){ |
4047 </xsl:text> |
4218 </xsl:text> |
|
4219 <xsl:text> this.bound_on_release = this.on_release.bind(this); |
|
4220 </xsl:text> |
|
4221 <xsl:text> this.bound_on_drag = this.on_drag.bind(this); |
|
4222 </xsl:text> |
|
4223 <xsl:text> |
|
4224 </xsl:text> |
4048 <xsl:text> this.position_elt.setAttribute("onmousedown", "hmi_widgets['"+this.element_id+"'].on_position_click(evt)"); |
4225 <xsl:text> this.position_elt.setAttribute("onmousedown", "hmi_widgets['"+this.element_id+"'].on_position_click(evt)"); |
4049 </xsl:text> |
4226 </xsl:text> |
4050 <xsl:text> this.position_elt.setAttribute("ontouchstart", "hmi_widgets['"+this.element_id+"'].on_position_click(evt)"); |
4227 <xsl:text> this.position_elt.setAttribute("ontouchstart", "hmi_widgets['"+this.element_id+"'].on_position_click(evt)"); |
4051 </xsl:text> |
4228 </xsl:text> |
4052 <xsl:text> window.addEventListener("mouseup", hmi_widgets[this.element_id].off_position_click.bind(this)); |
|
4053 </xsl:text> |
|
4054 <xsl:text> window.addEventListener("touchend", hmi_widgets[this.element_id].off_position_click.bind(this)); |
|
4055 </xsl:text> |
|
4056 <xsl:text> window.addEventListener("touchcancel", hmi_widgets[this.element_id].off_position_click.bind(this)); |
|
4057 </xsl:text> |
|
4058 <xsl:text> window.addEventListener("mousemove", hmi_widgets[this.element_id].on_move.bind(this)); |
|
4059 </xsl:text> |
|
4060 <xsl:text> window.addEventListener("touchmove", hmi_widgets[this.element_id].on_move.bind(this)); |
|
4061 </xsl:text> |
|
4062 <xsl:text> } |
4229 <xsl:text> } |
4063 </xsl:text> |
4230 </xsl:text> |
4064 <xsl:text> }, |
4231 <xsl:text> }, |
4065 </xsl:text> |
4232 </xsl:text> |
4066 <xsl:text> |
4233 <xsl:text> |
4067 </xsl:text> |
4234 </xsl:text> |
4068 <xsl:variable name="g" select="$geometry[@Id = $hmi_element/@id]"/> |
4235 <xsl:variable select="$geometry[@Id = $hmi_element/@id]" name="g"/> |
4069 <xsl:text> coordinates: [</xsl:text> |
4236 <xsl:text> coordinates: [</xsl:text> |
4070 <xsl:value-of select="$g/@x"/> |
4237 <xsl:value-of select="$g/@x"/> |
4071 <xsl:text>, </xsl:text> |
4238 <xsl:text>, </xsl:text> |
4072 <xsl:value-of select="$g/@y"/> |
4239 <xsl:value-of select="$g/@y"/> |
4073 <xsl:text>], |
4240 <xsl:text>], |
4074 </xsl:text> |
4241 </xsl:text> |
4075 </xsl:template> |
4242 </xsl:template> |
4076 <xsl:template mode="widget_defs" match="widget[@type='List']"> |
4243 <xsl:template mode="widget_defs" match="widget[@type='List' or @type='TextStyleList']"> |
4077 <xsl:param name="hmi_element"/> |
4244 <xsl:param name="hmi_element"/> |
4078 <xsl:text> items: { |
4245 <xsl:text> items: { |
4079 </xsl:text> |
4246 </xsl:text> |
4080 <xsl:for-each select="$hmi_element/*[@inkscape:label]"> |
4247 <xsl:for-each select="$hmi_element/*[@inkscape:label]"> |
4081 <xsl:text> </xsl:text> |
4248 <xsl:text> </xsl:text> |
4086 </xsl:text> |
4253 </xsl:text> |
4087 </xsl:for-each> |
4254 </xsl:for-each> |
4088 <xsl:text> }, |
4255 <xsl:text> }, |
4089 </xsl:text> |
4256 </xsl:text> |
4090 </xsl:template> |
4257 </xsl:template> |
|
4258 <xsl:template mode="widget_class" match="widget[@type='Meter']"> |
|
4259 <xsl:text>class MeterWidget extends Widget{ |
|
4260 </xsl:text> |
|
4261 <xsl:text> frequency = 10; |
|
4262 </xsl:text> |
|
4263 <xsl:text> origin = undefined; |
|
4264 </xsl:text> |
|
4265 <xsl:text> range = undefined; |
|
4266 </xsl:text> |
|
4267 <xsl:text> |
|
4268 </xsl:text> |
|
4269 <xsl:text> dispatch(value) { |
|
4270 </xsl:text> |
|
4271 <xsl:text> if(this.value_elt) |
|
4272 </xsl:text> |
|
4273 <xsl:text> this.value_elt.textContent = String(value); |
|
4274 </xsl:text> |
|
4275 <xsl:text> let [min,max,totallength] = this.range; |
|
4276 </xsl:text> |
|
4277 <xsl:text> let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min))); |
|
4278 </xsl:text> |
|
4279 <xsl:text> let tip = this.range_elt.getPointAtLength(length); |
|
4280 </xsl:text> |
|
4281 <xsl:text> this.needle_elt.setAttribute('d', "M "+this.origin.x+","+this.origin.y+" "+tip.x+","+tip.y); |
|
4282 </xsl:text> |
|
4283 <xsl:text> } |
|
4284 </xsl:text> |
|
4285 <xsl:text> |
|
4286 </xsl:text> |
|
4287 <xsl:text> init() { |
|
4288 </xsl:text> |
|
4289 <xsl:text> let min = this.min_elt ? |
|
4290 </xsl:text> |
|
4291 <xsl:text> Number(this.min_elt.textContent) : |
|
4292 </xsl:text> |
|
4293 <xsl:text> this.args.length >= 1 ? this.args[0] : 0; |
|
4294 </xsl:text> |
|
4295 <xsl:text> let max = this.max_elt ? |
|
4296 </xsl:text> |
|
4297 <xsl:text> Number(this.max_elt.textContent) : |
|
4298 </xsl:text> |
|
4299 <xsl:text> this.args.length >= 2 ? this.args[1] : 100; |
|
4300 </xsl:text> |
|
4301 <xsl:text> this.range = [min, max, this.range_elt.getTotalLength()] |
|
4302 </xsl:text> |
|
4303 <xsl:text> this.origin = this.needle_elt.getPointAtLength(0); |
|
4304 </xsl:text> |
|
4305 <xsl:text> } |
|
4306 </xsl:text> |
|
4307 <xsl:text> |
|
4308 </xsl:text> |
|
4309 <xsl:text>} |
|
4310 </xsl:text> |
|
4311 </xsl:template> |
4091 <xsl:template mode="widget_defs" match="widget[@type='Meter']"> |
4312 <xsl:template mode="widget_defs" match="widget[@type='Meter']"> |
4092 <xsl:param name="hmi_element"/> |
4313 <xsl:param name="hmi_element"/> |
4093 <xsl:text> frequency: 10, |
|
4094 </xsl:text> |
|
4095 <xsl:call-template name="defs_by_labels"> |
4314 <xsl:call-template name="defs_by_labels"> |
4096 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
4315 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
4097 <xsl:with-param name="labels"> |
4316 <xsl:with-param name="labels"> |
4098 <xsl:text>needle range</xsl:text> |
4317 <xsl:text>needle range</xsl:text> |
4099 </xsl:with-param> |
4318 </xsl:with-param> |
4100 </xsl:call-template> |
4319 </xsl:call-template> |
4101 <xsl:call-template name="defs_by_labels"> |
4320 <xsl:call-template name="defs_by_labels"> |
4102 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
4321 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
4103 <xsl:with-param name="labels"> |
4322 <xsl:with-param name="labels"> |
4104 <xsl:text>value min max</xsl:text> |
4323 <xsl:text>value min max</xsl:text> |
4105 </xsl:with-param> |
4324 </xsl:with-param> |
4106 <xsl:with-param name="mandatory" select="'no'"/> |
4325 <xsl:with-param select="'no'" name="mandatory"/> |
4107 </xsl:call-template> |
4326 </xsl:call-template> |
4108 <xsl:text> dispatch: function(value) { |
4327 <xsl:text> |
4109 </xsl:text> |
|
4110 <xsl:text> if(this.value_elt) |
|
4111 </xsl:text> |
|
4112 <xsl:text> this.value_elt.textContent = String(value); |
|
4113 </xsl:text> |
|
4114 <xsl:text> let [min,max,totallength] = this.range; |
|
4115 </xsl:text> |
|
4116 <xsl:text> let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min))); |
|
4117 </xsl:text> |
|
4118 <xsl:text> let tip = this.range_elt.getPointAtLength(length); |
|
4119 </xsl:text> |
|
4120 <xsl:text> this.needle_elt.setAttribute('d', "M "+this.origin.x+","+this.origin.y+" "+tip.x+","+tip.y); |
|
4121 </xsl:text> |
|
4122 <xsl:text> }, |
|
4123 </xsl:text> |
|
4124 <xsl:text> origin: undefined, |
|
4125 </xsl:text> |
|
4126 <xsl:text> range: undefined, |
|
4127 </xsl:text> |
|
4128 <xsl:text> init: function() { |
|
4129 </xsl:text> |
|
4130 <xsl:text> let min = this.min_elt ? |
|
4131 </xsl:text> |
|
4132 <xsl:text> Number(this.min_elt.textContent) : |
|
4133 </xsl:text> |
|
4134 <xsl:text> this.args.length >= 1 ? this.args[0] : 0; |
|
4135 </xsl:text> |
|
4136 <xsl:text> let max = this.max_elt ? |
|
4137 </xsl:text> |
|
4138 <xsl:text> Number(this.max_elt.textContent) : |
|
4139 </xsl:text> |
|
4140 <xsl:text> this.args.length >= 2 ? this.args[1] : 100; |
|
4141 </xsl:text> |
|
4142 <xsl:text> this.range = [min, max, this.range_elt.getTotalLength()] |
|
4143 </xsl:text> |
|
4144 <xsl:text> this.origin = this.needle_elt.getPointAtLength(0); |
|
4145 </xsl:text> |
|
4146 <xsl:text> }, |
|
4147 </xsl:text> |
4328 </xsl:text> |
4148 </xsl:template> |
4329 </xsl:template> |
4149 <xsl:template mode="widget_class" match="widget[@type='MultiState']"> |
4330 <xsl:template mode="widget_class" match="widget[@type='MultiState']"> |
4150 <xsl:text>class MultiStateWidget extends Widget{ |
4331 <xsl:text>class MultiStateWidget extends Widget{ |
4151 </xsl:text> |
4332 </xsl:text> |
4576 </xsl:text> |
4759 </xsl:text> |
4577 </xsl:template> |
4760 </xsl:template> |
4578 <xsl:template mode="widget_defs" match="widget[@type='Slider']"> |
4761 <xsl:template mode="widget_defs" match="widget[@type='Slider']"> |
4579 <xsl:param name="hmi_element"/> |
4762 <xsl:param name="hmi_element"/> |
4580 <xsl:call-template name="defs_by_labels"> |
4763 <xsl:call-template name="defs_by_labels"> |
4581 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
4764 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
4582 <xsl:with-param name="labels"> |
4765 <xsl:with-param name="labels"> |
4583 <xsl:text>handle range</xsl:text> |
4766 <xsl:text>handle range</xsl:text> |
4584 </xsl:with-param> |
4767 </xsl:with-param> |
4585 </xsl:call-template> |
4768 </xsl:call-template> |
4586 <xsl:call-template name="defs_by_labels"> |
4769 <xsl:call-template name="defs_by_labels"> |
4587 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
4770 <xsl:with-param select="$hmi_element" name="hmi_element"/> |
4588 <xsl:with-param name="labels"> |
4771 <xsl:with-param name="labels"> |
4589 <xsl:text>value min max setpoint</xsl:text> |
4772 <xsl:text>value min max setpoint</xsl:text> |
4590 </xsl:with-param> |
4773 </xsl:with-param> |
4591 <xsl:with-param name="mandatory" select="'no'"/> |
4774 <xsl:with-param select="'no'" name="mandatory"/> |
4592 </xsl:call-template> |
4775 </xsl:call-template> |
4593 <xsl:text> |
4776 <xsl:text> |
4594 </xsl:text> |
4777 </xsl:text> |
4595 </xsl:template> |
4778 </xsl:template> |
4596 <xsl:template mode="widget_class" match="widget[@type='Switch']"> |
4779 <xsl:template mode="widget_class" match="widget[@type='Switch']"> |