etherlab/entries_list.ysl2
changeset 2165 02a2b5dee5e3
parent 2162 43ab74687f45
child 2641 c9deff128c37
equal deleted inserted replaced
2021:bcf346f558bd 2165:02a2b5dee5e3
       
     1 /*
       
     2 
       
     3 Stylesheet used to list EtherCat dictionnary entries.
       
     4 
       
     5 Copyright (C) 2011-2014: Laurent BESSARD
       
     6 
       
     7 Distributed under the terms of the GNU Lesser General Public License as
       
     8 published by the Free Software Foundation; either version 2 of the License, or
       
     9 (at your option) any later version.
       
    10 
       
    11 See COPYING file for copyrights details.
       
    12 
       
    13 */
       
    14 
       
    15 include yslt.yml2
       
    16 estylesheet xmlns:ns="entries_list_ns" 
       
    17             extension-element-prefixes="ns" 
       
    18             exclude-result-prefixes="ns" {
       
    19     
       
    20     param "min_index";
       
    21     param "max_index";
       
    22     
       
    23     template "text()";
       
    24     
       
    25     template "Device" {
       
    26         apply "Profile/Dictionary/Objects/Object";
       
    27         foreach "RxPdo" {
       
    28             call "pdo_entries" with "direction", "'Receive'";
       
    29         }
       
    30         foreach "TxPdo" {
       
    31             call "pdo_entries" with "direction", "'Transmit'";
       
    32         }
       
    33     }
       
    34     
       
    35     template "Object" {
       
    36         variable "index" > «ns:HexDecValue(Index/text())»
       
    37         variable "entry_name" > «ns:EntryName(Name)»
       
    38         choose {
       
    39             when "$index >= $min_index and $index <= $max_index" {
       
    40                 variable "datatype_name" > «Type/text()»
       
    41                 choose {
       
    42                     when "ancestor::Dictionary/child::DataTypes/DataType[Name/text()=$datatype_name][SubItem]" {
       
    43                         apply "ancestor::Dictionary/child::DataTypes/DataType[Name/text()=$datatype_name][SubItem]" {
       
    44                             with "index" > «$index»
       
    45                             with "entry_name" > «$entry_name»
       
    46                         }
       
    47                     }
       
    48                     otherwise {
       
    49                         variable "subindex" > 0
       
    50                         variable "entry" {
       
    51                             > «ns:AddEntry($index, $subindex, $entry_name, $datatype_name, BitSize/text(), Flags/Access/text(), Flags/PdoMapping/text())»
       
    52                         }
       
    53                     }
       
    54                 }
       
    55             }
       
    56         }
       
    57     }
       
    58     
       
    59     template "DataType" {
       
    60         param "index";
       
    61         param "entry_name";
       
    62         foreach "SubItem" {
       
    63             variable "subindex" > «ns:HexDecValue(SubIdx/text())»
       
    64             variable "subentry_name" > «$entry_name» - «ns:EntryName(DisplayName, Name/text())»
       
    65             variable "entry" {
       
    66                 > «ns:AddEntry($index, $subindex, $subentry_name, Type/text(), BitSize/text(), Flags/Access/text(), Flags/PdoMapping/text())»
       
    67             }
       
    68         }
       
    69     }
       
    70     
       
    71     function "pdo_entries" {
       
    72         param "direction";
       
    73         variable "pdo_index" > «ns:HexDecValue(Index/text())»
       
    74         variable "pdo_name" > «ns:EntryName(Name)»
       
    75         foreach "Entry" {
       
    76             variable "index" > «ns:HexDecValue(Index/text())»
       
    77             choose {
       
    78                 when "$index >= $min_index and $index <= $max_index" {
       
    79                     variable "subindex" > «ns:HexDecValue(SubIndex/text())»
       
    80                     variable "subentry_name" > «ns:EntryName(Name)»
       
    81                     variable "access" {
       
    82                         choose {
       
    83                             when "$direction='Transmit'" > ro
       
    84                             otherwise > wo
       
    85                         }
       
    86                     }
       
    87                     variable "pdo_mapping" {
       
    88                         choose {
       
    89                             when "$direction='Transmit'" > T
       
    90                             otherwise > R
       
    91                         }
       
    92                     }
       
    93                     variable "entry" {
       
    94                         > «ns:AddEntry($index, $subindex, $subentry_name, DataType/text(), BitLen/text(), $access, $pdo_mapping, $pdo_index, $pdo_name, $direction)»
       
    95                     }
       
    96                 }
       
    97             }
       
    98         }
       
    99     }
       
   100 }