--- a/exemples/svghmi_jumps/svghmi_0@svghmi/svghmi.svg Fri Nov 18 10:44:56 2022 +0100
+++ b/exemples/svghmi_jumps/svghmi_0@svghmi/svghmi.svg Wed Nov 23 11:27:55 2022 +0100
@@ -25,7 +25,7 @@
<dc:format>image/svg+xml</dc:format>
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
@@ -40,17 +40,17 @@
- inkscape:window-width="1600"
- inkscape:window-height="836"
+ inkscape:window-width="1850" + inkscape:window-height="1036" - inkscape:zoom="0.23177389"
- inkscape:cx="1999.5317"
- inkscape:cy="-682.74047"
+ inkscape:zoom="0.46354778" + inkscape:cx="-544.27948" + inkscape:cy="655.56978" inkscape:window-maximized="1"
- inkscape:current-layer="hmi0"
+ inkscape:current-layer="g2496" inkscape:guide-bbox="true"
@@ -67,7 +67,7 @@
transform="translate(1320,1520)"
- inkscape:label="HMI:Page:RelativePage@/FB_ZERO" />
+ inkscape:label="HMI:Page:RelativePage:p=6@p=page_number@/FB_ZERO" /> sodipodi:insensitive="true"
@@ -77,7 +77,7 @@
transform="translate(2640,759.99998)"
- inkscape:label="HMI:Page:Relative" />
+ inkscape:label="HMI:Page:Relative:p=5@p=page_number" /> @@ -86,10 +86,10 @@
transform="translate(3940,-2.1367187e-5)"
- inkscape:label="HMI:Page:Conditional"
+ inkscape:label="HMI:Page:Conditional:p=4@p=page_number" sodipodi:insensitive="true" />
- inkscape:label="HMI:Page:Unconditional"
+ inkscape:label="HMI:Page:Unconditional:p=3@p=page_number" transform="translate(2640,-2.1367187e-5)"
@@ -99,7 +99,7 @@
sodipodi:insensitive="true" />
- inkscape:label="HMI:Page:AbsolutePage"
+ inkscape:label="HMI:Page:AbsolutePage:p=2@p=page_number" transform="translate(1320,759.99998)"
@@ -116,7 +116,7 @@
transform="translate(1320,-2.1367187e-5)"
- inkscape:label="HMI:Page:Home"
+ inkscape:label="HMI:Page:Home:p=1@p=page_number" sodipodi:insensitive="true" />
@@ -621,6 +621,18 @@
y="598.98303">HMI:Jump:RelativePage</tspan></text>
+ inkscape:label="HMI:Display@page_number" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:50.03883362px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + style="stroke-width:1px">0</tspan></text> @@ -1200,7 +1212,7 @@
inkscape:label="MYNODE:+1"
- transform="matrix(1.3729714,0,0,1.3729714,-299.47126,-800.64485)"
+ transform="matrix(1.3729714,0,0,1.3729714,-359.47134,-800.64485)" style="stroke-width:0.7283473">
@@ -1226,7 +1238,7 @@
inkscape:label="MYNODE:3"
- transform="translate(665.54481,-11.353461)">
+ transform="translate(620.54487,-11.353461)"> transform="translate(1466.6549,2099.2529)"
inkscape:label="HMI:Jump:RelativePage@/FB_TWO@enable=/FB_TWO/SOME_BOOL#enable"
@@ -1286,7 +1298,7 @@
- transform="translate(342.39289,-11.353461)"
+ transform="translate(312.39295,-11.353461)" inkscape:label="MYNODE:2">
@@ -1350,7 +1362,7 @@
inkscape:label="MYNODE:1"
- transform="translate(19.240974,-11.353461)">
+ transform="translate(4.2410198,-11.353461)"> transform="translate(1466.6549,2099.2529)"
inkscape:label="HMI:Jump:RelativePage@/FB_ZERO@enable=/FB_ZERO/SOME_BOOL#enable"
@@ -1815,4 +1827,23 @@
id="tspan2966">- Press Ctrl+X to edit SVG elements directly with XML editor</tspan></text>
+ transform="translate(-4020,2.1367187e-5)" + inkscape:label="HMI:VarInit:0@page_number" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.66666603px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + sodipodi:role="line">declaration of user_level HMI local variable</tspan><tspan + sodipodi:role="line">(not a PLC variable)</tspan></text> --- a/svghmi/detachable_pages.ysl2 Fri Nov 18 10:44:56 2022 +0100
+++ b/svghmi/detachable_pages.ysl2 Wed Nov 23 11:27:55 2022 +0100
@@ -137,6 +137,10 @@
const "_detachable_elements", "func:detachable_elements($hmi_pages | $keypads)";
const "detachable_elements", "$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]";
+emit "declarations:page-class" { + | class PageWidget extends Widget{} emit "declarations:detachable-elements" {
| var detachable_elements = {
@@ -165,8 +169,13 @@
const "all_page_widgets","$hmi_widgets[@id = $page_all_elements/@id and @id != $page/@id]";
const "page_managed_widgets","$all_page_widgets[not(@id=$in_forEach_widget_ids)]";
+ const "page_root_path", "$desc/path[not(@assign)]"; + if "count($page_root_path)>1" + error > Page id="«$page/@id»" : only one root path can be declared const "page_relative_widgets",
- "$page_managed_widgets[func:is_descendant_path(func:widget(@id)/path/@value, $desc/path/@value)]";
+ "$page_managed_widgets[func:is_descendant_path(func:widget(@id)/path/@value, $page_root_path/@value)]"; // Take closest ancestor in detachable_elements
// since nested detachable elements are filtered out
@@ -178,19 +187,19 @@
ancestor-or-self::*[@id = $detachable_elements/@id]""";
- //| widget: hmi_widgets["«@id»"],
| bbox: [«$p/@x», «$p/@y», «$p/@w», «$p/@h»],
- if "$desc/path/@value" {
- if "count($desc/path/@index)=0"
- warning > Page id="«$page/@id»" : No match for path "«$desc/path/@value»" in HMI tree
- | page_index: «$desc/path/@index»,
- | page_class: "«$indexed_hmitree/*[@hmipath = $desc/path/@value]/@class»",
+ if "count($page_root_path)=1"{ + if "count($page_root_path/@index)=0" + warning > Page id="«$page/@id»" : No match for path "«$page_root_path/@value»" in HMI tree + | page_index: «$page_root_path/@index», + | page_class: "«$indexed_hmitree/*[@hmipath = $page_root_path/@value]/@class»", + | [hmi_widgets["«$page/@id»"], []], foreach "$page_managed_widgets" {
const "widget_paths_relativeness"
foreach "func:widget(@id)/path" {
- value "func:is_descendant_path(@value, $desc/path/@value)";
+ value "func:is_descendant_path(@value, $page_root_path/@value)"; if "position()!=last()" > ,
| [hmi_widgets["«@id»"], [«$widget_paths_relativeness»]]`if "position()!=last()" > ,`
--- a/svghmi/svghmi.js Fri Nov 18 10:44:56 2022 +0100
+++ b/svghmi/svghmi.js Wed Nov 23 11:27:55 2022 +0100
@@ -525,6 +525,9 @@
: page_name + "@" + hmitree_paths[page_index]);
+ // when entering a page, assignments are evaluated + new_desc.widgets[0][0].assign(); --- a/svghmi/widget_jump.ysl2 Fri Nov 18 10:44:56 2022 +0100
+++ b/svghmi/widget_jump.ysl2 Wed Nov 23 11:27:55 2022 +0100
@@ -143,8 +143,8 @@
otherwise value "$page_desc/arg[1]/@value";
const "target_page_path" choose {
- when "arg" value "$hmi_pages_descs[arg[1]/@value = $target_page_name]/path[1]/@value";
- otherwise value "$page_desc/path[1]/@value";
+ when "arg" value "$hmi_pages_descs[arg[1]/@value = $target_page_name]/path[not(@assign)]/@value"; + otherwise value "$page_desc/path[not(@assign)]/@value"; if "not(func:same_class_paths($target_page_path, path[1]/@value))"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/svghmi/widget_page.ysl2 Wed Nov 23 11:27:55 2022 +0100
@@ -0,0 +1,60 @@
+ - XXX reference path TODO + - name=value: setting variable with literal value. + - name=other_name: copy variable content into another + "active"+"inactive" labeled elements can be provided to show feedback when pressed + HMI:Page:notify=1@notify=/PLCVAR + HMI:Page:ack=2:notify=1@ack=.local_var@notify=/PLCVAR + | dispatch: function(value, oldval, varnum) { + const "varid","generate-id()"; + const "varnum","position()-1"; + if "@assign" foreach "$widget/path[@assign]" if "$varid = generate-id()" { + | if(varnum == «$varnum») this.assignments["«@assign»"] = value; + foreach "arg[contains(@value,'=')]"{ + const "name","substring-before(@value,'=')"; + const "value","substring-after(@value,'=')"; + const "index" foreach "$paths" if "@assign = $name" value "position()-1"; + const "isVarName", "regexp:test($value,'^[a-zA-Z_][a-zA-Z0-9_]+$')"; + | const «$value» = this.assignments["«$value»"]; + | if(«$value» != undefined) + | this.apply_hmi_value(«$index», «$value»); + | this.apply_hmi_value(«$index», «$value»); --- a/svghmi/widgets_common.ysl2 Fri Nov 18 10:44:56 2022 +0100
+++ b/svghmi/widgets_common.ysl2 Wed Nov 23 11:27:55 2022 +0100
@@ -600,12 +600,14 @@
const "included_ids","$parsed_widgets/widget[not(@type = $excluded_types) and not(@id = $discardable_elements/@id)]/@id";
+const "page_ids","$parsed_widgets/widget[@type = 'Page']/@id"; const "hmi_widgets","$hmi_elements[@id = $included_ids]";
+const "page_widgets","$hmi_elements[@id = $page_ids]"; const "result_widgets","$result_svg_ns//*[@id = $hmi_widgets/@id]";
emit "declarations:hmi-elements" {
- apply "$hmi_widgets", mode="hmi_widgets";
+ apply "$hmi_widgets | $page_widgets", mode="hmi_widgets";