'##############
'Cockpit-Script
'##############

'Simuliert alle unmittelbar mit dem Armaturenbrett zusammenhängenden Funktionen

'(c) 23.10.2009 Rüdiger Hülsmann
'(c) 03.11.2012 Marcel Kuhnt
'(c) 27.02.2011 Markus Rabe

'Script Version: 1.0
'Omsi release: 1.0

'Needs:
'- antrieb
'- engine
'- bremse
'- lights
'- wiper?
'- doors

'NrSpecRandom Seed Area:
'350...355

'Revision History:
'- Rüdiger Hülsmann	09.06.2009	Last Change				
'- Marcel Kuhnt		13.06.2009	Added Gearbox switches			
'- Marcel Kuhnt		13.06.2009	Moved some switchvars to other scripts	
'- Rüdiger Hülsmann	19.06.2009	Added Openable Window Triggers
'- Rüdiger Hülsmann	23.10.2009	Added Battery and kinderwagen light
'- Marcel Kuhnt		26.10.2009	Radio switchable with Motorkühlung (replaced with cassette player)
'- Rüdiger Hülsmann	28.10.2009	Added driver door
'- Rüdiger Hülsmann	16.12.2009	Added driver curtain
'- Rüdiger Hülsmann	18.12.2009	Bugfix driver curtain
'- Marcel Kuhnt		15.04.2010	Traegheit debugged
'- Rüdiger Hülsmann	13.05.2010	Engine temperature
'- Rüdiger Hülsmann	03.06.2010	Automatic battery switch on key insertion (For standard-II-buses)
'- Rüdiger Hülsmann	08.06.2010	Automatic battery switch made optional, Auxiliary heating switchable by button or switch
'- Rüdiger Hülsmann	23.06.2010	Added mouse-clickable wiper lever on wheel console
'- Rüdiger Hülsmann	08.07.2010	Wiper lever: Improved usability 
'- Rüdiger Hülsmann	18.07.2010	Wiper lever: soundfix for keyboard operation and new ignition key algorithm 
'- Rüdiger Hülsmann	16.09.2010	Auxheat Switch Bugfix
'- Rüdiger Hülsmann	18.09.2010	Imported microphone switch
'- Rüdiger Hülsmann	17.10.2010	Added pressure warning needle
'- Rüdiger Hülsmann	23.10.2010	Added old-style gear button functionality
'- Rüdiger Hülsmann	06.11.2010	Gear-button "1" functionality removed for old-style gear buttons
'- Rüdiger Hülsmann	16.11.2010	Heating sliders
'- Rüdiger Hülsmann	23.11.2010	Central lubrication, cabin heater sound
'- Rüdiger Hülsmann	23.12.2010	Included 10 "multi-purpose" dummy switches
'- Rüdiger Hülsmann	29.12.2010	ASR switch
'- Rüdiger Hülsmann	04.01.2011	"D-only" gear selector function
'- Rüdiger Hülsmann	05.01.2011	fog lamp switch, high beam lever animation, clock debugged
'- Rüdiger Hülsmann	07.01.2011	Wiper lever sound and function debugges, availybility of several cockpit functions depending on bus type (via constfile)
'- Rüdiger Hülsmann	16.01.2011	Support for wiper turn-switch
'- Rüdiger Hülsmann	18.01.2011	Old-style gear button sounds
'- Rüdiger Hülsmann	26.01.2011	Invertable driver door
'- Rüdiger Hülsmann	26.01.2011	Thermometer
'- Markus Rabe		27.02.2011	Heizlüfter und Wagenheizung Motorabhängig, Leuchtmelder Hintertür an 80er D Wagen angepasst
'- Marcel Kuhnt		25.06.2011	Nebelscheinwerfer-Schalter (cp_licht_nebelschw_sw)
'- Marcel Kuhnt		29.06.2011	Türkontrolle für D92 und D86 integriert
'- Marcel Kuhnt		22.06.2012	Uhr läuft nur, wenn Strom vorhanden
'- Marcel Kuhnt		09.07.2012	Busbar wird als Faktor/Spannung interpretiert
'- Marcel Kuhnt		25.07.2012	Stromverbrauch, Generierung von Leitwert
'- Marcel Kuhnt		01.11.2012	Türentriegelungs-Leuchtmelder
'- Marcel Kuhnt		02.11.2012	Türentriegelungs-Leuchtmelder für drei Türen
'- Marcel Kuhnt		03.11.2012	Andere Klappfensterbezeichnungen und nur vier Stück
'- Marcel Kuhnt		04.11.2012	Zweite Türkontrolle
'- Marcel Kuhnt		22.03.2013	Hinzugefügt: Schalter Hublift & Knickschutz-Override
'- Marcel Kuhnt		11.09.2013	Dachluken
'- Marcel Kuhnt		12.09.2013	Added Fahrgastpendel
'- Marcel Kuhnt		13.09.2013	Zwei Fahrgastpendel, die zufällige physikalische Eigenschaften haben
'- Marcel Kuhnt		14.10.2013	Neues Heizgerät für NL/NG eingebaut, Klimator- und Wagenlüfter werden im Heizungs-Script simuliert
'- Rüdiger Hülsmann	26.10.2013	Kneeling-Funktion
'- Marcel Kuhnt		08.11.2013	Hublift-Masterschalter
'- Modified by KAJOTT3D 2013-2020


'------------------------------------------------------------------------------------------


'----------------------
'	Trigger
'----------------------

{trigger:automatic_R}
		(L.L.cockpit_gang3) !
		{if}
			(L.L.cockpit_gangR) 0.7 <
			{if}
				(T.L.ev_gangwahltaster)
			{endif}

			(L.L.Brake) 0.2 >
			(L.L.antrieb_getr_gangvorwahl) 1 <= &&
			(L.L.cockpit_gangR) ! &&
			{if}
				(L.L.antrieb_getr_gangvorwahl) 0 = !
				{if}
					(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
				{endif}
			
				0 (S.L.antrieb_getr_gangvorwahl)
			{endif}
				
			1 (S.L.cockpit_gangR)
		{endif}
{end}

{trigger:automatic_R_off}
		(L.L.cockpit_gangR) 1 =
		{if}
			0.7 (S.L.cockpit_gangR)
		{endif}
{end}

{trigger:automatic_N}
'		(L.L.antrieb_getr_gangvorwahl) 1 = !
		(L.L.cockpit_gangR) 0.6 >
		(L.L.cockpit_gang3) 0.6 > ||
		{if}
			(T.L.ev_gangwahltaster_N)
		{endif}

		(L.L.antrieb_getr_gangvorwahl) 1 = !
		{if}
			(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) -  - (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		1 (S.L.antrieb_getr_gangvorwahl)

		1 (S.L.cockpit_gangN)
		0 (S.L.cockpit_gangR) (S.L.cockpit_gang1) (S.L.cockpit_gang2) (S.L.cockpit_gang3)
{end}


{trigger:automatic_N_off}
		0 (S.L.cockpit_gangN)
{end}


{trigger:automatic_1}
	(L.L.antrieb_getr_gangvorwahl) 0 > (C.L.cockpit_gangwahltaster_alt) ! &&
	(C.L.cockpit_gear_D_only) ! &&
	{if}
		(L.L.antrieb_getr_gangvorwahl) 2 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		2 (S.L.antrieb_getr_gangvorwahl)
		1 (S.L.cockpit_gang1)
		0 (S.L.cockpit_gang2) (S.L.cockpit_gang3)
	{endif}
{end}


{trigger:automatic_1_off}
	(L.L.cockpit_gang1) 1 =
	{if}
		0.7 (S.L.cockpit_gang1)
	{endif}
{end}


{trigger:automatic_2}
		(L.L.antrieb_getr_gangvorwahl) 0 >
		(C.L.cockpit_gear_D_only) ! &&
		{if}
			(L.L.antrieb_getr_gangvorwahl) 3 = !
			{if}
				(T.L.ev_gangwahltaster)
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
			{endif}
			3 (S.L.antrieb_getr_gangvorwahl)
			1 (S.L.cockpit_gang2)
			0 (S.L.cockpit_gang1) (S.L.cockpit_gang3)
		{endif}
{end}


{trigger:automatic_2_off}
		(L.L.cockpit_gang2) 1 =
		{if}
			0.7 (S.L.cockpit_gang2)
		{endif}
{end}


{trigger:automatic_D}
		(L.L.cockpit_gangR) !
		{if}
			(L.L.cockpit_gang3) 0.7 <
			{if}
				(T.L.ev_gangwahltaster)
			{endif}

			(L.L.Brake) 0.2 >
			(L.L.antrieb_getr_gangvorwahl) 0 > &&
			(L.L.cockpit_gang3) ! &&
			{if}
				(L.L.antrieb_getr_gangvorwahl) 4 = !
				{if}
					(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
				{endif}
				4 (S.L.antrieb_getr_gangvorwahl)
			{endif}
			1 (S.L.cockpit_gang3)
			0 (S.L.cockpit_gang1) (S.L.cockpit_gang2)	
		
		{endif}
{end}


{trigger:automatic_D_off}
		(L.L.cockpit_gang3) 1 =
		{if}
			0.7 (S.L.cockpit_gang3)
		{endif}	
{end}

{trigger:horn}
	
		(L.L.cockpit_hupe) ! (L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
		{if}
			(T.L.ev_hupe_an)
		{endif}
		1 (S.L.cockpit_hupe)
	
{end}

{trigger:horn_off}	
	
		(L.L.cockpit_hupe) (L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
		{if}
			(T.L.ev_hupe_aus)
		{endif}
		0 (S.L.cockpit_hupe)	
	
{end}

{trigger:cp_retarder_direkt_toggle}
	(C.L.cockpit_has_retarder)
	{if}
		(L.L.cp_retarder_sw_direkt) ! (S.L.cp_retarder_sw_direkt) s1
		(M.L.kippschaltersound)
	{endif}
{end}


{trigger:cp_retarder_toggle}
	(C.L.cockpit_has_retarderswitch)
	{if}
		(L.L.cp_retarder_sw) ! (S.L.cp_retarder_sw) s1
		(M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_motorkuehlung_toggle}
	(C.L.cockpit_has_coolingswitch)
	{if}
		(L.L.cp_motorkuehlung_sw) ! (S.L.cp_motorkuehlung_sw) s1
		(M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_fahrerlicht_toggle}
	(L.L.cp_fahrerlicht_sw) ! (S.L.cp_fahrerlicht_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_notaus_on-off_toggle}
	(L.L.cp_notaus_sw) !
	{if}
		(L.L.cp_notaus_on-off_sw) ! (S.L.cp_notaus_on-off_sw) s1
		(M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_notaus_toggle}
	(L.L.cp_notaus_on-off_sw)
	{if}
		(L.L.cp_notaus_sw) ! (S.L.cp_notaus_sw) s1
		0 (S.L.elec_V_battery)
		0 (S.L.engine_injection_on)
		(M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_20h_aus_on-off_toggle}
	(L.L.cp_20h_aus_sw) !
	{if}
		(L.L.cp_20h_aus_on-off_sw) ! (S.L.cp_20h_aus_on-off_sw) s1
		(M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_20h_aus_toggle}
	(L.L.cp_20h_aus_on-off_sw)
	{if}
		(L.L.cp_20h_aus_sw) ! (S.L.cp_20h_aus_sw) s1
		(M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_licht_untenrechts_toggle}
	(L.L.cp_licht_int) 0 =
	{if}
		1 (S.L.cp_licht_untenrechts_sw) (S.L.cp_licht_unterdeck_sw)
		-1 (S.L.cp_licht_int) s1
	{else}
		0 (S.L.cp_licht_untenrechts_sw) (S.L.cp_licht_unterdeck_sw)
		0 (S.L.cp_licht_int) s1
	{endif}		
	(M.L.kippschaltersound)
{end}

{trigger:cp_licht_unterdeck_toggle}
	(L.L.cp_licht_int) 0 =
	{if}
		0 (S.L.cp_licht_untenrechts_sw) 
		1 (S.L.cp_licht_unterdeck_sw)
		1 (S.L.cp_licht_int) s1
	{else}
		0 (S.L.cp_licht_untenrechts_sw) (S.L.cp_licht_unterdeck_sw)
		0 (S.L.cp_licht_int) s1
	{endif}
	(M.L.kippschaltersound)	
{end}

{trigger:cp_licht_nebelschw_sw}
	(L.L.cp_licht_nebelschw_sw) 
	{if}
		0 (S.L.cp_licht_nebelschw_sw) s1
	{else}
		1 (S.L.cp_licht_nebelschw_sw) s1
	{endif}		
	(M.L.kippschaltersound)
{end}

{trigger:cp_wischer_schnell_toggle}
	(L.L.cp_wischer_schnell_sw) ! (S.L.cp_wischer_schnell_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:kw_wipermode_up}
	(L.L.cp_wischer_einaus_sw) ! (S.L.cp_wischer_einaus_sw) s1
	{if}
		2 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
		2 3 / (S.L.cockpit_wischerhebel) (S.L.cockpit_wischer_drehschalter)
		(L.L.cp_wischer_intervall_sw) !
		{if}
			(T.L.ev_wischerhebel)
		{endif}
	{else}
		(L.L.cp_wischer_intervall_sw)
		{if}
			1 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
			1 3 / (S.L.cockpit_wischerhebel) 
			0 (S.L.cockpit_wischer_drehschalter)
		{else}
			0 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischerhebel) 
			1 3 / (S.L.cockpit_wischer_drehschalter)
			(T.L.ev_wischerhebel)
		{endif}
	{endif}
	(C.L.wiper_lever) !
	{if}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_wischer_intervall_toggle}
	(L.L.cp_wischer_intervall_sw) ! (S.L.cp_wischer_intervall_sw) s1
	(L.L.cp_wischer_einaus_sw) ! &&
	{if}
		1 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
		1 3 / (S.L.cockpit_wischerhebel) 
		0 (S.L.cockpit_wischer_drehschalter)
	{else}
		(L.L.cp_wischer_einaus_sw)
		{if}
			2 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
			2 3 / (S.L.cockpit_wischerhebel) (S.L.cockpit_wischer_drehschalter)
		{else}
			0 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischerhebel)
			1 3 / (S.L.cockpit_wischer_drehschalter)
		{endif}

	{endif}
	(C.L.wiper_lever) !
	{if}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_wischer_wascher_button}
	1 (S.L.cp_wischer_wascher_sw) s1
	(C.L.wiper_lever)
	{if}
		(T.L.ev_wischerhebel)
		1 (S.L.cockpit_wischerhebel_x)
	{else}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_wischer_wascher_button_off}
	0 (S.L.cp_wischer_wascher_sw) s1
	(S.L.wiper_wascher_sw)
	(C.L.wiper_lever)
	{if}
		(T.L.ev_wischerhebel)
		0 (S.L.cockpit_wischerhebel_x)
	{else}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_auto_klimat_toggle}
	(L.L.cp_auto_klimat_function) ! (S.L.cp_auto_klimat_function)
	1 (S.L.cp_auto_klimat_sw)
{end}

{trigger:cp_auto_klimat_toggle_off}
	0 (S.L.cp_auto_klimat_sw)
{end}

{trigger:cp_reheat_toggle}
	(L.L.cp_reheat) ! (S.L.cp_reheat)
	1 (S.L.cp_reheat_sw) 
{end}

{trigger:cp_reheat_toggle_off}
	0 (S.L.cp_reheat_sw)
{end}

{trigger:cp_luefter_toggle}
	(L.L.cp_luefter_sw) ! (S.L.cp_luefter_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_klima_kier_toggle}
	(L.L.cp_klima_kier_function) ! (S.L.cp_klima_kier_function)
	1 (S.L.cp_klima_kier_sw)
{end}

{trigger:cp_klima_kier_toggle_off}
	0 (S.L.cp_klima_kier_sw)
{end}

{trigger:cp_spiegelheizung_toggle}
	(L.L.cp_spiegelheizung) !
	{if}
		1 (S.L.cp_spiegelheizung_sw) (S.L.cp_spiegelheizung)
	{else}
		-1 (S.L.cp_spiegelheizung_sw) 
		0 (S.L.cp_spiegelheizung)
	{endif}
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_spiegelheizung_toggle_off}
	0 (S.L.cp_spiegelheizung_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_kneeling_toggle}
	1 (S.L.cp_kneeling_sw)

	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	(L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) < &&
	(L.L.door_0) 0.01 < &&
	(L.L.door_1) 0.01 < &&
	(L.L.door_2) 0.01 < &&
	(L.L.door_3) 0.01 < &&
	(L.L.door_4) 0.01 < &&
	(L.L.door_5) 0.01 < &&
	(L.L.door_6) 0.01 < &&
	(L.L.door_7) 0.01 < &&
	{if}
		1 (S.L.cp_kneeling)
	{endif}
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_kneeling_toggle_off}
	0 (S.L.cp_kneeling_sw)
	(L.L.kneeling_timer) 4 <
	{if}
		0 (S.L.cp_kneeling)
	{endif}
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_kneeling2_toggle}
	-1 (S.L.cp_kneeling_sw)

	(L.L.elec_busbar_main)
	(L.L.door_0) 0.01 < &&
	(L.L.door_1) 0.01 < &&
	(L.L.door_2) 0.01 < &&
	(L.L.door_3) 0.01 < &&
	(L.L.door_4) 0.01 < &&
	(L.L.door_5) 0.01 < &&
	(L.L.door_6) 0.01 < &&
	(L.L.door_7) 0.01 < &&
	(L.L.cp_kneeling) &&
	{if}
		0 (S.L.cp_kneeling) (S.L.kneeling_timer)
		(T.L.ev_kneel_up)
	{endif}
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_kneeling2_toggle_off}
	0 (S.L.cp_kneeling_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_door_lock_01_left_toggle}

