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.ReadyServoTurn.ReadyServoTurn-ServoAndRelay.nodescript Maven / Gradle / Ivy
## Dieses Script erstellt Accessory, Macro für 4 ServoPorts mit 2 Positionen und Schalten von 4 Relais.
##
## history: 2022-08-08 A.Kuhtz, erste Version
##
##
## -------------- 1. Select Target
##application(text:de="4 Servo mit 2 Positionen und 4 Relais schalten", text:en="4 servo with 2 positions and switching 4 relays", text:nl="4 Servo met twee posities and 4 relais schakelen")
##instruction(text:de="Konfiguration von 4 Servo mit 2 Positionen und 4 Relais schalten", text:en="Configuration of 4 servo with 2 positions and switching 4 relays")
##
##input($AccessoryName:string, text:de="Name des Servo-Accessory: ", text:en="Name of the Servo-Accessory: ", default="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="Servo")
##input($SwitchCount:int, text:de="Anzahl der Schaltausgänge", text:en="Number of the switch ports", default=1)
##input($SwitchPortNumber:switch, text:de="Nummer des Schaltausgang", text:en="Number of the switch port", default=0)
##input($SwitchName:string, text:de="Name des Schaltausgang: ", text:en="Name of the switch port: ", default="Relais")
#set ($accessoryOffset = 0)
#set ($macroOffset = $MacroNumber)
#set ($maxServo = $ServoCount - 1)
#set ($currentServo = ${ServoPortNumber})
#set ($currentSwitch = ${SwitchPortNumber})
#set ($maxSwitch = $SwitchCount - 1)
## calculate the number of macros that are required
#set($macroCount = $ServoPositionCount - 1)
## begin - configure the accessorie and maros for the servos
#foreach ($currentServoIndex in [0..$maxServo])
### -------------- 3. execute part of the script
#set($currentAccessory = $AccessoryNumber + $accessoryOffset)
### Set label of Accessories
set accessory ${currentAccessory} name="${ServoName}_${accessoryOffset}"
### Set label of ServoPort
set servo $currentServo name="${ServoName}_${currentServoIndex}"
########################################
#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
add step ptype=servo action=start target=$targetPosition number=$currentServo
add step ptype=moveServoQuery number=$currentServo
#end ## #foreach
### Define Accessory
select accessory ${currentAccessory}
config accessory startup restore
#foreach ($currentMacroIndex in [0..$macroCount])
#set($currentMacroNum = $currentMacroIndex + $firstMacroNumber)
add aspect $currentMacroIndex macronumber=$currentMacroNum
#end ## #foreach
#set ($accessoryOffset = $accessoryOffset + 1)
#set ($macroOffset = $macroOffset + $ServoPositionCount)
#set ($currentServo = $currentServo + 1)
#end ## #foreach
## end - configure the accessorie and maros for the servos
### begin - configure the accessories and macros for the switch ports
## calculate the number of macros that are required
#set($macroCount = 1)
#set ($switchAccessoryOffset = $accessoryOffset)
#foreach ($currentSwitchIndex in [0..$maxSwitch])
### -------------- 3. execute part of the script
#set($currentAccessory = $AccessoryNumber + $accessoryOffset)
#set ($currentAccessoryOffset = $accessoryOffset - $switchAccessoryOffset)
### Set label of Accessories
set accessory ${currentAccessory} name="${SwitchName}_${currentAccessoryOffset}"
### Set label of SwitchPort
set switch $currentSwitch name="${SwitchName}_${currentSwitchIndex}"
########################################
#set($firstMacroNumber = $macroOffset)
#foreach ($currentMacroIndex in [0..$macroCount])
#set($currentMacroNum = $currentMacroIndex + $firstMacroNumber)
## calculate the target position
#set($switchAction = "on")
#if ($currentMacroIndex == $macroCount)
#set($switchAction = "off")
#end ## #if
### Set label of Macro
set macro ${currentMacroNum} name="${SwitchName}_${currentAccessoryOffset}_${switchAction}"
################################################
### 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
add step ptype=switch action=${switchAction} number=${currentSwitch}
#end ## #foreach
### Define Accessory
select accessory ${currentAccessory}
config accessory startup restore
#foreach ($currentMacroIndex in [0..$macroCount])
#set($currentMacroNum = $currentMacroIndex + $firstMacroNumber)
add aspect $currentMacroIndex macronumber=$currentMacroNum
#end ## #foreach
#set ($accessoryOffset = $accessoryOffset + 1)
#set ($currentAccessoryOffset = $currentAccessoryOffset + 1)
#set ($macroOffset = $macroOffset + 2)
#set ($currentSwitch = $currentSwitch + 1)
#end
### end - configure the accessories and macros for the switch ports