svghmi/parse_labels.ysl2
author GP Orcullo <kinsamanka@gmail.com>
Fri, 28 Oct 2022 17:26:50 +0800
branchpython3
changeset 3761 479ba844ded8
parent 3595 375626e60b63
child 4024 f9c6bbf66eea
permissions -rw-r--r--
xmlclass.py: fix AttributeError
3221
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3205
diff changeset
     1
// parse_labels.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
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
     4
//  Parses:
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
     5
//  "HMI:WidgetType|freq:param1:param2@a=path1,path1min,path1max@b=path2#a+b>3"
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
     6
//
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
     7
//  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
     8
//  widget type="WidgetType" id="blah456" {
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
     9
//      arg value="param1";
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    10
//      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
    11
//      path value=".path1" index=".path1" min="path1min" max="path1max" type="PAGE_LOCAL";
3060
4d20b92282e3 SVGHMI: Documentation fix
Edouard Tisserant
parents: 3017
diff changeset
    12
//      path value="/path1" index="348" type="HMI_INT";
4d20b92282e3 SVGHMI: Documentation fix
Edouard Tisserant
parents: 3017
diff changeset
    13
//      path value="path4" index="path4" type="HMI_LOCAL";
2882
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    14
//  }
ac08a5d15c15 SVGHMI: moving comments
Edouard Tisserant
parents: 2877
diff changeset
    15
//
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    16
const "pathregex",!"'^(\w+=)?([^,=]+)([-.\d,]*)$'"!;
3236
e4e27c4efb96 SVGHMI: Extend widget labels parsing to allow expressing widget's accepted types in labels
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3230
diff changeset
    17
3579
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    18
const "newline" |
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    19
const "twonewlines", "concat($newline,$newline)";
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    20
3473
1202b47e7e63 SVGHMI: fix widget's update frequency forcing : syntax checking was enforcing unit and js code was using undefined variables
Edouard Tisserant
parents: 3455
diff changeset
    21
template "*", mode="parselabel"
3236
e4e27c4efb96 SVGHMI: Extend widget labels parsing to allow expressing widget's accepted types in labels
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3230
diff changeset
    22
{
3592
b2bdb8b433e0 SVGHMI: rename veriables in parse_labels.ysl2 for better readability
Edouard Tisserant
parents: 3579
diff changeset
    23
    const "label","@inkscape:label";
3579
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    24
    const "desc", "svg:desc";
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    25
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    26
    // add svg:desc field if continuation "\" marker is found at the end of label
3592
b2bdb8b433e0 SVGHMI: rename veriables in parse_labels.ysl2 for better readability
Edouard Tisserant
parents: 3579
diff changeset
    27
    const "len","string-length($label)";
b2bdb8b433e0 SVGHMI: rename veriables in parse_labels.ysl2 for better readability
Edouard Tisserant
parents: 3579
diff changeset
    28
    const "has_continuation", "substring($label,$len,1)='\\'";
b2bdb8b433e0 SVGHMI: rename veriables in parse_labels.ysl2 for better readability
Edouard Tisserant
parents: 3579
diff changeset
    29
    const "full_decl" choose{
3579
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    30
        when "$has_continuation" {
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    31
           const "_continuation", "substring-before($desc, $twonewlines)";
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    32
           const "continuation" choose {
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    33
               when "$_continuation" value "$_continuation";
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    34
               otherwise value "$desc";
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    35
           }
3592
b2bdb8b433e0 SVGHMI: rename veriables in parse_labels.ysl2 for better readability
Edouard Tisserant
parents: 3579
diff changeset
    36
           value "concat(substring($label,1,$len - 1),translate($continuation,$newline,''))";
3579
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    37
        }
3592
b2bdb8b433e0 SVGHMI: rename veriables in parse_labels.ysl2 for better readability
Edouard Tisserant
parents: 3579
diff changeset
    38
        otherwise value "$label";
3579
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    39
    }
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
    40
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
    41
    const "id","@id";
3259
76da573569a6 SVGHMI: UI: added prefill of arguments according to values in widget instance in library. Also added library's widget instance description to description field.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3236
diff changeset
    42
3592
b2bdb8b433e0 SVGHMI: rename veriables in parse_labels.ysl2 for better readability
Edouard Tisserant
parents: 3579
diff changeset
    43
    const "declaration", "substring-after($full_decl,'HMI:')";
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
    44
3592
b2bdb8b433e0 SVGHMI: rename veriables in parse_labels.ysl2 for better readability
Edouard Tisserant
parents: 3579
diff changeset
    45
    const "_args", "substring-before($declaration,'@')";
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
    46
    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
    47
        when "$_args" value "$_args";
3592
b2bdb8b433e0 SVGHMI: rename veriables in parse_labels.ysl2 for better readability
Edouard Tisserant
parents: 3579
diff changeset
    48
        otherwise value "$declaration";
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
    49
    }
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
    50