(L.L.front_door_lock_button) 1 =
{if}
	(L.L.cp_door_lock_01_sw) 0 =
	{if}
		1 (S.L.cp_door_lock_01_sw) s1
		1 (S.L.cp_door_lock_0)
		0 (S.L.cp_door_lock_1)
		(L.L.door_0) 0.01 >
		{if}
			0 (S.L.door_gap01) (S.L.door_trigger_0)
			(M.L.piep_piep)
		{endif}
	{else}
		0 (S.L.cp_door_lock_01_sw) s1
		0 (S.L.cp_door_lock_0)
		0 (S.L.cp_door_lock_1)
		(L.L.door_0) 0.01 <
		(L.L.door_1) 0.01 > &&
		{if}
			0 (S.L.door_gap01) (S.L.door_trigger_0)
			(M.L.piep_piep)
		{else}
			(L.L.door_0) 0.01 >
			(L.L.door_1) 0.01 < &&
			{if}
				0 (S.L.door_gap01) (S.L.door_trigger_1)
				(M.L.piep_piep)
			{endif}
		{endif}
	{endif}
	(M.L.kippschaltersound)
	0 (S.L.cockpit_tuertaster1cg) (S.L.cockpit_tuertaster2cg)
{endif}

{end}

{trigger:cp_door_lock_01_right_toggle}

(L.L.front_door_lock_button) 1 =
{if}
	(L.L.cp_door_lock_01_sw) 0 =
	{if}
		-1 (S.L.cp_door_lock_01_sw) s1
		0 (S.L.cp_door_lock_0)
		1 (S.L.cp_door_lock_1)
		(L.L.door_1) 0.01 >
		{if}
			0 (S.L.door_gap01) (S.L.door_trigger_1)
			(M.L.piep_piep)
		{endif}
	{else}
		0 (S.L.cp_door_lock_01_sw) s1
		0 (S.L.cp_door_lock_0)
		0 (S.L.cp_door_lock_1)
		(L.L.door_0) 0.01 <
		(L.L.door_1) 0.01 > &&
		{if}
			0 (S.L.door_gap01) (S.L.door_trigger_0)
			(M.L.piep_piep)
		{else}
			(L.L.door_0) 0.01 >
			(L.L.door_1) 0.01 < &&
			{if}
				0 (S.L.door_gap01) (S.L.door_trigger_1)
				(M.L.piep_piep)
			{endif}
		{endif}
	{endif}
	(M.L.kippschaltersound)
	0 (S.L.cockpit_tuertaster1cg) (S.L.cockpit_tuertaster2cg)
{endif}
{end}

{trigger:bus_dooraft}
	(L.L.cieply_guzik) 1 =
	{if}
		(L.L.cp_cgon_sw) ! (S.L.cp_cgon_sw) s1
		(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
		(L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) < &&
		{if}
			1 (S.L.cp_cgon)

			(L.L.haltewunsch_1)
			{if}
				(L.L.cp_door_lock_0) !
				{if}
					0 (S.L.door_gap01) (S.L.door_trigger_0)
					1 (S.L.cockpit_tuertaster1cg)
				{endif}
				(L.L.cp_door_lock_1) !
				{if}
					0 (S.L.door_gap01) (S.L.door_trigger_1)
					1 (S.L.cockpit_tuertaster2cg)
				{endif}
			{endif}

			(L.L.haltewunsch_2)
			{if}
				0 (S.L.door_gap23) (S.L.door_trigger_23)
				1 (S.L.cockpit_tuertaster3cg)
			{endif}

			(L.L.haltewunsch_3)
			{if}
				0 (S.L.door_gap45) (S.L.door_trigger_45)
				1 (S.L.cockpit_tuertaster4cg)
			{endif}

			(L.L.haltewunsch_4)
			{if}
				0 (S.L.door_gap67) (S.L.door_trigger_67)
				1 (S.L.cockpit_tuertaster5cg)
			{endif}
		{else}
			0 (S.L.cp_cgon)
		{endif}
		(M.L.kippschaltersound)
	{else}
		0 (S.L.cp_cgon)
	{endif}
{end}

{trigger:cp_bus_door_all}
	(L.L.elec_busbar_vdo)
	{if}
		(L.L.door_20h_sw) (C.L.door_needs_stopbrakeswitch) && (C.L.door_needs_stopbrake) ! &&
		(L.L.bremse_halte) (C.L.door_needs_stopbrake) && ||
		(C.L.door_needs_stopbrake) (C.L.door_needs_stopbrakeswitch) || ! ||
		(L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) < ||
		{if}
			(L.L.door_0) 0.05 > !
			(L.L.cp_door_lock_0) ! &&
			{if}
				0 (S.L.door_gap01) (S.L.door_trigger_0)
				1 (S.L.cockpit_tuertaster1cg)
			{else}
				1 (S.L.cockpit_tuertaster1cg)
			{endif}
		
			(L.L.door_1) 0.05 > !
			(L.L.cp_door_lock_1) ! &&
			{if}
				0 (S.L.door_gap01) (S.L.door_trigger_1)
				1 (S.L.cockpit_tuertaster2cg)
			{else}
				1 (S.L.cockpit_tuertaster2cg)
			{endif}
			
			(L.L.door_3) 0.05 > !
			{if}
				0 (S.L.door_gap23) (S.L.door_trigger_23)
				1 (S.L.cockpit_tuertaster3cg)
			{else}
				1 (S.L.cockpit_tuertaster3cg)
			{endif}
			
			(L.L.door_4) 0.05 > !
			{if}
				0 (S.L.door_gap45) (S.L.door_trigger_45)
				1 (S.L.cockpit_tuertaster4cg)
			{else}
				1 (S.L.cockpit_tuertaster4cg)
			{endif}
			
			(L.L.door_6) 0.05 > !
			{if}
				0 (S.L.door_gap67) (S.L.door_trigger_67)
				1 (S.L.cockpit_tuertaster4cg)
			{else}
				1 (S.L.cockpit_tuertaster4cg)
			{endif}
		{endif}
	{endif}
	
	1 (S.L.cp_door_all_sw)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_bus_door_all_off}
	0 (S.L.cp_door_all_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_schalter_kinderwagen}
	1 (S.L.cp_inw_dis_sw)
	(L.L.elec_busbar_vdo) &&
	(L.L.check_timer) 7 >=
	(L.L.check_timer) 9 < &&
	(L.L.check_timer) 20.5 >= || &&
	{if}
		0 (S.L.halt_inw)
	{endif}
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_schalter_kinderwagen_off}
	0 (S.L.cp_inw_dis_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_dachluke_g_mb}
	1 (S.L.dachluke_mb_sw)
	(L.L.cockpit_heizregler_umluft) !
	{if}
		(L.L.cp_dachluke1_rot_mode) 3 <
		{if}
			(L.L.cp_dachluke1_rot) 0.333 + 0 max 1 min (S.L.cp_dachluke1_rot)
			(M.L.dachluke1_rot_mode)
		{else}
			0.333 (S.L.cp_dachluke1_rot)
			(M.L.dachluke1_rot_mode)
		{endif}
	{endif}
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_dachluke_g_mb_off}
	0 (S.L.dachluke_mb_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_dachluke_d_mb}
	-1 (S.L.dachluke_mb_sw)
	0 (S.L.cp_dachluke1_rot)
	(M.L.dachluke1_rot_mode)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_dachluke_d_mb_off}
	0 (S.L.dachluke_mb_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_regulacja_pulpitu_toggle}
	(L.L.cp_regulacja_pulpitu_sw) ! (S.L.cp_regulacja_pulpitu_sw) s1
	(L.L.bremse_halte) (L.L.door_20h_sw) && 
	(L.L.bremse_feststell) || &&
	{if}
		1 (S.L.cp_regulacja_pulpitu)
	{else}
		0 (S.L.cp_regulacja_pulpitu)
	{endif}
	(M.L.kippschaltersound)
{end}

{trigger:cp_regulacja_pulpitu_d_drag}
(L.L.cp_regulacja_pulpitu)
{if}
	(L.L.cp_regulacja_pulpitu_pos) (S.L.cp_regulacja_pulpitu_lastpos)
	(L.L.cp_regulacja_pulpitu_lift) (S.L.cp_regulacja_pulpitu_lastlift)

	(L.S.mouse_x) 100 / (L.L.cp_regulacja_pulpitu_pos) + (S.L.cp_regulacja_pulpitu_pos) s0
	l0 -0.5 <
	{if}
		-0.5 (S.L.cp_regulacja_pulpitu_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_regulacja_pulpitu_pos)
	{endif}

	(L.S.mouse_y) -150 / (L.L.cp_regulacja_pulpitu_lift) + (S.L.cp_regulacja_pulpitu_lift) s1
	l1 -1 <
	{if}
		-1 (S.L.cp_regulacja_pulpitu_lift)		
	{endif}
	l1 1 >
	{if}
		1 (S.L.cp_regulacja_pulpitu_lift)
	{endif}

	(L.L.cp_regulacja_pulpitu_pos) (L.L.cp_regulacja_pulpitu_lastpos) - (L.L.cp_regulacja_pulpitu_lift) (L.L.cp_regulacja_pulpitu_lastlift) - + 4 / (L.S.Timegap) / (S.L.cp_regulacja_pulpitu_speed)
{endif}
{end}

{trigger:cp_regulacja_pulpitu_d_off}
	0 (S.L.cp_regulacja_pulpitu_speed)
{end}

{trigger:cp_lus_ster_drag}

	(L.S.mouse_x) 80 / (L.L.cp_lus_ster_x_pos) + (S.L.cp_lus_ster_x_pos) s0
	l0 -1 <
	{if}
		-1 (S.L.cp_lus_ster_x_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_lus_ster_x_pos)
	{endif}

	(L.S.mouse_y) 80 / (L.L.cp_lus_ster_y_pos) + (S.L.cp_lus_ster_y_pos) s0
	l0 -1 <
	{if}
		-1 (S.L.cp_lus_ster_y_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_lus_ster_y_pos)
	{endif}

	(L.L.cp_lus_ster_p_sw) !
	{if}
		(L.L.cp_lus_ster_x) (L.S.Timegap) (L.L.cp_lus_ster_x_pos) -0.05 * * + -0.1 max 0.1 min (S.L.cp_lus_ster_x)
	{else}
		(L.L.cp_lus_ster_x_2) (L.S.Timegap) (L.L.cp_lus_ster_x_pos) -0.05 * * + -0.1 max 0.1 min (S.L.cp_lus_ster_x_2)
	{endif}
'	(L.L.cp_lus_ster_y) (L.S.Timegap) (L.L.cp_lus_ster_y_pos) * + -1 max 1 min (S.L.cp_lus_ster_y)
{end}

{trigger:cp_lus_ster_off}
	0 (S.L.cp_lus_ster_x_pos) (S.L.cp_lus_ster_y_pos)
{end}

{trigger:cp_lus_ster_2_drag}

	(L.S.mouse_x) 80 / (L.L.cp_lus_ster_x_2_pos) + (S.L.cp_lus_ster_x_2_pos) s0
	l0 -1 <
	{if}
		-1 (S.L.cp_lus_ster_x_2_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_lus_ster_x_2_pos)
	{endif}

	(L.L.cp_lus_ster_x_2) (L.S.Timegap) (L.L.cp_lus_ster_x_2_pos) -0.05 * * + -0.1 max 0.1 min (S.L.cp_lus_ster_x_2)
{end}

{trigger:cp_lus_ster_2_off}
	0 (S.L.cp_lus_ster_x_2_pos)
{end}

{trigger:cp_lus_ster_p_toggle}
	(L.L.cp_lus_ster_p_sw) ! (S.L.cp_lus_ster_p_sw)
{end}

{trigger:cp_luft_toggle}
	(L.L.cp_luft_function) !
	{if}
		1 (S.L.cp_luft_sw) (S.L.cp_luft_function)
	{else}
		-1 (S.L.cp_luft_sw)
		0 (S.L.cp_luft_function)
	{endif}
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_luft_toggle_off}
	0 (S.L.cp_luft_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_ogrzewanie_szyb_toggle}
	(L.L.cp_ogrzewanie_szyb_sw) ! (S.L.cp_ogrzewanie_szyb_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_nothahn_1_toggle}
	(L.L.cp_nothahn_1) ! (S.L.cp_nothahn_1) s1
	(M.L.nothahnsound)
{end}

{trigger:cp_nothahn_2_toggle}
	(L.L.cp_nothahn_2) ! (S.L.cp_nothahn_2) s1
	(M.L.nothahnsound)
{end}

{trigger:cp_nothahn_3_toggle}
	(L.L.cp_nothahn_3) ! (S.L.cp_nothahn_3) s1
	(M.L.nothahnsound)
{end}

{trigger:cp_nothahn_4_toggle}
	(L.L.cp_nothahn_4) ! (S.L.cp_nothahn_4) s1
	(M.L.nothahnsound)
{end}

{trigger:cp_elec_glass_g_mb}
	1 (S.L.elec_glass_mb_sw)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_elec_glass_g_mb_off}
	0 (S.L.elec_glass_mb_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_elec_glass_d_mb}
	-1 (S.L.elec_glass_mb_sw)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_elec_glass_d_mb_off}
	0 (S.L.elec_glass_mb_sw)
	(T.L.ev_kippschalter_aus)
{end}

'--------------------------------------------------------
'Dummys:

{trigger:cp_dummy_sw01_toggle}
	(L.L.cp_dummy_sw01) ! (S.L.cp_dummy_sw01) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw02_toggle}
	(L.L.cp_dummy_sw02) ! (S.L.cp_dummy_sw02) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw03_toggle}
	(L.L.cp_dummy_sw03) ! (S.L.cp_dummy_sw03) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw04_toggle}
	(L.L.cp_dummy_sw04) ! (S.L.cp_dummy_sw04) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw05_toggle}
	(L.L.cp_dummy_sw05) ! (S.L.cp_dummy_sw05) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw06_toggle}
	(L.L.cp_dummy_sw06) ! (S.L.cp_dummy_sw06) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw07_toggle}
	(L.L.cp_dummy_sw07) ! (S.L.cp_dummy_sw07) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw08_toggle}
	(L.L.cp_dummy_sw08) ! (S.L.cp_dummy_sw08) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw09_toggle}
	(L.L.cp_dummy_sw09) ! (S.L.cp_dummy_sw09) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_dummy_sw10_toggle}
	(L.L.cp_dummy_sw10) ! (S.L.cp_dummy_sw10) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_ASR_off_toggle}
	(L.L.cp_ASR_off) ! (S.L.cp_ASR_off)
	1 (S.L.cp_ASR_off_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_ASR_off_toggle_off}
	0 (S.L.cp_ASR_off_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_knick_ovrd_toggle}
	1 (S.L.cp_knick_ovrd_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_knick_ovrd_toggle_off}
	0 (S.L.cp_knick_ovrd_sw) s1
	(M.L.kippschaltersound)
{end}





{trigger:cp_klimator_sw_drag}
	(L.S.mouse_y) -100 / (L.L.cp_klimator_sw) + (S.L.cp_klimator_sw) s0
	l0 0 <
	{if}
		0 (S.L.cp_klimator_sw)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_klimator_sw)
	{endif}
{end}


{trigger:cp_rollo_drag}

	(L.L.cp_rollo_pos) (S.L.cp_rollo_lastpos)

	1 (S.L.cp_rollo_dragged)

	(C.L.rolety_zwijanie) !
	{if}
		0 (S.L.cp_rollo_speed)
	{endif}

	(L.S.mouse_y) 500 / (L.L.cp_rollo_pos) + (S.L.cp_rollo_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_rollo_pos)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_rollo_pos)
	{endif}

	(C.L.rolety_zwijanie) !
	{if}
		(L.L.cp_rollo_pos) (L.L.cp_rollo_lastpos) - abs (L.S.Timegap) / (S.L.cp_rollo_speed)
	{else}
		(L.L.cp_rollo_pos) (L.L.cp_rollo_lastpos) - (L.S.Timegap) / (S.L.cp_rollo_speed)
	{endif}
{end}

{trigger:cp_rollo_off}
	0 (S.L.cp_rollo_dragged)

	(C.L.rolety_zwijanie)
	{if}
		0 (S.L.cp_rollo_speed)
	{endif}

	(T.L.ev_rollo_end)
{end}

{trigger:cp_rollo_retract}
	(L.L.cp_rollo_bommel) 0 = (L.L.cp_rollo_pos) &&
	{if}
		(T.L.ev_rollo_retract)
	{endif}
	1 (S.L.cp_rollo_bommel) (S.L.cp_rollo_retract)

{end}

{trigger:cp_rollo_retract_off}
	0 (S.L.cp_rollo_bommel) (S.L.cp_rollo_retract) (S.L.cp_rollo_speed)
{end}

{trigger:cp_rollo2_drag}

	(L.L.cp_rollo2_pos) (S.L.cp_rollo2_lastpos)

	1 (S.L.cp_rollo2_dragged)
