svghmi/widget_listswitch.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Mon, 17 Jan 2022 15:17:47 +0100
changeset 3407 2f5c30054d50
parent 3403 4a048b5b9e3b
permissions -rw-r--r--
OPC-UA client: "static" class was forgotten for open62541 client structure preventing multiple client.
3403
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
     1
// widget_switch.ysl2
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
     2
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
     3
widget_desc("ListSwitch") {
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
     4
    longdesc
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
     5
    ||
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
     6
    ListSwitch widget displays one item of an HMI:List depending on value of
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
     7
    given variable. Main element of the widget must be a clone of the list or
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
     8
    of an item of that list.  
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
     9
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    10
    Given variable's current value is compared to list items
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    11
    label. For exemple if given variable type
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    12
    is HMI_INT and value is 1, then item with label '1' will be displayed.
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    13
    If matching variable of type HMI_STRING, then no quotes are needed. 
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    14
    For exemple, 'hello' match HMI_STRING 'hello'.
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    15
    ||
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    16
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    17
    shortdesc > Displays item of an HMI:List whose label matches value.
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    18
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    19
    path name="value" accepts="HMI_INT,HMI_STRING" > value to compare to labels
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    20
    
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    21
}
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    22
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    23
widget_class("ListSwitch"){
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    24
    ||
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    25
        frequency = 5;
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    26
    ||
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    27
}
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    28
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    29
widget_defs("ListSwitch") {
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    30
    // cloned element must be part of a HMI:List or a HMI:List
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    31
    const "targetid", "substring-after($hmi_element/@xlink:href,'#')";
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    32
    const "from_list", "$hmi_lists[(@id | */@id) = $targetid]";
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    33
    ||
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    34
        dispatch: function(value) {
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    35
            this.element.href.baseVal = "#"+hmi_widgets["«$from_list/@id»"].items[value];
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    36
        },
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    37
    ||
4a048b5b9e3b SVGHMI: added ListSwitch widget
Edouard Tisserant
parents:
diff changeset
    38
}