22 | var hmitree_types = [ |
22 | var hmitree_types = [ |
23 |
23 |
24 foreach "$indexed_hmitree/*" |
24 foreach "$indexed_hmitree/*" |
25 | /* «@index» «@hmipath» */ "«substring(local-name(), 5)»"`if "position()!=last()" > ,` |
25 | /* «@index» «@hmipath» */ "«substring(local-name(), 5)»"`if "position()!=last()" > ,` |
26 |
26 |
27 | ] |
27 | ]; |
28 | |
28 | |
29 } |
29 } |
30 |
30 |
31 template "*", mode="index" { |
31 template "*", mode="index" { |
32 param "index", "0"; |
32 param "index", "0"; |
65 with "parentpath" > «$parentpath» |
65 with "parentpath" > «$parentpath» |
66 } |
66 } |
67 } |
67 } |
68 |
68 |
69 // Parses: |
69 // Parses: |
70 // "HMI:WidgetType:param1:param2@path1@path2" |
70 // "HMI:WidgetType:param1:param2@path1,path1min,path1max@path2" |
71 // |
71 // |
72 // Into: |
72 // Into: |
73 // widget type="WidgetType" id="blah456" { |
73 // widget type="WidgetType" id="blah456" { |
74 // arg value="param1"; |
74 // arg value="param1"; |
75 // arg value="param2"; |
75 // arg value="param2"; |
76 // path value=".path1" index=".path1" type="PAGE_LOCAL"; |
76 // path value=".path1" index=".path1" min="path1min" max="path1max" type="PAGE_LOCAL"; |
77 // path value="/path1" index="348" type="HMI_INT"; |
77 // path value="/path1" index="348" type="HMI_INT"; |
78 // path value="path4" index="path4" type="HMI_LOCAL"; |
78 // path value="path4" index="path4" type="HMI_LOCAL"; |
79 // } |
79 // } |
80 // |
80 // |
81 template "*", mode="parselabel" { |
81 template "*", mode="parselabel" { |
82 const "label","@inkscape:label"; |
82 const "label","@inkscape:label"; |
|
83 const "id","@id"; |
83 const "description", "substring-after($label,'HMI:')"; |
84 const "description", "substring-after($label,'HMI:')"; |
84 |
85 |
85 const "_args", "substring-before($description,'@')"; |
86 const "_args", "substring-before($description,'@')"; |
86 const "args" choose { |
87 const "args" choose { |
87 when "$_args" value "$_args"; |
88 when "$_args" value "$_args"; |
93 when "$_type" value "$_type"; |
94 when "$_type" value "$_type"; |
94 otherwise value "$args"; |
95 otherwise value "$args"; |
95 } |
96 } |
96 |
97 |
97 if "$type" widget { |
98 if "$type" widget { |
98 attrib "id" > «@id» |
99 attrib "id" > «$id» |
99 attrib "type" > «$type» |
100 attrib "type" > «$type» |
100 foreach "str:split(substring-after($args, ':'), ':')" { |
101 foreach "str:split(substring-after($args, ':'), ':')" { |
101 arg { |
102 arg { |
102 attrib "value" > «.» |
103 attrib "value" > «.» |
103 } |
104 } |
104 } |
105 } |
105 const "paths", "substring-after($description,'@')"; |
106 const "paths", "substring-after($description,'@')"; |
106 foreach "str:split($paths, '@')" { |
107 foreach "str:split($paths, '@')" { |
107 if "string-length(.) > 0" path { |
108 if "string-length(.) > 0" path { |
108 attrib "value" > «.» |
109 const "pathminmax", "str:split(.,',')"; |
109 const "path", "."; |
110 const "path", "$pathminmax[1]"; |
110 const "item", "$indexed_hmitree/*[@hmipath = $path]"; |
111 const "pathminmaxcount", "count($pathminmax)"; |
|
112 attrib "value" > «$path» |
111 choose { |
113 choose { |
112 when "count($item) = 1" { |
114 when "$pathminmaxcount = 3" { |
113 attrib "index" > «$item/@index» |
115 attrib "min" > «$pathminmax[2]» |
114 attrib "type" > «local-name($item)» |
116 attrib "max" > «$pathminmax[3]» |
|
117 } |
|
118 when "$pathminmaxcount = 2" { |
|
119 error > Widget id:«$id» label:«$label» has wrong syntax of path section «$pathminmax» |
|
120 } |
|
121 } |
|
122 choose { |
|
123 when "regexp:test($path,'^\.[a-zA-Z0-9_]+')" { |
|
124 attrib "type" > PAGE_LOCAL |
|
125 } |
|
126 when "regexp:test($path,'^[a-zA-Z0-9_]+')" { |
|
127 attrib "type" > HMI_LOCAL |
115 } |
128 } |
116 otherwise { |
129 otherwise { |
117 choose { |
130 const "item", "$indexed_hmitree/*[@hmipath = $path]"; |
118 when "regexp:test($path,'^\.[a-zA-Z0-9_]+')" { |
131 const "pathtype", "local-name($item)"; |
119 attrib "type" > PAGE_LOCAL |
132 if "$pathminmaxcount = 3 and not($pathtype = 'HMI_INT' or $pathtype = 'HMI_REAL')" { |
120 } |
133 error > Widget id:«$id» label:«$label» path section «$pathminmax» use min and max on non mumeric value |
121 when "regexp:test($path,'^[a-zA-Z0-9_]+')" { |
134 } |
122 attrib "type" > HMI_LOCAL |
135 if "count($item) = 1" { |
123 } |
136 attrib "index" > «$item/@index» |
|
137 attrib "type" > «$pathtype» |
124 } |
138 } |
125 } |
139 } |
126 } |
140 } |
127 } |
141 } |
128 } |
142 } |