'	0 (S.L.cp_rollo2_speed)
	(L.S.mouse_y) 800 / (L.L.cp_rollo2_pos) + (S.L.cp_rollo2_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_rollo2_pos)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_rollo2_pos)
	{endif}

	(L.L.cp_rollo2_pos) (L.L.cp_rollo2_lastpos) - abs (L.S.Timegap) / (S.L.cp_rollo2_speed)

{end}

{trigger:cp_rollo2_off}
	0 (S.L.cp_rollo2_dragged)
	0 (S.L.cp_rollo2_speed)
	(T.L.ev_rollo2_end)
{end}

{trigger:cp_rollo2_retract}
	(L.L.cp_rollo2_bommel) 0 = (L.L.cp_rollo2_pos) &&
	{if}
		(T.L.ev_rollo2_retract)
	{endif}
	1 (S.L.cp_rollo2_bommel) (S.L.cp_rollo2_retract)

{end}

{trigger:cp_rollo2_retract_off}
	0 (S.L.cp_rollo2_bommel) (S.L.cp_rollo2_retract) (S.L.cp_rollo2_speed)
{end}

{trigger:cp_fahrerfenster_opn_drag}
	(L.L.cp_fahrerfenster_pos) (S.L.cp_fahrerfenster_lastpos)

	(L.S.mouse_x) -500 / (L.L.cp_fahrerfenster_pos) + (S.L.cp_fahrerfenster_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fahrerfenster_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fahrerfenster_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	1 (L.L.cp_fahrerfenster2_pos) - (L.L.cp_fahrerfenster_pos) <
	{if}
		1 (L.L.cp_fahrerfenster2_pos) - (S.L.cp_fahrerfenster_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.cp_fahrerfenster_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.cp_fahrerfenster_pos) (L.L.cp_fahrerfenster_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}


{trigger:cp_fahrerfenster_opn_off}
	0 (S.L.cp_fahrerfenster_speed)
{end}

{trigger:cp_fahrerfenster2_opn_drag}
	(L.L.cp_fahrerfenster2_pos) (S.L.cp_fahrerfenster2_lastpos)

	(L.S.mouse_x) 500 / (L.L.cp_fahrerfenster2_pos) + (S.L.cp_fahrerfenster2_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fahrerfenster2_pos)
		(L.L.cp_fahrerfenster2_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster2_cls)
		{endif}
		1 (S.L.cp_fahrerfenster2_endanschlag)
		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fahrerfenster2_pos)
		(L.L.cp_fahrerfenster2_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster2_opn)
		{endif}
		1 (S.L.cp_fahrerfenster2_endanschlag)
	{endif}

	1 (L.L.cp_fahrerfenster_pos) - (L.L.cp_fahrerfenster2_pos) <
	{if}
		1 (L.L.cp_fahrerfenster_pos) - (S.L.cp_fahrerfenster2_pos)
		(L.L.cp_fahrerfenster2_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster2_endanschlag)
	{endif}

	(L.L.cp_fahrerfenster2_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster2_endanschlag)
	{endif}


	(L.L.cp_fahrerfenster2_pos) (L.L.cp_fahrerfenster2_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster2_speed)
{end}


{trigger:cp_fahrerfenster2_opn_off}
	0 (S.L.cp_fahrerfenster2_speed)
{end}

{trigger:cp_fahrerfenster3_opn_drag}

	(L.L.cp_fahrerfenster3_pos) (S.L.cp_fahrerfenster3_lastpos)

	(L.S.mouse_x) 250 / (L.L.cp_fahrerfenster3_pos) + (S.L.cp_fahrerfenster3_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fahrerfenster3_pos)
		(L.L.cp_fahrerfenster3_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster3_endanschlag)
		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fahrerfenster3_pos)
		(L.L.cp_fahrerfenster3_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster3_endanschlag)
	{endif}

	(L.L.cp_fahrerfenster3_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster3_endanschlag)
	{endif}


	(L.L.cp_fahrerfenster3_pos) (L.L.cp_fahrerfenster3_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster3_speed)
{end}


{trigger:cp_fahrerfenster3_opn_off}
	0 (S.L.cp_fahrerfenster3_speed)
{end}

{trigger:cp_kasa_drag}

	1 (S.L.cp_kasa_dragged)
	(L.L.cp_kasa_pos) (S.L.cp_kasa_lastpos)

	(L.S.mouse_y) -1 * 100 / (L.L.cp_kasa_pos) + (S.L.cp_kasa_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_kasa_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_kasa_pos)
	{endif}

	(L.L.cp_kasa_pos) (L.L.cp_kasa_lastpos) - (L.S.Timegap) / (S.L.cp_kasa_speed)
{end}


{trigger:cp_kasa_off}
	0 (S.L.cp_kasa_dragged)
{end}

{trigger:cp_schluessel_mov_drag}

	(L.S.mouse_y) abs (L.S.mouse_x) abs >=
	{if}

		(L.S.mouse_y) 30 / (L.L.cp_schluessel_trans2) + 0 max 1 min (S.L.cp_schluessel_trans2) s1

		l1 0.2 <
		{if}
			0 (S.L.cp_schluessel_trans2_mode)
			0 (S.L.cp_mgielne_sw)
			0 (S.L.cp_taster_nebelschluss)

		{else} 
			l1 0.8 <
			{if}
				1 (S.L.cp_schluessel_trans2_mode)
				0 (S.L.cp_taster_nebelschluss)
				1 (S.L.cp_mgielne_sw)
			{else}
				2 (S.L.cp_schluessel_trans2_mode)
				1 (S.L.cp_taster_nebelschluss)
			{endif}
		{endif}
	{else}

		(L.S.mouse_x) 30 / (L.L.cp_schluessel_rot) + 0 max 1 min (S.L.cp_schluessel_rot) s1

		l1 0.2 <
		{if}
			0 (S.L.cp_schluessel_rot_mode) 
		{else} 
			l1 0.8 <
			{if}
				1 (S.L.cp_schluessel_rot_mode) 
			{else}
				2 (S.L.cp_schluessel_rot_mode)
			{endif}
		{endif}
	{endif}
{end}

{trigger:cp_schluessel_mov_off}

'	Einrasten auf den festen Positionen:
	(L.L.cp_schluessel_trans2_mode) 2 / (S.L.cp_schluessel_trans2)
	(L.L.cp_schluessel_rot_mode) 2 / (S.L.cp_schluessel_rot)

{end}

{trigger:cp_rampa_drag}

	1 (S.L.cp_rampa_dragged)
	(L.L.cp_rampa_pos) (S.L.cp_rampa_lastpos)

	(L.S.mouse_y) -500 / (L.L.cp_rampa_pos1) + (S.L.cp_rampa_pos1) s0
	l0 0 <
	{if}
		0 (S.L.cp_rampa_pos1)		
	{endif}

	(L.L.door_2) 0.9 >
	(L.L.door_3) 0.9 > &&
	{if}
		l0 1 >
		{if}
			1 (S.L.cp_rampa_pos1)
		{endif}
	{else}
		l0 0.003 >
		{if}
			0.003 (S.L.cp_rampa_pos1)
		{endif}
	{endif}

	(L.L.cp_rampa_pos1) (L.L.cp_rampa_lastpos) - (L.S.Timegap) / 0.2 * (S.L.cp_rampa_speed)
{end}


{trigger:cp_rampa_off}
	0 (S.L.cp_rampa_dragged)
{end}





{trigger:cp_lenkrad_toggle}
	(L.L.cp_lenkrad_visible) ! (S.L.cp_lenkrad_visible)
{end}

{trigger:cp_dykta_toggle}
	(L.L.cp_dykta_visible) ! (S.L.cp_dykta_visible)
{end}

{trigger:cp_batterietrennschalter_toggle}
	(L.L.cp_batterietrennschalter_antirepeat) !
	(L.L.cp_keyboard_e_m) 3 <= &&
	{if}

		(L.L.cp_keyboard_e_m) 1 =
		(L.L.cp_keyboard_e_m) 2 = ||
		{if}
			3 (S.L.cp_keyboard_e_m)
		{else}
			(L.L.cp_keyboard_e_m) 0 =
			{if}
				1 (S.L.cp_keyboard_e_m)
			{endif}
		{endif}

		(L.L.cp_keyboard_e_m) 1 =
		{if}
			0.375 (S.L.cp_kluczyk_rot)
			1 (S.L.cp_kluczyk_rot_mode)
			(L.L.check_timer_ar) 0 =
			{if}
				0 (S.L.check_timer)
			{endif}
			1 (S.L.elec_busbar_vdo_sw) (S.L.elec_busbar_main_sw)
			(T.L.ev_stacyjka)
		{endif}

		(L.L.cp_keyboard_e_m) 2 =
		{if}
			0.625 (S.L.cp_kluczyk_rot)
			2 (S.L.cp_kluczyk_rot_mode)
		{endif}

		(L.L.cp_keyboard_e_m) 3 =
		{if}
			1 (S.L.cp_kluczyk_rot)
			3 (S.L.cp_kluczyk_rot_mode)

				(L.L.engine_starter_antirepeat) !
				(L.L.engine_on) ! &&
				(L.L.cp_taster_motorabstellung) ! &&
				(L.L.check_timer) 3 >= &&
				{if}
					(L.L.antrieb_getr_gangwahl) 1 = (L.L.elec_busbar_main) 0.3 > &&
					{if}
						1 (S.L.engine_starter) (S.L.engine_injection_on)
						(T.L.ev_engine_starter)
					{endif}	
					1 (S.L.engine_starter_antirepeat)
				{endif}
			(T.L.ev_stacyjka)
		{endif}

		1 (S.L.cp_batterietrennschalter_antirepeat)
	{endif}
{end}
			
{trigger:cp_batterietrennschalter_toggle_off}
	0 (S.L.cp_batterietrennschalter_antirepeat) (S.L.engine_starter_antirepeat)

	(L.L.cp_keyboard_e_m) 3 =
	{if}
		0.625 (S.L.cp_kluczyk_rot)
		2 (S.L.cp_kluczyk_rot_mode) (S.L.cp_keyboard_e_m)
	{endif}

	0 (S.L.engine_starter_antirepeat) (S.L.engine_starter)
	0 (S.L.cp_taster_motorabstellung)
{end}

{trigger:kw_m_enginestart}
	(L.L.cp_batterietrennschalter_antirepeat) !
	(L.L.cp_keyboard_e_m) 0 >= &&
	{if}
		(L.L.cp_keyboard_e_m) 1 - (S.L.cp_keyboard_e_m)

		(L.L.cp_keyboard_e_m) 1 =
		{if}
			0.375 (S.L.cp_kluczyk_rot)
			1 (S.L.cp_kluczyk_rot_mode)
			(L.L.engine_injection_on) !
			{if}
				(T.L.ev_engine_shutdown_actuator_off)
			{endif}
			0 (S.L.engine_injection_on)
			0 (S.L.engine_starter_antirepeat) (S.L.engine_starter)
			0 (S.L.cp_taster_motorabstellung)
			(T.L.ev_stacyjka)
		{endif}

		(L.L.cp_keyboard_e_m) 0 =
		{if}
			0 (S.L.cp_kluczyk_rot) (S.L.elec_busbar_vdo_sw) (S.L.elec_busbar_main_sw)
			(T.L.ev_stacyjka)
		{endif}

		1 (S.L.engine_starter_antirepeat)
	{endif}
{end}

{trigger:kw_m_enginestart_off}
	0 (S.L.cp_batterietrennschalter_antirepeat) (S.L.engine_starter_antirepeat)
{end}

{trigger:cp_batterietrennschalter_separate_toggle}
	(L.L.elec_busbar_main_sw) ! (S.L.elec_busbar_main_sw) s1
	(M.L.kippschaltersound)
{end}


{trigger:cp_klappfenster_1}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_2) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_1) ! (S.L.cp_klappfenster_1) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_2}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_1) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_2) ! (S.L.cp_klappfenster_2) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_3}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_4) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_3) ! (S.L.cp_klappfenster_3) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_4}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_3) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_4) ! (S.L.cp_klappfenster_4) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_5}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_6) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_5) ! (S.L.cp_klappfenster_5) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_6}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_5) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_6) ! (S.L.cp_klappfenster_6) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_7}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_8) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_7) ! (S.L.cp_klappfenster_7) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_8}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_7) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_8) ! (S.L.cp_klappfenster_8) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_9}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_10) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_9) ! (S.L.cp_klappfenster_9) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_10}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_9) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_10) ! (S.L.cp_klappfenster_10) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_11}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_12) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_11) ! (S.L.cp_klappfenster_11) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_12}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_11) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_12) ! (S.L.cp_klappfenster_12) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_13}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_14) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_13) ! (S.L.cp_klappfenster_13) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_14}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_13) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_14) ! (S.L.cp_klappfenster_14) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_15}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_16) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_15) ! (S.L.cp_klappfenster_15) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_16}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_15) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_16) ! (S.L.cp_klappfenster_16) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_17}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_18) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_17) ! (S.L.cp_klappfenster_17) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_klappfenster_18}
	(L.L.window_optional)
	{if}
		(L.L.cp_klappfenster_17) !
	{else}
		(L.L.window_optional) !
	{endif}
	{if}
	(L.L.cp_klappfenster_18) ! (S.L.cp_klappfenster_18) s1
	(M.L.klappfenstersound)
	{endif}
{end}

{trigger:cp_dachluke1_mov_drag}
	(L.S.mouse_y) -50 / (L.L.cp_dachluke1_rot) + 0 max 1 min (S.L.cp_dachluke1_rot) s1

	(L.L.cp_dachluke1_rot_mode) 3 / (L.L.cp_dachluke1_rot) =
	{if}
		1 (S.L.dachluke1_ar) (S.L.dachluke2_ar) (S.L.dachluke3_ar) (S.L.dachluke4_ar)
	{endif}

	(M.L.dachluke1_rot_mode)
{end}

{trigger:cp_dachluke1_mov_off}

	(L.L.cp_dachluke1_rot_mode) 3 / (S.L.cp_dachluke1_rot)
{end}

{trigger:cp_dachluke2_mov_drag}
	(L.S.mouse_y) -50 / (L.L.cp_dachluke2_rot) + 0 max 1 min (S.L.cp_dachluke2_rot) s1

	(L.L.cp_dachluke2_rot_mode) 3 / (L.L.cp_dachluke2_rot) =
	{if}
		1 (S.L.dachluke1_ar) (S.L.dachluke2_ar) (S.L.dachluke3_ar) (S.L.dachluke4_ar)
	{endif}

	l1 0.166666 <
	{if}
		0 (S.L.cp_dachluke2_rot_mode)

		(L.L.elec_busbar_main)
		{if}
			0 (S.L.cp_dachluke_2_S1)
			0 (S.L.cp_dachluke_2_S2)

			0 (S.L.dachluke2_ar) (S.L.dachluke3_ar) (S.L.dachluke4_ar)

			(L.L.dachluke1_ar) 1 = !
			{if}
				1 (S.L.dachluke1_ar)
				(T.L.ev_dachluke2_elec)
			{endif}
		{endif}
	{endif}

	l1 0.166666 >=
	l1 0.5 < &&
	{if}
		1 (S.L.cp_dachluke2_rot_mode)

		(L.L.elec_busbar_main)
		{if}
			0 (S.L.cp_dachluke_2_S1)
			1 (S.L.cp_dachluke_2_S2)

			0 (S.L.dachluke1_ar) (S.L.dachluke3_ar) (S.L.dachluke4_ar)

			(L.L.dachluke2_ar) 1 = !
			{if}
				1 (S.L.dachluke2_ar)
				(T.L.ev_dachluke2_elec)
			{endif}
		{endif}
	{endif}

	l1 0.5 >=
	l1 0.833333 < &&
	{if}
		2 (S.L.cp_dachluke2_rot_mode)

		(L.L.elec_busbar_main)
		{if}
			1 (S.L.cp_dachluke_2_S1)
			1 (S.L.cp_dachluke_2_S2)

			0 (S.L.dachluke1_ar) (S.L.dachluke2_ar) (S.L.dachluke4_ar)

			(L.L.dachluke3_ar) 1 = !
			{if}
				1 (S.L.dachluke3_ar)
				(T.L.ev_dachluke2_elec)
			{endif}
		{endif}
	{endif}

	l1 0.833333 >=
	{if}
		3 (S.L.cp_dachluke2_rot_mode)

		(L.L.elec_busbar_main)
		{if}
			1 (S.L.cp_dachluke_2_S1)
			0 (S.L.cp_dachluke_2_S2)

			0 (S.L.dachluke1_ar) (S.L.dachluke2_ar) (S.L.dachluke3_ar)

			(L.L.dachluke4_ar) 1 = !
			{if}
				1 (S.L.dachluke4_ar)
				(T.L.ev_dachluke2_elec)
			{endif}
		{endif}
	{endif}
{end}

{trigger:cp_dachluke2_mov_off}

	(L.L.cp_dachluke2_rot_mode) 3 / (S.L.cp_dachluke2_rot)

{end}

{trigger:cp_dachluke_1}
	(L.L.cp_dachluke_1) 1 + (S.L.cp_dachluke_1) 3 >
	{if}
		0 (S.L.cp_dachluke_1)
	{endif}
	(L.L.cp_dachluke_1) s0
	(M.L.dachluke_pos_rot)
	l1 (S.L.cp_dachluke_1_pos)
	l2 (S.L.cp_dachluke_1_rot)
	l3 (S.L.cp_dachluke_1_S1)
	l4 (S.L.cp_dachluke_1_S2)
{end}

