svghmi/widget_input.ysl2
author Edouard Tisserant
Fri, 21 Oct 2022 10:39:43 +0200
changeset 3648 ff42600fddd7
parent 3536 4ee33be5b8b6
child 3706 39ae17a1cabe
permissions -rw-r--r--
SVGHMI: add automatic reconnection of websocket with 1s reconnection delay after first attempt.
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: 2882
diff changeset
     1
// widget_input.ysl2
2779
75c6a31caca6 SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents: 2763
diff changeset
     2
3233
315f17e74ef5 SVGHMI: Added widget_desc to declare widget signature and description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     3
widget_desc("Input") {
315f17e74ef5 SVGHMI: Added widget_desc to declare widget signature and description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     4
    longdesc
315f17e74ef5 SVGHMI: Added widget_desc to declare widget signature and description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     5
    || 
315f17e74ef5 SVGHMI: Added widget_desc to declare widget signature and description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     6
    Input widget takes one variable path, and displays current value in
3241
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3233
diff changeset
     7
    optional "value" labeled sub-element. 
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3233
diff changeset
     8
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3233
diff changeset
     9
    Click on optional "edit" labeled element opens keypad to edit value.
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3233
diff changeset
    10
    
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3233
diff changeset
    11
    Operation on current value is performed when click on sub-elements with
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3233
diff changeset
    12
    label starting with '=', '+' or '-' sign. Value after sign is used as
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3233
diff changeset
    13
    operand.
3233
315f17e74ef5 SVGHMI: Added widget_desc to declare widget signature and description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    14
    ||
3100
c51f9cf365c6 SVGHMI: Input widget overrides undershot() and overshot() methods to display "min: xxx" or "max: xxx" when user input goes out of given range.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3094
diff changeset
    15
3233
315f17e74ef5 SVGHMI: Added widget_desc to declare widget signature and description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    16
    shortdesc > Input field with predefined operation buttons
3100
c51f9cf365c6 SVGHMI: Input widget overrides undershot() and overshot() methods to display "min: xxx" or "max: xxx" when user input goes out of given range.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3094
diff changeset
    17
3241
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3233
diff changeset
    18
    arg name="format" accepts="string" > optional printf-like format 
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    19
3241
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3233
diff changeset
    20
    path name="edit" accepts="HMI_INT, HMI_REAL, HMI_STRING" > single variable to edit
3233
315f17e74ef5 SVGHMI: Added widget_desc to declare widget signature and description
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    21
    
3094
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    22
}
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    23
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    24
widget_class("Input")
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    25
||
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    26
     on_op_click(opstr) {
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    27
         this.change_hmi_value(0, opstr);
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    28
     }
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    29
     edit_callback(new_val) {
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    30
         this.apply_hmi_value(0, new_val);
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    31
     }
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    32
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    33
     is_inhibited = false;
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    34
     alert(msg){
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    35
         this.is_inhibited = true;
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    36
         this.display = msg;
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    37
         setTimeout(() => this.stopalert(), 1000);
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    38
         this.request_animate();
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    39
     }
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    40
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    41
     stopalert(){
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    42
         this.is_inhibited = false;
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    43
         this.display = this.last_value;
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    44
         this.request_animate();
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    45
     }
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    46
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    47
     overshot(new_val, max) {
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    48
         this.alert("max");
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    49
     }
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    50
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    51
     undershot(new_val, min) {
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    52
         this.alert("min");
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    53
     }
3523
13282f91e6ff SVGHMI: set initial displayed value of input widget to empty string.
Edouard Tisserant
parents: 3241
diff changeset
    54
13282f91e6ff SVGHMI: set initial displayed value of input widget to empty string.
Edouard Tisserant
parents: 3241
diff changeset
    55
     display = "";
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    56
||
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    57
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3188
diff changeset
    58
