svghmi/widget_multistate.ysl2
branchsvghmi
changeset 3232 7bdb766c2a4d
parent 3018 22b969b409b0
child 3241 fe945f1f48b7
equal deleted inserted replaced
3231:5243c2a2f7f8 3232:7bdb766c2a4d
     1 // widget_multistate.ysl2
     1 // widget_multistate.ysl2
     2 
     2 
     3 template "widget[@type='MultiState']", mode="widget_class"
     3 widget_class("MultiState")
     4     ||
     4     ||
     5     class MultiStateWidget extends Widget{
       
     6         frequency = 5;
     5         frequency = 5;
     7         state = 0;
     6         state = 0;
     8         dispatch(value) {
     7         dispatch(value) {
     9             this.state = value;
     8             this.state = value;
    10             for(let choice of this.choices){
     9             for(let choice of this.choices){
    39         }
    38         }
    40 
    39 
    41         init() {
    40         init() {
    42             this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)");
    41             this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)");
    43         }
    42         }
    44     }
       
    45     ||
    43     ||
    46 
    44 
    47 template "widget[@type='MultiState']", mode="widget_defs" {
    45 widget_defs("MultiState") {
    48     param "hmi_element";
    46     param "hmi_element";
    49     |     choices: [
    47     |     choices: [
    50     const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+|false|true)(#.*)?$'"!;
    48     const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+|false|true)(#.*)?$'"!;
    51     foreach "$result_svg_ns//*[@id = $hmi_element/@id]//*[regexp:test(@inkscape:label,$regex)]" {
    49     foreach "$result_svg_ns//*[@id = $hmi_element/@id]//*[regexp:test(@inkscape:label,$regex)]" {
    52         const "literal", "regexp:match(@inkscape:label,$regex)[2]";
    50         const "literal", "regexp:match(@inkscape:label,$regex)[2]";