svghmi/widgets_common.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Thu, 24 Dec 2020 17:00:43 +0100
branchsvghmi
changeset 3098 5823b73b132f
parent 3058 6ea4b7e1a9ed
child 3099 c7d14130401f
permissions -rw-r--r--
SVGHMI: decoupled operation string evaluation from HMI variable uptdate in change_hmi_variable(), paving the way for min/max boundaries enforcement
2884
50b9832c51fc SVGHMI: update Makefile to pick all changes to any dependency
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2883
diff changeset
     1
// widgets_common.ysl2
50b9832c51fc SVGHMI: update Makefile to pick all changes to any dependency
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2883
diff changeset
     2
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
     3
in xsl decl labels(*ptr, name="defs_by_labels") alias call-template {
dc78ffa5253d SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents: 2807
diff changeset
     4
    with "hmi_element", "$hmi_element";
2810
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
     5
    with "labels"{text *ptr};
2937
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
     6
    content;
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
     7
};
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
     8
2937
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
     9
decl optional_labels(*ptr) alias - {
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
    10
    /* TODO add some per label xslt variable to check if exist */
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
    11
    labels(*ptr){
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
    12
        with "mandatory","'no'";
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
    13
        content;
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
    14
    }
2836
ce6cecdb7320 SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents: 2834
diff changeset
    15
};
ce6cecdb7320 SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents: 2834
diff changeset
    16
2937
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
    17
decl activable_labels(*ptr) alias - {
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
    18
    optional_labels(*ptr) {
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
    19
        with "subelements","'active inactive'";
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
    20
        content;
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2920
diff changeset
    21
    }
2920
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
    22
};
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
    23
2955
64e603b84aa3 SVGHMI: Exclude non-widget HMI:* labeled elements from hmi_widget. Namely : HMI:Page HMI:Lang and HMI:List have been excluded.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2954
diff changeset
    24
template "svg:*", mode="hmi_widgets" {
2886
6c82fad8be65 SVGHMI: Simplification and optimization. func:parselabel becomes a template.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2884
diff changeset
    25
    const "widget", "func:widget(@id)";
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
    26
    const "eltid","@id";
3024
Edouard Tisserant
parents: 3022 3019
diff changeset
    27
    const "args" foreach "$widget/arg" > "«func:escape_quotes(@value)»"`if "position()!=last()" > ,`
2950
1e53d8b60ee9 SVGHMI: Parameters common to all widget constructors now passed as ordered parameters.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2949
diff changeset
    28
    const "indexes" foreach "$widget/path" {
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
    29
        choose {
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
    30
            when "not(@index)" {
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: 3007
diff changeset
    31
                choose {
3058
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
    32
                    when "not(@type)" {
3056
827bf284feec Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents: 3026
diff changeset
    33
                        warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree
3058
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
    34
                        > undefined`if "position()!=last()" > ,`
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
    35
                    }
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: 3007
diff changeset
    36
                    when "@type = 'PAGE_LOCAL'" 
3025
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
    37
                        > "«@value»"`if "position()!=last()" > ,`
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: 3007
diff changeset
    38
                    when "@type = 'HMI_LOCAL'" 
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: 3007
diff changeset
    39
                        > hmi_local_index("«@value»")`if "position()!=last()" > ,`
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: 3007
diff changeset
    40
                }
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
    41
            }
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
    42
            otherwise {
2950
1e53d8b60ee9 SVGHMI: Parameters common to all widget constructors now passed as ordered parameters.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2949
diff changeset
    43
                > «@index»`if "position()!=last()" > ,`
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    44
            }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    45
        }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    46
    }
2950
1e53d8b60ee9 SVGHMI: Parameters common to all widget constructors now passed as ordered parameters.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2949
diff changeset
    47
1e53d8b60ee9 SVGHMI: Parameters common to all widget constructors now passed as ordered parameters.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2949
diff changeset
    48
    |   "«@id»": new «$widget/@type»Widget ("«@id»",[«$args»],[«$indexes»],{
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
    49
    apply "$widget", mode="widget_defs" with "hmi_element",".";
2949
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
    50
    |   })`if "position()!=last()" > ,`
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
    51
}
2948
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    52
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    53
def "func:unique_types" {
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    54
    param "elts_with_type";
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    55
    choose {
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    56
        when "count($elts_with_type) > 1" {
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    57
            const "prior_results","func:unique_types($elts_with_type[position()!=last()])";
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    58
            choose {
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    59
                when "$elts_with_type[last()][@type = $prior_results/@type]"{
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    60
                    // type already in
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    61
                    result "$prior_results";
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    62
                }
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    63
                otherwise {
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    64
                    result "$prior_results | $elts_with_type[last()]";
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    65
                }
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    66
            }
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    67
        }
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    68
        otherwise {
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    69
            result "$elts_with_type";
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    70
        }
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    71
    }
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    72
}
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
    73
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: 3007
diff changeset
    74
