author | Edouard Tisserant |
Tue, 17 Mar 2020 14:01:37 +0100 | |
branch | svghmi |
changeset 2881 | 3bb49f93d48c |
parent 2880 | svghmi/gen_index_xhtml.ysl2@9da4ac0c9add |
permissions | -rw-r--r-- |
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
1 |
in xsl decl labels(*ptr, name="defs_by_labels") alias call-template { |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
2 |
with "hmi_element", "$hmi_element"; |
2810
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
3 |
with "labels"{text *ptr}; |
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
4 |
}; |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
5 |
|
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
6 |
in xsl decl optional_labels(*ptr, name="defs_by_labels") alias call-template { |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
7 |
with "hmi_element", "$hmi_element"; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
8 |
with "labels"{text *ptr}; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
9 |
with "mandatory","'no'"; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
10 |
}; |
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
11 |
|
2881 | 12 |
template "svg:*", mode="hmi_elements" { |
13 |
const "widget", "func:parselabel(@inkscape:label)/widget"; |
|
14 |
const "eltid","@id"; |
|
15 |
| "«@id»": { |
|
16 |
| type: "«$widget/@type»", |
|
17 |
| args: [ |
|
18 |
foreach "$widget/arg" |
|
19 |
| "«@value»"`if "position()!=last()" > ,` |
|
20 |
| ], |
|
21 |
| indexes: [ |
|
22 |
foreach "$widget/path" { |
|
23 |
choose { |
|
24 |
when "not(@index)" { |
|
25 |
warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree |
|
26 |
} |
|
27 |
otherwise { |
|
28 |
| «@index»`if "position()!=last()" > ,` |
|
2792
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
29 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
30 |
} |
0c0d3895b036
SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents:
2791
diff
changeset
|
31 |
} |
2881 | 32 |
| ], |
33 |
| element: id("«@id»"), |
|
34 |
apply "$widget", mode="widget_defs" with "hmi_element","."; |
|
35 |
| }`if "position()!=last()" > ,` |
|
36 |
} |
|
2810
63b9a37b73c7
SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents:
2808
diff
changeset
|
37 |
|
2793
2a97688c94c5
SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents:
2792
diff
changeset
|
38 |
|
2881 | 39 |
function "defs_by_labels" { |
40 |
param "labels","''"; |
|
41 |
param "mandatory","'yes'"; |
|
42 |
param "hmi_element"; |
|
43 |
const "widget_type","@type"; |
|
44 |
foreach "str:split($labels)" { |
|
45 |
const "name","."; |
|
46 |
const "elt_id","$result_svg_ns//*[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]/@id"; |
|
47 |
choose { |
|
48 |
when "not($elt_id)" { |
|
49 |
if "$mandatory='yes'" { |
|
50 |
// TODO FIXME error > «$widget_type» widget must have a «$name» element |
|
51 |
warning > «$widget_type» widget must have a «$name» element |
|
2834
6ac6a9dff594
SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents:
2833
diff
changeset
|
52 |
} |
2881 | 53 |
// otherwise produce nothing |
2797
c5ba1e77f054
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents:
2796
diff
changeset
|
54 |
} |
2881 | 55 |
otherwise { |
56 |
| «$name»_elt: id("«$elt_id»"), |
|
2836
ce6cecdb7320
SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents:
2834
diff
changeset
|
57 |
} |
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
58 |
} |
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
59 |
} |
2881 | 60 |
} |
2808
dc78ffa5253d
SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents:
2807
diff
changeset
|
61 |