svghmi/hmi_tree.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Tue, 09 Feb 2021 07:41:24 +0100
branchsvghmi
changeset 3127 d4dfd47f8156
parent 3097 a098b2dd9dff
child 3129 f2709923c82c
permissions -rw-r--r--
SVGHMI: Enforce formating HMI_LOCAL and PAGE_LOCAL variables until the end of variable name
2873
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
     1
// hmi_tree.ysl2
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
     2
2843
94696b3f69fb SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents: 2842
diff changeset
     3
2873
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
     4
// HMI Tree computed from VARIABLES.CSV in svghmi.py
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
     5
const "hmitree", "ns:GetHMITree()";
2853
6d39beb19f38 SVGHMI: whitespaces and comments
Edouard Tisserant
parents: 2852
diff changeset
     6
2877
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
     7
const "_categories" {
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
     8
    noindex > HMI_PLC_STATUS
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
     9
    noindex > HMI_CURRENT_PAGE
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    10
}
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    11
const "categories", "exsl:node-set($_categories)";
2867
901c89c0cc08 SVGHMI: unsignificant changes or changes in generated code
Edouard Tisserant
parents: 2866
diff changeset
    12
2873
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    13
// HMI Tree Index
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    14
const "_indexed_hmitree" apply "$hmitree", mode="index";
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    15
const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)";
2843
94696b3f69fb SVGHMI : still trying to optimize. Added xslt code to identitfy minimum set of elements needed by a particular page. Plan is to remove unseen/unused elements from the DOM, and re-appending them later when used, on page switch. Disabled previous optimization.
Edouard Tisserant
parents: 2842
diff changeset
    16
2941
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    17
emit "preamble:hmi-tree" {
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    18
    | var hmi_hash = [«$hmitree/@hash»];
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    19
    |
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    20
    | var heartbeat_index = «$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index»;
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    21
    |
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    22
    | var hmitree_types = [
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    23
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    24
    foreach "$indexed_hmitree/*" 
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    25
    |     /* «@index»  «@hmipath» */ "«substring(local-name(), 5)»"`if "position()!=last()" > ,`
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    26
3097
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
    27
    | ];
2941
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    28
    |
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    29
}
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    30
2873
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    31
template "*", mode="index" {
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    32
    param "index", "0";
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    33
    param "parentpath", "''";
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    34
    const "content" {
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    35
        const "path"
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    36
            choose {
2890
ae8063127e95 SVGHMI: make root HMI tree node a HMI_NODE, droped HMI_ROOT node type
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2886
diff changeset
    37
                when "count(ancestor::*)=0" > /
ae8063127e95 SVGHMI: make root HMI tree node a HMI_NODE, droped HMI_ROOT node type
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2886
diff changeset
    38
                when "count(ancestor::*)=1" > /«@name»
2873
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    39
                otherwise > «$parentpath»/«@name»
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    40
            }
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    41
        choose {
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    42
            when "not(local-name() = $categories/noindex)" {
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    43
                xsl:copy {
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    44
                    attrib "index" > «$index»
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    45
                    attrib "hmipath" > «$path»
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    46
                    foreach "@*" xsl:copy;
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    47
                }
2873
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    48
                apply "*[1]", mode="index"{
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    49
                     with "index", "$index + 1";
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    50
                     with "parentpath" > «$path»
2854
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    51
                }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    52
            }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    53
            otherwise {
2873
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    54
                apply "*[1]", mode="index"{
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    55
                    with "index", "$index";
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    56
                    with "parentpath" > «$path»
2854
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    57
                }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    58
            }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    59
        }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    60
    }
2842
2f73f001955a SVGHMI: attempt to optimize for webkit, because of really slow style recompute in svg:use : "unlink clones" (as in inkscape) but stop deep-copy when meeting a widget, and create a new clone instead.
Edouard Tisserant
parents: 2841
diff changeset
    61
2873
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    62
    copy "$content";
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    63
    apply "following-sibling::*[1]", mode="index" {
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    64
        with "index", "$index + count(exsl:node-set($content)/*)";
022db76c3bff SVGHMI : create hmi_tree.ysl2, rename bbox_intersect.ysl2 into geometry.ysl2 and move more code into. Add per included ysl2 file debug output.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2872
diff changeset
    65
        with "parentpath" > «$parentpath»
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
    66
    }
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    67
}
2874
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
    68
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    69
//  Parses:
3097
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
    70