{trigger:cp_dachluke_2}
	(L.L.cp_dachluke_2) 1 + (S.L.cp_dachluke_2) 3 >
	{if}
		0 (S.L.cp_dachluke_2)
	{endif}
	(L.L.cp_dachluke_2) s0
	(M.L.dachluke_pos_rot)
	l1 (S.L.cp_dachluke_2_pos)
	l2 (S.L.cp_dachluke_2_rot)
	l3 (S.L.cp_dachluke_2_S1)
	l4 (S.L.cp_dachluke_2_S2)
{end}

{trigger:cp_dachluke_3}
	(L.L.cp_dachluke_3) 1 + (S.L.cp_dachluke_3) 3 >
	{if}
		0 (S.L.cp_dachluke_3)
	{endif}
	(L.L.cp_dachluke_3) s0
	(M.L.dachluke_pos_rot)
	l1 (S.L.cp_dachluke_3_pos)
	l2 (S.L.cp_dachluke_3_rot)
	l3 (S.L.cp_dachluke_3_S1)
	l4 (S.L.cp_dachluke_3_S2)
{end}

{trigger:cp_Fahrertuer_drag}
(L.L.cp_fahrertuer_griff)
{if}
	1 (S.L.cp_fahrertuer_dragged)
	(L.L.cp_fahrertuer_pos) (S.L.cp_fahrertuer_lastpos)

	(L.S.mouse_x) 1000 / (L.L.cp_fahrertuer_pos) + (S.L.cp_fahrertuer_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fahrertuer_pos)
		0 (S.L.cp_fahrertuer_griff)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fahrertuer_pos)
	{endif}

	(L.L.cp_fahrertuer_pos) (L.L.cp_fahrertuer_lastpos) - (L.S.Timegap) / (S.L.cp_fahrertuer_speed)
{endif}
{end}

{trigger:cp_Fahrertuer_off}
	0 (S.L.cp_fahrertuer_dragged)
{end}

{trigger:cp_Fahrertuer_griff_drag}

	(L.L.cp_fahrertuer_griff_pos) (S.L.cp_fahrertuer_griff_lastpos)

	(C.L.big_cabin) 1 =
	{if}
		(L.S.mouse_y) 40 / (L.L.cp_fahrertuer_griff_pos) + (S.L.cp_fahrertuer_griff_pos) s2
	{else}
		(L.S.mouse_y) -70 / (L.L.cp_fahrertuer_griff_pos) + (S.L.cp_fahrertuer_griff_pos) s2
	{endif}
	
	l2 0 <=
	{if}
		0 (S.L.cp_fahrertuer_griff_pos)
	{endif}

	l2 0.5 >
	{if}
		1 (S.L.cp_fahrertuer_griff)
	{endif}

	l2 1 >
	{if}
		1 (S.L.cp_fahrertuer_griff_pos)
	{endif}

	(L.L.cp_fahrertuer_pos)
	(L.L.cp_fahrertuer_pos) !
	l2 0.5 > && ||
	{if}
		1 (S.L.cp_fahrertuer_dragged)
		(L.L.cp_fahrertuer_pos) (S.L.cp_fahrertuer_lastpos)

		(L.S.mouse_x) 1000 / (L.L.cp_fahrertuer_pos) + (S.L.cp_fahrertuer_pos) s0
		l0 0 <
		{if}
			0 (S.L.cp_fahrertuer_pos)		
		{endif}
		l0 1 >
		{if}
			1 (S.L.cp_fahrertuer_pos)
		{endif}

		(L.L.cp_fahrertuer_pos) (L.L.cp_fahrertuer_lastpos) - (L.S.Timegap) / (S.L.cp_fahrertuer_speed)
	{endif}

	(L.L.cp_fahrertuer_griff_pos) (L.L.cp_fahrertuer_griff_lastpos) - (L.S.Timegap) / (S.L.cp_fahrertuer_griff_speed)
{end}

{trigger:cp_Fahrertuer_griff_off}
	0 (S.L.cp_fahrertuer_griff_pos)
	0 (S.L.cp_fahrertuer_dragged)
{end}

{trigger:cp_radio_toggle}
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_radio) ! (S.L.cp_radio) s1
		{if}
'			1 (S.L.cockpit_KR_play) 
			1 (S.L.Snd_Radio) (S.L.elec_radio)
		{else}
'			1 (S.L.cockpit_KR_stop)
'			0 (S.L.cockpit_KR_play) 
			0 (S.L.Snd_Radio) (S.L.elec_radio)
		{endif}
	{endif}
{end}

{trigger:KR_play}
	(L.L.cockpit_KR_play) 0.1 < 
	{if}
		(T.L.ev_kr_play)
	{endif}
	1 (S.L.cockpit_KR_play) (S.L.Snd_Radio)
{end}


{trigger:KR_play_off}
	0.8 (S.L.cockpit_KR_play)
{end}

{trigger:KR_stop}
	1 (S.L.cockpit_KR_stop)
	0 (S.L.cockpit_KR_play) (S.L.Snd_Radio)
	(T.L.ev_kr_stop)
{end}


{trigger:KR_stop_off}
	0 (S.L.cockpit_KR_stop)
{end}


{trigger:taster_standheizung}

	(L.L.cp_taster_standheizung_target) ! (S.L.cp_taster_standheizung_target) s1

	1 (S.L.cp_taster_standheizung)

{end}

{trigger:taster_standheizung_off}

	0 (S.L.cp_taster_standheizung)
	
{end}


{trigger:taster_nebelschluss}

	(L.L.cp_taster_nebelschluss_target) ! (S.L.cp_taster_nebelschluss_target)
	1 (S.L.cp_taster_nebelschluss)		
{end}

{trigger:taster_nebelschluss_off}
	
	(L.L.cp_taster_nebelschluss_target)
	{if}
		0.6 (S.L.cp_taster_nebelschluss)
	{else}
		0 (S.L.cp_taster_nebelschluss)
	{endif}

{end}


{trigger:cp_wiperlever_drag}

'	Fallunterscheidung: Hebel in x- oder y-Richtung?

	(C.L.wiper_lever)
	{if}
	
		(L.S.mouse_y) abs (L.S.mouse_x) abs >=
		{if}
			(L.S.mouse_y) -50 / (L.L.cockpit_wischerhebel) + 0 max 1 min (S.L.cockpit_wischerhebel) s0
		
