SVGHMI: Add predefined assignments to jump widget to notify PLC or other widgets about jump.
authorEdouard Tisserant
Fri, 02 Sep 2022 12:02:43 +0200
changeset 3597 f69c68cffec3
parent 3596 9c725829d8f0
child 3598 13677d093946
SVGHMI: Add predefined assignments to jump widget to notify PLC or other widgets about jump.
svghmi/widget_jump.ysl2
tests/projects/svghmi/svghmi_0@svghmi/svghmi.svg
--- a/svghmi/widget_jump.ysl2	Fri Sep 02 10:46:05 2022 +0200
+++ b/svghmi/widget_jump.ysl2	Fri Sep 02 12:02:43 2022 +0200
@@ -13,7 +13,7 @@
 
     - Absolute: force page jump to be not relative even if first path is of type HMI_NODE
 
-    - name=value: Notify jump by setting variable with path having same name assigned
+    - name=value: Notify PLC about jump by setting variable with path having same name assigned
 
     "active"+"inactive" labeled elements can be provided and reflect current
     page being shown.
@@ -35,6 +35,10 @@
     HMI:Jump:AbsolutePage:Absolute@/PUMP9
     HMI:Jump:AbsolutePage:Absolute:notify=1@notify=/PUMP9
 
+    Jump with feedback
+
+    HMI:Jump:AbsolutePage:notify=1@notify=.did_jump
+
     ||
 
     shortdesc > Jump to given page
@@ -63,6 +67,7 @@
                         (that.is_relative && that.indexes.length > 0) ?
                         that.indexes[0] + that.offset : undefined;
                     fading_page_switch(name, index);
+                    that.notify();
                 }
             }
         }
@@ -106,6 +111,16 @@
     > ;\n
     |     },
 
+    |     notify: function() {
+    const "paths","path";
+    foreach "arg[position()>1 and contains(@value,'=')]"{
+        const "name","substring-before(@value,'=')";
+        const "value","substring-after(@value,'=')";
+        const "index" foreach "$paths" if "@assign = $name" value "position()-1";
+    |         // «@value»
+    |         this.apply_hmi_value(«$index», «$value»);
+    }
+    |     },
 }
 
 widget_page("Jump"){
--- a/tests/projects/svghmi/svghmi_0@svghmi/svghmi.svg	Fri Sep 02 10:46:05 2022 +0200
+++ b/tests/projects/svghmi/svghmi_0@svghmi/svghmi.svg	Fri Sep 02 12:02:43 2022 +0200
@@ -133,12 +133,12 @@
      inkscape:pageopacity="0"
      inkscape:pageshadow="2"
      inkscape:document-units="px"
-     inkscape:current-layer="g1450-4-9"
+     inkscape:current-layer="hmi0"
      showgrid="false"
      units="px"
-     inkscape:zoom="1.1339844"
-     inkscape:cx="1880.7924"
-     inkscape:cy="528.36862"
+     inkscape:zoom="0.40092403"
+     inkscape:cx="323.58553"
+     inkscape:cy="-56.756946"
      inkscape:window-width="1600"
      inkscape:window-height="836"
      inkscape:window-x="0"
@@ -3257,14 +3257,14 @@
              style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.28600003;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
           <text
              xml:space="preserve"
-             style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#434343;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+             style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#434343;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
              x="1093.7899"
              y="657.59668"
              id="text1454-0-7"><tspan
                sodipodi:role="line"
                x="1093.7899"
                y="657.59668"
-               style="text-align:center;text-anchor:middle;fill:#434343;fill-opacity:1;stroke-width:0.99999994px;"
+               style="text-align:center;text-anchor:middle;fill:#434343;fill-opacity:1;stroke-width:0.99999994px"
                id="tspan1460-3-5">Disabled</tspan></text>
         </g>
         <g
@@ -3366,14 +3366,14 @@
              style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.28600003;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
           <text
              xml:space="preserve"
-             style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#434343;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+             style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#434343;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
              x="1093.7899"
              y="657.59668"
              id="text1454-0-7-2"><tspan
                sodipodi:role="line"
                x="1093.7899"
                y="657.59668"
-               style="text-align:center;text-anchor:middle;fill:#434343;fill-opacity:1;stroke-width:0.99999994px;"
+               style="text-align:center;text-anchor:middle;fill:#434343;fill-opacity:1;stroke-width:0.99999994px"
                id="tspan1460-3-5-9">Disabled</tspan></text>
         </g>
         <g
@@ -3465,14 +3465,14 @@
              style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.28600003;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
           <text
              xml:space="preserve"
-             style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#434343;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+             style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#434343;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
              x="1093.7899"
              y="657.59668"
              id="text1454-0-7-8"><tspan
                sodipodi:role="line"
                x="1093.7899"
                y="657.59668"
-               style="text-align:center;text-anchor:middle;fill:#434343;fill-opacity:1;stroke-width:0.99999994px;"
+               style="text-align:center;text-anchor:middle;fill:#434343;fill-opacity:1;stroke-width:0.99999994px"
                id="tspan1460-3-5-7">Disabled</tspan></text>
         </g>
         <g
@@ -3564,14 +3564,14 @@
              style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.28600003;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
           <text
              xml:space="preserve"
-             style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#434343;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+             style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#434343;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
              x="1093.7899"
              y="657.59668"
              id="text1454-0-7-3"><tspan
                sodipodi:role="line"
                x="1093.7899"
                y="657.59668"
-               style="text-align:center;text-anchor:middle;fill:#434343;fill-opacity:1;stroke-width:0.99999994px;"
+               style="text-align:center;text-anchor:middle;fill:#434343;fill-opacity:1;stroke-width:0.99999994px"
                id="tspan1460-3-5-6">Disabled</tspan></text>
         </g>
         <g
@@ -8526,4 +8526,35 @@
            style="text-align:center;text-anchor:middle;fill:#ff6600;stroke-width:0.99999994px">up</tspan></text>
     </g>
   </g>
+  <g
+     transform="translate(-940,-418)"
+     inkscape:label="HMI:Jump:Home:notify=42:plop=&quot;WTF&quot;@notify=/SELECTION@plop=/PUMP0/STRIN"
+     id="g2343">
+    <g
+       inkscape:label="button"
+       id="g2335">
+      <path
+         sodipodi:nodetypes="cssssccc"
+         inkscape:connector-curvature="0"
+         id="path2333"
+         d="m 1217.4113,1410.4016 -22,24.5657 c -10.7925,12.0511 6.1317,35.5791 -13.5791,35.5791 h -174.2877 c -19.71078,0 -2.7866,-23.528 -13.57905,-35.5791 l -22,-24.5657 127.74845,-48.4334 z"
+         style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
+    </g>
+    <g
+       inkscape:label="text"
+       id="g2341">
+      <text
+         inkscape:label="home_jmp"
+         id="text2339"
+         y="1436.9814"
+         x="1090.7626"
+         style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#ff6600;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+         xml:space="preserve"><tspan
+           style="text-align:center;text-anchor:middle;fill:#ff6600;stroke-width:0.99999994px"
+           y="1436.9814"
+           x="1090.7626"
+           id="tspan2337"
+           sodipodi:role="line">Home</tspan></text>
+    </g>
+  </g>
 </svg>