svghmi/hmi_tree.ysl2
branchsvghmi
changeset 3221 3d307ad803ea
parent 3205 62753288be74
child 3381 3a0908b0319d
equal deleted inserted replaced
3220:ec365ef396b1 3221:3d307ad803ea
    71         with "index", "$index + count(exsl:node-set($content)/*)";
    71         with "index", "$index + count(exsl:node-set($content)/*)";
    72         with "parentpath" > «$parentpath»
    72         with "parentpath" > «$parentpath»
    73     }
    73     }
    74 }
    74 }
    75 
    75 
    76 //  Parses:
    76 include parse_labels.ysl2
    77 //  "HMI:WidgetType:param1:param2@path1,path1min,path1max@path2"
       
    78 //
       
    79 //  Into:
       
    80 //  widget type="WidgetType" id="blah456" {
       
    81 //      arg value="param1";
       
    82 //      arg value="param2";
       
    83 //      path value=".path1" index=".path1" min="path1min" max="path1max" type="PAGE_LOCAL";
       
    84 //      path value="/path1" index="348" type="HMI_INT";
       
    85 //      path value="path4" index="path4" type="HMI_LOCAL";
       
    86 //  }
       
    87 //
       
    88 template "*", mode="parselabel" {
       
    89     const "label","@inkscape:label";
       
    90     const "id","@id";
       
    91     const "description", "substring-after($label,'HMI:')";
       
    92 
       
    93     const "_args", "substring-before($description,'@')";
       
    94     const "args" choose {
       
    95         when "$_args" value "$_args";
       
    96         otherwise value "$description";
       
    97     }
       
    98 
       
    99     const "_type", "substring-before($args,':')";
       
   100     const "type" choose {
       
   101         when "$_type" value "$_type";
       
   102         otherwise value "$args";
       
   103     }
       
   104 
       
   105     if "$type" widget {
       
   106         attrib "id" > «$id»
       
   107         attrib "type" > «$type»
       
   108         foreach "str:split(substring-after($args, ':'), ':')" {
       
   109             arg {
       
   110                 attrib "value" > «.»
       
   111             }
       
   112         }
       
   113         const "paths", "substring-after($description,'@')";
       
   114         foreach "str:split($paths, '@')" {
       
   115             if "string-length(.) > 0" path {
       
   116                 const "pathminmax", "str:split(.,',')";
       
   117                 const "path", "$pathminmax[1]";
       
   118                 const "pathminmaxcount", "count($pathminmax)";
       
   119                 attrib "value" > «$path»
       
   120                 choose {
       
   121                     when "$pathminmaxcount = 3" {
       
   122                         attrib "min" > «$pathminmax[2]»
       
   123                         attrib "max" > «$pathminmax[3]»
       
   124                     }
       
   125                     when "$pathminmaxcount = 2" {
       
   126                         error > Widget id:«$id» label:«$label» has wrong syntax of path section «$pathminmax»
       
   127                     }
       
   128                 }
       
   129                 choose {
       
   130                     when "regexp:test($path,'^\.[a-zA-Z0-9_]+$')" {
       
   131                         attrib "type" > PAGE_LOCAL
       
   132                     }
       
   133                     when "regexp:test($path,'^[a-zA-Z0-9_]+$')" {
       
   134                         attrib "type" > HMI_LOCAL
       
   135                     }
       
   136                     otherwise {
       
   137                         const "item", "$indexed_hmitree/*[@hmipath = $path]";
       
   138                         const "pathtype", "local-name($item)";
       
   139                         if "$pathminmaxcount = 3 and not($pathtype = 'HMI_INT' or $pathtype = 'HMI_REAL')" {
       
   140                             error > Widget id:«$id» label:«$label» path section «$pathminmax» use min and max on non mumeric value
       
   141                         }
       
   142                         if "count($item) = 1" {
       
   143                             attrib "index" > «$item/@index»
       
   144                             attrib "type" > «$pathtype»
       
   145                         }
       
   146                     }
       
   147                 }
       
   148             }
       
   149         }
       
   150     }
       
   151 }
       
   152 
    77 
   153 const "_parsed_widgets" {
    78 const "_parsed_widgets" {
   154     widget type="VarInitPersistent" {
    79     widget type="VarInitPersistent" {
   155         arg value="0";
    80         arg value="0";
   156         path value="lang";
    81         path value="lang";