'			Stufen:
'			0: Aus
'			1: Intervall
'			2: Langsam
'			3: Schnell

			l0 0.17 <
			{if}
				0 (S.L.cockpit_wischerhebel_mode) (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
			{else} 
				l0 0.5 <
				{if}
					1 (S.L.cockpit_wischerhebel_mode) (S.L.cp_wischer_intervall_sw)
					0 (S.L.cp_wischer_schnell_sw) (S.L.cp_wischer_einaus_sw)
				{else}
					l0 0.83 <
					{if}
						2 (S.L.cockpit_wischerhebel_mode)
						1 (S.L.cp_wischer_einaus_sw)
						0 (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_schnell_sw)
					{else}
						3 (S.L.cockpit_wischerhebel_mode)
						1 (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
						0 (S.L.cp_wischer_intervall_sw)
					{endif}
				{endif}
			{endif}
		{else}
			(L.S.mouse_x) -50 / (L.L.cockpit_wischerhebel_x) + 0 max 1 min (S.L.cockpit_wischerhebel_x) s1

'			Waschanlage (Hebel nach oben)	
			l1 0.9 >
			{if}
				(L.L.cp_wischer_wascher_sw) !
				{if}
					(T.L.ev_wischerhebel)
				{endif}
				1 (S.L.cp_wischer_wascher_sw)
			{else}
				(L.L.cp_wischer_wascher_sw)
				{if}
					(T.L.ev_wischerhebel)
				{endif}
				0 (S.L.cp_wischer_wascher_sw)
			{endif}

		{endif}
	{endif}

{end}

{trigger:cp_wiperlever_off}

'	Einrasten auf den festen Positionen:
	(L.L.cockpit_wischerhebel_mode) 3 / (S.L.cockpit_wischerhebel)
	(L.L.cp_wischer_wascher_sw)
	{if}
		(T.L.ev_wischerhebel)
		0 (S.L.cockpit_wischerhebel_x) (S.L.cp_wischer_wascher_sw)
	{endif}
{end}


{trigger:cp_wiper_turnswitch_drag}

'	(C.L.wiper_turnswitch)
'	{if}
	
		(L.S.mouse_y) -50 / (L.L.cockpit_wischer_drehschalter) + 0 max 1 min (S.L.cockpit_wischer_drehschalter) s0
	
'		Stufen:
'		0: Intervall
'		1: Aus
'		2: Langsam
'		3: Schnell

		l0 0.17 <
		{if}
			1 (S.L.cp_wischer_intervall_sw)
			0 (S.L.cockpit_wischer_drehschalter_mode) (S.L.cp_wischer_schnell_sw) (S.L.cp_wischer_einaus_sw)		
		{else} 
			l0 0.5 <
			{if}
				0 (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
				1 (S.L.cockpit_wischer_drehschalter_mode)
			{else}
				l0 0.83 <
				{if}
					2 (S.L.cockpit_wischer_drehschalter_mode)
					1 (S.L.cp_wischer_einaus_sw)
					0 (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_schnell_sw)
				{else}
					3 (S.L.cockpit_wischer_drehschalter_mode)
					1 (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
					0 (S.L.cp_wischer_intervall_sw)
				{endif}
			{endif}
		{endif}
'	{endif}

{end}

{trigger:cp_wiper_turnswitch_off}

'	Einrasten auf den festen Positionen:
	(L.L.cockpit_wischer_drehschalter_mode) 3 / (S.L.cockpit_wischer_drehschalter)
{end}

{trigger:cp_heizregler_temp_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_temp) + 0 max 1 min (S.L.cockpit_heizregler_temp)
{end}

{trigger:cp_klima_temp_drag}
	(L.S.mouse_y) 150 / (L.L.cockpit_klima_temp) + -1 max 1 min (S.L.cockpit_klima_temp)
{end}

{trigger:cp_klima_kier_temp_drag}
	(L.S.mouse_y) 150 / (L.L.cockpit_klima_kier_temp) + -1 max 1 min (S.L.cockpit_klima_kier_temp)
{end}

{trigger:cp_heizregler_bug_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_bug) + 0 max 1 min (S.L.cockpit_heizregler_bug)

'	Stufen:
'	0: Kierowca
'	1: Kierowca + Szyby
'	2: Szyby

	l0 0.2 <
	{if}
		0 (S.L.cockpit_heizregler_bug_mode)
	{else}
		l0 0.8 <
		{if}
			1 (S.L.cockpit_heizregler_bug_mode)
		{else}
			2 (S.L.cockpit_heizregler_bug_mode)
		{endif}
	{endif}

{end}

{trigger:cp_heizregler_umluft_toggle}
	(L.L.cockpit_heizregler_umluft) ! (S.L.cockpit_heizregler_umluft) s1
	1 (S.L.cockpit_heizregler_umluft_sw)
	
'	Stufen:
'	0: Umluftheizung
'	2: Frischluftheizung

	(L.L.cockpit_heizregler_umluft) !
	{if}
		0 (S.L.cockpit_heizregler_ventilation_mode)
	{else}
		2 (S.L.cockpit_heizregler_ventilation_mode)
	{endif}

	(L.L.cockpit_heizregler_umluft)
	{if}
		0 (S.L.cp_dachluke1_rot)
		(M.L.dachluke1_rot_mode)
		0 (S.L.cp_luft_function)
	{endif}
{end}

{trigger:cp_heizregler_umluft_toggle_off}
	0 (S.L.cockpit_heizregler_umluft_sw)
{end}

'----------------------
'	Init
'----------------------

{macro:cockpit_init}
	0 (S.L.cockpit_hupe_volume) (S.L.door_handsteuerung)
	1 (S.L.cp_retarder_sw) (S.L.cp_lenkrad_visible) (S.L.cockpit_wischer_drehschalter_mode)
	0.6 (S.L.cp_taster_standheizung)
	1 (S.L.dachluke1_ar)

	(C.L.cockpit_zentralschmierung_dist) random (S.L.cp_zentralschmierung_nextkm)

	0.333 (S.L.cockpit_wischer_drehschalter)

'	22 (S.L.check_timer)

	350 (M.V.NrSpecRandom) 5 * 7.5 + (S.L.cp_Fahrgastpendel_traeg)
	351 (M.V.NrSpecRandom) 5 * 7.5 + (S.L.cp_Fahrgastpendel_2_traeg)
	352 (M.V.NrSpecRandom) 0.8 * 0.1 + (S.L.cp_Fahrgastpendel_reib)
	353 (M.V.NrSpecRandom) 0.8 * 0.1 + (S.L.cp_Fahrgastpendel_2_reib)
	354 (M.V.NrSpecRandom) -0.1 * 0.05 - (S.L.cp_Fahrgastpendel_refl)
	355 (M.V.NrSpecRandom) -0.1 * 0.05 - (S.L.cp_Fahrgastpendel_2_refl)

	(L.S.Weather_Temperature) 3 + (S.L.Cabinair_Temp)
	
	(L.S.Weather_Temperature) 10 <
	{if}
		(L.S.Weather_Temperature) 10 <
		{if}
			1 (S.L.para_Passanger) (S.L.para_Front_s) (S.L.para_Front) (S.L.para_Door)
		{else}
			(L.S.Weather_Temperature) -1 * 10 * 100 + (S.L.para_Passanger) (S.L.para_Front_s) (S.L.para_Front) (S.L.para_Door)
		{endif}
	{endif}
	
	(L.S.Weather_Temperature) 0 <
	(L.L.cp_spiegelheizung) ! &&
	{if}
		(L.S.Weather_Temperature) -10 <
		{if}
			1 (S.L.mroz)
		{else}
			(L.S.Weather_Temperature) -10 / (S.L.mroz)
		{endif}
	{endif}
	
	
{end}

'----------------------
'	Frame
'----------------------
{macro:cockpit_frame}

	(L.L.elec_glass_mb_sw) 1 =
	(L.L.elec_busbar_main) &&
	{if}
		(L.L.cp_fahrerfenster2_pos) 0 >
		{if}
			(L.L.cp_fahrerfenster2_pos) (L.S.Timegap) 0.4 * - (S.L.cp_fahrerfenster2_pos)
		{else}
			0 (S.L.cp_fahrerfenster2_pos)
		{endif}
	{endif}
	
	(L.L.elec_glass_mb_sw) -1 =
	(L.L.elec_busbar_main) &&
	{if}
		(L.L.cp_fahrerfenster2_pos) 1 <
		{if}
			(L.L.cp_fahrerfenster2_pos) (L.S.Timegap) 0.4 * + (S.L.cp_fahrerfenster2_pos)
		{else}
			1 (S.L.cp_fahrerfenster2_pos)
		{endif}
	{endif}
	
	(L.L.cockpit_glass) 2 =
	(L.L.cockpit_glass) 3 = ||
	{if}
		1 (S.L.cockpit_glass_2_3)
	{else}
		0 (S.L.cockpit_glass_2_3)
	{endif}
	
	(L.L.cockpit_glass) 2 =
	(L.L.cockpit_glass) 3 = ||
	{if}
		0.43 (S.L.kabina_zahltisch)
		0.57 (S.L.kabina_niska)
	{else}
		(L.L.cockpit_glass) 1 =
		{if}
			1 (S.L.kabina_zahltisch)
			0 (S.L.kabina_niska)
		{else}
			0 (S.L.kabina_zahltisch)
			1 (S.L.kabina_niska)
		{endif}
	{endif}
	
	(L.L.cockpit_glass) 1 = !
	{if}
		0 (S.L.kabina_wysoka)
	{else}
		1 (S.L.kabina_wysoka)
	{endif}
	
'	Auto klimat
	(L.L.Cabinair_Temp) (L.L.Klima_Temp) <
	{if}
		(L.L.cp_auto_klimat_function) &&
		(L.L.cp_reheat) ||
		{if}
			1 (S.L.cp_heizluefter)
			(L.L.air_conditioning)
			{if}
				1 (S.L.cp_klima_function)
			{endif}
		{else}
			0 (S.L.cp_heizluefter)
			0 (S.L.cp_klima_function)
		{endif}
	{else}
		(L.L.cp_auto_klimat_function) &&
		(L.L.cp_reheat) ||
		{if}
			(L.L.air_conditioning)
			{if}
				1 (S.L.cp_klima_function)
			{endif}
			0 (S.L.cp_heizluefter)
		{else}
			0 (S.L.cp_heizluefter)
			0 (S.L.cp_klima_function)
		{endif}
	{endif}
		
' 	Reset
	(L.L.elec_busbar_main) !
	(L.L.reset_anti_repat) ! &&
	{if}
		0 (S.L.cp_ASR_off)
		0 (S.L.cp_dachluke1_rot)
		(M.L.dachluke1_rot_mode)
		0 (S.L.cp_luft_function)
		
		1 (S.L.reset_anti_repat)
	{endif}
	
	(L.L.elec_busbar_main)
	{if}
		0 (S.L.reset_anti_repat)
	{endif}
	
	(L.L.elec_busbar_main) !
	{if}
		0 (S.L.cp_keyboard_e_m)
	{else}
		(L.L.cp_keyboard_e_m) !
		{if}
			1 (S.L.cp_keyboard_e_m)
		{endif}
	{endif}

	(L.L.door_20h_sw) (C.L.door_needs_stopbrakeswitch) && (C.L.door_needs_stopbrake) ! &&
	(L.L.bremse_halte) (C.L.door_needs_stopbrake) && ||
	(C.L.door_needs_stopbrake) (C.L.door_needs_stopbrakeswitch) || ! ||
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
	(L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) < ||
	(L.L.elec_busbar_main) &&
	(L.L.cp_cgon) &&
	{if}
		1 (S.L.cp_cgon)
	{else}
		0 (S.L.cp_cgon)
	{endif}

	(L.L.wysw_stop_ar) trunc 0 =
	(L.L.haltewunschlampe_all) &&
	{if}
		1 (S.L.wysw_stop_ar)
		0 (S.L.IBIS_wint1)
	{endif}

	(L.L.IBIS_wint1) 6 >
	{if}
		2 (S.L.wysw_stop_ar)
	{endif}

	(L.L.haltewunschlampe_all) !
	{if}
		0 (S.L.wysw_stop_ar)
	{endif}

	(M.L.Imieniny)

'	(L.L.v_kab_duza) trunc 3 =
'	{if}
'		1 (L.L.cp_fahrertuer_pos) - 0.3 * 0 max 0.3 min (S.L.w_cien_kier)
'	{else}
'		1 (L.L.cp_fahrertuer_pos) - 0 max 1 min (S.L.w_cien_kier)
'	{endif}

	(L.L.cp_cgon)
	(L.L.cockpit_bus) &&
	{if}
		(L.L.cockpit_light_cg) (L.S.Timegap) + (S.L.cockpit_light_cg) (S.L.cockpit_light_cg0) (S.L.cockpit_light_cg1)

		(L.L.cockpit_light_cg) 1 >=
		{if}
			0 (S.L.cockpit_light_cg) (S.L.cockpit_light_cg0) (S.L.cockpit_light_cg1)
		{endif}
	{else}
		1 (S.L.cockpit_light_cg) (S.L.cockpit_light_cg0) (S.L.cockpit_light_cg1)
	{endif}

	(L.L.cp_door_lock_0)
	{if}
		1 (S.L.cockpit_light_cg0)
	{endif}

	(L.L.cp_door_lock_1)
	{if}
		1 (S.L.cockpit_light_cg1)
	{endif}

	(L.L.lights_cp_stand)
	{if}
		1 (S.L.przyciski)
	{else}
		0 (S.L.przyciski)
	{endif}

	(L.L.mirror_right) 0 =
	(L.L.mirror_right) 1 = ||
	{if}
		1 (S.L.mirror_right_0-1)
	{else}
		0 (S.L.mirror_right_0-1)
	{endif}
	
	(L.L.display_ext) 3 =
	{if}
		0 (S.L.v_Matrix_LED2)
		0 (S.L.v_Matrix_lights)
	{endif}

	(L.L.display_ext) 0 =
	{if}
		1 (S.L.v_Matrix_LED2)
		(L.S.Year) (C.L.Matrix_Baujahr) - 0.01 max (C.L.Matrix_Fehlerpixel_pro_Jahr) * 971 (M.V.NrSpecRandom) 1 + * (S.L.Matrix_Fehlerpixel)

		(L.L.lights_stand)
		{if}
			1 (S.L.v_Matrix_lights)
		{else}
			0 (S.L.v_Matrix_lights)
		{endif}
	{else}
			0 (S.L.v_Matrix_lights)
	{endif}

	(L.L.v_Matrix_LED) 1 =
	{if}
		(L.S.Year) (C.L.Matrix_Baujahr) - 0.01 max (C.L.Matrix_Fehlerpixel_pro_Jahr_LED) * 971 (M.V.NrSpecRandom) 1 + * (S.L.Matrix_Fehlerpixel)

		(L.L.elec_busbar_rg)
		(L.L.IBIS_modetimerS) 29.5 >= &&
		{if}
			2 (S.L.v_Matrix_LED2)
		{else}
			0 (S.L.v_Matrix_LED2)
		{endif}
	{endif}

'Übertragen der Schalterstellungen:
	(L.L.cp_retarder_sw) (S.L.antrieb_retarder_sw)
	(L.L.cp_retarder_sw_direkt) (S.L.antrieb_retarder_sw_direkt)
	(L.L.cp_wischer_schnell_sw) (S.L.wiper_schnell_sw)
	(L.L.cp_wischer_einaus_sw) (S.L.wiper_einaus_sw)
	(L.L.cp_wischer_intervall_sw) (S.L.wiper_intervall_sw)
	(L.L.cp_wischer_wascher_sw) (S.L.wiper_wascher_sw)


	(L.L.cp_kneeling) 1 =
	(L.L.elec_busbar_main) &&
	(L.L.bremse_suspension_drainvalve_0_R) &&
	{if}
		(L.L.kneeling_timer) (L.S.Timegap) + (S.L.kneeling_timer)
	{endif}

	(L.L.elec_busbar_main) 0 =
	{if}
		0 (S.L.Snd_Radio) (S.L.elec_radio)
	{endif}

	
	(M.L.tacho_frame)
	(M.L.uhr_frame)
	(M.L.drehzahlmesser_frame)
	(M.L.hupe_frame)
	(M.L.blinkerhebel_frame)
	(M.L.wischerhebel_frame)
	(M.L.wischer_drehschalter_frame)
	(M.L.oeldruck_frame)
	(M.L.tankuhr_frame)
	(M.L.cockpitlights_frame)
	(M.L.displaylights_frame)
	(M.L.klimator_frame)
	(M.L.klima_frame)
	(M.L.schluessel_frame)
	(M.L.fahrertuer_frame)
	(M.L.engine_thermometer_frame)
	(M.L.IBIS_LCD-refresh)
	(M.L.microphone_frame)
	(M.L.pressure_warning_needle_frame)
	(M.L.zentralschmierung_frame)
	(M.L.Thermometer_frame)
	(M.L.Timer_frame)
	(M.L.Fahrgastpendel)
	(M.L.elec_vdo)
	(M.L.szyby_frame)
	(M.L.spiegelheizung)
	(M.L.lift_calc_z_limit)
	(M.L.kneel_auto_lift)

	(C.L.rolety_zwijanie) !
	{if}
		(M.L.rollo_frame)
		(M.L.rollo2_frame)
	{endif}

{end}

{macro:tacho_frame}
	(L.L.check_timer) 2.5 >
	{if}
		(L.L.Velocity) (F.L.cockpit_tacholinie) (S.L.cockpit_tachowinkel)
		(L.L.Velocity) (F.L.cockpit_tacholinie_e6) (S.L.cockpit_tachowinkel_e6)
	{else}
		-10 (S.L.cockpit_tachowinkel) (S.L.cockpit_tachowinkel_e6)
	{endif}
{end}

{macro:uhr_frame}
	(L.L.elec_busbar_avail) 0.5 >
	{if}
		(L.S.Time) s0 60 / (S.L.cockpit_uhr_min) 12 / (S.L.cockpit_uhr_std)
		l0 trunc (S.L.cockpit_uhr_sek)
	{endif}
{end} 

{macro:drehzahlmesser_frame}
	(L.L.check_timer) 2.5 >
	{if}
		(L.L.engine_n) (F.L.cockpit_drehzahllinie) (S.L.cockpit_drehzahlwinkel)
	{else}
		-10 (S.L.cockpit_drehzahlwinkel)
	{endif}
	
	(L.L.check_timer) 2.5 >
	{if}
		(L.L.engine_n) 700 >
		{if}
			(L.L.engine_n) 700 - 2000 / 0.26 * (S.L.zmiennaX)
			(L.L.engine_n) (F.L.cockpit_drehzahllinie) 1 (L.L.zmiennaX) - * (S.L.cockpit_drehzahlwinkel_2000)
		{else}
			(L.L.engine_n) (F.L.cockpit_drehzahllinie) (S.L.cockpit_drehzahlwinkel_2000)
		{endif}
	{else}
		-10 (S.L.cockpit_drehzahlwinkel_2000)
	{endif}
{end}



{macro:hupe_frame}
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	{if}
		(L.L.cockpit_hupe) 1 =
		{if}
			(L.L.cockpit_hupe_volume) 1 <
			{if}
				(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * + (S.L.cockpit_hupe_volume)
			{else}
				1 (S.L.cockpit_hupe_volume)
			{endif}
		{else}
			(L.L.cockpit_hupe_volume) 0 >
			{if}
				(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * - (S.L.cockpit_hupe_volume)
			{else}
				0 (S.L.cockpit_hupe_volume)
			{endif}
		{endif}
	{else}
		(L.L.cockpit_hupe_volume) 0 >
		{if}
			(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * - (S.L.cockpit_hupe_volume)
		{else}
			0 (S.L.cockpit_hupe_volume)
		{endif}
	{endif}	
	
{end}

{macro:blinkerhebel_frame}
	(L.L.lights_sw_blinker) 1 =
	{if}	
		-1 (S.L.cockpit_blinkerhebel)
	{else}
		(L.L.lights_sw_blinker) 2 =
		{if}
			1 (S.L.cockpit_blinkerhebel)
		{else}
			0 (S.L.cockpit_blinkerhebel)
		{endif}
	{endif}

'	Hebel-Animation für Fernlicht
	(L.L.lights_sw_fern)
	{if}	
		(L.L.cockpit_fernlichthebel) -1 = !
		{if}
			1 (S.L.cockpit_fernlichthebel)
		{endif}

		(L.L.cp_schluessel_rot) 0.8 >
		{if}
			-1 (S.L.cockpit_fernlichthebel)
		{endif}
	{else}
		0 (S.L.cockpit_fernlichthebel)
	{endif}


{end}

{macro:wischerhebel_frame}

	(L.L.cockpit_wischerhebel_lastmode) (L.L.cockpit_wischerhebel_mode) = !
	{if}
		(T.L.ev_wischerhebel)
	{endif}
	(L.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischerhebel_lastmode)
{end}

{macro:wischer_drehschalter_frame}

	(L.L.cockpit_wischer_drehschalter_lastmode) (L.L.cockpit_wischer_drehschalter_mode) = !
	{if}
		(T.L.ev_wischerhebel)
	{endif}
	(L.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischer_drehschalter_lastmode)
{end}



{macro:cockpitlights_frame}

'	Störungsmelder
	(L.L.bremse_p_tank01) 650000 <
	(L.L.bremse_p_tank02) 650000 < ||
	(L.L.bremse_p_tank03) 650000 < ||
	(L.L.elec_busbar_vdo) *
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_masterfailure)

	(L.L.engine_n) 150 <
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_engine)

'	Batterie
	(L.L.elec_ladekontrolle) (L.L.elec_busbar_vdo) *
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_batterie)

'	Luft
	(L.L.doorEntriegelung_01) (L.L.doorEntriegelung_23) (L.L.doorEntriegelung_45) (L.L.doorEntriegelung_67) || || ||
	(L.L.elec_busbar_vdo) &&
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_luft)


	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	{if}
		(L.L.elec_antirepeat) !
		{if}
			(T.L.ev_IBIS-startupsound)
			1 (S.L.elec_antirepeat)
		{endif}
	{else}
		0 (S.L.elec_antirepeat)
	{endif}

	(C.L.tuertaster_blink)
	{if}
		(L.L.haltewunschlampe_all)
		(L.L.halt_inw) ||
		(L.L.doorEntriegelung_01) ||
		(L.L.doorEntriegelung_23) ||
		(L.L.doorEntriegelung_45) ||
		(L.L.doorEntriegelung_67) ||
		{if}
			(L.S.Timegap) (L.L.light_stop_runtime) + (S.L.light_stop_runtime)
			(L.L.light_stop_runtime) 0.7 >
			{if}
				(L.L.light_stop) ! (S.L.light_stop)
				0 (S.L.light_stop_runtime)
			{endif}
		{else}
			0 (S.L.light_stop_runtime) (S.L.light_stop)
		{endif}
	{endif}

'	Tuertaster 1
	(L.L.elec_busbar_vdo)
	{if}
		(L.L.front_door_lock_button)
		{if}
			(L.L.haltewunsch_1)
			(L.L.cockpit_light_tuerkontrolle) &&
			(L.L.doorEntriegelung_01) ||
		{else}
			(L.L.doorEntriegelung_01)
		{endif}
			{if}
				(L.L.light_stop) (S.L.light_stop0)
			{else}

				(L.L.front_door_lock_button)
				{if}
					(L.L.door_0) 0.1 >
					(L.L.door_1) 0.1 > ||
				{else}
					(L.L.door_0) 0.1 >
				{endif}

				(S.L.light_stop0)

			{endif}

	{else}
		0 (S.L.light_stop0)
	{endif}

'	Tuertaster 2
	(L.L.elec_busbar_vdo)
	{if}
		(L.L.front_door_lock_button)
		{if}
			(L.L.haltewunsch_2)
			(L.L.cockpit_light_tuerkontrolle) &&
			(L.L.doorEntriegelung_23) ||
		{else}
			(L.L.haltewunsch_1)
			(L.L.cockpit_light_tuerkontrolle) &&
			(L.L.doorEntriegelung_01) ||
		{endif}
			{if}
				(L.L.light_stop) (S.L.light_stop1)
			{else}

				(L.L.front_door_lock_button)
				{if}
					(L.L.door_2) 0.1 >
					(L.L.door_3) 0.1 > ||
				{else}
					(L.L.door_1) 0.1 >
				{endif}

				(S.L.light_stop1)

			{endif}

	{else}
		0 (S.L.light_stop1)
	{endif}

'	Tuertaster 3
	(L.L.elec_busbar_vdo)
	{if}
		(L.L.front_door_lock_button)
		{if}
			(L.L.haltewunsch_3)
			(L.L.cockpit_light_tuerkontrolle) &&
			(L.L.doorEntriegelung_45) ||
		{else}
			(L.L.haltewunsch_2)
			(L.L.cockpit_light_tuerkontrolle) &&
			(L.L.doorEntriegelung_23) ||
		{endif}
			{if}
				(L.L.light_stop) (S.L.light_stop2)
			{else}

				(L.L.front_door_lock_button)
				{if}
					(L.L.door_4) 0.1 >
					(L.L.door_5) 0.1 > ||
				{else}
					(L.L.door_2) 0.1 >
					(L.L.door_3) 0.1 > ||
				{endif}

				(S.L.light_stop2)

			{endif}

	{else}
		0 (S.L.light_stop2)
	{endif}

'	Tuertaster 4
	(L.L.elec_busbar_vdo)
	{if}
		(L.L.front_door_lock_button)
		{if}
			(L.L.haltewunsch_4)
			(L.L.cockpit_light_tuerkontrolle) &&
			(L.L.doorEntriegelung_67) ||
		{else}
			(L.L.haltewunsch_3)
			(L.L.cockpit_light_tuerkontrolle) &&
			(L.L.doorEntriegelung_45) ||
		{endif}
			{if}
				(L.L.light_stop) (S.L.light_stop3)
			{else}

				(L.L.front_door_lock_button)
				{if}
					(L.L.door_6) 0.1 >
					(L.L.door_7) 0.1 > ||
				{else}
					(L.L.door_4) 0.1 >
					(L.L.door_5) 0.1 > ||
				{endif}

				(S.L.light_stop3)

			{endif}

	{else}
		0 (S.L.light_stop3)
	{endif}

'	Tuertaster 5
	(L.L.elec_busbar_vdo)
	{if}
		(L.L.front_door_lock_button) !
		{if}
			(L.L.haltewunsch_4)
			(L.L.cockpit_light_tuerkontrolle) &&
			(L.L.doorEntriegelung_67) ||
		{endif}
			{if}
				(L.L.light_stop) (S.L.light_stop4)
			{else}

				(L.L.front_door_lock_button) !
				{if}
					(L.L.door_6) 0.1 >
					(L.L.door_7) 0.1 > ||
				{endif}

				(S.L.light_stop4)

			{endif}

	{else}
		0 (S.L.light_stop4)
	{endif}

'	Türkontrolle
	(L.L.door_20h_sw) (C.L.door_needs_stopbrakeswitch) && (C.L.door_needs_stopbrake) ! &&
	(L.L.bremse_halte) (C.L.door_needs_stopbrake) && ||
	(C.L.door_needs_stopbrake) (C.L.door_needs_stopbrakeswitch) || ! ||
	(L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) < ||
	(L.L.elec_busbar_vdo) &&
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_tuerkontrolle)

	(L.L.lights_nebelschluss)
	(L.L.elec_busbar_vdo) &&
	(S.L.cockpit_light_nebelschluss)

'	Kontrolle Feststellbremse
	(L.L.bremse_p_Brzyl_FBA) 650000 <
	(L.L.elec_busbar_vdo) *
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_feststellbremse)

'	Geschwindigkeitswarnung
	(L.L.Velocity) 54 >
	(L.L.elec_busbar_vdo) &&
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_speedwarning)