3408
13c5cac55ac7 SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
Edouard Tisserant
parents: 3259
diff changeset
    51
    const "_typefreq", "substring-before($args,':')";
13c5cac55ac7 SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
Edouard Tisserant
parents: 3259
diff changeset
    52
    const "typefreq" choose {
13c5cac55ac7 SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
Edouard Tisserant
parents: 3259
diff changeset
    53
        when "$_typefreq" value "$_typefreq";
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
    54
        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
    55
    }
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
    56
3412
04c4835ca376 SVGHMI: Fixed support for frequency parsing in widget label
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3408
diff changeset
    57
    const "freq", "substring-after($typefreq,'|')";
3408
13c5cac55ac7 SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
Edouard Tisserant
parents: 3259
diff changeset
    58
13c5cac55ac7 SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
Edouard Tisserant
parents: 3259
diff changeset
    59
    const "_type", "substring-before($typefreq,'|')";
13c5cac55ac7 SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
Edouard Tisserant
parents: 3259
diff changeset
    60
    const "type" choose {
13c5cac55ac7 SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
Edouard Tisserant
parents: 3259
diff changeset
    61
        when "$_type" value "$_type";
13c5cac55ac7 SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
Edouard Tisserant
parents: 3259
diff changeset
    62
        otherwise value "$typefreq";
13c5cac55ac7 SVGHMI: add syntax for widget update frequency in widget label: HMI:WidgetType|freq:arg0:arg1@path
Edouard Tisserant
parents: 3259
diff changeset
    63
    }
2886
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2885
diff changeset
    64
    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
    65
        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
    66
        attrib "type" > «$type»
3455
2716cd8e498d SVGHMI: Add support for forcing widget update frequency with period longer than a second. As an example, "HMI:Display|10s@/myvar" updates variable every 10 seconds.
Edouard Tisserant
parents: 3412
diff changeset
    67
        if "$freq" {
3473
1202b47e7e63 SVGHMI: fix widget's update frequency forcing : syntax checking was enforcing unit and js code was using undefined variables
Edouard Tisserant
parents: 3455
diff changeset
    68
            if "not(regexp:test($freq,'^[0-9]*(\.[0-9]+)?[smh]?'))" {
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    69
                error > Widget id:«$id» label:«$full_decl» has wrong syntax of frequency forcing «$freq»
3455
2716cd8e498d SVGHMI: Add support for forcing widget update frequency with period longer than a second. As an example, "HMI:Display|10s@/myvar" updates variable every 10 seconds.
Edouard Tisserant
parents: 3412
diff changeset
    70
            }
2716cd8e498d SVGHMI: Add support for forcing widget update frequency with period longer than a second. As an example, "HMI:Display|10s@/myvar" updates variable every 10 seconds.
Edouard Tisserant
parents: 3412
diff changeset
    71
            attrib "freq" > «$freq»
2716cd8e498d SVGHMI: Add support for forcing widget update frequency with period longer than a second. As an example, "HMI:Display|10s@/myvar" updates variable every 10 seconds.
Edouard Tisserant
parents: 3412
diff changeset
    72
        }
3595
375626e60b63 SVGHMI: rework Jump widget to cope with Enable Expressions.
Edouard Tisserant
parents: 3594
diff changeset
    73
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    74
        // find "#" + JS expr at the end
3593
122b1094b8e6 SVGHMI: preliminary implementation of a general enable bit for all widgets, using "#" at the end of widget declaration, and a "disabled" element that becomes visible instead of widget when disabled.
Edouard Tisserant
parents: 3592
diff changeset
    75
        const "tail", "substring-after($declaration,'@')";
