svghmi/widget_button.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Tue, 29 Mar 2022 08:50:01 +0200
branchwxPython4
changeset 3446 de8cc85b688a
parent 3419 76995a304fe0
child 3520 b27e50143083
permissions -rw-r--r--
Tests: refactored sikuli based test
2944
2a20038fbea9 Added button and circular bar widgets.
dgaberscek
parents:
diff changeset
     1
// widget_button.ysl2
2a20038fbea9 Added button and circular bar widgets.
dgaberscek
parents:
diff changeset
     2
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: 3232
diff changeset
     3
widget_desc("Button") {
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: 3232
diff changeset
     4
    longdesc
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: 3232
diff changeset
     5
    ||
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: 3232
diff changeset
     6
    Button widget takes one boolean variable path, and reflect current true
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: 3232
diff changeset
     7
    or false value by showing "active" or "inactive" labeled 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: 3232
diff changeset
     8
    respectively. Pressing and releasing button changes variable to true and
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: 3232
diff changeset
     9
    false respectively. Potential inconsistency caused by quick consecutive
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: 3232
diff changeset
    10
    presses on the button is mitigated by using a state machine that wait for
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: 3232
diff changeset
    11
    previous state change to be reflected on variable before applying next one.
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: 3232
diff changeset
    12
    ||
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: 3232
diff changeset
    13
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: 3232
diff changeset
    14
    shortdesc > Push button reflecting consistently given boolean variable
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: 3232
diff changeset
    15
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: 3232
diff changeset
    16
    path name="value" accepts="HMI_BOOL" > Boolean variable
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: 3232
diff changeset
    17
    
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: 3232
diff changeset
    18
}
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: 3232
diff changeset
    19
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    20
// Finite state machine
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    21
decl fsm(name);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    22
decl state(name);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    23
decl on_mouse(position);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    24
decl on_dispatch(value);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    25
decl jump(state);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    26
decl show(eltname);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    27
decl hmi_value(value);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    28
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: 3086
diff changeset
    29