'	Dummy-Schalter:

	(L.L.cp_dummy_sw01) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func01)

	(L.L.cp_dummy_sw02) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func02)

	(L.L.cp_dummy_sw03) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func03)

	(L.L.cp_dummy_sw04) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func04)

	(L.L.cp_dummy_sw05) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func05)

	(L.L.cp_dummy_sw06) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func06)

	(L.L.cp_dummy_sw07) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func07)

	(L.L.cp_dummy_sw08) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func08)

	(L.L.cp_dummy_sw09) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func09)

	(L.L.cp_dummy_sw10) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func10)

	(L.L.elec_busbar_vdo)
	(L.L.bremse_p_Tank04) 750000 < &&
	(L.L.antrieb_failure_general) ||
	(L.L.door_failure_general) ||
	(L.L.pasek_failure_general) ||
	(L.L.zly_poziom_normal) 1 = ||
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_warning)

	(L.L.lights_blinkgeber)
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_blinker)

	(L.L.lights_blinker_l)
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_blinker_l)

	(L.L.lights_blinker_r)
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_blinker_r)

	(L.L.lights_warnblinkgeber)
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_warn)

	(L.L.lights_fern)
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_fern)
	
	(L.L.lights_abbl)
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_abbl)

	(L.L.bremse_ABS_eingriff)
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_abs)
	
	(L.L.cp_rampa_pos)
	(L.L.check_timer) 1.5 < ||
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_ramp)
	
	(L.L.check_timer) 1.5 <
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_dpf_green)
	
	(L.L.check_timer) 1.5 <
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_dpf_yellow)
	
	(L.L.check_timer) 1.5 <
	(L.L.check_timer) 0.2 > &&
	(S.L.cockpit_light_tacho_failure)

	(L.L.cockpit_heizregler_umluft)
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_umluft)
	
	(L.L.cp_taster_standheizung_target)
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_standheizung)
	
	(L.L.cp_klima_kier_function)
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_klima_kier)
	
	(L.L.cp_auto_klimat_function)
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_auto_klimat)
	
	(L.L.cp_reheat)
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_reheat)
{end}

{macro:displaylights_frame}

'	Luki
	(L.L.cp_dachluke_1_S1)
	(L.L.cp_dachluke_1_S2) ||
	(L.L.cp_dachluke_2_S1) ||
	(L.L.cp_dachluke_2_S2) ||
	(L.L.cp_dachluke_3_S1) ||
	(L.L.cp_dachluke_3_S2) ||
	{if}
		1 (S.L.cockpit_light_luki)
	{else}
		0 (S.L.cockpit_light_luki)
	{endif}

'	Klima
	(L.L.cp_klima_RPM) 70 >
	(L.L.cp_klima_kier_RPM) 70 > ||
	{if}
		1 (S.L.cockpit_light_klima)
	{else}
		0 (S.L.cockpit_light_klima)
	{endif}

	(L.L.cockpit_bus)
	{if}
		(L.L.kneeling_timer) 4 <
		{if}
			(L.L.elec_busbar_main)
			(L.L.bremse_kneeling) &&
			(L.L.bremse_p_Tank04) 650000 < ||
			(L.L.zaw_ar) 0 = ! ||
			(S.L.cockpit_light_kneeling)
			0 (S.L.cockpit_light_kneeling2)
		{else}
			0 (S.L.cockpit_light_kneeling)
			1 (S.L.cockpit_light_kneeling2)
		{endif}
		0 (S.L.cockpit_light_kn-lift)
	{else}
		0 (S.L.cockpit_light_kneeling) (S.L.cockpit_light_kneeling2)

			(L.L.elec_busbar_main)
			(L.L.bremse_kneeling) &&
			(L.L.bremse_p_Tank04) 650000 < ||
			(L.L.zaw_ar) 0 = ! ||
			(L.L.zly_poziom_normal) 1 = ||
			(S.L.cockpit_light_kn-lift)

	{endif}

'	Klucz
	(L.L.door_failure_general)
	(L.L.elec_failure_general) ||
	(L.L.rg_failure_general) ||
	(L.L.pasek_failure_general) ||
	(L.L.engine_failure_general) ||
	(L.L.antrieb_failure_general) ||
	(L.L.elec_busbar_vdo) &&
	(S.L.cockpit_light_failure)

'	Kinderwagenwunsch
	(L.L.door_kinderwagenwunsch) (L.L.elec_busbar_vdo) *
	(S.L.cockpit_light_kinderwagenwunsch)

'	Kippschalter-Beleuchtung
	(L.L.cp_retarder_sw_direkt) (L.L.elec_busbar_main) *
	(L.L.brake) 0.05 > ||
	(L.L.antrieb_getr_aktugang) 0 = ! &&
	(S.L.cockpit_light_retarder_direkt)

	(L.L.cp_retarder_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_retarder)

	(L.L.cp_fahrerlicht_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_fahrerlicht)

	(L.L.cp_licht_untenrechts_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_licht_untenrechts)

	(L.L.cp_licht_unterdeck_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_licht_unterdeck)

'	(L.L.cp_licht_oberdeck_sw) (L.L.elec_busbar_main) *
'	(S.L.cockpit_light_licht_oberdeck)

	(L.L.cp_wischer_schnell_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_wischer_schnell)

	(L.L.cp_wischer_einaus_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_wischer_einaus)

	(L.L.cp_wischer_intervall_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_wischer_intervall)
	
	(L.L.cp_wischer_wascher_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_wischer_wascher)

	(L.L.cp_heizluefter) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_heizluefter)
	
	(L.L.cp_spiegelheizung) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_spiegelheizung)

	(L.L.cp_motorkuehlung_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_motorkuehlung)

	(L.L.door_handsteuerung) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_tuer_handsteuerung)

	(L.L.cp_ASR_off) (L.L.elec_busbar_vdo) *
	(S.L.cockpit_light_ASR_off)

	(L.L.cp_hub_up_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_hub_up)

	(L.L.cp_hub_dn_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_hub_dn)

	(L.L.cp_knick_ovrd_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_knick_ovrd)

	(L.L.haltewunschlampe_all) (L.L.elec_busbar_main) * (L.L.light_stop) *
	(S.L.cockpit_light_wagenhalt)

	(L.L.halt_inw) (L.L.elec_busbar_main) * (L.L.light_stop) *
	(S.L.cockpit_light_halt_inw)

{end}

{macro:oeldruck_frame}
	(L.L.engine_n) (F.L.cockpit_oeldruck) (L.L.elec_busbar_main) * s0

	(L.L.cockpit_oeldruck) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_oeldruck)
{end}

{macro:tankuhr_frame}
	(L.L.check_timer) 2.5 >
	{if}
		(L.L.engine_tank_content) (L.L.elec_busbar_main) * s0
	{else}
		0 s0
	{endif}

	(L.L.cockpit_tankuhr) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_tankuhr)
{end}

{macro:engine_thermometer_frame}
	(L.L.check_timer) 2.5 >
	{if}
		(L.L.engine_temperature) (F.L.cockpit_engine_temperature) (L.L.elec_busbar_main) * s0
	{else}
		0 s0
	{endif}

	(L.L.cockpit_motortemperaturwinkel) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_motortemperaturwinkel)
{end}

{macro:dachluke_pos_rot}
	l0 0.5 <=
	{if}
		0 s1 s2 s3 s4
		(T.L.ev_dachluke_close)
	{else}
	l0 1.5 <=
	{if}
		0.5 s1
		1 s2
		0.80 s3
		0.10 s4
		(T.L.ev_dachluke_open)
	{else}
	l0 2.5 <=
	{if}
		1 s1
		0 s2
		1 s3
		1 s4
		(T.L.ev_dachluke_change)
	{else}
		0.5 s1
		-1 s2
		0.10 s3
		0.80 s4
		(T.L.ev_dachluke_change)
	{endif}
	{endif}
	{endif}
{end}

{macro:nothahnsound}
	l1
	{if}
		(T.L.ev_nothahn_ein)
	{else}
		(T.L.ev_nothahn_aus)
	{endif}	
{end}

{macro:kippschaltersound}
	l1
	{if}
		(T.L.ev_kippschalter_ein)
	{else}
		(T.L.ev_kippschalter_aus)
	{endif}	
{end}

{macro:klappfenstersound}
	l1
	{if}
		(L.L.window_optional) !
		{if}
			(T.L.ev_klappfenster_opn)
		{else}
			(T.L.ev_klappfenster_opn_mov)
		{endif}
	{else}
		(L.L.window_optional) !
		{if}
			(T.L.ev_klappfenster_cls)
		{else}
			(T.L.ev_klappfenster_cls_mov)
		{endif}
	{endif}	
{end}

{macro:klappfenstersound_T}
	l1
	{if}
		(T.L.ev_klappfenster_opn_T)
	{else}
		(T.L.ev_klappfenster_cls_T)
	{endif}	
{end}


{macro:klimator_frame}

'Frontheizgerät:
	(L.L.cp_klimator_sw) (L.L.elec_busbar_main) * s1

'Anlauf oder Auslauf?
	l1 100 * (L.L.cp_klimator_RPM) > 
	{if}
		1.5 s0
	{else}
		0.5 s0
	{endif}

' Berechnung der Luefterbeschleunigung:

'Sollwert:
	l1 100 * 
'Istwert:
	(L.L.cp_klimator_RPM)
'Beschleunigung:
	- s0 * (L.S.Timegap) *
'Addition zum Istwert:
	(L.L.cp_klimator_RPM) + (S.L.cp_klimator_RPM)

'Leitwert generieren:
	(L.L.cp_klimator_sw) 0.5 >
	{if}
		(L.L.elec_busbar_Rinv_summe) (C.L.cp_klimator_Rinv) + (S.L.elec_busbar_Rinv_summe)
	{else}
		(L.L.cp_klimator_sw) -0.5 <
		{if}
			(L.L.elec_busbar_Rinv_summe) (C.L.cp_klimator_Rinv) 0.6 * + (S.L.elec_busbar_Rinv_summe)
		{endif}
	{endif}

'Raumheizgeräte:
	(L.L.engine_n) 399 >
	{if}
		(L.L.cp_heizluefter) (L.L.elec_busbar_main) * s1
	{else}
		0 s1
	{endif}

'Anlauf oder Auslauf?
	l1 100 * (L.L.cp_cabinheater_RPM) > 
	{if}
		6 s0
	{else}
		1.0 s0
	{endif}

' Berechnung der Luefterbeschleunigung:

'Sollwert:
	l1 100 * 
'Istwert:
	(L.L.cp_cabinheater_RPM)
'Beschleunigung:
	- s0 * (L.S.Timegap) *
'Addition zum Istwert:
	(L.L.cp_cabinheater_RPM) + (S.L.cp_cabinheater_RPM)

'Leitwert generieren:
	(L.L.cp_heizluefter) 0.5 >
	{if}
		(L.L.elec_busbar_Rinv_summe) (C.L.cp_cabinheater_Rinv) + (S.L.elec_busbar_Rinv_summe)
	{else}
		(L.L.cp_heizluefter) -0.5 <
		{if}
			(L.L.elec_busbar_Rinv_summe) (C.L.cp_cabinheater_Rinv) 0.6 * + (S.L.elec_busbar_Rinv_summe)
		{endif}
	{endif}

'Raumheizgeräte:
	(L.L.engine_n) 399 >
	{if}
		(L.L.cp_luefter_sw) (L.L.elec_busbar_main) * s5
	{else}
		0 s5
	{endif}

'Anlauf oder Auslauf?
	l5 100 * (L.L.cp_cabinheater2_RPM) > 
	{if}
		6 s6
	{else}
		1.0 s6
	{endif}

'Sollwert:
	l5 100 * 
'Istwert:
	(L.L.cp_cabinheater2_RPM)
'Beschleunigung:
	- s6 * (L.S.Timegap) *
'Addition zum Istwert:
	(L.L.cp_cabinheater2_RPM) + (S.L.cp_cabinheater2_RPM)


'Lufty dachowe:
	(L.L.engine_n) 399 >
	{if}
		(L.L.cp_luft_function) (L.L.elec_busbar_main) * s7
	{else}
		0 s7
	{endif}

	l7 100 * (L.L.cp_luft_RPM) > 
	{if}
		6 s8
	{else}
		1.0 s8
	{endif}

	l7 100 * 

	(L.L.cp_luft_RPM)

	- s8 * (L.S.Timegap) *

	(L.L.cp_luft_RPM) + (S.L.cp_luft_RPM)
{end}

{macro:klima_frame}

'Klima:
	(L.L.cp_reheat)
	{if}
		16 (L.L.cockpit_klima_temp) 4 * + (S.L.Klima_Temp)
	{else}
		22 (L.L.cockpit_klima_temp) 4 * + (S.L.Klima_Temp)
	{endif}

	(L.L.engine_n) 399 >
	(L.L.Klima_ar) ! &&
	{if}
		(L.L.cp_klima_function) (L.L.elec_busbar_main) * s2

		(L.L.Cabinair_Temp) (L.L.Klima_Temp) - abs 0.3 <
		{if}
			1 (S.L.Klima_ar)
		{endif}
	{else}
		0 s2
		(L.L.Cabinair_Temp) (L.L.Klima_Temp) - abs 0.8 >
		{if}
			0 (S.L.Klima_ar)
		{endif}
	{endif}

	l2 100 * (L.L.cp_klima_RPM) > 
	{if}
		6 s3
	{else}
		1.0 s3
	{endif}

	l2 100 * 

	(L.L.cp_klima_RPM)

	- s3 * (L.S.Timegap) *

	(L.L.cp_klima_RPM) + (S.L.cp_klima_RPM)

{end}

{macro:schluessel_frame}

	(L.L.cp_schluessel_trans_lastmode) (L.L.cp_schluessel_trans_mode) = !
	{if}
		(T.L.ev_light_switch_fog)
	{endif}
	(L.L.cp_schluessel_trans_mode) (S.L.cp_schluessel_trans_lastmode)


	(L.L.cp_schluessel_rot_lastmode) (L.L.cp_schluessel_rot_mode) = !
	{if}
		(T.L.ev_light_switch)
	{endif}
	(L.L.cp_schluessel_rot_mode) (S.L.cp_schluessel_rot_lastmode)
{end}



{macro:traegheit}

'Simuliert träges Verhalten (exponentiell)

'Ladekonventionen:
'	Sollwert		l0
'	Istwert			l1
'	Konstante Anlauf	l2 (Einheiten/s)
'	Konstante Ablauf	l3 (Einheiten/s)

'Anlauf oder Auslauf?
	l0 l1 > 
	{if}
		l2 (L.S.Timegap) * 2 min -2 max s4
	{else}
		l3 (L.S.Timegap) * 2 min -2 max s4
	{endif}


'Sollwert:
	l0
'Istwert:
	l1
'Beschleunigung:
	- l4 *
'Addition zum Istwert:
	l1 + s1
{end}