emit "preamble:local-variable-indexes" {
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: 3007
diff changeset
    75
    ||
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: 3007
diff changeset
    76
    let hmi_locals = {};
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: 3007
diff changeset
    77
    var last_remote_index = hmitree_types.length - 1;
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: 3007
diff changeset
    78
    var next_available_index = hmitree_types.length;
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: 3007
diff changeset
    79
3025
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
    80
    const local_defaults = {
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
    81
    ||
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
    82
    foreach "$parsed_widgets/widget[@type = 'VarInit']"{
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
    83
        if "count(path) != 1" error > VarInit «@id» must have only one variable given.
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
    84
        if "path/@type != 'PAGE_LOCAL' and path/@type != 'HMI_LOCAL'" error > VarInit «@id» only applies to HMI variable.
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
    85
        | "«path/@value»":«arg[1]/@value»`if "position()!=last()" > ,`
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
    86
    }
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
    87
    ||
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
    88
    };
3022
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
    89
    var cache = hmitree_types.map(_ignored => undefined);
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
    90
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: 3007
diff changeset
    91
    function page_local_index(varname, pagename){
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: 3007
diff changeset
    92
        let pagevars = hmi_locals[pagename];
3022
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
    93
        let new_index;
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: 3007
diff changeset
    94
        if(pagevars == undefined){
3022
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
    95
            new_index = next_available_index++;
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
    96
            hmi_locals[pagename] = {[varname]:new_index}
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: 3007
diff changeset
    97
        } else {
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: 3007
diff changeset
    98
            let result = pagevars[varname];
3022
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
    99
            if(result != undefined) {
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
   100
                return result;
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
   101
            }
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
   102
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
   103
            new_index = next_available_index++;
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
   104
            pagevars[varname] = new_index;
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
   105
        }
3025
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   106
        let defaultval = local_defaults[varname];
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   107
        if(defaultval != undefined) 
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   108
            cache[new_index] = defaultval; 
3022
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
   109
        return new_index;
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: 3007
diff changeset
   110
    }
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: 3007
diff changeset
   111
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: 3007
diff changeset
   112
    function hmi_local_index(varname){
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: 3007
diff changeset
   113
        return page_local_index(varname, "HMI_LOCAL");
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: 3007
diff changeset
   114
    }
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: 3007
diff changeset
   115
    ||
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: 3007
diff changeset
   116
}
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: 3007
diff changeset
   117
