SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
authorEdouard Tisserant
Tue, 18 Jan 2022 10:55:14 +0100
changeset 3408 13c5cac55ac7
parent 3404 6f5cd8d5dc11
child 3409 440183be80a2
SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
svghmi/parse_labels.ysl2
svghmi/widgets_common.ysl2
tests/svghmi/svghmi_0@svghmi/svghmi.svg
--- a/svghmi/parse_labels.ysl2	Sun Jan 16 16:59:40 2022 +0100
+++ b/svghmi/parse_labels.ysl2	Tue Jan 18 10:55:14 2022 +0100
@@ -2,7 +2,7 @@
 
 
 //  Parses:
-//  "HMI:WidgetType:param1:param2@path1,path1min,path1max@path2"
+//  "HMI:WidgetType|freq:param1:param2@path1,path1min,path1max@path2"
 //
 //  Into:
 //  widget type="WidgetType" id="blah456" {
@@ -28,15 +28,23 @@
         otherwise value "$description";
     }
 
-    const "_type", "substring-before($args,':')";
-    const "type" choose {
-        when "$_type" value "$_type";
+    const "_typefreq", "substring-before($args,':')";
+    const "typefreq" choose {
+        when "$_typefreq" value "$_typefreq";
         otherwise value "$args";
     }
 
+    const "freq", "substring-after($typefreq,':')";
+
+    const "_type", "substring-before($typefreq,'|')";
+    const "type" choose {
+        when "$_type" value "$_type";
+        otherwise value "$typefreq";
+    }
     if "$type" widget {
         attrib "id" > «$id»
         attrib "type" > «$type»
+        if "freq" attrib "frequency" > «$freq»
         foreach "str:split(substring-after($args, ':'), ':')" {
             arg {
                 attrib "value" > «.»
--- a/svghmi/widgets_common.ysl2	Sun Jan 16 16:59:40 2022 +0100
+++ b/svghmi/widgets_common.ysl2	Tue Jan 18 10:55:14 2022 +0100
@@ -83,7 +83,14 @@
         if "position()!=last()" > ,
     }
 
-    |   "«@id»": new «$widget/@type»Widget ("«@id»",[«$args»],[«$indexes»],[«$minmaxes»],{
+    const "freq" choose {
+        when "$widget/freq"
+            > «$widget/freq»
+        otherwise
+            > undefined
+    }
+
+    |   "«@id»": new «$widget/@type»Widget ("«@id»",«$freq»,[«$args»],[«$indexes»],[«$minmaxes»],{
     apply "$widget", mode="widget_defs" with "hmi_element",".";
     |   })`if "position()!=last()" > ,`
 }
@@ -164,9 +171,10 @@
         unsubscribable = false;
         pending_animate = false;
 
-        constructor(elt_id,args,indexes,minmaxes,members){
+        constructor(elt_id, freq, args, indexes, minmaxes, members){
             this.element_id = elt_id;
             this.element = id(elt_id);
+            if(freq !== undefined) this.frequency = freq;
             this.args = args;
             this.indexes = indexes;
             this.minmaxes = minmaxes;
--- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg	Sun Jan 16 16:59:40 2022 +0100
+++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg	Tue Jan 18 10:55:14 2022 +0100
@@ -128,9 +128,9 @@
      inkscape:current-layer="hmi0"
      showgrid="false"
      units="px"
-     inkscape:zoom="0.84355636"
-     inkscape:cx="-1054.5035"
-     inkscape:cy="482.64214"
+     inkscape:zoom="0.59648442"
+     inkscape:cx="816.53059"
+     inkscape:cy="446.56258"
      inkscape:window-width="1600"
      inkscape:window-height="836"
      inkscape:window-x="0"
@@ -2240,49 +2240,6 @@
        inkscape:transform-center-x="1.0089177e-06" />
   </g>
   <g
-     transform="matrix(0.57180538,0,0,0.57180538,-522.96165,161.69266)"
-     id="g443"
-     inkscape:label="HMI:Button@/SELECTION"
-     style="stroke-width:1">
-    <rect
-       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"
-       id="rect5492"
-       width="245.44583"
-       height="95.723877"
-       x="971.96545"
-       y="594.82263"
-       ry="23.930969"
-       inkscape:label="inactive"
-       rx="23.930969" />
-    <rect
-       rx="23.930969"
-       inkscape:label="active"
-       ry="23.930969"
-       y="594.82263"
-       x="971.96545"
-       height="95.723877"
-       width="245.44583"
-       id="rect433"
-       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:#fdfdfd;fill-opacity:1;fill-rule:nonzero;stroke:#ffd0b2;stroke-width:28.60938263;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
-       style="stroke-width:1"
-       inkscape:label="text"
-       id="g952">
-      <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:#ff6600;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-         x="1090.7626"
-         y="656.98151"
-         id="text950"
-         inkscape:label="setting_jmp"><tspan
-           sodipodi:role="line"
-           id="tspan948"
-           x="1090.7626"
-           y="656.98151"
-           style="text-align:center;text-anchor:middle;fill:#ff6600;stroke-width:0.99999994px">up</tspan></text>
-    </g>
-  </g>
-  <g
      id="g5053"
      inkscape:label="HMI:Switch@/PUMP0/BOOLOUT"
      transform="translate(43.983597,40.477445)">
@@ -3595,25 +3552,25 @@
   </g>
   <text
      xml:space="preserve"
-     style="font-style:normal;font-weight:normal;font-size:59.01374435px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#82ff77;fill-opacity:1;stroke:none;stroke-width:0.3688359px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-     x="689.9715"
-     y="539.24927"
+     style="font-style:normal;font-weight:normal;font-size:25.76535034px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#82ff77;fill-opacity:1;stroke:none;stroke-width:0.3688359px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+     x="949.96338"
+     y="514.57275"
      id="text995-6"
      inkscape:label="HMI:Display:Ploc %d (%d) grmbl !@/PUMP0/PRESSURE@/PUMP0/SLOTH"><tspan
        sodipodi:role="line"
        id="tspan993-3"
-       x="689.9715"
-       y="539.24927"
+       x="949.96338"
+       y="514.57275"
        style="text-align:center;text-anchor:middle;fill:#82ff77;fill-opacity:1;stroke-width:0.3688359px">8888</tspan></text>
   <text
      id="text831-1"
      y="477.76758"
-     x="581.62634"
+     x="841.62634"
      style="font-style:normal;font-weight:normal;font-size:25.4761734px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;display:inline;fill:#008000;fill-opacity:1;stroke:none;stroke-width:0.63690436px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
      xml:space="preserve"
      inkscape:label="actual_label"><tspan
        y="477.76758"
-       x="581.62634"
+       x="841.62634"
        id="tspan829-7"
        sodipodi:role="line"
        style="stroke-width:0.63690436px">Multiple variables</tspan></text>
@@ -7560,4 +7517,176 @@
      x="0"
      transform="translate(-2307.336,1146.3377)"
      inkscape:label="HMI:ListSwitch@/ALARMSTATUS" />
+  <g
+     style="stroke-width:1"
+     inkscape:label="HMI:Button|16@/SELECTION"
+     id="g1094"
+     transform="matrix(0.57180538,0,0,0.57180538,-362.96165,161.69266)">
+    <rect
+       rx="23.930969"
+       inkscape:label="inactive"
+       ry="23.930969"
+       y="594.82263"
+       x="971.96545"
+       height="95.723877"
+       width="245.44583"
+       id="rect1084"
+       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" />
+    <rect
+       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:#fdfdfd;fill-opacity:1;fill-rule:nonzero;stroke:#ffd0b2;stroke-width:28.60938263;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"
+       id="rect1086"
+       width="245.44583"
+       height="95.723877"
+       x="971.96545"
+       y="594.82263"
+       ry="23.930969"
+       inkscape:label="active"
+       rx="23.930969" />
+    <g
+       id="g1092"
+       inkscape:label="text"
+       style="stroke-width:1">
+      <text
+         inkscape:label="setting_jmp"
+         id="text1090"
+         y="656.98151"
+         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="656.98151"
+           x="1090.7626"
+           id="tspan1088"
+           sodipodi:role="line">up</tspan></text>
+    </g>
+  </g>
+  <g
+     transform="matrix(0.57180538,0,0,0.57180538,-202.96165,161.69266)"
+     id="g1106"
+     inkscape:label="HMI:Button|8@/SELECTION"
+     style="stroke-width:1">
+    <rect
+       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"
+       id="rect1096"
+       width="245.44583"
+       height="95.723877"
+       x="971.96545"
+       y="594.82263"
+       ry="23.930969"
+       inkscape:label="inactive"
+       rx="23.930969" />
+    <rect
+       rx="23.930969"
+       inkscape:label="active"
+       ry="23.930969"
+       y="594.82263"
+       x="971.96545"
+       height="95.723877"
+       width="245.44583"
+       id="rect1098"
+       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:#fdfdfd;fill-opacity:1;fill-rule:nonzero;stroke:#ffd0b2;stroke-width:28.60938263;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
+       style="stroke-width:1"
+       inkscape:label="text"
+       id="g1104">
+      <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:#ff6600;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+         x="1090.7626"
+         y="656.98151"
+         id="text1102"
+         inkscape:label="setting_jmp"><tspan
+           sodipodi:role="line"
+           id="tspan1100"
+           x="1090.7626"
+           y="656.98151"
+           style="text-align:center;text-anchor:middle;fill:#ff6600;stroke-width:0.99999994px">up</tspan></text>
+    </g>
+  </g>
+  <g
+     style="stroke-width:1"
+     inkscape:label="HMI:Button|4@/SELECTION"
+     id="g1118"
+     transform="matrix(0.57180538,0,0,0.57180538,-42.96165,161.69266)">
+    <rect
+       rx="23.930969"
+       inkscape:label="inactive"
+       ry="23.930969"
+       y="594.82263"
+       x="971.96545"
+       height="95.723877"
+       width="245.44583"
+       id="rect1108"
+       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" />
+    <rect
+       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:#fdfdfd;fill-opacity:1;fill-rule:nonzero;stroke:#ffd0b2;stroke-width:28.60938263;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"
+       id="rect1110"
+       width="245.44583"
+       height="95.723877"
+       x="971.96545"
+       y="594.82263"
+       ry="23.930969"
+       inkscape:label="active"
+       rx="23.930969" />
+    <g
+       id="g1116"
+       inkscape:label="text"
+       style="stroke-width:1">
+      <text
+         inkscape:label="setting_jmp"
+         id="text1114"
+         y="656.98151"
+         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="656.98151"
+           x="1090.7626"
+           id="tspan1112"
+           sodipodi:role="line">up</tspan></text>
+    </g>
+  </g>
+  <g
+     transform="matrix(0.57180538,0,0,0.57180538,-522.96165,161.69266)"
+     id="g443"
+     inkscape:label="HMI:Button|2@/SELECTION"
+     style="stroke-width:1">
+    <rect
+       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"
+       id="rect5492"
+       width="245.44583"
+       height="95.723877"
+       x="971.96545"
+       y="594.82263"
+       ry="23.930969"
+       inkscape:label="inactive"
+       rx="23.930969" />
+    <rect
+       rx="23.930969"
+       inkscape:label="active"
+       ry="23.930969"
+       y="594.82263"
+       x="971.96545"
+       height="95.723877"
+       width="245.44583"
+       id="rect433"
+       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:#fdfdfd;fill-opacity:1;fill-rule:nonzero;stroke:#ffd0b2;stroke-width:28.60938263;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
+       style="stroke-width:1"
+       inkscape:label="text"
+       id="g952">
+      <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:#ff6600;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+         x="1090.7626"
+         y="656.98151"
+         id="text950"
+         inkscape:label="setting_jmp"><tspan
+           sodipodi:role="line"
+           id="tspan948"
+           x="1090.7626"
+           y="656.98151"
+           style="text-align:center;text-anchor:middle;fill:#ff6600;stroke-width:0.99999994px">up</tspan></text>
+    </g>
+  </g>
 </svg>