{macro:fahrertuer_frame}

	(L.L.cp_fahrertuer_dragged) !
	{if}
		(L.L.cp_fahrertuer_pos) (L.S.Timegap) (L.L.cp_fahrertuer_speed) 0.5 * * + (S.L.cp_fahrertuer_pos)

		(L.L.cp_fahrertuer_pos) 1 >
		{if}
			1 (S.L.cp_fahrertuer_pos)
			(L.L.cp_fahrertuer_speed) /-/ 0.7 * (S.L.cp_fahrertuer_speed)
		{endif}
		(L.L.cp_fahrertuer_pos) 0 <
		{if}
			0 (S.L.cp_fahrertuer_speed) (S.L.cp_fahrertuer_pos)
		{endif}

		(L.L.cp_fahrertuer_pos) 0 >
		{if}
			(L.L.cp_fahrertuer_speed) (L.S.Timegap) (L.L.A_Trans_Y) (C.L.cp_fahrertuer_anschlagseite) * (L.L.A_Trans_X) /-/ + 0.3 * (L.L.cp_fahrertuer_globalangle) * * + (S.L.cp_fahrertuer_speed)
		{endif}
	
		(L.L.cp_fahrertuer_speed) s0 (S.L.cp_fahrertuer_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 2 * - (S.L.cp_fahrertuer_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 2 * + (S.L.cp_fahrertuer_speed)
		{endif}


		(L.L.cp_fahrertuer_speed) 0 > (L.L.cp_fahrertuer_lastspeed) 0 < &&
		(L.L.cp_fahrertuer_speed) 0 < (L.L.cp_fahrertuer_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_fahrertuer_speed)
		{endif}	 
	
	{endif}

	(L.L.cp_fahrertuer_pos) 0 > (L.L.cp_fahrertuer_open) ! &&
	{if}
		(T.L.ev_fahrertuer_auf)
		1 (S.L.cp_fahrertuer_open)
	{endif}

	(L.L.cp_fahrertuer_pos) 0 = (L.L.cp_fahrertuer_open) &&
	{if}
		(T.L.ev_fahrertuer_zu)
		0 (S.L.cp_fahrertuer_open)
	{endif}

	(L.L.cp_fahrertuer_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_fahrertuer_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)

	(L.L.cp_fahrertuer_griff_pos) 0.5 > !
	(L.L.cp_fahrertuer_pos) ! &&
	{if}
		0 (S.L.cp_fahrertuer_griff)
	{endif}

	(L.L.cp_fahrertuer_pos) (F.L.fahrertuer_moc_pos) (S.L.cp_fahrertuer_moc_pos)
{end}

{macro:rollo_frame}
	(L.L.cp_rollo_pos) (L.L.cp_rollo_rastpos) max (S.L.cp_rollo_rastpos)

	(L.L.cp_rollo_dragged) !
	{if}
		(L.L.cp_rollo_retract)
		{if}
			(L.L.cp_rollo_speed) (L.S.Timegap) (L.L.cp_rollo_pos) 14 * * - (S.L.cp_rollo_speed)
			(L.L.cp_rollo_pos) (L.S.Timegap) (L.L.cp_rollo_speed) * + (S.L.cp_rollo_pos) (S.L.cp_rollo_rastpos)
					
		{else}
			(L.L.cp_rollo_pos) (L.L.cp_rollo_rastpos) < 
			{if}
				(L.L.cp_rollo_speed) (L.S.Timegap) 14 * + (S.L.cp_rollo_speed)
				(L.L.cp_rollo_pos) (L.S.Timegap) (L.L.cp_rollo_speed) * + (L.L.cp_rollo_rastpos) min (S.L.cp_rollo_pos)
			{else}
				0 (S.L.cp_rollo_speed)
			{endif}
		{endif}

		(L.L.cp_rollo_pos) 1 >
		{if}
			1 (S.L.cp_rollo_pos) (S.L.cp_rollo_rastpos)
		{else}
			(L.L.cp_rollo_pos) 0 <
			{if}
			0 (S.L.cp_rollo_pos) (S.L.cp_rollo_retract) (S.L.cp_rollo_rastpos)
			{endif}
		{endif}

	{endif}
{end}


{macro:rollo2_frame}
	(L.L.cp_rollo2_pos) (L.L.cp_rollo2_rastpos) max (S.L.cp_rollo2_rastpos)

	(L.L.cp_rollo2_dragged) !
	{if}
		(L.L.cp_rollo2_retract)
		{if}
			(L.L.cp_rollo2_speed) (L.S.Timegap) (L.L.cp_rollo2_pos) 14 * * - (S.L.cp_rollo2_speed)
			(L.L.cp_rollo2_pos) (L.S.Timegap) (L.L.cp_rollo2_speed) * + (S.L.cp_rollo2_pos) (S.L.cp_rollo2_rastpos)
					
		{else}
			(L.L.cp_rollo2_pos) (L.L.cp_rollo2_rastpos) < 
			{if}
				(L.L.cp_rollo2_speed) (L.S.Timegap) 14 * + (S.L.cp_rollo2_speed)
				(L.L.cp_rollo2_pos) (L.S.Timegap) (L.L.cp_rollo2_speed) * + (L.L.cp_rollo2_rastpos) min (S.L.cp_rollo2_pos)
			{else}
				0 (S.L.cp_rollo2_speed)
			{endif}
		{endif}

		(L.L.cp_rollo2_pos) 1 >
		{if}
			1 (S.L.cp_rollo2_pos) (S.L.cp_rollo2_rastpos)
		{else}
			(L.L.cp_rollo2_pos) 0 <
			{if}
			0 (S.L.cp_rollo2_pos) (S.L.cp_rollo2_retract) (S.L.cp_rollo2_rastpos)
			{endif}
		{endif}

	{endif}
{end}


{macro:microphone_frame}
'	(L.L.IBIS_korekta_numeru_przystanku) +
	(M.V.GetTTBusstopIndex) 1 - (L.L.IBIS_korekta_numeru_przystanku) + (L.L.IBIS_busstop) >
	{if}
'		(L.L.IBIS_nextstop) (L.S.Timegap) + (S.L.IBIS_nextstop)
'		(L.L.IBIS_nextstop) 6 >=
'		{if}
        	(M.V.GetTTBusstopIndex) 1 - (L.L.IBIS_korekta_numeru_przystanku) + (S.L.IBIS_busstop)
			0 (S.L.door_last)
'			0 (S.L.IBIS_nextstop)
			0 (S.L.IBIS_wint1) (S.L.przewijanie_timer) (S.L.monitor_nast_przyst_antirepeat)
			(L.L.wysw_stop_ar) trunc 1 =
			{if}
				2 (S.L.wysw_stop_ar)
			{endif}
'		{endif}
	{endif}
{end}

{macro:IBIS_LCD-refresh}

		(L.L.przewijanie_timer) 3 <
		{if}
			(L.L.przewijanie_timer) (L.S.Timegap) + (S.L.przewijanie_timer)
		{else}
			0 (S.L.przewijanie_timer)
		{endif}

		(L.L.IBIS_LinieKurs) 100 / (S.L.cp_rg_1xx)
		(L.L.IBIS_LinieKurs) (L.L.cp_rg_1xx) trunc 100 * - 10 / (S.L.cp_rg_x1x)
		(L.L.IBIS_LinieKurs) (L.L.cp_rg_1xx) trunc 100 * - (L.L.cp_rg_x1x) trunc 10 * - (S.L.cp_rg_xx1)

(L.L.IBIS_modetimerS) 31 >
(L.L.elec_busbar_rg) &&
{if}
	(L.L.Velocity) 1 <
	(L.L.door_0) 0.2 > &&
	(L.L.door_1) 0.2 > ||
	(L.L.door_2) 0.2 > ||
	(L.L.door_3) 0.2 > ||
	(L.L.door_4) 0.2 > ||
	(L.L.door_5) 0.2 > ||
	(L.L.door_6) 0.2 > ||
	(L.L.door_7) 0.2 > ||
	{if}

		(L.L.IBIS_RouteIndex) 0 >=
		{if}
			(M.V.GetTTBusstopIndex) (L.$.IBIS_busstop_name) $length s4 24 >
			{if}
				"Przystanek:" 35 $SetLengthL
				"@" $+
				(M.V.GetTTBusstopIndex) (L.$.IBIS_busstop_name) l4 $SetLengthR " " (L.L.przewijanie_timer) 0 max 22 * $* $+ 60 $SetLengthR $+
			{else}
				(M.V.GetTTBusstopIndex) (L.$.IBIS_busstop_name) $length 24 - /-/ trunc s6
				"Przystanek:" 35 $SetLengthL
				"@" $+
				" " l6 $* (M.V.GetTTBusstopIndex) (L.$.IBIS_busstop_name) $+ 35 $SetLengthL $+
			{endif}
			(S.$.IBIS_cabindisplay)
			" " (S.$.IBIS_cabindisplay)
		{else}
			(L.$.Matrix_Nr) $length trunc 1 + s2 4 - 0 max s1
			(L.$.IBIS_terminus_name) $length s4 19 >
			{if}
				"_" l2 $* "Kierunek:" $+ 34 $SetLengthL
				"@" $+

				(L.L.cp_rg_1xx) 0.5 >
				(L.L.cp_rg_1xx) 1.5 < &&
				{if}
					" " $+
				{else}
					"_" $+
				{endif}

				(L.L.cp_rg_x1x) 0.5 >
				(L.L.cp_rg_x1x) 1.5 < &&
				{if}
					" " $+
				{else}
					"_" $+
				{endif}

				(L.L.cp_rg_xx1) 0.5 >
				(L.L.cp_rg_xx1) 1.5 < &&
				{if}
					" " $+
				{else}
					"_" $+
				{endif}
				"______" l1 $SetLengthR $+
				(L.$.IBIS_terminus_name) l4 $SetLengthR " " (L.L.przewijanie_timer) 0 max 22 * $* $+ 40 $SetLengthR $+
			{else}
				20 (L.$.IBIS_terminus_name) $length - 2 / s3


				"_" l2 $* "Kierunek:" $+ 34 $SetLengthL
				"@" $+
				"_" l2 $* " " l3 $* (L.$.IBIS_terminus_name) $+ $+ 35 $SetLengthL $+
			{endif}
			(S.$.IBIS_cabindisplay)
			(L.$.Matrix_Nr) 35 $SetLengthL (S.$.IBIS_cabindisplay)
		{endif}
	{else}
		(L.L.IBIS_wint1) (L.S.Timegap) + (S.L.IBIS_wint1)
'		10 (S.L.IBIS_wint1)

		(L.L.IBIS_wint1) 6 <=
		{if}
			(L.L.wysw_stop_ar) trunc 1 =
			(L.L.haltewunschlampe_all) &&
			{if}
				" " (S.$.IBIS_cabindisplay)
				"`STOP" 5 $SetLengthL (S.$.IBIS_cabindisplay)
			{else}
				(L.L.IBIS_RouteIndex) 0 >=
				{if}
					(M.V.GetTTBusstopIndex) (L.$.IBIS_busstop_name) $length s4 24 >
					{if}
						"Nastêpny przystanek:" 35 $SetLengthL
						"@" $+
						(M.V.GetTTBusstopIndex) (L.$.IBIS_busstop_name) l4 $SetLengthR " " (L.L.przewijanie_timer) 0 max 22 * $* $+ 60 $SetLengthR $+
					{else}
						(M.V.GetTTBusstopIndex) (L.$.IBIS_busstop_name) $length 24 - /-/ trunc s6
						"Nastêpny przystanek:" 35 $SetLengthL
						"@" $+
						" " l6 $* (M.V.GetTTBusstopIndex) (L.$.IBIS_busstop_name) $+ 35 $SetLengthL $+
					{endif}
					(S.$.IBIS_cabindisplay)
					" " (S.$.IBIS_cabindisplay)
				{endif}
			{endif}
		{endif}

		(L.L.IBIS_wint1) 6 >
		(L.L.IBIS_wint1) 12 <= &&
		{if}

			(L.$.Matrix_Nr) $length trunc 1 + s2 4 - 0 max s1
			(L.$.IBIS_terminus_name) $length s4 19 >
			{if}
				"_" l2 $* "Kierunek:" $+ 34 $SetLengthL
				"@" $+

				(L.L.cp_rg_1xx) 0.5 >
				(L.L.cp_rg_1xx) 1.5 < &&
				{if}
					" " $+
				{else}
					"_" $+
				{endif}

				(L.L.cp_rg_x1x) 0.5 >
				(L.L.cp_rg_x1x) 1.5 < &&
				{if}
					" " $+
				{else}
					"_" $+
				{endif}

				(L.L.cp_rg_xx1) 0.5 >
				(L.L.cp_rg_xx1) 1.5 < &&
				{if}
					" " $+
				{else}
					"_" $+
				{endif}
				"______" l1 $SetLengthR $+
				(L.$.IBIS_terminus_name) l4 $SetLengthR " " (L.L.przewijanie_timer) 0 max 22 * $* $+ 40 $SetLengthR $+
			{else}
				20 (L.$.IBIS_terminus_name) $length - 2 / s3


				"_" l2 $* "Kierunek:" $+ 34 $SetLengthL
				"@" $+
				"_" l2 $* " " l3 $* (L.$.IBIS_terminus_name) $+ $+ 35 $SetLengthL $+
			{endif}
			(S.$.IBIS_cabindisplay)
			(L.$.Matrix_Nr) 35 $SetLengthL (S.$.IBIS_cabindisplay)
		{endif}

		(L.L.IBIS_wint1) 12 >
		(L.L.IBIS_wint1) 18 <= &&
		{if}
			(L.S.Time) 3600 / s6 trunc s7 10 / trunc s5 1 =
			{if}
				" "
			{else}
				"_"
			{endif}

			(L.S.Time) 3600 / trunc l5 10 * trunc - trunc 1 =
			{if}
				" " $+
			{else}
				"_" $+
			{endif}

			l6 l7 - 6 * trunc s4 1 =
			{if}
				"|\ " $+
			{else}
				"|\_" $+
			{endif}

			l6 l7 - 60 * l4 10 * - trunc 1 =
			{if}
				" " $+
			{else}
				"_" $+
			{endif}

			(L.L.zeller) 0 =
			{if}
			"Niedziela" (S.$.nazwa_dnia_tygodnia) $+ 30 $SetLengthL
			{endif}
			(L.L.zeller) 1 =
			{if}
			"Poniedzia³ek" (S.$.nazwa_dnia_tygodnia) $+ 30 $SetLengthL
			{endif}
			(L.L.zeller) 2 =
			{if}
			"Wtorek" (S.$.nazwa_dnia_tygodnia) $+ 30 $SetLengthL
			{endif}
			(L.L.zeller) 3 =
			{if}
			"Œroda" (S.$.nazwa_dnia_tygodnia) $+ 30 $SetLengthL
			{endif}
			(L.L.zeller) 4 =
			{if}
			"Czwartek" (S.$.nazwa_dnia_tygodnia) $+ 30 $SetLengthL
			{endif}
			(L.L.zeller) 5 =
			{if}
			"Pi¹tek" (S.$.nazwa_dnia_tygodnia) $+ 30 $SetLengthL
			{endif}
			(L.L.zeller) 6 =
			{if}
			"Sobota" (S.$.nazwa_dnia_tygodnia) $+ 30 $SetLengthL
			{endif}
			"@" $+
			(M.L.Miesiac) "|" $+
			(L.S.Year) $IntToStr 2 $+ $+ $+ 35 $SetLengthL $+
			(S.$.IBIS_cabindisplay)
			(L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh ":" $+
			l0 l1 - 60 * s2 trunc s3 "02" $IntToStrEnh $+ 25 $SetLengthL (S.$.IBIS_cabindisplay)
			0 (S.L.przewijanie_timer)
		{endif}

		(L.L.IBIS_wint1) 18 >
		(L.L.IBIS_wint1) 24 <= &&
		{if}
			24 (L.$.Imieniny_2) $length - trunc s5
			"Imieniny:" "  " $+ (L.$.Imieniny_1) $+ 35 $SetLengthL
			"@" $+
'			"\" 
			" " l5 $* (L.$.Imieniny_2) $+ 35 $SetLengthL $+

			(S.$.IBIS_cabindisplay)
			" " (S.$.IBIS_cabindisplay)
			0 (S.L.przewijanie_timer)
		{endif}

		(L.L.IBIS_wint1) 24 >
		{if}
			(L.L.IBIS_TerminusCode) trunc 0 =
			{if}
				13 (S.L.IBIS_wint1)
			{else}
				6 (S.L.IBIS_wint1)
				0 (S.L.przewijanie_timer)
			{endif}
		{endif}
	{endif}
{else}
	"" (S.$.IBIS_cabindisplay)
	"" (S.$.IBIS_cabindisplay)
	13 (S.L.IBIS_wint1)
{endif}

	(L.S.Month) 3 >=
	{if}
		(L.S.Year) s5
		2 s6
	{else}
		(L.S.Year) 1 - s5
		0 s6
	{endif}
	23 (L.S.Month) * 9 / trunc s7
	l7 (L.S.Day) + 4 + (L.S.Year) + s7
	l5 4 / trunc l7 + s7
	l5 100 / trunc s4
	l7 l4 - s7
	l5 400 / trunc l7 + s7
	l7 l6 - s7
	l7 7 % trunc (S.L.zeller)
{end}

{macro:Dzien}
	(L.S.Day) s0
	(L.S.Month) s1
	(L.S.Year) s2
	{if}
		"sobota"
	{endif}
{end}

{macro:Miesiac}

'1xxx
	(L.S.Year) 1000 / trunc s1 1 =
	{if}
		"\"
	{else}
		""
	{endif}

'x1xx
	(L.S.Year) l1 1000 * - s3 100 / trunc s2 1 =
	{if}
		"\" $+
	{else}
		"" $+
	{endif}

'xx1x
	l3 l2 100 * - s5 10 / trunc s4 1 =
	{if}
		"\" $+
	{else}
		"" $+
	{endif}

'xxx1
	l5 l4 10 * - trunc 1 =
	{if}
		"\" $+
	{else}
		"" $+
	{endif}

	(L.S.Day) trunc 11 =
	{if}
		"|" $+
	{else}
		(L.S.Day) trunc 1 =
		(L.S.Day) trunc 10 = ||
		(L.S.Day) trunc 12 >=
		(L.S.Day) trunc 19 <= && ||
		(L.S.Day) trunc 21 = ||
		(L.S.Day) trunc 31 = ||
		{if}
			"\" $+
		{else}
			"" $+
		{endif}
	{endif}

	(L.S.Month) 1 =
	{if}
		"        ||||" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"stycznia"
	{endif}
	(L.S.Month) 2 =
	{if}
		"          |||||" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"lutego"
	{endif}
	(L.S.Month) 3 =
	{if}
		"           |||" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"marca"
	{endif}
	(L.S.Month) 4 =
	{if}
		"        |||||" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"kwietnia"
	{endif}
	(L.S.Month) 5 =
	{if}
		"            |||" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"maja"
	{endif}
	(L.S.Month) 6 =
	{if}
		"         |||\" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"czerwca"
	{endif}
	(L.S.Month) 7 =
	{if}
		"           ||||\" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"lipca"
	{endif}
	(L.S.Month) 8 =
	{if}
		"        |||||" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"sierpnia"
	{endif}
	(L.S.Month) 9 =
	{if}
		"        ||||" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"wrzeœnia"
	{endif}
	(L.S.Month) 10 =
	{if}
		"     ||\" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"paŸdziernika"
	{endif}
	(L.S.Month) 11 =
	{if}
		"        ||\" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"listopada"
	{endif}
	(L.S.Month) 12 =
	{if}
		"         ||||" $+ (L.S.Day) "02" $IntToStrEnh "|" $+
		"grudnia"
	{endif}
{end}

{macro:pressure_warning_needle_frame}

	(L.L.bremse_p_Tank01) (L.L.bremse_p_Tank02) + 2 / (S.L.cockpit_warndruck) (F.L.cockpit_warndruck) (S.L.cockpit_warndruckwinkel)

{end}

{macro:zentralschmierung_frame}

	(L.L.cp_zentralschmierung_nextkm) (L.L.velocity) 3600 / (L.S.Timegap) * + (S.L.cp_zentralschmierung_nextkm)
	(C.L.cockpit_zentralschmierung_dist) >
	(L.L.cp_zentralschmierung_runtime) (C.L.cockpit_zentralschmierung_maxtime) < &&
	{if}
		1 (S.L.cockpit_light_zentralschmierung)
		(L.L.cp_zentralschmierung_runtime) (L.S.Timegap) + (S.L.cp_zentralschmierung_runtime)
	{else}
		(L.L.cockpit_light_zentralschmierung)
		{if}
			0 (S.L.cp_zentralschmierung_nextkm)
		{endif}
		0 (S.L.cockpit_light_zentralschmierung) (S.L.cp_zentralschmierung_runtime)
	{endif}	

{end}

{macro:Thermometer_frame}
(L.L.elec_busbar_main)
{if}
	(L.L.Cabinair_Temp) s0 trunc " 3" $IntToStrEnh "." $+ 
	l0 abs l0 abs trunc - 10 * trunc " 1" $IntToStrEnh $+ "C" $+

	" " $+

	(L.S.Weather_Temperature) s1 trunc " 3" $IntToStrEnh "." $+ 
	l1 abs l1 abs trunc - 10 * trunc " 1" $IntToStrEnh $+ "C" $+ $+

	(S.$.cockpit_temperatur)
{else}
" "	(S.$.cockpit_temperatur)
{endif}
{end}

{macro:Timer_frame}
	(L.L.elec_busbar_main)
	{if}
		(L.S.Time) 3600 / trunc "02" s1 $IntToStrEnh ":" $+
		(L.S.Time) 60 / l1 60 * - trunc "02" $IntToStrEnh $+
	{else}
		""
	{endif}
	(S.$.cockpit_timer)

	(L.L.elec_busbar_vdo)
	{if}
		(L.L.kmcounter_km) trunc " 6" $IntToStrEnh "." $+ 
		(L.L.kmcounter_m) 100 / trunc " 1" $IntToStrEnh $+
		"@" $+
		(L.S.Time) 3600 / trunc "02" s1 $IntToStrEnh ":" $+
		(L.S.Time) 60 / l1 60 * - trunc "02" $IntToStrEnh $+ $+
	{else}
		""
	{endif}
	(S.$.cockpit_tacho)

{end}

{trigger:cp_Fahrgastpendel}
	1 (S.L.cp_Fahrgastpendel_drag)
{end}

{trigger:cp_Fahrgastpendel_2}
	1 (S.L.cp_Fahrgastpendel_2_drag)
{end}

{trigger:cp_Fahrgastpendel_off}
	0 (S.L.cp_Fahrgastpendel_drag)
{end}

{trigger:cp_Fahrgastpendel_2_off}
	0 (S.L.cp_Fahrgastpendel_2_drag)
{end}

{trigger:cp_Fahrgastpendel_drag}
	(L.L.cp_Fahrgastpendel_drag)
	{if}
		(L.L.cp_Fahrgastpendel_Pos) (L.S.mouse_y) 500 / + 1 min 0 max s0
		l0 (L.L.cp_Fahrgastpendel_Pos) - (L.S.Timegap) / (S.L.cp_Fahrgastpendel_Speed)
		l0 (S.L.cp_Fahrgastpendel_Pos)
	{endif}
{end}

{trigger:cp_Fahrgastpendel_2_drag}
	(L.L.cp_Fahrgastpendel_2_drag)
	{if}
		(L.L.cp_Fahrgastpendel_2_Pos) (L.S.mouse_y) 500 / + 1 min 0 max s0
		l0 (L.L.cp_Fahrgastpendel_2_Pos) - (L.S.Timegap) / (S.L.cp_Fahrgastpendel_2_Speed)
		l0 (S.L.cp_Fahrgastpendel_2_Pos)
	{endif}
{end}

{macro:Fahrgastpendel}
'Sollwert: (wenn mindestens ein Typ an der Stelle durchgeht)
	2 (M.V.GetHumanCountOnPathLink) 4 (M.V.GetHumanCountOnPathLink) + 1 min s4

'Wenn ein Fahrgast durchwill, dann überschreibe die "Drag"-Eigenschaft:
	l4 {if} 0 (S.L.cp_Fahrgastpendel_drag) (S.L.cp_Fahrgastpendel_2_drag) {endif}

'1:====================================

'Differenz * InvTrägheit = Beschleunigung
	l4 (L.L.cp_Fahrgastpendel_Pos) - (L.L.cp_Fahrgastpendel_traeg) * s1

	(L.L.cp_Fahrgastpendel_drag) !
	{if}

'Anwendung einer Reibungskraft:
		l1 (L.L.cp_Fahrgastpendel_Speed) sgn (L.L.cp_Fahrgastpendel_reib) * - s0
'Prüfen, ob sich die Beschleunigung infolge der Reibung umkehrt - dann wird sie auf 0 gesetzt:
		l0 l1 * 0 < {if} 0 s0 {endif}
'Anwenden der Beschleunigung:
		(L.L.cp_Fahrgastpendel_Speed) l0 (L.S.Timegap) * + (S.L.cp_Fahrgastpendel_Speed)
'Anwenden der Position:
		(L.L.cp_Fahrgastpendel_Pos) (L.L.cp_Fahrgastpendel_Speed) (L.S.Timegap) * + (S.L.cp_Fahrgastpendel_Pos) s0
	{else}
		(L.L.cp_Fahrgastpendel_Pos) s0
	{endif}


'Limits: (Anschlag an Haltestange mit 10% Abprallstärke)
	l0 0 <
	{if}
		0 (S.L.cp_Fahrgastpendel_Pos)
		(T.L.ev_fahrgastpendel_zu)
		(L.L.cp_Fahrgastpendel_Speed) (L.L.cp_Fahrgastpendel_refl) * (S.L.cp_Fahrgastpendel_Speed)
	{endif}
'(anderes Ende ohne Reflexion)
	l0 1 >
	{if}
		1 (S.L.cp_Fahrgastpendel_Pos)
		0 (S.L.cp_Fahrgastpendel_Speed)
	{endif}

'2:====================================

'Differenz * InvTrägheit = Beschleunigung
	l4 (L.L.cp_Fahrgastpendel_2_Pos) - (L.L.cp_Fahrgastpendel_2_traeg) * s1

	(L.L.cp_Fahrgastpendel_2_drag) !
	{if}

'Anwendung einer Reibungskraft:
		l1 (L.L.cp_Fahrgastpendel_2_Speed) sgn (L.L.cp_Fahrgastpendel_2_reib) * - s0
'Prüfen, ob sich die Beschleunigung infolge der Reibung umkehrt - dann wird sie auf 0 gesetzt:
		l0 l1 * 0 < {if} 0 s0 {endif}
'Anwenden der Beschleunigung:
		(L.L.cp_Fahrgastpendel_2_Speed) l0 (L.S.Timegap) * + (S.L.cp_Fahrgastpendel_2_Speed)
'Anwenden der Position:
		(L.L.cp_Fahrgastpendel_2_Pos) (L.L.cp_Fahrgastpendel_2_Speed) (L.S.Timegap) * + (S.L.cp_Fahrgastpendel_2_Pos) s0
	{else}
		(L.L.cp_Fahrgastpendel_2_Pos) s0
	{endif}


'Limits: (Anschlag an Haltestange mit 10% Abprallstärke)
	l0 0 <
	{if}
		0 (S.L.cp_Fahrgastpendel_2_Pos)
		(T.L.ev_fahrgastpendel_2_zu)
		(L.L.cp_Fahrgastpendel_2_Speed) (L.L.cp_Fahrgastpendel_2_refl) * (S.L.cp_Fahrgastpendel_2_Speed)
	{endif}
'(anderes Ende ohne Reflexion)
	l0 1 >
	{if}
		1 (S.L.cp_Fahrgastpendel_2_Pos)
		0 (S.L.cp_Fahrgastpendel_2_Speed)
	{endif}

{end}


{macro:elec_vdo}

	(L.L.elec_busbar_main)
	(L.L.elec_busbar_vdo_Sw) 1 = &&
	{if}
		1 (S.L.elec_busbar_vdo)
	{else}
		0 (S.L.elec_busbar_vdo)
	{endif}

{end}

{macro:szyby_frame}
	(L.L.Envir_Brightness) (F.L.Szyby) (S.L.Szyby)

	(L.L.mroz) 1 <
	(L.L.mroz) 0 > &&
	(L.S.PrecipType) 1 >= &&
	{if}
		(L.S.Weather_Temperature) -0.0005 * (L.S.PrecipRate) * (L.S.Timegap) * s0
		(L.L.mroz) l0 + (S.L.mroz)
	{endif}

	(L.S.Weather_Temperature) (L.L.Cabinair_Temp) - abs 0.0003 * (L.S.Timegap) * s2

	(L.L.para_Passanger) 1 <
	(L.L.para_Passanger) 0 > &&
	(L.S.PrecipType) 1 >= &&
	{if}
		(L.S.Weather_Temperature) (L.L.Cabinair_Temp) - -5 < &&
		{if}
			(L.L.para_Passanger) l2 + (S.L.para_Passanger)
		{else}
			(L.L.para_Passanger) l2 0.00001 * - (S.L.para_Passanger)
		{endif}
	{endif}

	(L.L.para_Front_s) 1 <
	(L.L.para_Front_s) 0 > &&
	(L.S.PrecipType) 1 >= &&
	{if}
		(L.S.Weather_Temperature) (L.L.Cabinair_Temp) - -5 < &&
		{if}
			(L.L.para_Front_s) l2 + (S.L.para_Front_s)
		{else}
			(L.L.para_Front_s) l2 0.00001 * - (S.L.para_Front_s)
		{endif}
	{endif}

	(L.L.para_Front) 1 <
	(L.L.para_Front) 0 > &&
	(L.S.PrecipType) 1 >= &&
	{if}
		(L.S.Weather_Temperature) (L.L.Cabinair_Temp) - -5 < &&
		{if}
			(L.L.para_Front) l2 + (S.L.para_Front)
		{else}
			(L.L.para_Front) l2 0.00001 * - (S.L.para_Front)
		{endif}
	{endif}

{end}

{macro:spiegelheizung}

	(L.L.cp_spiegelheizung)
	(L.L.elec_busbar_main) &&
	(L.L.lusterko_failure_general) ! &&
	{if}
		(L.L.mroz) 1 <=
		(L.L.mroz) 0 > &&
		{if}
			(L.L.mroz) -0.03 (L.S.Timegap) * + (S.L.mroz)
		{endif}
	{endif}

	(L.L.elec_busbar_main)
	{if}

		(L.L.cp_reheat)
		{if}
			-0.008 (L.S.Timegap) * s1
		{else}
			-0.002 (L.S.Timegap) * s1
		{endif}
		
		(L.S.Timegap) s3

		(L.L.para_Passanger) 1 <=
		(L.L.para_Passanger) 0 >= &&
		{if}
			(L.L.para_Passanger) l1 0.3 * + (S.L.para_Passanger)
		{endif}

		(L.L.para_Front_s) 1 <=
		(L.L.para_Front_s) 0 >= &&
		{if}
			(L.L.para_Front_s) l1 0.6 * + (S.L.para_Front_s)
		{endif}

		(L.L.para_Front) 1 <=
		(L.L.para_Front) 0 >= &&
		{if}
			(L.L.para_Front) l1 0.85 * + (S.L.para_Front)
		{endif}

		(L.L.para_Door) 1 <=
		(L.L.para_Door) 0 >= &&
		{if}
			(L.L.para_Door) l1 0.85 * + (S.L.para_Door)
		{endif}

		(L.L.cp_ogrzewanie_szyb_sw)
		(L.L.para_Door) 1 <= &&
		(L.L.para_Door) 0 >= &&
		{if}
			(L.L.para_Door) l2 + (S.L.para_Door)
		{endif}
	{endif}
{end}

{macro:lift_calc_z_limit}


	(L.L.cp_rampa_dragged) 0 =
	{if}
		(L.L.cp_rampa_pos1) 0.45 <
		{if}
			(L.L.cp_rampa_pos1) 0.01 >
			{if}
				(L.L.cp_rampa_pos1) (L.S.Timegap) - (S.L.cp_rampa_pos1)
			{else}
				0 (S.L.cp_rampa_pos1)
			{endif}
		{else}
			(L.L.cp_rampa_pos1) 1 <
			{if}
				(L.L.cp_rampa_pos1) (L.S.Timegap) + (S.L.cp_rampa_pos1)
			{else}
				1 (S.L.cp_rampa_pos1)
			{endif}
		{endif}
	{endif}

'Höhe im Bereich des Auszuges messen:
'	x	y	z
	2.09	0.423	0.289	(M.V.GetHeightAbovePoint) 0.44 - 0.32 * (S.L.lift_pos_z_limit)

	(L.L.cp_rampa_pos1)  (L.L.cp_rampa_pos1) (L.L.lift_pos_z_limit) * + (S.L.cp_rampa_pos)


	(L.L.cp_rampa_pos1) 1 =
	(L.L.ramp_open_ar) ! &&
	{if}
		(T.L.ev_ramp_open)
		1 (S.L.ramp_open_ar)
	{endif}

	(L.L.cp_rampa_pos1) 0.9 <
	{if}
		0 (S.L.ramp_open_ar)
	{endif}

	(L.L.cp_rampa_pos1) 0 =
	(L.L.ramp_close_ar) ! &&
	{if}
		(T.L.ev_ramp_close)
		1 (S.L.ramp_close_ar)
	{endif}

	(L.L.cp_rampa_pos1) 0 = !
	(L.L.ramp_close_ar) &&
	{if}
		(T.L.ev_ramp_close)
		0 (S.L.ramp_close_ar)
	{endif}

{end}

{macro:dachluke1_rot_mode}

	(L.L.cp_dachluke1_rot) 0.166666 <
	{if}
		0 (S.L.cp_dachluke1_rot_mode)


			0 (S.L.cp_dachluke_1_S1)
			0 (S.L.cp_dachluke_1_S2)

			0 (S.L.dachluke2_ar) (S.L.dachluke3_ar) (S.L.dachluke4_ar)

			(L.L.dachluke1_ar) 1 = !
			{if}
				1 (S.L.dachluke1_ar)
				(T.L.ev_dachluke_elec)
			{endif}

	{endif}

	(L.L.cp_dachluke1_rot) 0.166666 >=
	(L.L.cp_dachluke1_rot) 0.5 < &&
	{if}
		1 (S.L.cp_dachluke1_rot_mode)

		(L.L.elec_busbar_main)
		{if}
			0 (S.L.cp_dachluke_1_S1)
			1 (S.L.cp_dachluke_1_S2)

			0 (S.L.dachluke1_ar) (S.L.dachluke3_ar) (S.L.dachluke4_ar)

			(L.L.dachluke2_ar) 1 = !
			{if}
				1 (S.L.dachluke2_ar)
				(T.L.ev_dachluke_elec)
			{endif}
		{endif}
	{endif}

	(L.L.cp_dachluke1_rot) 0.5 >=
	(L.L.cp_dachluke1_rot) 0.833333 < &&
	{if}
		2 (S.L.cp_dachluke1_rot_mode)

		(L.L.elec_busbar_main)
		{if}
			1 (S.L.cp_dachluke_1_S1)
			1 (S.L.cp_dachluke_1_S2)

			0 (S.L.dachluke1_ar) (S.L.dachluke2_ar) (S.L.dachluke4_ar)

			(L.L.dachluke3_ar) 1 = !
			{if}
				1 (S.L.dachluke3_ar)
				(T.L.ev_dachluke_elec)
			{endif}
		{endif}
	{endif}

	(L.L.cp_dachluke1_rot) 0.833333 >=
	{if}
		3 (S.L.cp_dachluke1_rot_mode)

		(L.L.elec_busbar_main)
		{if}
			1 (S.L.cp_dachluke_1_S1)
			0 (S.L.cp_dachluke_1_S2)

			0 (S.L.dachluke1_ar) (S.L.dachluke2_ar) (S.L.dachluke3_ar)

			(L.L.dachluke4_ar) 1 = !
			{if}
				1 (S.L.dachluke4_ar)
				(T.L.ev_dachluke_elec)
			{endif}
		{endif}
	{endif}
{end}

{macro:kneel_auto_lift}
	(L.L.door_0) 0.8 >
	(L.L.door_1) 0.8 > ||
	(L.L.door_2) 0.8 > ||
	(L.L.door_3) 0.8 > ||
	(L.L.door_4) 0.8 > ||
	(L.L.door_5) 0.8 > ||
	(L.L.door_6) 0.8 > ||
	(L.L.door_7) 0.8 > ||
	(L.L.cp_kneeling) &&
	{if}
		1 (S.L.kneeling_auto_lift)
	{endif}

	(L.L.elec_busbar_main)
	(L.L.door_0) 0.8 < &&
	(L.L.door_1) 0.8 < &&
	(L.L.door_2) 0.8 < &&
	(L.L.door_3) 0.8 < &&
	(L.L.door_4) 0.8 < &&
	(L.L.door_5) 0.8 < &&
	(L.L.door_6) 0.8 < &&
	(L.L.door_7) 0.8 < &&
	(L.L.kneeling_auto_lift) &&
	{if}
		0 (S.L.cp_kneeling) (S.L.kneeling_timer) (S.L.kneeling_auto_lift)
		0 (S.L.bremse_kneeling)
	{endif}
{end}
