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

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

## Dieses Script erstellt Accessory, Macro um einen ServoPort mit 2 Schaltern zu steuern.
##  
## history: 2019-03-12 A.Kuhtz, erste Version
##
##
## -------------- 1. Select Target
##application(text:de="Weichenantrieb mit Servo mit 2 Eingängen und Accessory steuern", text:en="Turnout (servo) controlled with 2 inputs and accessory", text:nl="Wisselaandrijving met Servo met twee ingangen en aansturen van Accessoires")
##instruction(text:de="Konfiguration von Servo für Weichensteuerung mittels 2 Eingängen (Schalter) und Accessory ", text:en="Configuration of servo for turnouts with 2 inputs (switches) and accessory")
##
##input($AccessoryName:string, text:de="Name des Accessory: ", text:en="Name of the Accessory: ", default="Schalter-Servo")
##input($selectedAccessory:accessory, text:de="Nummer des verwendeten Accessory", text:en="Number of the used Accessory", default=0)
##input($MacroNumber:macro, text:de="Nummer des ersten Macros (Total: 4)", text:en="Number of the first macro (total: 4)", default=0)
##input($ServoPortNumber:servo, text:de="Nummer des ServoPort", text:en="Number of the servo port", default=0)
##input($ServoName:string, text:de="Name des Servo: ", text:en="Name of the servo: ", default="Schalter-Servo")
##input($InputPortNumber:input, text:de="Nummer des Eingang (Total: 2)", text:en="Number of the input port (total: 2)", default=0)
##input($InputName:string, text:de="Name des Eingang: ", text:en="Name of the iput port: ", default="Schalter-Servo")

### -------------- 2. configure variables 
#set($targetPosition0 = 0)
#set($targetPosition1 = 100)
#set($macroCount = 2)
#set($macroNumber0 = $MacroNumber)
#set($macroNumber1 = $MacroNumber + 1)
#set($macroNumber2 = $MacroNumber + 2)
#set($macroNumber3 = $MacroNumber + 3)
#set($inputPortNumber0 = $InputPortNumber)
#set($inputPortNumber1 = $InputPortNumber + 1)

### ----- make sure we have the input ports available -------
assert port number=${inputPortNumber0} ptype=input
assert port number=${inputPortNumber1} ptype=input

### ----- restart the node if restart is pending ----
restart pendingonly=true delay=3000

### -------------- 3. execute part of the script

### Set label of Accessories
set accessory ${selectedAccessory} name="${AccessoryName}"

### Set label of Macro
set macro ${macroNumber0} name="${AccessoryName}_gerade_Schalter"
set macro ${macroNumber1} name="${AccessoryName}_abzweig_Schalter"

set macro ${macroNumber2} name="${AccessoryName}_gerade"
set macro ${macroNumber3} name="${AccessoryName}_abzweig"

### Set label of ServoPort
set servo ${ServoPortNumber} name="${ServoName}"

### Set label of InputPort
set input ${inputPortNumber0} name="${InputName}_gerade"
set input ${inputPortNumber1} name="${InputName}_abzweig"

### Set label of aspect
set aspect 0 accessory=${selectedAccessory} name="${InputName}_gerade"
set aspect 1 accessory=${selectedAccessory} name="${InputName}_abzweig"

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

### macro straight switch
select macro ${macroNumber0}

wait 30

config macro repeat=0 slowdown=1

add step ptype=input action=query1 number=${inputPortNumber0}
add step ptype=input action=query0 number=${inputPortNumber0}

add step ptype=macro action=stop  number=${macroNumber1}
add step ptype=macro action=start number=${macroNumber2}

wait 50

### macro round switch
select macro ${macroNumber1}

wait 30

config macro repeat=0 slowdown=1

add step ptype=input action=query1 number=${inputPortNumber1}
add step ptype=input action=query0 number=${inputPortNumber1}

add step ptype=macro action=stop  number=${macroNumber0}
add step ptype=macro action=start number=${macroNumber3}

wait 50

### macro straight ###
select macro ${macroNumber2}

wait 30

config macro repeat=1 slowdown=1

add step ptype=macro action=stop number=${macroNumber3}

add step ptype=servo action=start target=$targetPosition0 number=$ServoPortNumber
add step ptype=moveServoQuery number=$ServoPortNumber
add step ptype=macro action=start number=${macroNumber1}

wait 50

### macro round ###
select macro ${macroNumber3}

wait 30

config macro repeat=1 slowdown=1

add step ptype=macro action=stop number=${macroNumber2}

add step ptype=servo action=start target=$targetPosition1 number=$ServoPortNumber
add step ptype=moveServoQuery number=$ServoPortNumber
add step ptype=macro action=start number=${macroNumber0}

wait 50

### Define Accessory
select accessory ${selectedAccessory}
config accessory startup restore

#set($maxMacroIndex = $macroCount - 1)
#foreach ($currentMacroIndex in [0..$maxMacroIndex])

#set($currentMacroNum = $currentMacroIndex + $MacroNumber + 2)

add aspect $currentMacroIndex macronumber=$currentMacroNum
#end






© 2015 - 2024 Weber Informatics LLC | Privacy Policy