Templates: a complete example
This page shows one configuration that uses many template features together. Read Templates first: it explains each feature with a short sample. The tests of the expander run this sample, so the expanded configuration below is the exact result.
Sample 10-station. This sample shows a complete station: two platforms, their doors and one variable for each automatic door. The template Platform makes the platform, then runs a block for its doors. The doors use inherit: true to get the station and the platform from the Platform call. The right platform has reverse: its counters count from the other end, and the entry order does not change. ${asd.count} gives the number of automatic doors after the doors are made. The structure comes from a real railway station. The names and the addresses are examples.
# Sample 10 - a station with two platforms of doors, the full example of the design record.
# Anonymised from a real railway station: the structure is real, the names are not.
# The bindings are invented: plc1 and its DB numbers do not exist.
namespaces: [di]
imports:
- { alias: ac, uri: "http://acme.example/UA/Doors/", filename: ./Acme.Doors.NodeSet2.xml }
templates:
# One automatic sliding door.
ASD:
counter: { asd: n } # Each use takes the next value of counter asd as n: "01", "02", ...
params:
station: { type: string, inherit: true } # Comes from the enclosing Platform call.
platform: { type: string, inherit: true }
db: { type: number, inherit: true } # The first data block of the platform.
instances:
- browseName: "ASD${n}"
displayName: "Automatic Sliding Door ${n}"
nodeId: "s=${station}-${platform}-ASD${n}"
typeDefinition: ac:AutomaticDoorType
componentOf: "${parent}"
optionals:
- ac:DoorSwitches.ac:LeftLeafLockedSwitch
- ac:DoorSwitches.ac:RightLeafLockedSwitch
mapping:
- node: "${parent}/ASD${n}/ac:Status/ac:IsOpen"
value: "plc1:DB${db + $number(n)},X0.0"
# One emergency egress door.
EED:
counter: { eed: n }
params: { station: { type: string, inherit: true }, platform: { type: string, inherit: true } }
instances:
- browseName: "EED${n}"
displayName: "Emergency Egress Door ${n}"
nodeId: "s=${station}-${platform}-EED${n}"
typeDefinition: ac:EmergencyEgressDoorType
componentOf: "${parent}"
# A module: one automatic door, then one emergency door.
ASD_EED: [ASD, EED]
# One inhibition variable per automatic door.
DoorVariables:
params: { doors: { type: number } }
repeat: { count: "${doors}", index: { name: i, start: 1, format: "00" } }
instances:
- browseName: "Door${i}"
displayName: "DoorInhibition${i}"
dataType: ac:DoorInhibitionRequestEnum
componentOf: "${parent}/ac:AutomaticTrainSystem/ac:PlatformDoorInhibitionRequest"
minimumSamplingInterval: 100
# One platform: the platform object, its doors, its variables.
Platform:
params:
station: { type: string }
platform: { type: string }
db: { type: number }
side: { type: string, enum: [left, right] }
instances:
- browseName: "${platform}"
displayName: "Platform ${platform}"
nodeId: "s=${station}-${platform}"
typeDefinition: ac:PlatformType
componentOf: "${parent}"
expand:
parent: "${parent}/${platform}"
counters:
asd: { start: 1, format: "00" }
eed: { start: 1, format: "00" }
reverse: "${side = 'right'}"
layout:
- EED
- { repeat: 3, use: ASD_EED }
- EED
- { use: DoorVariables, with: { doors: "${asd.count}" } }
instances:
- browseName: SA
displayName: Station A
nodeId: s=SA
typeDefinition: ac:StationType
organizedBy: /ua:Objects/di:DeviceSet
- expand:
parent: $SA
with: { station: SA }
over:
- { platform: P1, side: left, db: 100 }
- { platform: P2, side: right, db: 200 }
use: Platform
The expanded configuration
namespaces:
- di
imports:
- alias: ac
uri: http://acme.example/UA/Doors/
filename: ./Acme.Doors.NodeSet2.xml
instances:
- browseName: SA
displayName: Station A
nodeId: s=SA
typeDefinition: ac:StationType
organizedBy: /ua:Objects/di:DeviceSet
- browseName: P1
displayName: Platform P1
nodeId: s=SA-P1
typeDefinition: ac:PlatformType
componentOf: $SA
- browseName: EED01
displayName: Emergency Egress Door 01
nodeId: s=SA-P1-EED01
typeDefinition: ac:EmergencyEgressDoorType
componentOf: $SA/P1
- browseName: ASD01
displayName: Automatic Sliding Door 01
nodeId: s=SA-P1-ASD01
typeDefinition: ac:AutomaticDoorType
componentOf: $SA/P1
optionals:
- ac:DoorSwitches.ac:LeftLeafLockedSwitch
- ac:DoorSwitches.ac:RightLeafLockedSwitch
- browseName: EED02
displayName: Emergency Egress Door 02
nodeId: s=SA-P1-EED02
typeDefinition: ac:EmergencyEgressDoorType
componentOf: $SA/P1
- browseName: ASD02
displayName: Automatic Sliding Door 02
nodeId: s=SA-P1-ASD02
typeDefinition: ac:AutomaticDoorType
componentOf: $SA/P1
optionals:
- ac:DoorSwitches.ac:LeftLeafLockedSwitch
- ac:DoorSwitches.ac:RightLeafLockedSwitch
- browseName: EED03
displayName: Emergency Egress Door 03
nodeId: s=SA-P1-EED03
typeDefinition: ac:EmergencyEgressDoorType
componentOf: $SA/P1
- browseName: ASD03
displayName: Automatic Sliding Door 03
nodeId: s=SA-P1-ASD03
typeDefinition: ac:AutomaticDoorType
componentOf: $SA/P1
optionals:
- ac:DoorSwitches.ac:LeftLeafLockedSwitch
- ac:DoorSwitches.ac:RightLeafLockedSwitch
- browseName: EED04
displayName: Emergency Egress Door 04
nodeId: s=SA-P1-EED04
typeDefinition: ac:EmergencyEgressDoorType
componentOf: $SA/P1
- browseName: EED05
displayName: Emergency Egress Door 05
nodeId: s=SA-P1-EED05
typeDefinition: ac:EmergencyEgressDoorType
componentOf: $SA/P1
- browseName: Door01
displayName: DoorInhibition01
dataType: ac:DoorInhibitionRequestEnum
componentOf: $SA/P1/ac:AutomaticTrainSystem/ac:PlatformDoorInhibitionRequest
minimumSamplingInterval: 100
- browseName: Door02
displayName: DoorInhibition02
dataType: ac:DoorInhibitionRequestEnum
componentOf: $SA/P1/ac:AutomaticTrainSystem/ac:PlatformDoorInhibitionRequest
minimumSamplingInterval: 100
- browseName: Door03
displayName: DoorInhibition03
dataType: ac:DoorInhibitionRequestEnum
componentOf: $SA/P1/ac:AutomaticTrainSystem/ac:PlatformDoorInhibitionRequest
minimumSamplingInterval: 100
- browseName: P2
displayName: Platform P2
nodeId: s=SA-P2
typeDefinition: ac:PlatformType
componentOf: $SA
- browseName: EED05
displayName: Emergency Egress Door 05
nodeId: s=SA-P2-EED05
typeDefinition: ac:EmergencyEgressDoorType
componentOf: $SA/P2
- browseName: ASD03
displayName: Automatic Sliding Door 03
nodeId: s=SA-P2-ASD03
typeDefinition: ac:AutomaticDoorType
componentOf: $SA/P2
optionals:
- ac:DoorSwitches.ac:LeftLeafLockedSwitch
- ac:DoorSwitches.ac:RightLeafLockedSwitch
- browseName: EED04
displayName: Emergency Egress Door 04
nodeId: s=SA-P2-EED04
typeDefinition: ac:EmergencyEgressDoorType
componentOf: $SA/P2
- browseName: ASD02
displayName: Automatic Sliding Door 02
nodeId: s=SA-P2-ASD02
typeDefinition: ac:AutomaticDoorType
componentOf: $SA/P2
optionals:
- ac:DoorSwitches.ac:LeftLeafLockedSwitch
- ac:DoorSwitches.ac:RightLeafLockedSwitch
- browseName: EED03
displayName: Emergency Egress Door 03
nodeId: s=SA-P2-EED03
typeDefinition: ac:EmergencyEgressDoorType
componentOf: $SA/P2
- browseName: ASD01
displayName: Automatic Sliding Door 01
nodeId: s=SA-P2-ASD01
typeDefinition: ac:AutomaticDoorType
componentOf: $SA/P2
optionals:
- ac:DoorSwitches.ac:LeftLeafLockedSwitch
- ac:DoorSwitches.ac:RightLeafLockedSwitch
- browseName: EED02
displayName: Emergency Egress Door 02
nodeId: s=SA-P2-EED02
typeDefinition: ac:EmergencyEgressDoorType
componentOf: $SA/P2
- browseName: EED01
displayName: Emergency Egress Door 01
nodeId: s=SA-P2-EED01
typeDefinition: ac:EmergencyEgressDoorType
componentOf: $SA/P2
- browseName: Door01
displayName: DoorInhibition01
dataType: ac:DoorInhibitionRequestEnum
componentOf: $SA/P2/ac:AutomaticTrainSystem/ac:PlatformDoorInhibitionRequest
minimumSamplingInterval: 100
- browseName: Door02
displayName: DoorInhibition02
dataType: ac:DoorInhibitionRequestEnum
componentOf: $SA/P2/ac:AutomaticTrainSystem/ac:PlatformDoorInhibitionRequest
minimumSamplingInterval: 100
- browseName: Door03
displayName: DoorInhibition03
dataType: ac:DoorInhibitionRequestEnum
componentOf: $SA/P2/ac:AutomaticTrainSystem/ac:PlatformDoorInhibitionRequest
minimumSamplingInterval: 100
mapping:
- node: $SA/P1/ASD01/ac:Status/ac:IsOpen
value: plc1:DB101,X0.0
- node: $SA/P1/ASD02/ac:Status/ac:IsOpen
value: plc1:DB102,X0.0
- node: $SA/P1/ASD03/ac:Status/ac:IsOpen
value: plc1:DB103,X0.0
- node: $SA/P2/ASD03/ac:Status/ac:IsOpen
value: plc1:DB203,X0.0
- node: $SA/P2/ASD02/ac:Status/ac:IsOpen
value: plc1:DB202,X0.0
- node: $SA/P2/ASD01/ac:Status/ac:IsOpen
value: plc1:DB201,X0.0
More about templates
- Templates: one procedure for each feature.
- Templates: reference: the keys, the expressions and the limits.
- Templates: error codes: each TPL code, with a sample and its message.