--- a/svghmi/hmi_tree.ysl2 Tue Dec 22 14:57:59 2020 +0100
+++ b/svghmi/hmi_tree.ysl2 Thu Dec 24 16:56:19 2020 +0100
@@ -24,7 +24,7 @@
foreach "$indexed_hmitree/*"
| /* «@index» «@hmipath» */ "«substring(local-name(), 5)»"`if "position()!=last()" > ,`
- | ]
+ | ];
|
}
@@ -67,19 +67,20 @@
}
// Parses:
-// "HMI:WidgetType:param1:param2@path1@path2"
+// "HMI:WidgetType:param1:param2@path1,path1min,path1max@path2"
//
// Into:
// widget type="WidgetType" id="blah456" {
// arg value="param1";
// arg value="param2";
-// path value=".path1" index=".path1" type="PAGE_LOCAL";
+// path value=".path1" index=".path1" min="path1min" max="path1max" type="PAGE_LOCAL";
// path value="/path1" index="348" type="HMI_INT";
// path value="path4" index="path4" type="HMI_LOCAL";
// }
//
template "*", mode="parselabel" {
const "label","@inkscape:label";
+ const "id","@id";
const "description", "substring-after($label,'HMI:')";
const "_args", "substring-before($description,'@')";
@@ -95,7 +96,7 @@
}
if "$type" widget {
- attrib "id" > «@id»
+ attrib "id" > «$id»
attrib "type" > «$type»
foreach "str:split(substring-after($args, ':'), ':')" {
arg {
@@ -105,22 +106,35 @@
const "paths", "substring-after($description,'@')";
foreach "str:split($paths, '@')" {
if "string-length(.) > 0" path {
- attrib "value" > «.»
- const "path", ".";
- const "item", "$indexed_hmitree/*[@hmipath = $path]";
+ const "pathminmax", "str:split(.,',')";
+ const "path", "$pathminmax[1]";
+ const "pathminmaxcount", "count($pathminmax)";
+ attrib "value" > «$path»
choose {
- when "count($item) = 1" {
- attrib "index" > «$item/@index»
- attrib "type" > «local-name($item)»
+ when "$pathminmaxcount = 3" {
+ attrib "min" > «$pathminmax[2]»
+ attrib "max" > «$pathminmax[3]»
+ }
+ when "$pathminmaxcount = 2" {
+ error > Widget id:«$id» label:«$label» has wrong syntax of path section «$pathminmax»
+ }
+ }
+ choose {
+ when "regexp:test($path,'^\.[a-zA-Z0-9_]+')" {
+ attrib "type" > PAGE_LOCAL
+ }
+ when "regexp:test($path,'^[a-zA-Z0-9_]+')" {
+ attrib "type" > HMI_LOCAL
}
otherwise {
- choose {
- when "regexp:test($path,'^\.[a-zA-Z0-9_]+')" {
- attrib "type" > PAGE_LOCAL
- }
- when "regexp:test($path,'^[a-zA-Z0-9_]+')" {
- attrib "type" > HMI_LOCAL
- }
+ const "item", "$indexed_hmitree/*[@hmipath = $path]";
+ const "pathtype", "local-name($item)";
+ if "$pathminmaxcount = 3 and not($pathtype = 'HMI_INT' or $pathtype = 'HMI_REAL')" {
+ error > Widget id:«$id» label:«$label» path section «$pathminmax» use min and max on non mumeric value
+ }
+ if "count($item) = 1" {
+ attrib "index" > «$item/@index»
+ attrib "type" > «$pathtype»
}
}
}