gen_index_xhtml {
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: 3086
diff changeset
    30
3413
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    31
const "_push_button_fsm" fsm {
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    32
    state "init" {
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    33
        on_dispatch "false" jump "reflect_off";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    34
        on_dispatch "true" jump "reflect_on";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    35
    }
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    36
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    37
    state "reflect_on" {
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    38
        show "active";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    39
        on_mouse "down" jump "on";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    40
        on_mouse "up" jump "off";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    41
        on_dispatch "false" jump "reflect_off";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    42
    }
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    43
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    44
    state "on" {
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    45
        hmi_value "true";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    46
        show "active";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    47
        on_mouse "up" jump "off";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    48
        on_dispatch "false" jump "reflect_off";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    49
    }
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    50
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    51
    state "reflect_off" {
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    52
        show "inactive";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    53
        on_mouse "down" jump "on";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    54
        on_mouse "up" jump "off";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    55
        on_dispatch "true" jump "reflect_on";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    56
    }
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    57
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    58
    state "off" {
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    59
        hmi_value "false";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    60
        show "inactive";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    61
        on_mouse "down" jump "on";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    62
        on_dispatch "true" jump "reflect_on";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    63
    }
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    64
}
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
    65
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    66
// State machine to drive HMI_BOOL on a potentially laggy connection
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    67
const "_button_fsm" fsm {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    68
    state "init" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    69
        on_dispatch "false" jump "released";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    70
        on_dispatch "true" jump "pressed";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    71
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    72
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    73
    state "pressing" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    74
        // show "waitactive";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    75
        hmi_value "true";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    76
        on_dispatch "true" jump "pressed";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    77
        on_mouse "up" jump "shortpress";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    78
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    79
    state "pressed" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    80
        show "active";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    81
        on_mouse "up" jump "releasing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    82
        on_dispatch "false" jump "released";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    83
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    84
    state "shortpress" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    85
        on_dispatch "true" jump "releasing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    86
        on_mouse "down" jump "pressing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    87
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    88
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    89
    state "releasing" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    90
        // show "waitinactive";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    91
        hmi_value "false";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    92
        on_dispatch "false" jump "released";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    93
        on_mouse "down" jump "shortrelease";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    94
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    95
    state "released" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    96
        show "inactive";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    97
        on_mouse "down" jump "pressing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    98
        on_dispatch "true" jump "pressed";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    99
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   100
    state "shortrelease" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   101
        on_dispatch "false" jump "pressing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   102
        on_mouse "up" jump "releasing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   103
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   104
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   105
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   106
template "fsm", mode="dispatch_transition" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   107
    |         switch (this.state) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   108
    apply "state", mode="dispatch_transition";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   109
    |         }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   110
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   111
template "state", mode="dispatch_transition" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   112
    |           case "«@name»":
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   113
       apply "on-dispatch";
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   114
    |             break;
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   115
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   116
template "on-dispatch" {
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   117
    |             if(value ==  «@value») {
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   118
    apply "jump", mode="transition";
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   119
    |             }
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   120
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   121
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   122
template "fsm", mode="mouse_transition" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   123
    param "position";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   124
    |         switch (this.state) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   125
    apply "state", mode="mouse_transition" with "position", "$position";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   126
    |         }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   127
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   128
template "state", mode="mouse_transition" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   129
    param "position";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   130
    |           case "«@name»":
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   131
    apply "on-mouse[@position = $position]";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   132
    |             break;
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   133
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   134
template "on-mouse" {
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   135
    // up or down state is already assumed because apply statement filters it
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   136
    apply "jump", mode="transition";
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   137
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   138
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   139
template "jump", mode="transition" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   140
    |             this.state = "«@state»";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   141
    |             this.«@state»_action();
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   142
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   143
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   144
template "fsm", mode="actions" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   145
    apply "state", mode="actions";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   146
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   147
template "state", mode="actions" {
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   148
    |     «@name»_action(){
3419
76995a304fe0 SVGHMI: remove debug code
Edouard Tisserant
parents: 3417
diff changeset
   149
    // | console.log("Entering state «@name»", this.frequency);
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   150
    apply "*", mode="actions";
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   151
    |     }
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   152
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   153
template "show", mode="actions" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   154
    |         this.display = "«@eltname»";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   155
    |         this.request_animate();
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   156
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   157
template "hmi-value", mode="actions" {
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   158
    |         this.apply_hmi_value(0, «@value»);
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   159
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   160
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: 3086
diff changeset
   161
}
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: 3086
diff changeset
   162
3413
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   163
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   164
function "generated_button_class" {
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   165
    param "fsm";
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
   166
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   167
    |     display = "inactive";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   168
    |     state = "init";
3059
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3058
diff changeset
   169
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   170
    |     dispatch(value) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   171
    apply "$fsm", mode="dispatch_transition";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   172
    |     }
3056
827bf284feec Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents: 3024
diff changeset
   173
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   174
    |     onmouseup(evt) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   175
    |         svg_root.removeEventListener("pointerup", this.bound_onmouseup, true);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   176
    apply "$fsm", mode="mouse_transition" with "position", "'up'";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   177
    |     }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   178
    |     onmousedown(evt) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   179
    |         svg_root.addEventListener("pointerup", this.bound_onmouseup, true);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   180
    apply "$fsm", mode="mouse_transition" with "position", "'down'";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   181
    |     }
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
   182
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   183
    apply "$fsm", mode="actions";
3056
827bf284feec Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents: 3024
diff changeset
   184
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   185
    |     animate(){
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   186
    |         if (this.active_elt && this.inactive_elt) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   187
    foreach "str:split('active inactive')" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   188
    |             if(this.display == "«.»")
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   189
    |                 this.«.»_elt.style.display = "";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   190
    |             else
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   191
    |                 this.«.»_elt.style.display = "none";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   192
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   193
    |         }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   194
    |     }
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
   195
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   196
    |     init() {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   197
    |         this.bound_onmouseup = this.onmouseup.bind(this);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   198
    |         this.element.addEventListener("pointerdown", this.onmousedown.bind(this));
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   199
    |     }
3024
Edouard Tisserant
parents: 3018
diff changeset
   200
}
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
   201
3413
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   202
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   203
widget_class("Button"){
3417
9b9775d230f5 SVGHMI: fix again appication of frequency value when given in label. Use it on PushButton instance in svghmi test.
Edouard Tisserant
parents: 3413
diff changeset
   204
    |     frequency = 5;
3413
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   205
    const "fsm","exsl:node-set($_button_fsm)";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   206
    call "generated_button_class" with "fsm", "$fsm";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   207
}
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   208
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: 3086
diff changeset
   209
widget_defs("Button") {
2976
99c4521bb844 SVGHMI: Changed widget button handler to element attribute.
dgaberscek
parents: 2961
diff changeset
   210
    optional_labels("active inactive");
3000
a9a45977bac0 SVGHMI: prefer apply_hmi_value() to change_hmi_value() when possible
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2976
diff changeset
   211
}
3413
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   212
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   213
widget_class("PushButton"){
3417
9b9775d230f5 SVGHMI: fix again appication of frequency value when given in label. Use it on PushButton instance in svghmi test.
Edouard Tisserant
parents: 3413
diff changeset
   214
    |     frequency = 20;
3413
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   215
    const "fsm","exsl:node-set($_push_button_fsm)";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   216
    call "generated_button_class" with "fsm", "$fsm";
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   217
}
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   218
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   219
widget_defs("PushButton") {
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   220
    optional_labels("active inactive");
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   221
}
2e84a2782295 SVGHMI: Add pushbutton widget, that can take reflect short press in variable, but has no garantee on consistency.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3241
diff changeset
   222