122b1094b8e6 SVGHMI: preliminary implementation of a general enable bit for all widgets, using "#" at the end of widget declaration, and a "disabled" element that becomes visible instead of widget when disabled.
Edouard Tisserant
parents: 3592
diff changeset
    76
        const "taillen","string-length($tail)";
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    77
        const "has_enable", "contains($tail, '#')";
3593
122b1094b8e6 SVGHMI: preliminary implementation of a general enable bit for all widgets, using "#" at the end of widget declaration, and a "disabled" element that becomes visible instead of widget when disabled.
Edouard Tisserant
parents: 3592
diff changeset
    78
        const "paths" choose{
122b1094b8e6 SVGHMI: preliminary implementation of a general enable bit for all widgets, using "#" at the end of widget declaration, and a "disabled" element that becomes visible instead of widget when disabled.
Edouard Tisserant
parents: 3592
diff changeset
    79
            when "$has_enable" {
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    80
               value "substring-before($tail,'#')";
3593
122b1094b8e6 SVGHMI: preliminary implementation of a general enable bit for all widgets, using "#" at the end of widget declaration, and a "disabled" element that becomes visible instead of widget when disabled.
Edouard Tisserant
parents: 3592
diff changeset
    81
            }
122b1094b8e6 SVGHMI: preliminary implementation of a general enable bit for all widgets, using "#" at the end of widget declaration, and a "disabled" element that becomes visible instead of widget when disabled.
Edouard Tisserant
parents: 3592
diff changeset
    82
            otherwise value "$tail";
122b1094b8e6 SVGHMI: preliminary implementation of a general enable bit for all widgets, using "#" at the end of widget declaration, and a "disabled" element that becomes visible instead of widget when disabled.
Edouard Tisserant
parents: 3592
diff changeset
    83
        }
122b1094b8e6 SVGHMI: preliminary implementation of a general enable bit for all widgets, using "#" at the end of widget declaration, and a "disabled" element that becomes visible instead of widget when disabled.
Edouard Tisserant
parents: 3592
diff changeset
    84
        if "$has_enable" {
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    85
            const "enable_expr", "substring-after($tail,'#')";
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    86
            attrib "enable_expr" value "$enable_expr";
3593
122b1094b8e6 SVGHMI: preliminary implementation of a general enable bit for all widgets, using "#" at the end of widget declaration, and a "disabled" element that becomes visible instead of widget when disabled.
Edouard Tisserant
parents: 3592
diff changeset
    87
        }
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    88
3595
375626e60b63 SVGHMI: rework Jump widget to cope with Enable Expressions.
Edouard Tisserant
parents: 3594
diff changeset
    89
        foreach "str:split(substring-after($args, ':'), ':')" {
375626e60b63 SVGHMI: rework Jump widget to cope with Enable Expressions.
Edouard Tisserant
parents: 3594
diff changeset
    90
            arg {
375626e60b63 SVGHMI: rework Jump widget to cope with Enable Expressions.
Edouard Tisserant
parents: 3594
diff changeset
    91
                attrib "value" > «.»
375626e60b63 SVGHMI: rework Jump widget to cope with Enable Expressions.
Edouard Tisserant
parents: 3594
diff changeset
    92
            }
375626e60b63 SVGHMI: rework Jump widget to cope with Enable Expressions.
Edouard Tisserant
parents: 3594
diff changeset
    93
        }