2949
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   118
emit "preamble:widget-base-class" {
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: 3007
diff changeset
   119
    ||
3019
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   120
    var pending_widget_animates = [];
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   121
2949
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   122
    class Widget {
2963
113e2f2e324d SVGHMI: more Widget properties declared ES6 style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2958
diff changeset
   123
        offset = 0;
113e2f2e324d SVGHMI: more Widget properties declared ES6 style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2958
diff changeset
   124
        frequency = 10; /* FIXME arbitrary default max freq. Obtain from config ? */
2980
2a21d6060d64 SVGHMI: add "unsubscribable" property to widgets in order to generalize what already happens for jump buttons.
Edouard Tisserant
parents: 2963
diff changeset
   125
        unsubscribable = false;
3019
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   126
        pending_animate = false;
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   127
2950
1e53d8b60ee9 SVGHMI: Parameters common to all widget constructors now passed as ordered parameters.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2949
diff changeset
   128
        constructor(elt_id,args,indexes,members){
2958
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2955
diff changeset
   129
            this.element_id = elt_id;
2950
1e53d8b60ee9 SVGHMI: Parameters common to all widget constructors now passed as ordered parameters.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2949
diff changeset
   130
            this.element = id(elt_id);
1e53d8b60ee9 SVGHMI: Parameters common to all widget constructors now passed as ordered parameters.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2949
diff changeset
   131
            this.args = args;
1e53d8b60ee9 SVGHMI: Parameters common to all widget constructors now passed as ordered parameters.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2949
diff changeset
   132
            this.indexes = indexes;
2949
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   133
            Object.keys(members).forEach(prop => this[prop]=members[prop]);
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   134
        }
2958
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2955
diff changeset
   135
2951
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   136
        unsub(){
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   137
            /* remove subsribers */
3005
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   138
            if(!this.unsubscribable)
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   139
                for(let i = 0; i < this.indexes.length; i++) {
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   140
                    let index = this.indexes[i];
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   141
                    if(this.relativeness[i])
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   142
                        index += this.offset;
3022
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
   143
                    subscribers(index).delete(this);
3005
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   144
                }
2951
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   145
            this.offset = 0;
3005
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   146
            this.relativeness = undefined;
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   147
        }
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   148
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: 3007
diff changeset
   149
        sub(new_offset=0, relativeness, container_id){
2951
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   150
            this.offset = new_offset;
3005
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   151
            this.relativeness = relativeness;
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: 3007
diff changeset
   152
            this.container_id = container_id ;
2951
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   153
            /* add this's subsribers */
3005
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   154
            if(!this.unsubscribable)
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   155
                for(let i = 0; i < this.indexes.length; i++) {
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: 3007
diff changeset
   156
                    let index = this.get_variable_index(i);
3058
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
   157
                    if(index == undefined) continue;
3022
f6fe42b7ce60 SVGHMI: finished initial implementation of PAGE_LOCAL and HMI_LOCAL variables.
Edouard Tisserant
parents: 3017
diff changeset
   158
                    subscribers(index).add(this);
3005
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3004
diff changeset
   159
                }
2951
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   160
            need_cache_apply.push(this); 
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   161
        }
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   162
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   163
        apply_cache() {
3025
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   164
            if(!this.unsubscribable) for(let index in this.indexes){
2951
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   165
                /* dispatch current cache in newly opened page widgets */
3024
Edouard Tisserant
parents: 3022 3019
diff changeset
   166
                let realindex = this.get_variable_index(index);
3058
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
   167
                if(realindex == undefined) continue;
2951
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   168
                let cached_val = cache[realindex];
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   169
                if(cached_val != undefined)
3026
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   170
                    this._dispatch(cached_val, cached_val, index);
2951
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   171
            }
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   172
        }
506fe9272660 SVGHMI: Widget's specific sub/unsub traits are now wxpressed in widget's class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2950
diff changeset
   173
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: 3007
diff changeset
   174
        get_variable_index(varnum) {
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: 3007
diff changeset
   175
            let index = this.indexes[varnum];
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: 3007
diff changeset
   176
            if(typeof(index) == "string"){
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: 3007
diff changeset
   177
                index = page_local_index(index, this.container_id);
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: 3007
diff changeset
   178
            } else {
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: 3007
diff changeset
   179
                if(this.relativeness[varnum]){
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: 3007
diff changeset
   180
                    index += this.offset;
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: 3007
diff changeset
   181
                }
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: 3007
diff changeset
   182
            }
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: 3007
diff changeset
   183
            return index;
3001
003fd80ff0b8 SVGHMI: add get_idx(index) to widget objects to factorize a bit code repeated accross widgets. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2997
diff changeset
   184
        }
3098
5823b73b132f SVGHMI: decoupled operation string evaluation from HMI variable uptdate in change_hmi_variable(), paving the way for min/max boundaries enforcement
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3058
diff changeset
   185
3058
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
   186
        change_hmi_value(index, opstr) {
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
   187
            let realindex = this.get_variable_index(index);
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
   188
            if(realindex == undefined) return undefined;
3098
5823b73b132f SVGHMI: decoupled operation string evaluation from HMI variable uptdate in change_hmi_variable(), paving the way for min/max boundaries enforcement
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3058
diff changeset
   189
            let old_val = cache[realindex];
5823b73b132f SVGHMI: decoupled operation string evaluation from HMI variable uptdate in change_hmi_variable(), paving the way for min/max boundaries enforcement
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3058
diff changeset
   190
            let new_val = eval_operation_string(old_val, opstr);
5823b73b132f SVGHMI: decoupled operation string evaluation from HMI variable uptdate in change_hmi_variable(), paving the way for min/max boundaries enforcement
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3058
diff changeset
   191
            return apply_hmi_value(realindex, new_val);
3004
705e34c6fe93 SVGHMI: More JS code refactoring : change_hmi_value and apply_hmi_value now methods of widget class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3001
diff changeset
   192
        }
705e34c6fe93 SVGHMI: More JS code refactoring : change_hmi_value and apply_hmi_value now methods of widget class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3001
diff changeset
   193
705e34c6fe93 SVGHMI: More JS code refactoring : change_hmi_value and apply_hmi_value now methods of widget class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3001
diff changeset
   194
        apply_hmi_value(index, new_val) {
3058
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
   195
            let realindex = this.get_variable_index(index);
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
   196
            if(realindex == undefined) return undefined;
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
   197
            return apply_hmi_value(realindex, new_val);
3004
705e34c6fe93 SVGHMI: More JS code refactoring : change_hmi_value and apply_hmi_value now methods of widget class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3001
diff changeset
   198
        }
3006
bbffdefd2eed SVGHMI: JS refactoring continued : "dispatch_value_to_widget" becomes widget class member "new_hmi_value" (was also broken by previous relativeness commit)
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3005
diff changeset
   199
bbffdefd2eed SVGHMI: JS refactoring continued : "dispatch_value_to_widget" becomes widget class member "new_hmi_value" (was also broken by previous relativeness commit)
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3005
diff changeset
   200
        new_hmi_value(index, value, oldval) {
3025
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   201
            // TODO avoid searching, store index at sub()
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   202
            for(let i = 0; i < this.indexes.length; i++) {
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   203
                let refindex = this.get_variable_index(i);
3058
6ea4b7e1a9ed Merge + fix side effects of making warning instead of errors in case of missing HMI variable
Edouard Tisserant
parents: 3040 3056
diff changeset
   204
                if(refindex == undefined) continue;
3025
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   205
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   206
                if(index == refindex) {
3026
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   207
                    this._dispatch(value, oldval, i);
3025
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   208
                    break;
48e7e336c052 SVGHMI: HMI:VarInit:"a string"@a_value : empty widget (i.e. empty svg:group) that initialize content of local variables to value given as first argument.
Edouard Tisserant
parents: 3024
diff changeset
   209
                }
3006
bbffdefd2eed SVGHMI: JS refactoring continued : "dispatch_value_to_widget" becomes widget class member "new_hmi_value" (was also broken by previous relativeness commit)
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3005
diff changeset
   210
            }
bbffdefd2eed SVGHMI: JS refactoring continued : "dispatch_value_to_widget" becomes widget class member "new_hmi_value" (was also broken by previous relativeness commit)
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3005
diff changeset
   211
        }
3019
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   212
        
3026
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   213
        _dispatch(value, oldval, varnum) {
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   214
            let dispatch = this.dispatch;
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   215
            if(dispatch != undefined){
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   216
                try {
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   217
                    dispatch.call(this, value, oldval, varnum);
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   218
                } catch(err) {
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   219
                    console.log(err);
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   220
                }
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   221
            }
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   222
        }
d454ed480c0f SVGHMI: factorize dispatch calling logic.
Edouard Tisserant
parents: 3025
diff changeset
   223
3019
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   224
        _animate(){
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   225
            this.animate();
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   226
            this.pending_animate = false;
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   227
        }
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   228
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   229
        request_animate(){
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   230
            if(!this.pending_animate){
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   231
                pending_widget_animates.push(this);
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   232
                this.pending_animate = true;
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   233
                requestHMIAnimation();
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   234
            }
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   235
497aac6522a3 SVGHMI: provide request_animate() to Widget authors so that they can register redraw code when events lead to redraw. Widget member animate() is called when it is time to update DOM.
Edouard Tisserant
parents: 3007
diff changeset
   236
        }
2949
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   237
    }
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   238
    ||
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   239
}
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   240
3007
360300a8b995 SVGHMI : have to move some JS declarations from "preamble" to "declarations" and others from "declarations" to "definitions" section to make room for JS libraries that would be used by widget classes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3006
diff changeset
   241