//  "HMI:WidgetType:param1:param2@path1,path1min,path1max@path2"
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    71
//
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    72
//  Into:
2893
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2890
diff changeset
    73
//  widget type="WidgetType" id="blah456" {
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    74
//      arg value="param1";
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    75
//      arg value="param2";
3097
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
    76
//      path value=".path1" index=".path1" min="path1min" max="path1max" type="PAGE_LOCAL";
3060
4d20b92282e3 SVGHMI: Documentation fix
Edouard Tisserant
parents: 3017
diff changeset
    77
//      path value="/path1" index="348" type="HMI_INT";
4d20b92282e3 SVGHMI: Documentation fix
Edouard Tisserant
parents: 3017
diff changeset
    78
//      path value="path4" index="path4" type="HMI_LOCAL";
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    79
//  }
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    80
//
2886
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
    81
template "*", mode="parselabel" {
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
    82
    const "label","@inkscape:label";
3097
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
    83
    const "id","@id";
2877
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    84
    const "description", "substring-after($label,'HMI:')";
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    85
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    86
    const "_args", "substring-before($description,'@')";
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    87
    const "args" choose {
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    88
        when "$_args" value "$_args";
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    89
        otherwise value "$description";
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    90
    }
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    91
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    92
    const "_type", "substring-before($args,':')";
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    93
    const "type" choose {
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    94
        when "$_type" value "$_type";
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    95
        otherwise value "$args";
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    96
    }
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
    97
2886
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
    98
    if "$type" widget {
3097
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
    99
        attrib "id" > «$id»
2877
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   100
        attrib "type" > «$type»
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   101
        foreach "str:split(substring-after($args, ':'), ':')" {
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   102
            arg {
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   103
                attrib "value" > «.»
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   104
            }
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   105
        }
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   106
        const "paths", "substring-after($description,'@')";
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   107
        foreach "str:split($paths, '@')" {
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   108
            if "string-length(.) > 0" path {
3097
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   109
                const "pathminmax", "str:split(.,',')";
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   110
                const "path", "$pathminmax[1]";
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   111
                const "pathminmaxcount", "count($pathminmax)";
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   112
                attrib "value" > «$path»
3017
15e2df3e5610 SVGHMI: Intermediate state while implementing local HMI variables. Now write to cache only (no send), still need to implement dispatch on change.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
   113
                choose {
3097
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   114
                    when "$pathminmaxcount = 3" {
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   115
                        attrib "min" > «$pathminmax[2]»
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   116
                        attrib "max" > «$pathminmax[3]»
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   117
                    }
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   118
                    when "$pathminmaxcount = 2" {
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   119
                        error > Widget id:«$id» label:«$label» has wrong syntax of path section «$pathminmax»
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   120
                    }
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   121
                }
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   122
                choose {
3127
d4dfd47f8156 SVGHMI: Enforce formating HMI_LOCAL and PAGE_LOCAL variables until the end of variable name
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3097
diff changeset
   123
                    when "regexp:test($path,'^\.[a-zA-Z0-9_]+$')" {
3097
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   124
                        attrib "type" > PAGE_LOCAL
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   125
                    }
3127
d4dfd47f8156 SVGHMI: Enforce formating HMI_LOCAL and PAGE_LOCAL variables until the end of variable name
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3097
diff changeset
   126
                    when "regexp:test($path,'^[a-zA-Z0-9_]+$')" {
3097
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   127
                        attrib "type" > HMI_LOCAL
3017
15e2df3e5610 SVGHMI: Intermediate state while implementing local HMI variables. Now write to cache only (no send), still need to implement dispatch on change.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
   128
                    }
15e2df3e5610 SVGHMI: Intermediate state while implementing local HMI variables. Now write to cache only (no send), still need to implement dispatch on change.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
   129
                    otherwise {
3097
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   130
                        const "item", "$indexed_hmitree/*[@hmipath = $path]";
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   131
                        const "pathtype", "local-name($item)";
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   132
                        if "$pathminmaxcount = 3 and not($pathtype = 'HMI_INT' or $pathtype = 'HMI_REAL')" {
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   133
                            error > Widget id:«$id» label:«$label» path section «$pathminmax» use min and max on non mumeric value
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   134
                        }
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   135
                        if "count($item) = 1" {
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   136
                            attrib "index" > «$item/@index»
a098b2dd9dff SVGHMI: Added parsing of min and max value that can be given as @path,min,max in widget description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3060
diff changeset
   137
                            attrib "type" > «$pathtype»
3017
15e2df3e5610 SVGHMI: Intermediate state while implementing local HMI variables. Now write to cache only (no send), still need to implement dispatch on change.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
   138
                        }
15e2df3e5610 SVGHMI: Intermediate state while implementing local HMI variables. Now write to cache only (no send), still need to implement dispatch on change.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
   139
                    }
2911
211d6a185e31 SVGHMI: More infrastructure for editing values with a keypad.
Edouard Tisserant
parents: 2904
diff changeset
   140
                }
2877
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   141
            }
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   142
        }
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   143
    }
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   144
}
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2874
diff changeset
   145
