data.nodescript.turnouts.TurnoutsI18N.nodescript Maven / Gradle / Ivy
###
### this script defines one accessory: turnout with fro polarisation
###
### Hardware: 2 ports are used
### Software:
### 1 accessory
### 2 macros, off & on
###
### history: 2016-11-24 kw created
###
### how to use:
### A) configure
### In section 1, define your ports and the desired accessory number
### In section 2, define your settings (like brightness and speed)
### B) load and run this script
### what will happen?
### 1. the ports will be configured with the given parameters
### 2. two new macros for the aspects will be defined
### 3. these macros will be assigned to the accessory
### C) have fun
###
### ----------------> 1. Select Target
### note: there are two lines for each user config - either direct set or input.
### you may comment ##input if you want to use direct setting
###
###
##application(text:de="Konfiguration einer Weiche mit Magnetantrieb und Herzpolarisation", text:en="Configuration of a turnout with magnet motor and frog polarisation", text:nl="Wisselaandrijving met een enkele spoel en puntstuk polarisatie")
##instruction(text:de="Konfiguration einer Weiche mit Magnetantrieb und Herzpolarisation", text:en="Configuration of a turnout with magnet motor and frog polarisation")
##input($my_accessory:accessory, text:de="Auswahl des zu erzeugenden Accessory", text:en="Select the accessory to create", default=0)
## #set($my_accessory = 0)
##
##input($macro0:macro, text:de="Auswahl des ersten zu erzeugenden Makros", text:en="Select the first macro", default=0)
## #set($macro0 = 0)
#set($macro1 = $macro0 + 1) ## we will use two macros: this and the following one
##
##input($coil0:switch, text:de="Auswahl der ersten Spule", text:en="Select the first coil", default=0)
## #set($coil0 = 0)
#set($coil1 = $coil0 + 1)
##
##input($frog_relay:switch, text:de="Auswahl des Herzrelais", text:en="Select the frog polarisation relay", default=0)
## #set($coil0 = 0)
##input($frog_invert:boolean, text:de="Herz umpolen", text:en="invert frog polarity", default=false)
#if ($coil1 == $frog_relay)
## TODO this must throw an exception or validation error
## Works with Build 2550 or later ...
$exceptionThrower.throwUserDefined("The switch port for frog_relay is already used for coil1!")
#end
## ----------------> 2. set Parameters for Ports
#set($pulseduration = 20)
##define($turnoutLabel:string, text:de="Weiche${my_accessory}", text:en="Turnout${my_accessory}")
set switch ${coil0} name="${turnoutLabel}_L0"
set switch ${coil1} name="${turnoutLabel}_L1"
set switch ${frog_relay} name="${turnoutLabel}_pola"
## ----------------> 3. execute part of the script
## Macro
set macro ${macro0} name="${turnoutLabel}_m0"
set macro ${macro1} name="${turnoutLabel}_m1"
## Fill Macros
select macro ${macro0}
config macro repeat=1 slowdown=1
add step ptype=macro action=stop name="${turnoutLabel}_m1" ## stop other side
add step ptype=switch action=off number=${coil1} ## always turn off other side
add step ptype=switch action=on number=${coil0}
add step delay=${pulseduration} ptype=switch action=off number=${coil0}
#if ($frog_invert)
add step ptype=switch action=on number=${frog_relay}
#else
add step ptype=switch action=off number=${frog_relay}
#end
add step macro end
select macro ${macro1}
config macro repeat=1 slowdown=1
add step ptype=macro action=stop name="${turnoutLabel}_m0" ## stop other side
add step ptype=switch action=off number=${coil0} ## always turn off other side
add step ptype=switch action=on number=${coil1}
add step delay=${pulseduration} ptype=switch action=off number=${coil1}
#if ($frog_invert)
add step ptype=switch action=off number=${frog_relay}
#else
add step ptype=switch action=on number=${frog_relay}
#end
add step macro end
## Define Accessory
set accessory ${my_accessory} name="${turnoutLabel}"
select accessory ${my_accessory}
config accessory startup restore ## possible choice: restore, aspect=1, none
add aspect 0 macroname="${turnoutLabel}_m0"
add aspect 1 macroname="${turnoutLabel}_m1"
## addtional infos
## get help: http://forum.opendcc.de/wiki/doku.php?id=tools:scripting-node-syntax