emit "declarations:hmi-classes" {
2948
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
   242
    const "used_widget_types", "func:unique_types($parsed_widgets/widget)";
faaf677ea99d SVGHMI: Add an exslt function to collect used widget types, in order to only include necessary JS definitions in furure changes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2941
diff changeset
   243
    apply "$used_widget_types", mode="widget_class";
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   244
}
2810
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
   245
2949
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   246
template "widget", mode="widget_class"
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   247
||
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   248
class «@type»Widget extends Widget{
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   249
    /* empty class, as «@type» widget didn't provide any */
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   250
}
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   251
||
e50908ddec60 SVGHMI: One class per widget type, widget objects are instances of these classes, and members are passed through constructor. This allows to keep compatible with previous widget_defs template used in most widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2948
diff changeset
   252
3024
Edouard Tisserant
parents: 3022 3019
diff changeset
   253
const "excluded_types", "str:split('Page Lang VarInit')";
Edouard Tisserant
parents: 3022 3019
diff changeset
   254
const "included_ids","$parsed_widgets/widget[not(@type = $excluded_types)]/@id";
2955
64e603b84aa3 SVGHMI: Exclude non-widget HMI:* labeled elements from hmi_widget. Namely : HMI:Page HMI:Lang and HMI:List have been excluded.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2954
diff changeset
   255