375626e60b63 SVGHMI: rework Jump widget to cope with Enable Expressions.
Edouard Tisserant
parents: 3594
diff changeset
    94
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    95
        // for stricter syntax checking, this should make error
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    96
        // if $paths contains "@@" or ends with "@" (empty paths)
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
    97
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
        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
    99
            if "string-length(.) > 0" path {
3236
e4e27c4efb96 SVGHMI: Extend widget labels parsing to allow expressing widget's accepted types in labels
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3230
diff changeset
   100
                // 1 : global match
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   101
                // 2 : assign=
3236
e4e27c4efb96 SVGHMI: Extend widget labels parsing to allow expressing widget's accepted types in labels
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3230
diff changeset
   102
                // 2 : /path
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   103
                // 3 : min,max
3236
e4e27c4efb96 SVGHMI: Extend widget labels parsing to allow expressing widget's accepted types in labels
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3230
diff changeset
   104
                const "path_match", "regexp:match(.,$pathregex)";
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   105
                const "pathassign", "substring-before($path_match[2],'=')";
3236
e4e27c4efb96 SVGHMI: Extend widget labels parsing to allow expressing widget's accepted types in labels
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3230
diff changeset
   106
                const "pathminmax", "str:split($path_match[4],',')";
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   107
                const "path", "$path_match[3]";
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
   108
                const "pathminmaxcount", "count($pathminmax)";
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   109
                if "not($path)"
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   110
                    error > Widget id:«$id» label:«$full_decl» has wrong syntax
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   111
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   112
                attrib "value" value "$path";
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   113
                if "$pathassign"
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   114
                    attrib "assign" value "$pathassign";
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
   115
                choose {
3236
e4e27c4efb96 SVGHMI: Extend widget labels parsing to allow expressing widget's accepted types in labels
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3230
diff changeset
   116
                    when "$pathminmaxcount = 2" {
e4e27c4efb96 SVGHMI: Extend widget labels parsing to allow expressing widget's accepted types in labels
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3230
diff changeset
   117
                        attrib "min" > «$pathminmax[1]»
e4e27c4efb96 SVGHMI: Extend widget labels parsing to allow expressing widget's accepted types in labels
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3230
diff changeset
   118
                        attrib "max" > «$pathminmax[2]»
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
   119
                    }
3236
e4e27c4efb96 SVGHMI: Extend widget labels parsing to allow expressing widget's accepted types in labels
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3230
diff changeset
   120
                    when "$pathminmaxcount = 1 or $pathminmaxcount > 2" {
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   121
                        error > Widget id:«$id» label:«$full_decl» has wrong syntax of path section «$pathminmax»
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
   122
                    }
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
   123
                }
3229
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   124
                if "$indexed_hmitree" 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
   125
                    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
   126
                        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
   127
                    }
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
   128
                    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
   129
                        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
   130
                    }
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
   131
                    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
   132
                        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
   133
                        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
   134
                        if "$pathminmaxcount = 3 and not($pathtype = 'HMI_INT' or $pathtype = 'HMI_REAL')" {
3594
30f7eade322f SVGHMI: add support for "enable expressions" with arbitrary variable name assignment.
Edouard Tisserant
parents: 3593
diff changeset
   135
                            error > Widget id:«$id» label:«$full_decl» path section «$pathminmax» use min and max on non mumeric value
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
   136
                        }
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
                        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
   138
                            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
   139
                            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
   140
                        }
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
   141
                    }
2911
211d6a185e31 SVGHMI: More infrastructure for editing values with a keypad.
Edouard Tisserant
parents: 2904
diff changeset
   142
                }
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
   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
        }
3579
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
   145
        choose{
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
   146
            when "$has_continuation" {
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
   147
               const "_continuation", "substring-after($desc, $twonewlines)";
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
   148
               if "$_continuation"
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
   149
                       desc value "$_continuation";
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
   150
            }
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
   151
            otherwise
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
   152
                if "$desc" desc value "$desc/text()";
c5070b6973ba SVGHMI: add support for multiline widget declaration using svg:desc.
Edouard Tisserant
parents: 3503
diff changeset
   153
        }
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
   154
    }
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
   155
}
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
   156
3229
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   157
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   158
// Templates to generate label back from parsed tree
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   159
template "arg", mode="genlabel" > :«@value»
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   160
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   161
template "path", mode="genlabel" {
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   162
    > @«@value»
3230
95f07764991f SVGHMI: fixed typo
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3229
diff changeset
   163
    if "string-length(@min)>0 or string-length(@max)>0"  > ,«@min»,«@max»
3229
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   164
}
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   165
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   166
template "widget", mode="genlabel" {
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   167
    > HMI:«@type»
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   168
    apply "arg", mode="genlabel";
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   169
    apply "path", mode="genlabel";
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   170
}
c5be4fd425e7 SVGHMI: still quite naive path substitution whn prepearing widget for DnD, but now uses label generation.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
   171