plcopen/pou_block_instances.ysl2
branch1.1 Korean release
changeset 1384 02fe382c4511
parent 1345 53e51e786654
child 1382 675a6229fc60
equal deleted inserted replaced
1280:72a826dfcfbb 1384:02fe382c4511
       
     1 include yslt.yml2
       
     2 estylesheet xmlns:ppx="http://www.plcopen.org/xml/tc6_0201"
       
     3             xmlns:xhtml="http://www.w3.org/1999/xhtml"
       
     4             xmlns:ns="pou_block_instances_ns" 
       
     5             extension-element-prefixes="ns" 
       
     6             exclude-result-prefixes="ns" {
       
     7     
       
     8     template "text()";
       
     9     
       
    10     template "ppx:pou" {
       
    11         apply "ppx:body/*[self::ppx:FBD or self::ppx:LD or self::ppx:SFC]/*";
       
    12     }
       
    13     
       
    14     function "add_instance" {
       
    15         param "type";
       
    16         value "ns:AddBlockInstance($type, @localId, ppx:position/@x, ppx:position/@y, @width, @height)";
       
    17     }
       
    18     
       
    19     function "execution_order" {
       
    20         choose {
       
    21             when "@executionOrderId" > «@executionOrderId»
       
    22             otherwise > 0
       
    23         }
       
    24     }
       
    25     
       
    26     function "ConnectionInfos" {
       
    27         param "type";
       
    28         param "negated";
       
    29         param "edge";
       
    30         param "formalParameter";
       
    31         value "ns:AddInstanceConnection($type, $formalParameter, $negated, $edge, ppx:relPosition/@x, ppx:relPosition/@y)";
       
    32     }
       
    33     
       
    34     template "ppx:position" {
       
    35         value "ns:AddLinkPoint(@x, @y)";
       
    36     }
       
    37     
       
    38     template "ppx:connection" {
       
    39         value "ns:AddConnectionLink(@refLocalId, @formalParameter)";
       
    40         apply "ppx:position";
       
    41     }
       
    42     
       
    43     template "ppx:connectionPointIn" {
       
    44         param "negated";
       
    45         param "edge";
       
    46         param "formalParameter";
       
    47         call "ConnectionInfos" {
       
    48             with "type" > input
       
    49             with "negated" > «$negated»
       
    50             with "edge" > «$edge»
       
    51             with "formalParameter" > «$formalParameter»
       
    52         }
       
    53         apply "ppx:connection";
       
    54     }
       
    55     
       
    56     template "ppx:connectionPointOut" {
       
    57         param "negated";
       
    58         param "edge";
       
    59         param "formalParameter";
       
    60         call "ConnectionInfos" {
       
    61             with "type" > output
       
    62             with "negated" > «$negated»
       
    63             with "edge" > «$edge»
       
    64             with "formalParameter" > «$formalParameter»
       
    65         }
       
    66     }
       
    67     
       
    68     template "ppx:connectionPointOutAction" {
       
    69         call "ConnectionInfos" {
       
    70             with "type" > output
       
    71         }
       
    72     }
       
    73     
       
    74     template "ppx:comment" {
       
    75         value "ns:SetSpecificValues(ppx:content/xhtml:p/text())";
       
    76         call "add_instance" {
       
    77             with "type" > «local-name()»
       
    78         }
       
    79     }
       
    80     
       
    81     template "ppx:block" {
       
    82         variable "execution_order" {
       
    83             call "execution_order";
       
    84         }
       
    85         value "ns:SetSpecificValues(@instanceName, $execution_order)";
       
    86         call "add_instance" {
       
    87             with "type" > «@typeName»
       
    88         }
       
    89         foreach "ppx:inputVariables/ppx:variable" {
       
    90             apply "ppx:connectionPointIn" {
       
    91                 with "negated", "@negated";
       
    92                 with "edge", "@edge";
       
    93                 with "formalParameter", "@formalParameter";
       
    94             }
       
    95         }
       
    96         foreach "ppx:outputVariables/ppx:variable" {
       
    97             apply "ppx:connectionPointOut" {
       
    98                 with "negated", "@negated";
       
    99                 with "edge", "@edge";
       
   100                 with "formalParameter", "@formalParameter";
       
   101             }
       
   102         }
       
   103     }
       
   104     
       
   105     template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived" {
       
   106         > «@name»
       
   107     }
       
   108   
       
   109     template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string" {
       
   110         > STRING
       
   111     }
       
   112   
       
   113     template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:wstring" {
       
   114         > WSTRING
       
   115     }
       
   116     
       
   117     template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*" {
       
   118         > «local-name()»
       
   119     }
       
   120     
       
   121     function "VariableBlockInfos" {
       
   122         param "type";
       
   123         variable "expression" > «ppx:expression/text()»
       
   124         variable "value_type" {
       
   125             choose {
       
   126                 when "ancestor::ppx:transition[@name=$expression]" > BOOL
       
   127                 when "ancestor::ppx:pou[@name=$expression]" {
       
   128                     apply "ancestor::ppx:pou/child::ppx:interface/ppx:returnType"
       
   129                 }
       
   130                 otherwise {
       
   131                     apply "ancestor::ppx:pou/child::ppx:interface/*/ppx:variable[@name=$expression]/ppx:type"
       
   132                 }
       
   133             }
       
   134         }
       
   135         variable "execution_order" {
       
   136             call "execution_order";
       
   137         }
       
   138         value "ns:SetSpecificValues($expression, $value_type, $execution_order)";
       
   139         call "add_instance" {
       
   140             with "type" > «$type»
       
   141         }
       
   142         apply "ppx:connectionPointIn" {
       
   143             with "negated", "@negatedIn";
       
   144             with "edge", "@edgeIn";
       
   145         }
       
   146         apply "ppx:connectionPointOut" {
       
   147             with "negated", "@negatedOut";
       
   148             with "edge", "@edgeOut";
       
   149         }
       
   150     }
       
   151     
       
   152     template "ppx:inVariable" {
       
   153         call "VariableBlockInfos" with "type", "'input'";
       
   154     }
       
   155     
       
   156     template "ppx:outVariable" {
       
   157         call "VariableBlockInfos" with "type", "'output'";
       
   158     }
       
   159     
       
   160     template "ppx:inOutVariable" {
       
   161         call "VariableBlockInfos" with "type", "'inout'";
       
   162     }
       
   163     
       
   164     template "ppx:connector|ppx:continuation" {
       
   165         value "ns:SetSpecificValues(@name)";
       
   166         call "add_instance" {
       
   167             with "type" > «local-name()»
       
   168         }
       
   169         apply "ppx:connectionPointIn";
       
   170         apply "ppx:connectionPointOut";
       
   171     }
       
   172     
       
   173     template "ppx:leftPowerRail|ppx:rightPowerRail" {
       
   174         variable "type", "local-name()";
       
   175         variable "connectors" {
       
   176             choose {
       
   177                 when "$type='leftPowerRail'" > «count(ppx:connectionPointOut)»
       
   178                 otherwise > «count(ppx:connectionPointIn)»
       
   179             }
       
   180         }
       
   181         value "ns:SetSpecificValues($connectors)";
       
   182         call "add_instance" {
       
   183             with "type" > «$type»
       
   184         }
       
   185         choose {
       
   186             when "$type='leftPowerRail'" {
       
   187                 apply "ppx:connectionPointOut";
       
   188             }
       
   189             otherwise {
       
   190                 apply "ppx:connectionPointIn";
       
   191             }
       
   192         }
       
   193     }
       
   194     
       
   195     template "ppx:contact|ppx:coil" {
       
   196         variable "type", "local-name()";
       
   197         variable "storage" {
       
   198             choose {
       
   199                 when "$type='coil'" > «@storage»
       
   200             }
       
   201         }
       
   202         variable "execution_order" {
       
   203             call "execution_order";
       
   204         }
       
   205         value "ns:SetSpecificValues(ppx:variable/text(), @negated, @edge, $storage, $execution_order)";
       
   206         call "add_instance" {
       
   207             with "type" > «$type»
       
   208         }
       
   209         apply "ppx:connectionPointIn";
       
   210         apply "ppx:connectionPointOut";
       
   211     }
       
   212     
       
   213     template "ppx:step" {
       
   214         value "ns:SetSpecificValues(@name, @initialStep)";
       
   215         apply "ppx:connectionPointOutAction" {
       
   216             with "negated", "@negated";
       
   217         }
       
   218         call "add_instance" {
       
   219             with "type" > «local-name()»
       
   220         }
       
   221         apply "ppx:connectionPointIn";
       
   222         apply "ppx:connectionPointOut";
       
   223     }
       
   224     
       
   225     template "ppx:transition" {
       
   226         variable "priority" {
       
   227             choose {
       
   228                 when "@priority" > «@priority»
       
   229                 otherwise > 0
       
   230             }
       
   231         }
       
   232         variable "condition_type" {
       
   233             choose {
       
   234                 when "ppx:condition/ppx:connectionPointIn" > connection
       
   235                 when "ppx:condition/ppx:reference" > reference
       
   236                 when "ppx:condition/ppx:inline" > inline
       
   237             }
       
   238         }
       
   239         variable "condition" {
       
   240             choose {
       
   241                 when "ppx:reference" > «ppx:condition/ppx:reference/@name»
       
   242                 when "ppx:inline" > «ppx:condition/ppx:inline/ppx:body/ppx:ST/xhtml:p/text()»
       
   243             }
       
   244         }
       
   245         value "ns:SetSpecificValues($priority, $condition_type, $condition)";
       
   246         apply "ppx:condition/ppx:connectionPointIn" {
       
   247             with "negated", "ppx:condition/@negated";
       
   248         }
       
   249         call "add_instance" {
       
   250             with "type" > «local-name()»
       
   251         }
       
   252         apply "ppx:connectionPointIn";
       
   253         apply "ppx:connectionPointOut";
       
   254     }
       
   255     
       
   256     template "ppx:selectionDivergence|ppx:selectionConvergence|ppx:simultaneousDivergence|ppx:simultaneousConvergence" {
       
   257         variable "type" > «local-name()»
       
   258         variable "connectors" {
       
   259             choose {
       
   260                 when "$type='selectionDivergence' or $type='simultaneousDivergence'" {
       
   261                     > «count(ppx:connectionPointOut)»
       
   262                 }
       
   263                 otherwise > «count(ppx:connectionPointIn)»
       
   264             }
       
   265         }
       
   266         value "ns:SetSpecificValues($connectors)";
       
   267         call "add_instance" {
       
   268             with "type" > «$type»
       
   269         }
       
   270         apply "ppx:connectionPointIn";
       
   271         apply "ppx:connectionPointOut";
       
   272     }
       
   273     
       
   274     template "ppx:jumpStep" {
       
   275         variable "type" > jump
       
   276         value "ns:SetSpecificValues(@targetName)";
       
   277         call "add_instance" {
       
   278             with "type" > «$type»
       
   279         }
       
   280         apply "ppx:connectionPointIn";
       
   281     }
       
   282     
       
   283     template "ppx:action" {
       
   284         variable "type" {
       
   285             choose {
       
   286                 when "ppx:reference" > reference
       
   287                 when "ppx:inline" > inline
       
   288             }
       
   289         }
       
   290         variable "value" {
       
   291             choose {
       
   292                 when "ppx:reference" > «ppx:reference/@name»
       
   293                 when "ppx:inline" > «ppx:inline/ppx:ST/xhtml:p/text()»
       
   294             }
       
   295         }
       
   296         variable "qualifier" {
       
   297             choose {
       
   298                 when "@qualifier" > «@qualifier»
       
   299                 otherwise > N
       
   300             }
       
   301         }
       
   302         value "ns:AddAction($qualifier, $type, $value, @duration, @indicator)";
       
   303     }
       
   304     
       
   305     template "ppx:actionBlock" {
       
   306         value "ns:SetSpecificValues()";
       
   307         apply "ppx:action";
       
   308         call "add_instance" {
       
   309             with "type" > «local-name()»
       
   310         }
       
   311         apply "ppx:connectionPointIn" {
       
   312             with "negated", "@negated";
       
   313         }
       
   314     }
       
   315 }