3007
360300a8b995 SVGHMI : have to move some JS declarations from "preamble" to "declarations" and others from "declarations" to "definitions" section to make room for JS libraries that would be used by widget classes.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3006
diff changeset
   256
emit "declarations:hmi-elements" {
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: 2937
diff changeset
   257
    | var hmi_widgets = {
3024
Edouard Tisserant
parents: 3022 3019
diff changeset
   258
    apply "$hmi_elements[@id = $included_ids]", mode="hmi_widgets";
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: 2937
diff changeset
   259
    | }
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: 2937
diff changeset
   260
}
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: 2937
diff changeset
   261
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   262
function "defs_by_labels" {
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   263
    param "labels","''";
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   264
    param "mandatory","'yes'";
2920
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   265
    param "subelements","/..";
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   266
    param "hmi_element";
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   267
    const "widget_type","@type";
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   268
    foreach "str:split($labels)" {
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   269
        const "name",".";
2920
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   270
        const "elt","$result_svg_ns//*[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]";
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   271
        choose {
2920
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   272
            when "not($elt/@id)" {
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   273
                if "$mandatory='yes'" {
2920
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   274
                    error > «$widget_type» widget must have a «$name» element
2834
6ac6a9dff594 SVGHMI: be a bit more tolerant with missing HMI paths or missing elements in widgets : continue build (with warning) and fail silently at runtime.
Edouard Tisserant
parents: 2833
diff changeset
   275
                }
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   276
                // otherwise produce nothing
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   277
            }
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   278
            otherwise {
2920
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   279
                |     «$name»_elt: id("«$elt/@id»"),
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   280
                if "$subelements" {
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   281
                |     «$name»_sub: {
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   282
                    foreach "str:split($subelements)" {
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   283
                        const "subname",".";
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   284
                        const "subelt","$elt/*[@inkscape:label=$subname][1]";
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   285
                        choose {
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   286
                            when "not($subelt/@id)" {
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   287
                                if "$mandatory='yes'" {
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   288
                                    error > «$widget_type» widget must have a «$name»/«$subname» element
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   289
                                }
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   290
                |         /* missing «$name»/«$subname» element */
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   291
                            }
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   292
                            otherwise {
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   293
                |         "«$subname»": id("«$subelt/@id»")`if "position()!=last()" > ,`
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   294
                            }
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   295
                        }
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   296
                    }
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   297
                |     },
3ee337c8c769 SVGHMI: finished shift and capslock support n keypad widget. Added a helper in widgets_common to collect subelements likle active/inactive/disabled...
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   298
                }
2836
ce6cecdb7320 SVGHMI : still behave, even if important things are missing in SVG widget definitions (ex: needle missing for Meter widget)
Edouard Tisserant
parents: 2834
diff changeset
   299
            }
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
   300
        }
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
   301
    }
2881
3bb49f93d48c SVGHMI: added widget_common.ysl2
Edouard Tisserant
parents: 2880
diff changeset
   302
}
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
   303
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   304
def "func:escape_quotes" {
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   305
    param "txt";
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   306
    // have to use a python string to enter escaped quote
3024
Edouard Tisserant
parents: 3022 3019
diff changeset
   307
    // const "frstln", "string-length($frst)";
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   308
    choose {
3024
Edouard Tisserant
parents: 3022 3019
diff changeset
   309
        when !"contains($txt,'\"')"! {
Edouard Tisserant
parents: 3022 3019
diff changeset
   310
            result !"concat(substring-before($txt,'\"'),'\\\"',func:escape_quotes(substring-after($txt,'\"')))"!;
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   311
        }
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   312
        otherwise {
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   313
            result "$txt";
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   314
        }
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   315
    }
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   316
}
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2881
diff changeset
   317