svghmi/hmi_tree.ysl2
author Edouard Tisserant
Mon, 23 Mar 2020 15:13:36 +0100
branchsvghmi
changeset 2893 d57a12b8f5db
parent 2890 ae8063127e95
child 2894 4cf9ad35e6d0
permissions -rw-r--r--
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.
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
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
    17
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
    18
    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
    19
    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
    20
    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
    21
        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
    22
            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
    23
                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
    24
                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
    25
                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
    26
            }
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
    27
        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
    28
            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
    29
                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
    30
                    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
    31
                    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
    32
                    foreach "@*" xsl:copy;
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    33
                }
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
    34
                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
    35
                     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
    36
                     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
    37
                }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    38
            }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    39
            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
    40
                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
    41
                    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
    42
                    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
    43
                }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    44
            }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    45
        }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
    46
    }
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
    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
    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
    49
    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
    50
        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
    51
        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
    52
    }
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
    53
}
2874
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
    54
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
    55
def "func:get_hmi_tree_elt" {
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
    56
    param "path";
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
    57
    param "root", "$hmitree";
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
    58
    message > get_hmi_tree_elt «$path»
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
    59
    if "not(starts-with($path, '/'))" error > Given path "«$path»" should start with a "/"
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
    60
    const "stripped", "substring($path, 2)";
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
    61
    const "token" choose {
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
    62
        when "contains($stripped, '/')" value "substring-before($stripped, '/')";
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
    63
        otherwise value "$stripped";
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
    64
    }
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
    65
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
    66
    choose {
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
    67
        when "string-length($token) = 0"{
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
    68
            result "$root";
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
    69
        }
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
    70
        otherwise{
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
    71
            const "rest", "substring-after($stripped, $token)";
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
    72
            const "match", "$root/*[@name = $token]";
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
            choose {
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
    74
                when "string-length($rest) > 0"{
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
    75
                    result "func:get_hmi_tree_el($rest, $match)";
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
    76
                }
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
    77
                otherwise{
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
    78
                    result "$match";
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
    79
                }
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
    80
            }
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
    81
        }
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
    82
    }
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
    83
}
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
    84
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    85
//  Parses:
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    86
//  "HMI:WidgetType:param1:param2@path1@path2"
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    87
//
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    88
//  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
    89
//  widget type="WidgetType" id="blah456" {
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    90
//      arg value="param1";
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    91
//      arg value="param2";
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
    92
//      path value="path1" index="345";
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    93
//      path value="path2";
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    94
//  }
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    95
//
2886
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
    96
template "*", mode="parselabel" {
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
    97
    const "label","@inkscape:label";
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
    98
    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
    99
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
    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
   101
    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
   102
        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
   103
        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
   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 "_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
   107
    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
   108
        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
   109
        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
   110
    }
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
   111
2886
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   112
    if "$type" widget {
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   113
        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
   114
        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
   115
        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
   116
            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
   117
                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
   118
            }
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
   119
        }
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
   120
        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
   121
        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
   122
            if "string-length(.) > 0" path {
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
   123
                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
   124
                const "path", ".";
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
   125
                const "item", "$indexed_hmitree/*[@hmipath = $path]";
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
   126
                if "count($item) = 1"
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
   127
                    attrib "index" > «$item/@index»
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
   128
            }
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
   129
        }
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
   130
    }
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
   131
}
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
   132
2886
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   133
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
   134
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
   135
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   136
def "func:widget" {
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   137
    param "id";
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   138
    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
   139
}
f398896b7ebf SVGHMI: intermediate untested state. Excluded ForEach widget from pages handled widgets.
Edouard Tisserant
parents: 2882
diff changeset
   140
2886
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   141
2874
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   142
// Debug data
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   143
template "*", mode="testtree"{
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   144
    param "indent", "''";
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   145
    > «$indent» «local-name()» 
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   146
    foreach "@*" > «local-name()»="«.»" 
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   147
    > \n
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   148
    apply "*", mode="testtree" {
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   149
        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
   150
    };
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   151
}
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   152
function "debug_hmitree" {
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   153
    | Raw HMI tree
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   154
    apply "$hmitree", mode="testtree";
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   155
    |
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   156
    | Indexed HMI tree
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   157
    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
   158
    |
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   159
    | Parsed Widgets
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   160
    copy "_parsed_widgets";
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
   161
    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
   162
}
b67af0b8dc72 SVGHMI: more debug code moved to hmi_tree.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2873
diff changeset
   163
!debug_output_calls.append("debug_hmitree")