All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
data.nodescript.application.ReadyServo8.ReadyServo8-ServoTurnout_with_inputs.nodescript Maven / Gradle / Ivy
## Dieses Script erstellt Accessory, Macro und ServoPort mit mehr als 2 Positionen.
##
## history: 2024-08-05 A.Kuhtz, erste Version
##
##
## Prüfung auf ReadyServo8
##require(vid="251", pid="232")
## -------------- 1. Select Target
##application(text:de="Weichenantrieb mit Servo mit mehr als 2 Positionen", text:en="Turnout (servo) for more than 2 positions", text:nl="Wisselaandrijving met Servo met meer dan twee posities")
##instruction(text:de="Konfiguration von Servo für Weichensteuerung mit mehr als 2 Positionen", text:en="Configuration of servo for turnouts with more than 2 positions")
##
##input($AccessoryName:string, text:de="Name des Accessory", text:en="Name of the Accessory", default="Multipos-Servo")
##input($AccessoryNumber: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 (Benötigt = Anzahl Positionen)", text:en="Number of the first macro (total = number of positions)", default=0)
##input($ServoCount:int, text:de="Anzahl der Servos", text:en="Number of the servos", default=1)
##input($ServoPortNumber:servo, text:de="Nummer des ServoPort", text:en="Number of the servo port", default=0)
##input($ServoPositionCount:int, text:de="Anzahl der ServoPositionen", text:en="Number of servo positions", default=2)
##input($ServoName:string, text:de="Name des Servo", text:en="Name of the servo", default="Multipos-Servo")
##input($InputPortNumber:input, text:de="Nummer des Eingang (Total: 2 pro Servo)", text:en="Number of the input port (total: 2 per servo)", default=8)
##input($InputName:string, text:de="Name des Eingang", text:en="Name of the input port", default="Schalter-Servo")
#set ($accessoryOffset = 0)
#set ($macroOffset = $MacroNumber)
#set ($maxServo = $ServoCount - 1)
#set ($currentServo = ${ServoPortNumber})
#set ($currentInput = ${InputPortNumber})
#set($initializeAccessoryNumber = $node_accessory_count - 1 )
## calculate the number of macros that are required
#set($macroCount = $ServoPositionCount - 1)
#set($initializeMacroNumber = $node_macro_count - ($ServoPositionCount * $ServoCount) - 1 )
### Set label of the initialize accessory
set accessory ${initializeAccessoryNumber} name="Initialize"
### Set label of the initialize macro
set macro ${initializeMacroNumber} name="Initialize"
set aspect 0 accessory=${initializeAccessoryNumber} name="Initialize Macros"
### Configure the initialize accessory
select accessory ${initializeAccessoryNumber}
config accessory startup aspect=0
add aspect 0 macronumber=$initializeMacroNumber
### Configure the initialize macro
select macro ${initializeMacroNumber}
config macro repeat=1 slowdown=1
#set($totalInputHandlerMacroCount = (2 * $ServoCount) )
#foreach ($currentInputMacroStepIndex in [1..$totalInputHandlerMacroCount])
#set($inputMacroNum = $initializeMacroNumber + $currentInputMacroStepIndex)
add step ptype=macro action=start number=$inputMacroNum
#end
### -------------- 3. execute part of the script
#foreach ($currentServoIndex in [0..$maxServo])
#set($currentAccessory = $AccessoryNumber + $accessoryOffset)
### Set label of Accessories
set accessory ${currentAccessory} name="${AccessoryName}_${accessoryOffset}"
### Set label of ServoPort
set servo $currentServo name="${ServoName}_${currentServoIndex}"
### configure the port as inputport
assert port number=${currentInput} ptype=input
### Set label of InputPort
set input ${currentInput} name="${InputName}${ServoName}_${currentServoIndex}"
### Set label of aspect
set aspect 0 accessory=${currentAccessory} name="${AccessoryName}_gerade"
set aspect 1 accessory=${currentAccessory} name="${AccessoryName}_abzweig"
########################################
#set($firstMacroNumber = $macroOffset)
#foreach ($currentMacroIndex in [0..$macroCount])
#set($currentMacroNum = $currentMacroIndex + $firstMacroNumber)
## calculate the target position
#set($targetPosition = $currentMacroIndex *10)
#if ($currentMacroIndex == $macroCount)
#set($targetPosition = 100)
#end
### Set label of Macro
set macro ${currentMacroNum} name="${AccessoryName}_${accessoryOffset}_Pos_${currentMacroIndex}"
################################################
### configure macro
###
select macro ${currentMacroNum}
config macro repeat=1 slowdown=1
### stop all macro
#foreach ($macroNum in [0..$macroCount])
#set($stopMacroNum = $macroNum + $firstMacroNumber)
#if ($stopMacroNum != $currentMacroNum)
add step ptype=macro action=stop number=${stopMacroNum}
#end ## #if
#end ## #foreach macroNum
#if ($targetPosition == 0)
#set($halfTargetPosition = 50)
#set($switchAction = "off")
#else
#set($halfTargetPosition = $targetPosition / 2)
#set($switchAction = "on")
#end
add step ptype=servo action=start target=$halfTargetPosition number=$currentServo
add step ptype=moveServoQuery number=$currentServo
add step ptype=servo action=start target=$targetPosition number=$currentServo
add step ptype=moveServoQuery number=$currentServo
#end ## #foreach currentMacroIndex
### Define Accessory
select accessory ${currentAccessory}
config accessory startup restore
#foreach ($currentMacroIndex in [0..$macroCount])
#set($currentMacroNum = $currentMacroIndex + $firstMacroNumber)
add aspect $currentMacroIndex macronumber=$currentMacroNum
#if ($currentMacroIndex == 0)
set aspect $currentMacroIndex accessory=${currentAccessory} name="gerade"
#else
set aspect $currentMacroIndex accessory=${currentAccessory} name="abzweig"
#end
#end ## #foreach currentMacroIndex
################################################
### configure macro for manual input evaluation
###
#set($macroNumberInput0 = $initializeMacroNumber + 1)
#set($macroNumberInput1 = $initializeMacroNumber + 2)
#set($firstMacroNumber = $macroOffset)
#set($secondMacroNumber = $firstMacroNumber + 1)
### Set label of the manual input macros
set macro ${macroNumberInput0} name="${AccessoryName}_${accessoryOffset} manual input 0"
set macro ${macroNumberInput1} name="${AccessoryName}_${accessoryOffset} manual input 1"
select macro ${macroNumberInput0}
config macro repeat=1 slowdown=1
add step ptype=input action=query0 number=$currentInput
add step ptype=macro action=start number=$firstMacroNumber
add step ptype=moveServoQuery number=$currentServo
add step ptype=input action=query1 number=$currentInput
add step ptype=macro action=start number=$macroNumberInput1
select macro ${macroNumberInput1}
config macro repeat=1 slowdown=1
add step ptype=input action=query1 number=$currentInput
add step ptype=macro action=start number=$secondMacroNumber
add step ptype=moveServoQuery number=$currentServo
add step ptype=input action=query0 number=$currentInput
add step ptype=macro action=start number=$macroNumberInput0
#set($accessoryOffset = $accessoryOffset + 1)
#set($macroOffset = $macroOffset + $ServoPositionCount)
#set($currentServo = $currentServo + 1)
#set($currentInput = $currentInput + 1)
#set($initializeMacroNumber = $initializeMacroNumber + 2)
#end ## #foreach currentServoIndex