2886
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   146
const "_parsed_widgets" apply "$hmi_elements", mode="parselabel";
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   147
const "parsed_widgets","exsl:node-set($_parsed_widgets)";
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   148
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   149
def "func:widget" {
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   150
    param "id";
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   151
    result "$parsed_widgets/widget[@id = $id]";
2885
f398896b7ebf SVGHMI: intermediate untested state. Excluded ForEach widget from pages handled widgets.
Edouard Tisserant
parents: 2882
diff changeset
   152
}
f398896b7ebf SVGHMI: intermediate untested state. Excluded ForEach widget from pages handled widgets.
Edouard Tisserant
parents: 2882
diff changeset
   153
2894
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
   154
def "func:is_descendant_path" {
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
   155
    param "descend";
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
   156
    param "ancest";
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
   157
    // TODO : use HMI tree to answer more accurately
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
   158
    result "string-length($ancest) > 0 and starts-with($descend,$ancest)";
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
   159
}
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
   160
2900
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2894
diff changeset
   161
def "func:same_class_paths" {
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2894
diff changeset
   162
    param "a";
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2894
diff changeset
   163
    param "b";
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2894
diff changeset
   164
    const "class_a", "$indexed_hmitree/*[@hmipath = $a]/@class";
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2894
diff changeset
   165
    const "class_b", "$indexed_hmitree/*[@hmipath = $b]/@class";
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2894
diff changeset
   166
    result "$class_a and $class_b and $class_a = $class_b";
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2894
diff changeset
   167
}
2894
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
   168
2874
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   169
// Debug data
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   170
template "*", mode="testtree"{
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   171
    param "indent", "''";
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   172
    > «$indent» «local-name()» 
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   173
    foreach "@*" > «local-name()»="«.»" 
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   174
    > \n
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   175
    apply "*", mode="testtree" {
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   176
        with "indent" value "concat($indent,'>')"
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   177
    };
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   178
}
2941
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
   179
2940
034b6ce4f885 SVGHMI: Introduced "emit" to simplify producing per-topic code and content from anywhere in code. Applied to debug output, next to JS.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2939
diff changeset
   180
emit "debug:hmi-tree" {
2874
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   181
    | Raw HMI tree
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   182
    apply "$hmitree", mode="testtree";
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   183
    |
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   184
    | Indexed HMI tree
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   185
    apply "$indexed_hmitree", mode="testtree";
2886
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   186
    |
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   187
    | Parsed Widgets
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   188
    copy "_parsed_widgets";
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   189
    apply "$parsed_widgets", mode="testtree";
2874
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   190
}