All Downloads are FREE. Search and download functionalities are using the official Maven repository.

data.nodescript.turnouts.Threewayturnout_Maerklin_Servo_iTrain.nodescript Maven / Gradle / Ivy

## Dieses Script erstellt Accessory, Macro und ServoPort für 3-Wegweichen.
##
## Es wurde nur für die ST4 oder LightControl geschrieben
##
##  
## history: 2020-03-05 A.Kuhtz, G. Pyne-James, V 1.0, changed for one servo with Märklin 3-way turnout
##
## -------------- 1. Select Target
##application(text:de="3-Wegweiche (Märklin) mit 1 Servo an ST4 oder LightControl (iTrain)", text:en="3-way turnout (Maerklin) with 2 servo at ST4 or LightControl (iTrain)", text:nl="Driewegwissel (Maerklin) met 2 Servo op de ST4 of LightControl (iTrain)")
##instruction(text:de="Konfiguration für 3-Wegweiche mit 3 Aspekten für 2 Servo.", link="https://forum.opendcc.de/wiki/doku.php?id=konfigvorlagen:turnouts#3wegweiche_mit_servo_an_st4_itrain")
##instruction(text:en="Configuration of 3-way turnout with 3 aspects for 2 servo.", link="https://forum.opendcc.de/wiki/doku.php?id=konfigvorlagen:turnouts#3wegweiche_mit_servo_an_st4_itrain")
##author(A. Kuhtz, G. Pyne-James)
##
##input($selectedAccessory:accessory, text:de="Nummer des verwendeten Accessory", text:en="Number of the accessory to use", text:nl="Nummer van het te gebruiken accessoire", default=0)
##input($macroStraight:macro, text:de="Nummer des ersten Macros (total 3)", text:en="Number of the first macro (total 3)", text:nl="Nummer van de eerste macro (totaal 3)", default=0)
##input($servoBlue:servo, text:de="Nummer des ersten Servo (total 2)", text:en="Number of the first servo port (total 2)", text:nl="Nummer van de eerste servopoort (totaal 2)", default=0)

##input($threeWayTurnoutName:string, text:de="Bezeichnung der 3-Wegweiche: ", text:en="Name of the 3-way turnout: ", text:nl="Naam van de Driewegwissel: ", default="3WW")

## -------------- 2. set Parameters for Ports

## Makro
#if ($node_macro_count - 3 - $macroStraight  < 0)
 $exceptionThrower.throwUserDefined("zu wenig Makros frei (benötigt: 3)")
#end

## Servo
#if ( ($node_servo_count - $servoBlue) < 2)
 $exceptionThrower.throwUserDefined("zu wenig ServoPorts frei (benötigt: 2)")
#end

#if ($user_lang == "de")
	#set($labelRight = "rechts")
	#set($labelStraight = "gerade")
	#set($labelLeft = "links")
	#set($labelServo = "Servo")
#elseif ($user_lang == "nl")
	#set($labelRight = "rechtsaf")
	#set($labelStraight = "rechtdoor")
	#set($labelLeft = "links")
	#set($labelServo = "Servo")
#else
	#set($labelRight = "Divert right")
	#set($labelStraight = "straight")
	#set($labelLeft = "Divert left")
	#set($labelServo = "Servo")
#end


## -------------- 3. execute part of the script
#set($servoGreen = $servoBlue + 1)                    ## need additional servo
#set($macroRight = $macroStraight + 1)                ## need some additional macros
#set($macroLeft = $macroStraight + 2)                 ## need some additional macros

## Set label of the accessory
set accessory ${selectedAccessory} name="A$numberTool.format("#00", ${selectedAccessory})-iTr$numberTool.format("#00", ${selectedAccessory}) | M$numberTool.format("#00", ${macroStraight})$numberTool.format("#00", ${macroRight})$numberTool.format("#00", ${macroLeft})-SP$numberTool.format("#00", ${servoBlue})$numberTool.format("#00", ${servoGreen}) | ${threeWayTurnoutName}"

set aspect 0 accessory=${selectedAccessory} name="${labelStraight}"
set aspect 1 accessory=${selectedAccessory} name="${labelRight}"
set aspect 2 accessory=${selectedAccessory} name="${labelLeft}"

## Set label of the macro
set macro ${macroStraight} name="M$numberTool.format("#00", ${macroStraight})-SP$numberTool.format("#00", ${servoBlue})$numberTool.format("#00", ${servoGreen}) | ${labelStraight}"
set macro ${macroRight} name="M$numberTool.format("#00", ${macroRight})-SP$numberTool.format("#00", ${servoBlue})$numberTool.format("#00", ${servoGreen}) | ${labelRight}"
set macro ${macroLeft} name="M$numberTool.format("#00", ${macroLeft})-SP$numberTool.format("#00", ${servoBlue})$numberTool.format("#00", ${servoGreen}) | ${labelLeft}"

### Set label of ServoPort
set servo ${servoBlue} name="SP$numberTool.format("#00", ${servoBlue}) | ${threeWayTurnoutName}"
set servo ${servoGreen} name="SP$numberTool.format("#00", ${servoGreen}) | ${threeWayTurnoutName}"

################################################
### configure macro
###


### macro straight
select macro ${macroStraight}

config macro repeat=1 slowdown=1

add step ptype=macro action=stop number=${macroRight}
add step ptype=macro action=stop number=${macroLeft}
add step ptype=servo action=start number=${servoGreen} target=0
add step ptype=moveServoQuery number=${servoGreen}
add step ptype=servo action=start number=${servoBlue} target=0
add step ptype=moveServoQuery number=${servoBlue}

### macro right
select macro ${macroRight}

config macro repeat=1 slowdown=1

add step ptype=macro action=stop number=${macroStraight}
add step ptype=macro action=stop number=${macroLeft}
add step ptype=servo action=start number=${servoBlue} target=0
add step ptype=moveServoQuery number=${servoBlue}
add step ptype=servo action=start number=${servoGreen} target=100
add step ptype=moveServoQuery number=${servoGreen}

### macro left
select macro ${macroLeft}

config macro repeat=1 slowdown=1

add step ptype=macro action=stop number=${macroStraight}
add step ptype=macro action=stop number=${macroRight}
add step ptype=servo action=start number=${servoGreen} target=0
add step ptype=moveServoQuery number=${servoGreen}
add step ptype=servo action=start number=${servoBlue} target=100
add step ptype=moveServoQuery number=${servoBlue}

## Define Accessory

select accessory ${selectedAccessory}
add aspect 0 macronumber=$macroStraight
add aspect 1 macronumber=$macroRight
add aspect 2 macronumber=$macroLeft
config accessory startup restore ## restore; none; aspect=1




© 2015 - 2024 Weber Informatics LLC | Privacy Policy