svghmi/hmi_tree.ysl2
branchsvghmi
changeset 2877 682bce953795
parent 2874 b67af0b8dc72
child 2882 ac08a5d15c15
equal deleted inserted replaced
2876:d2adbc273125 2877:682bce953795
     2 
     2 
     3 
     3 
     4 // HMI Tree computed from VARIABLES.CSV in svghmi.py
     4 // HMI Tree computed from VARIABLES.CSV in svghmi.py
     5 const "hmitree", "ns:GetHMITree()";
     5 const "hmitree", "ns:GetHMITree()";
     6 
     6 
       
     7 const "_categories" {
       
     8     noindex > HMI_ROOT
       
     9     noindex > HMI_PLC_STATUS
       
    10     noindex > HMI_CURRENT_PAGE
       
    11 }
       
    12 const "categories", "exsl:node-set($_categories)";
     7 
    13 
     8 // HMI Tree Index
    14 // HMI Tree Index
     9 const "_indexed_hmitree" apply "$hmitree", mode="index";
    15 const "_indexed_hmitree" apply "$hmitree", mode="index";
    10 const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)";
    16 const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)";
    11 
    17 
    44         with "index", "$index + count(exsl:node-set($content)/*)";
    50         with "index", "$index + count(exsl:node-set($content)/*)";
    45         with "parentpath" > «$parentpath»
    51         with "parentpath" > «$parentpath»
    46     }
    52     }
    47 }
    53 }
    48 
    54 
       
    55 def "func:parselabel" {
       
    56     param "label";
       
    57     const "description", "substring-after($label,'HMI:')";
       
    58 
       
    59     const "_args", "substring-before($description,'@')";
       
    60     const "args" choose {
       
    61         when "$_args" value "$_args";
       
    62         otherwise value "$description";
       
    63     }
       
    64 
       
    65     const "_type", "substring-before($args,':')";
       
    66     const "type" choose {
       
    67         when "$_type" value "$_type";
       
    68         otherwise value "$args";
       
    69     }
       
    70 
       
    71     const "ast" if "$type" widget {
       
    72         attrib "type" > «$type»
       
    73         foreach "str:split(substring-after($args, ':'), ':')" {
       
    74             arg {
       
    75                 attrib "value" > «.»
       
    76             }
       
    77         }
       
    78         const "paths", "substring-after($description,'@')";
       
    79         foreach "str:split($paths, '@')" {
       
    80             if "string-length(.) > 0" path {
       
    81                 attrib "value" > «.»
       
    82                 const "path", ".";
       
    83                 const "item", "$indexed_hmitree/*[@hmipath = $path]";
       
    84                 if "count($item) = 1"
       
    85                     attrib "index" > «$item/@index»
       
    86             }
       
    87         }
       
    88     }
       
    89 
       
    90     result "exsl:node-set($ast)";
       
    91 }
       
    92 
    49 // Debug data
    93 // Debug data
    50 template "*", mode="testtree"{
    94 template "*", mode="testtree"{
    51     param "indent", "''";
    95     param "indent", "''";
    52     > «$indent» «local-name()» 
    96     > «$indent» «local-name()» 
    53     foreach "@*" > «local-name()»="«.»" 
    97     foreach "@*" > «local-name()»="«.»"