data.nodescript.turnouts.DoubleSlip_Servo_Frog_Rocrail.nodescript Maven / Gradle / Ivy
## Dieses Script erstellt Asseccory, Macro und ServoPort für Doppelkreuzungsweiche
##
## Es wurde nur für die LightControl, ST4 oder OneControl geschrieben
##
##
## history: 2021-09-29 A.Kuhtz, V 1.0, nach Vorlage Ludwig für iTrain (exsachse)
##
## -------------- 1. Select Target
##application(text:de="Doppelkreuzungsweiche mit Servo an LightControl (Rocrail)", text:en="Double slip (servo) at LightControl (Rocrail)", text:nl="Kruiswissel (Dubbele Engelsman) met Servo op de LightControl (Rocrail)")
##instruction(text:de="Konfiguration für Doppelkreuzungsweiche mit 4 Aspekten für 2 Servo und Herzstückpolarisierung (Rocrail).", link="https://forum.opendcc.de/wiki/doku.php?id=konfigvorlagen:turnouts#doppelkreuzungsweiche_mit_servo_an_lightcontrol_rocrail")
##instruction(text:en="Configuration of double slip with 4 aspects for 2 servo and frog polarization (Rocrail).", link="https://forum.opendcc.de/wiki/doku.php?id=konfigvorlagen:turnouts#doppelkreuzungsweiche_mit_servo_an_lightcontrol_rocrail")
##instruction(text:nl="Configuration of double slip with 4 aspects for 2 servo and frog polarization (Rocrail).", link="https://forum.opendcc.de/wiki/doku.php?id=konfigvorlagen:turnouts#doppelkreuzungsweiche_mit_servo_an_lightcontrol_rocrail")
##author(A. Kuhtz)
##
##input($selectedAccessory:accessory, text:de="Nummer des ersten verwendeten Accessory (total 2)", text:en="Number of the first accessory to use (total 2)", default=0)
##input($my_macro:macro, text:de="Nummer des ersten Macros (total 4)", text:en="Number of the first macro (total 4)", default=0)
##input($my_servo:servo, text:de="Nummer des ersten Servo (total 2)", text:en="Number of the first servo port (total 2)", default=0)
##input($my_switch:switch, text:de="Nummer des ersten Schaltausgang (total 2)", text:en="Number of the first switch port (total 2)", default=0)
## -------------- 2. set Parameters for Ports
## Makro
#if ($node_macro_count - 4 - $my_macro < 0)
$exceptionThrower.throwUserDefined("zu wenig Makros frei (benötigt: 4)")
#end
## Servo
#if ($node_servo_count - ($my_servo + 1) < 1)
$exceptionThrower.throwUserDefined("zu wenig ServoPorts frei (benötigt: 2)")
#end
## Switch
#if ($node_first_switchport_number + $node_switch_count - ($my_switch + 1) < 1)
$exceptionThrower.throwUserDefined("zu wenig Schaltausgänge frei (benötigt: 2)")
#end
## -------------- 3. execute part of the script
#set($AccessoryName0 = "DKW Servo1")
#set($AccessoryName1 = "DKW Servo2")
#set($accessory0 = $selectedAccessory)
#set($accessory1 = $accessory0 + 1)
#set($servo0 = $my_servo)
#set($servo1 = $my_servo + 1)
#set($switch0 = $my_switch)
#set($switch1 = $my_switch + 1)
#set($macro0 = $my_macro) ## need some additional macros
#set($macro1 = $macro0 + 1) ## need some additional macros
#set($macro2 = $macro1 + 1) ## need some additional macros
#set($macro3 = $macro2 + 1) ## need some additional macros
## Set label of the accessory
set accessory ${accessory0} name="${AccessoryName0}"
set accessory ${accessory1} name="${AccessoryName1}"
set aspect 0 accessory=${accessory0} name="A - C"
set aspect 1 accessory=${accessory0} name="A - D"
set aspect 0 accessory=${accessory1} name="B - D"
set aspect 1 accessory=${accessory1} name="B - C"
## Set label of the macro
set macro ${macro0} name="A - C"
set macro ${macro1} name="A - D"
set macro ${macro2} name="B - D"
set macro ${macro3} name="B - C"
### Set label of ServoPort
set servo ${servo0} name="Servo1 A/B"
set servo ${servo1} name="Servo2 C/D"
### Set label of SwitchPort
set switch ${switch0} name="Herzstück AB"
set switch ${switch1} name="Herzstück CD"
################################################
### configure macro
###
### macro A-C
select macro ${macro0}
config macro repeat=1 slowdown=1
add step ptype=macro action=stop number=${macro1}
add step ptype=servo action=start number=${servo0} target=0
add step delay=5 ptype=switch action=off number=${switch1}
add step ptype=moveServoQuery number=${servo0}
### macro A-D
select macro ${macro1}
config macro repeat=1 slowdown=1
add step ptype=macro action=stop number=${macro0}
add step ptype=servo action=start number=${servo0} target=100
add step delay=5 ptype=switch action=on number=${switch1}
add step ptype=moveServoQuery number=${servo0}
### macro B-D
select macro ${macro2}
config macro repeat=1 slowdown=1
add step ptype=macro action=stop number=${macro3}
add step ptype=servo action=start number=${servo1} target=0
add step delay=5 ptype=switch action=on number=${switch0}
add step ptype=moveServoQuery number=${servo1}
### macro B-C
select macro ${macro3}
config macro repeat=1 slowdown=1
add step ptype=macro action=stop number=${macro2}
add step ptype=servo action=start number=${servo1} target=100
add step delay=5 ptype=switch action=off number=${switch0}
add step ptype=moveServoQuery number=${servo1}
## Define Accessory
select accessory ${accessory0}
add aspect 0 macronumber=$macro0
add aspect 1 macronumber=$macro1
select accessory ${accessory1}
add aspect 0 macronumber=$macro2
add aspect 1 macronumber=$macro3
config accessory startup restore ## restore; none; aspect=1