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.signals.DB_Ks_VorSignal.nodescript Maven / Gradle / Ivy
### Dieses Script definiert ein Accessory,
### um die 2 bis 5 LED eines KS-Vorsignals (DB) anzusteuern.
###
### Die Auswahl der Zusatzanzeiger wird über Checkboxen ausgewählt
###-----------------------------------------------------------------------------------
### Hardware: 2-4 Lightport (1gn, 2=ge, *Optional Zs3v=ge, Ke=ws, Vk/Wh=ws)
### Software: 1 accessory mit 2-3 Aspects
### 2 - 4 macros Kv0, Kv1,
### optional: Kv1+Zs3v,
### Ke = Kennlicht (Betr.Dunkel)
### Zusatz: Verk.Abstand / Widerholer,
### 2 - 4 aspekte wie Macros
###
### history: 0.1 - 2021-05-07 R. Brandt - Ersterstellung durch Ausgegliederung Kv
### 0.2 - 2021-12-26 R. Brandt - Fehler KeD bereinigt,
### Kommentare verbessert
###
###
### KS-Vorsignal
###
### Verk. +----------+
### Abstand |ws* |
### | |
### Hp0 | ge |
### | |
### Ks1 | gn |
### | |
### Wieder- | |
### holer/Ke |ws* |
### +----------+
### *Geschw.- +--+
### Voranzeiger |ge|
### 2-15 +--+
###
#########################################
### how to use:
### A) Set checkboxes to define the signal
### In section 1 select Target
### In section 2 define the signal
### B) configure
### In section 1, define your settings (like brightness and speed)
### In section 2, define your ports
### In section 3, define the macros
### C) load and run this script
### what will happen?
### 1. the ports will be configured with the given parameters
### 2. all new macros for the aspects will be defined
### 3. these macros will be assigned to the accessory
### D) have fun
###
### -------------- A1: Select Target
##application(text:de="DB KS Vorsignal", text:en="DB KS distant signals")
##instruction(text:de="DB KS Vorsignal: 2-4 Lichtausgänge: Kv1(gr), Kv0(ge), Zs3v, Ke 2-4 Aspekte/Macros: Kv1, Kv0, Kv1b1V, Ke", link="https://forum.opendcc.de/wiki/doku.php?id=konfigvorlagen:signale_db_hv_ks#db_ks_vorsignal")
##instruction(text:en="DB KS distant signal: 2-10 lightports: Kv1, Kv0, Kv1, Zs3v, Ke 2-4 Aspekte/Macros: Kv0, Kv1b1V, Ke", link="https://forum.opendcc.de/wiki/doku.php?id=konfigvorlagen:signale_db_hv_ks#db_ks_vorsignal")
###
##input($AccessoryName:string, text:de="Name des KS-Vorsignal-Accessories: ", text:en="Name of the KS distant signal Accessory: ", default="Kv-Sig")
##input($my_accessory:accessory, text:de="Nummer des zu erzeugenden Accessory: ", text:en="Nummber of the Accessory: ", default=0)
##input($my_macro:macro, text:de="Nummer des ersten Macros (Kv1): ", text:en="Number of the first macro: ", default=0)
##input($start_led:light, text:de="Nummer des ersten Lightport (gn LED): ", text:en="Number of the first Lightport: ", default=0)
### -------------- A2: Signal-Auswahl
### optionale Anzeigen
##input($existing_Zs3v:boolean, text:de="Zs3v Geschw.Voranzeiger (zu Ks2)", text:en="Zs3V (to Ks2)", default=false)
##input($existing_Ke:boolean, text:de="Kennlicht verk.Abstand", text:en="Marker light short distance", default=false)
##input($existing_Wh:boolean, text:de="Kennlicht Widerholer", text:en="Marker light repeater", default=false)
##input($existing_Ked:boolean, text:de="Kennlicht bei betrieblich dunkel", text:en="Marker light with dark signal", default=false)
##input($prevent_replace_labels:boolean, text:de="Keine Namen füer Accessory, Makros, Ports ersetzen", text:en="Prevent replace labels for accessory, macro and ports", default=false)
####################################################################################################
############################# Ab hier werden Daten definiert ####################################
####################################################################################################
#set($led_gap = 1) ### die anderen LED sind an den folgenden Lightports angeschlossen
###
### -------------- B1: set Parameters for Ports
#set($WertbeiOff = 0)
#set($WertbeiOn = 200)
#set($Ueberblenden = 5) ### alt: 15
#set($OnTime = 0)
##set($blinka =
#if (${dimm_range} == 8) ### Es handelt sich um einen Knoten mit 8 Bit Dimming
#set($DimmzeitOff = 10)
#set($DimmzeitOn = 10)
#set($DimmzeitOffParam = "DimmOff=${DimmzeitOff}")
#set($DimmzeitOnParam = "DimmOn=${DimmzeitOn}")
#else ### Es handelt sich um einen Knoten mit 16 Bit Dimming
#set($DimmzeitOff = 2500)
#set($DimmzeitOn = 2500)
#set($DimmzeitOffParam = "DimmOff88=${DimmzeitOff}")
#set($DimmzeitOnParam = "DimmOn88=${DimmzeitOn}")
#end
####################################################################################################
############################# Ab hier werden Ligthports definiert ###############################
####################################################################################################
### Leds with Port-Parameters
### and labels: if ${prevent_replace_labels} NOT true
##################################################
#set($led_count = 0)
###
###
#set($led_Kv0 = $led_count * $led_gap + $start_led) ### LED yellow an erstem lightport, der eingegeben wurde
config port ptype=light ValueOff=${WertbeiOff} ValueOn=${WertbeiOn} DimmOff=${DimmzeitOff} DimmOn=${DimmzeitOn} number=${led_Kv0}
#set($led_count = $led_count + 1)
#if (!${prevent_replace_labels})
set light ${led_Kv0} name="${AccessoryName}_${my_accessory}_${led_Kv0}_Kv0"
#end
#set($led_Kv1 = $led_count * $led_gap + $start_led) ### LED green an nächstem lightport, der eingegeben wurde
config port ptype=light ValueOff=${WertbeiOff} ValueOn=${WertbeiOn} DimmOff=${DimmzeitOff} DimmOn=${DimmzeitOn} number=${led_Kv1}
#set($led_count = $led_count + 1)
#if (!${prevent_replace_labels})
set light ${led_Kv1} name="${AccessoryName}_${my_accessory}_${led_Kv1}_Kv1"
#end
#if (${existing_Zs3v})
#set($led_Zs3v = $led_count * $led_gap + $start_led) ### LED Zs3v an nächstem lightport
#set($led_count = $led_count + 1)
config port ptype=light ValueOff=${WertbeiOff} ValueOn=${WertbeiOn} DimmOff=${DimmzeitOff} DimmOn=${DimmzeitOn} number=${led_Zs3v}
#if (!${prevent_replace_labels})
set light ${led_Zs3v} name="${AccessoryName}_${my_accessory}_${led_Zs3v}_Zs3v"
#end
#end
#if (${existing_Ke} or ${existing_Wh} or ${existing_Ked})
#set($led_Ke = $led_count * $led_gap + $start_led) ### LED Ke an nächstem lightport
#set($led_count = $led_count + 1)
config port ptype=light ValueOff=${WertbeiOff} ValueOn=${WertbeiOn} DimmOff=${DimmzeitOff} DimmOn=${DimmzeitOn} number=${led_Ke}
#if (!${prevent_replace_labels})
set light ${led_Ke} name="${AccessoryName}_${my_accessory}_${led_Ke}_Ke"
#end
#end
####################################################################################################
#set ($macro_count = 0)
#set ($end_led = $start_led + $led_count) ### set the last LED-port
#set ($end_led = $end_led - 1) ### - 1 because the counter was incremented before
#set ($macro_fail = -10)
#set ($step_max = 0)
####################################################################################################
############################# Ab hier werden Macros definiert ###################################
####################################################################################################
### -------------- B3. execute part of the script
##################################################
### labels, if ${prevent_replace_labels} NOT true
### At start of macro all LED from $tart_led to $end_led will set down
###########################################
### macros Kv0 & Kv1 are obligat
### Macro Kv0: gelb
#set($macroKv0 = $my_macro + $macro_count) ### need some additional macros
#set($macro_count = $macro_count + 1)
#if (!${prevent_replace_labels})
set macro ${macroKv0} name="${AccessoryName}_${my_accessory}_Kv0"
#end
select macro ${macroKv0}
config macro repeat=1 slowdown=1
### Signal dunkel
#set ($step_count = 0)
#foreach ($port in [$start_led..$end_led])
add step ptype=light action=down number=${port}
#set($step_count = $step_count + 1)
#end
### Kv0 setzten, $Ueberblenden Ticks dunkel
#if (${existing_Ke} or ${existing_Wh})
add step ptype=light action=up delay=${Ueberblenden} number=${led_Ke}
#set($step_count = $step_count + 1)
#end
add step ptype=light action=up delay=${Ueberblenden} number=${led_Kv0}
#set($step_count = $step_count + 1)
#if ($step_count > $step_max)
#set ($step_max = $step_count)
#set ($macro_fail = ${macro_count} - 1)
#end
### Ende Macro Kv0
### Macro Kv1: grün
#set($macroKv1 = $my_macro + $macro_count) ### need some additional macros
#set($macro_count = $macro_count + 1)
#if (!${prevent_replace_labels})
set macro ${macroKv1} name="${AccessoryName}_${my_accessory}_Kv1"
#end
select macro ${macroKv1}
config macro repeat=1 slowdown=1
### Signal dunkel
#set ($step_count = 0)
#foreach ($port in [$start_led..$end_led])
add step ptype=light action=down number=${port}
#set($step_count = $step_count + 1)
#end
### Kv1 setzten, $Ueberblenden
#if (${existing_Wh})
add step ptype=light action=up delay=${Ueberblenden} number=${led_Ke}
#set($step_count = $step_count + 1)
#end
add step ptype=light action=up delay=${Ueberblenden} number=${led_Kv1}
#set($step_count = $step_count + 1)
#if ($step_count > $step_max)
#set ($step_max = $step_count)
#set ($macro_fail = ${macro_count} - 1)
#end
### Ende Macro Kv1
#if (${existing_Zs3v})
### Macro Kv1V = led_Kv1 + led_Zs3v (+ led_Ke)
#set($macroKv1V = $my_macro + $macro_count) ### need some additional macros
#set($macro_count = $macro_count + 1)
#if (!${prevent_replace_labels})
set macro ${macroKv1V} name="${AccessoryName}_${my_accessory}_Kv1V"
#end
### macro operations
select macro ${macroKv1V}
config macro repeat=1 slowdown=1
### Signal dunkel
#set ($step_count = 0)
#foreach ($port in [$start_led..$end_led])
add step ptype=light action=down number=${port}
#set($step_count = $step_count + 1)
#end
### Kv1 setzten, $Ueberblenden Ticks dunkel
add step ptype=light action=up delay=${Ueberblenden} number=${led_Zs3v}
#set($step_count = $step_count + 1)
#if (${existing_Ke} or ${existing_Wh})
add step ptype=light action=up delay=${Ueberblenden} number=${led_Ke}
#set($step_count = $step_count + 1)
#end
add step ptype=light action=up delay=${Ueberblenden} number=${led_Kv1}
#set($step_count = $step_count + 1)
#if (${step_count} > ${step_max})
#set ($step_max = $step_count)
#set ($macro_fail = $macro_count - 1)
#end
#end
### Ende Macro Kv1V
### Kennlicht für dunkles Signal
#if (${existing_Ked})
### Macro Ked: Kennlicht
#set($macroKeD = $my_macro + $macro_count) ### need some additional macros
#set($macro_count = $macro_count + 1)
#if (!${prevent_replace_labels})
set macro ${macroKeD} name="${AccessoryName}_${my_accessory}_KeD"
#end
### macro operations
select macro ${macroKeD}
config macro repeat=1 slowdown=1
### Signal dunkel
#set ($step_count = 0)
#foreach ($port in [$start_led..$end_led])
add step ptype=light action=down number=${port}
#end
### Ke setzten, $Ueberblenden Ticks dunkel
add step ptype=light action=up delay=${Ueberblenden} number=${led_Ke}
#set($step_count = $step_count + 1)
#if (${step_count} > ${step_max})
#set ($step_max = $step_count)
#set ($macro_fail = $macro_count)
#end
#end
### end macro Ked
### Ende aller Macro
####################################################################################################/
### Define Accessory
####################################################################################################/
#if (!${prevent_replace_labels})
### Set label of Accessories
set accessory ${my_accessory} name="${AccessoryName}_${my_accessory}"
#end
#if (${existing_Ke})
#set($kevka = "+ Ke")
#else
#if (${existing_Wh})
#set($kevka = "+ Wh")
#else
#set($kevka = "")
#end
#end
select accessory ${my_accessory}
#set($aspect_count = 0)
add aspect 0 macroname="${AccessoryName}_${my_accessory}_Kv1" ## Kv1
#if (${existing_Wh})
set aspect 0 accessory=${my_accessory} name="Aspect 0 = Kv1 $kevka" ## nur Wh
#else
set aspect 0 accessory=${my_accessory} name="Aspect 0 = Kv1" ## nur Wh
#end
#set($aspect_count = $aspect_count + 1)
add aspect 1 macroname="${AccessoryName}_${my_accessory}_Kv0" ## Kv0
set aspect 1 accessory=${my_accessory} name="Aspect 1 = Kv0 $kevka"
#set($aspect_count = $aspect_count + 1)
#if (${existing_Zs3v})
add aspect $aspect_count macroname="${AccessoryName}_${my_accessory}_Kv1V" ## Kv1 Bl + Zs3v ( + Ke?)
set aspect $aspect_count accessory=${my_accessory} name="Aspect ${aspect_count} = Kv1 + Zs3v $kevka"
#set($aspect_count = $aspect_count + 1)
#end
#if (${existing_Ked})
add aspect $aspect_count macroname="${AccessoryName}_${my_accessory}_KeD" ## Ke bei dunkel
set aspect $aspect_count accessory=${my_accessory} name="Aspect ${aspect_count} = Ke (betr. dunkel)"
#set($aspect_count = $aspect_count + 1)
#end
config accessory startup aspect=1
############################################################################################/
### Test all data
############################################################################################/
### Test if Ke and Wh projected
#if (${existing_Ke} and ${existing_Wh})
#if ($user_lang == "de")
$exceptionThrower.throwUserDefined("Kennlicht und Widerholer sind nicht gleichzeitig erlaubt")
#else
$exceptionThrower.throwUserDefined("Ke und repeater are not allowed at once")
#end
#end
### Test on maximum aspects
#if (${aspect_count} > ${node_accessory_macro_mapped})
#if ($user_lang == "de")
$exceptionThrower.throwUserDefined("Maximal unterstützte Anzahl Aspecte auf diesem Knoten: $node_accessory_macro_mapped: benutzt $aspect_count")
#else
$exceptionThrower.throwUserDefined("Maximum supported number of aspects on this node: $node_accessory_macro_mapped: used $aspect_count")
#end
#end
### Test on maximum macros for the node
#if (${my_macro} + ${macro_count} > ${node_macro_count})
#set ($my_macro = $my_macro + 1)
#if ($user_lang == "de")
$exceptionThrower.throwUserDefined("Maximale Anzahl Macros auf diesem Knoten: $node_macro_count: benutzt $my_macro + neu $macro_count")
#else
$exceptionThrower.throwUserDefined("Maximum number of macros on this node: $node_macro_count: $my_macro + new $macro_count")
#end
#end
#if (${led_count} - 1 * ${led_gap} + ${start_led} > ${node_light_count})
#if ($user_lang == "de")
$exceptionThrower.throwUserDefined("Maximal unterstützte Anzahl Ligthports auf diesem Knoten: $node_light_count: benutzt $led_count")
#else
$exceptionThrower.throwUserDefined("Maximum supported number of Ligthports on this node: $node_light_count: used $led_count")
#end
#end
### Test on maximum macro-steps in all macros.
#if (${step_max} > ${node_macro_size})
#if ($user_lang == "de")
$exceptionThrower.throwUserDefined("Maximal unterstützte Macro-Schritte in Macro $macro_fail = $step_max erlaubt = $node_macro_size")
#else
$exceptionThrower.throwUserDefined("Maximum supported number macro-steps in macro $macro_fail = $step_max allowed = $node_macro_size")
#end
#end
### Test on maximum light-ports for the node