# HG changeset patch # User Edouard Tisserant # Date 1642499714 -3600 # Node ID 13c5cac55ac7bc765c0906eefc094739177daee0 # Parent 6f5cd8d5dc115c6427608a08c0ac1ed7f6c5092f SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path diff -r 6f5cd8d5dc11 -r 13c5cac55ac7 svghmi/parse_labels.ysl2 --- 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" > «.» diff -r 6f5cd8d5dc11 -r 13c5cac55ac7 svghmi/widgets_common.ysl2 --- 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; diff -r 6f5cd8d5dc11 -r 13c5cac55ac7 tests/svghmi/svghmi_0@svghmi/svghmi.svg --- 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" /> - - - - up - - - @@ -3595,25 +3552,25 @@ 8888 Multiple variables @@ -7560,4 +7517,176 @@ x="0" transform="translate(-2307.336,1146.3377)" inkscape:label="HMI:ListSwitch@/ALARMSTATUS" /> + + + + + up + + + + + + + up + + + + + + + up + + + + + + + up + +