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

data.nodescript.application.ReadyServo8.ReadyServo8-CrossingsServoLights.nodescript Maven / Gradle / Ivy

## Dieses Script erstellt Accessory, Macro und ServoPort für Bahnübergang mit 2 Servo.
##  
## history: 2024-08-10 A.Kuhtz, erste Version
##
##

## Prüfung auf ReadyServo8
##require(vid="251", pid="232")

## -------------- 1. Select Target
##application(text:de="Bahnübergang mit Servo und Blinklichtern", text:en="Crossing with 2 servo and warning lights", text:nl="Crossing with 2 servo and warning lights")
##instruction(text:de="Konfiguration von Bahnübergang mit Servo und Blinklichtern", text:en="Configuration of crossing with 2 servo and warning lights")
##
##input($AccessoryName:string, text:de="Name des Accessory: ", text:en="Name of the Accessory: ", default="Übergang")
##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="Schranke")
##input($SwitchPortNumber:switch, text:de="Nummer des Schaltausgang", text:en="Number of the switch port", default=8)
##input($SwitchName:string, text:de="Name des 1. Schaltausgang: ", text:en="Name of the 1. switch port: ", default="Stopstelle")
##input($SwitchNameBlink:string, text:de="Name des 2. Schaltausgang: ", text:en="Name of the 2. switch port: ", default="Blinklicht")

#set ($accessoryOffset = 0)
#set ($macroOffset = $MacroNumber)
#set ($currentServo = ${ServoPortNumber})
#set ($currentSwitch = ${SwitchPortNumber} + 6)
#set ($currentSwitchBlink = $currentSwitch + 1)

## calculate the number of macros that are required
#set($macroCount  = 2 - 1)

#if (${script_automation})
    #set ($accessoryOffset = $accessoryOffset + 6)
	#set ($macroOffset = $macroOffset + 12)
	#set ($currentServo = $currentServo + 6)
    #set ($currentSwitch = $currentSwitch)
	#set ($currentSwitchBlink = $currentSwitch + 1)
#end


#foreach ($currentCrossingIndex in [0..0])

    ### Define the servos
    #set ($servoA = ${currentServo})
    #set ($servoB = ${currentServo} + 1)
    ### Define the lights macro
    #set ($lightsMacroNumber = 2 + $macroOffset)

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

    #set($currentAccessory = $AccessoryNumber + $accessoryOffset)

    ### Set label of Accessories
set accessory ${currentAccessory} name="${AccessoryName}_${accessoryOffset}"

### configure the port as switchport
assert port number=${currentSwitch} ptype=switch
assert port number=${currentSwitchBlink} ptype=switch

    ### Set label of SwitchPort
set switch $currentSwitch name="${SwitchName}_${currentSwitch}"
set switch $currentSwitchBlink name="${SwitchNameBlink}_${currentSwitchBlink}"

    ### Set label of ServoPort
set servo $servoA name="${ServoName}_${servoA}"
set servo $servoB name="${ServoName}_${servoB}"

    ########################################
    #set($firstMacroNumber = $macroOffset)

    #foreach ($currentMacroIndex in [0..$macroCount])

        #set($currentMacroNum = $currentMacroIndex + $firstMacroNumber)

        ## calculate the target position
        #set($targetPosition = 0)
        #set($targetPositionName = "öffnen")
        #if ($currentMacroIndex == $macroCount)
            #set($targetPosition = 100)
            #set($targetPositionName = "schliessen")
        #end

        ### Set label of Macro
    set macro ${currentMacroNum} name="${AccessoryName}_${accessoryOffset}_${targetPositionName}"

        ################################################
        ### 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=macro action=start number=${lightsMacroNumber}
    add step delay=50 ptype=delay

        #if($targetPosition == 100)

	    ### activate the Stopstelle
            add step delay=50 ptype=switch action=on number=${currentSwitch}
            add step delay=100 ptype=delay
        #end


    add step ptype=servo action=start target=$targetPosition number=$servoA
    add step ptype=servo action=start target=$targetPosition number=$servoB
    add step ptype=moveServoQuery number=$servoA
    add step ptype=moveServoQuery number=$servoB

        #if($targetPosition == 0)
        add step delay=100 ptype=delay
        add step ptype=macro action=stop number=${lightsMacroNumber}

		### switch off blink leds
        add step ptype=switch action=off number=${currentSwitchBlink}
	    ### deactivate the Stopstelle
        add step delay=50 ptype=switch action=off number=${currentSwitch}
        #end

    #end


    ### Set label of Macro
set macro ${lightsMacroNumber} name="${AccessoryName}_${accessoryOffset}_Blinklicht"

    ################################################
    ### configure macro
    ###
select macro ${lightsMacroNumber}
config macro repeat=0 slowdown=1

add step ptype=switch action=on number=${currentSwitchBlink}
add step delay=50 ptype=switch action=off number=${currentSwitchBlink}
add step delay=50 ptype=delay

    ### Define Accessory
select accessory ${currentAccessory}
config accessory startup restore
    #foreach ($currentMacroIndex in [0..$macroCount])

        #set($currentMacroNum = $currentMacroIndex + $firstMacroNumber)

		#if ($currentMacroIndex == 0)
		add aspect $currentMacroIndex macronumber=$currentMacroNum aspectname="Öffnen"
		#else
		add aspect $currentMacroIndex macronumber=$currentMacroNum aspectname="Schliessen"
		#end
    #end

    #set ($accessoryOffset = $accessoryOffset + 1)
    #set ($macroOffset = $macroOffset + 2 + 1)
    #set ($currentServo = $currentServo + 2)

###    #set ($ServoPortNumber = $ServoPortNumber + 2)
    #set ($currentSwitch = $currentSwitch - 2)
    #set ($currentSwitchBlink = $currentSwitch + 1)
#end




© 2015 - 2024 Weber Informatics LLC | Privacy Policy