widget_defs("Input") {
3094
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    59
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    60
    const "value_elt" optional_labels("value");
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: 2882
diff changeset
    61
    const "have_value","string-length($value_elt)>0";
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: 2882
diff changeset
    62
    value "$value_elt";
3094
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    63
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    64
    const "edit_elt" optional_labels("edit");
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    65
    const "have_edit","string-length($edit_elt)>0";
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    66
    value "$edit_elt";
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    67
3536
4ee33be5b8b6 SVGHMI: fix js exception because of trying to find already detached elements by id.
Edouard Tisserant
parents: 3523
diff changeset
    68
    const "action_elements", "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]";
4ee33be5b8b6 SVGHMI: fix js exception because of trying to find already detached elements by id.
Edouard Tisserant
parents: 3523
diff changeset
    69
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: 2882
diff changeset
    70
    if "$have_value"
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: 2882
diff changeset
    71
    |     frequency: 5,
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: 2882
diff changeset
    72
    |     dispatch: function(value) {
3094
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    73
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    74
3155
99ce78ddd353 SVGHMI: finally found why HMI:Input wasnt't initializing properly: vsprintf takes a list. Also, removed intermediate variable last_val, since edit_value() works on strings anyhow, and in case of formated floats, it is better to workl on already formated value.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3153
diff changeset
    75
    if "$have_value or $have_edit" {
3153
671283404554 Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3118
diff changeset
    76
        choose{
671283404554 Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3118
diff changeset
    77
            when "count(arg) = 1" {
3188
c173452bf894 SVGHMI: Fixed problems happening when value is higher than maximum or lower than minimum in Input widget. "max" and "min" string was getting into keypad text field, was not diplayed systematically, and was staying forever sometime.
Edouard Tisserant
parents: 3155
diff changeset
    78
    |         this.last_value = vsprintf("«arg[1]/@value»", [value]);
3153
671283404554 Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3118
diff changeset
    79
            }
671283404554 Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3118
diff changeset
    80
            otherwise {
3188
c173452bf894 SVGHMI: Fixed problems happening when value is higher than maximum or lower than minimum in Input widget. "max" and "min" string was getting into keypad text field, was not diplayed systematically, and was staying forever sometime.
Edouard Tisserant
parents: 3155
diff changeset
    81
    |         this.last_value = value;
3153
671283404554 Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3118
diff changeset
    82
            }
671283404554 Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3118
diff changeset
    83
        }
3188
c173452bf894 SVGHMI: Fixed problems happening when value is higher than maximum or lower than minimum in Input widget. "max" and "min" string was getting into keypad text field, was not diplayed systematically, and was staying forever sometime.
Edouard Tisserant
parents: 3155
diff changeset
    84
    |         if(!this.is_inhibited){
c173452bf894 SVGHMI: Fixed problems happening when value is higher than maximum or lower than minimum in Input widget. "max" and "min" string was getting into keypad text field, was not diplayed systematically, and was staying forever sometime.
Edouard Tisserant
parents: 3155
diff changeset
    85
    |             this.display = this.last_value;
c173452bf894 SVGHMI: Fixed problems happening when value is higher than maximum or lower than minimum in Input widget. "max" and "min" string was getting into keypad text field, was not diplayed systematically, and was staying forever sometime.
Edouard Tisserant
parents: 3155
diff changeset
    86
    if "$have_value" {
c173452bf894 SVGHMI: Fixed problems happening when value is higher than maximum or lower than minimum in Input widget. "max" and "min" string was getting into keypad text field, was not diplayed systematically, and was staying forever sometime.
Edouard Tisserant
parents: 3155
diff changeset
    87
    |             this.request_animate();
3155
99ce78ddd353 SVGHMI: finally found why HMI:Input wasnt't initializing properly: vsprintf takes a list. Also, removed intermediate variable last_val, since edit_value() works on strings anyhow, and in case of formated floats, it is better to workl on already formated value.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3153
diff changeset
    88
    }
3188
c173452bf894 SVGHMI: Fixed problems happening when value is higher than maximum or lower than minimum in Input widget. "max" and "min" string was getting into keypad text field, was not diplayed systematically, and was staying forever sometime.
Edouard Tisserant
parents: 3155
diff changeset
    89
    |         }
3100
c51f9cf365c6 SVGHMI: Input widget overrides undershot() and overshot() methods to display "min: xxx" or "max: xxx" when user input goes out of given range.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3094
diff changeset
    90
    }
c51f9cf365c6 SVGHMI: Input widget overrides undershot() and overshot() methods to display "min: xxx" or "max: xxx" when user input goes out of given range.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3094
diff changeset
    91
    |     },
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
    92
3100
c51f9cf365c6 SVGHMI: Input widget overrides undershot() and overshot() methods to display "min: xxx" or "max: xxx" when user input goes out of given range.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3094
diff changeset
    93
    if "$have_value" {
c51f9cf365c6 SVGHMI: Input widget overrides undershot() and overshot() methods to display "min: xxx" or "max: xxx" when user input goes out of given range.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3094
diff changeset
    94
    |     animate: function(){
3188
c173452bf894 SVGHMI: Fixed problems happening when value is higher than maximum or lower than minimum in Input widget. "max" and "min" string was getting into keypad text field, was not diplayed systematically, and was staying forever sometime.
Edouard Tisserant
parents: 3155
diff changeset
    95
    |         this.value_elt.textContent = String(this.display);
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: 2882
diff changeset
    96
    |     },
3100
c51f9cf365c6 SVGHMI: Input widget overrides undershot() and overshot() methods to display "min: xxx" or "max: xxx" when user input goes out of given range.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3094
diff changeset
    97
    }
3094
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
    98
3536
4ee33be5b8b6 SVGHMI: fix js exception because of trying to find already detached elements by id.
Edouard Tisserant
parents: 3523
diff changeset
    99
    foreach "$action_elements" {
4ee33be5b8b6 SVGHMI: fix js exception because of trying to find already detached elements by id.
Edouard Tisserant
parents: 3523
diff changeset
   100
    |     action_elt_«position()»: id("«@id»"),
4ee33be5b8b6 SVGHMI: fix js exception because of trying to find already detached elements by id.
Edouard Tisserant
parents: 3523
diff changeset
   101
    }
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: 2882
diff changeset
   102
    |     init: function() {
3094
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
   103
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
   104
    if "$have_edit" {
3188
c173452bf894 SVGHMI: Fixed problems happening when value is higher than maximum or lower than minimum in Input widget. "max" and "min" string was getting into keypad text field, was not diplayed systematically, and was staying forever sometime.
Edouard Tisserant
parents: 3155
diff changeset
   105
    |         this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_value);
3153
671283404554 Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3118
diff changeset
   106
        if "$have_value" {
671283404554 Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3118
diff changeset
   107
    |         this.value_elt.style.pointerEvents = "none";
671283404554 Allow printf-like formating in HMI:Input, usefull for example when dealing with floating point numbers.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3118
diff changeset
   108
        }
3523
13282f91e6ff SVGHMI: set initial displayed value of input widget to empty string.
Edouard Tisserant
parents: 3241
diff changeset
   109
    |         this.animate();
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: 2882
diff changeset
   110
    }
3094
3e184f1e1012 SVGHMI: almost rewrote Input widget to make it new class based style.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3034
diff changeset
   111
3536
4ee33be5b8b6 SVGHMI: fix js exception because of trying to find already detached elements by id.
Edouard Tisserant
parents: 3523
diff changeset
   112
    foreach "$action_elements" {
4ee33be5b8b6 SVGHMI: fix js exception because of trying to find already detached elements by id.
Edouard Tisserant
parents: 3523
diff changeset
   113
    |         this.action_elt_«position()».onclick = () => this.on_op_click("«func:escape_quotes(@inkscape:label)»");
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   114
    }
2911
211d6a185e31 SVGHMI: More infrastructure for editing values with a keypad.
Edouard Tisserant
parents: 2910
diff changeset
   115
3523
13282f91e6ff SVGHMI: set initial displayed value of input widget to empty string.
Edouard Tisserant
parents: 3241
diff changeset
   116
    if "$have_value" {
13282f91e6ff SVGHMI: set initial displayed value of input widget to empty string.
Edouard Tisserant
parents: 3241
diff changeset
   117
    |         this.value_elt.textContent = "";
13282f91e6ff SVGHMI: set initial displayed value of input widget to empty string.
Edouard Tisserant
parents: 3241
diff changeset
   118
    }
2911
211d6a185e31 SVGHMI: More infrastructure for editing values with a keypad.
Edouard Tisserant
parents: 2910
diff changeset
   119
    |     },
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
   120
}