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

'Simuliert alle unmittelbar mit dem Armaturenbrett zusammenhängenden Funktionen

'(c) 23.10.2009 Rüdiger Hülsmann
'(c) 15.04.2010 Marcel Kuhnt

'Script Version: 1.0
'Omsi release: 1.0

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


'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

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


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


' manual or automatic

{trigger:kw_s_3}

	(L.L.antrieb_getr_aktugang) 5 = !
	{if}
		 5 (S.L.antrieb_getr_aktugang) 
	{endif} 
{end}


' upshift downshift


{trigger:kw_s_1}

	(L.L.antrieb_getr_aktugang) 5 = 
	{if}

		(L.L.antrieb_upshift_request) !  
		{if}
			1 (S.L.antrieb_upshift_request) 
			
		{endif}

		(L.L.antrieb_shift_quo) 1 + (S.L.antrieb_shift_quo) 
	{endif}
{end}


{trigger:kw_s_2}

	(L.L.antrieb_dnshift_request) ! (L.L.antrieb_getr_aktugang) 5 = &&
	{if}
		1 (S.L.antrieb_dnshift_request) 
	{endif}  
{end}


{trigger:automatic_R}

	(L.L.antrieb_getr_aktugang) 1 <= 
	{if}
		(L.L.antrieb_getr_aktugang) 0 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		
		0 (S.L.antrieb_getr_aktugang)
		-1 (S.L.antrieb_getr_aktugang)	
		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_R_mouse}

	(L.L.antrieb_getr_gangvorwahl) 1 <= 
	{if}
		(L.L.antrieb_getr_gangvorwahl) 0 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		0 (S.L.antrieb_getr_gangvorwahl)

		1 (S.L.cockpit_gangR)
	{endif}

{end}

{trigger:automatic_R_mouse_off}

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


{trigger:automatic_N}

		(L.L.antrieb_getr_gangvorwahl) 1 = !
			{if}
				(T.L.ev_gangwahltaster_N)
				(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) -  - (S.L.antrieb_getr_gangwahlzeitpunkt)
			{endif}
		1 (S.L.antrieb_getr_gangvorwahl) (S.L.cockpit_gangN)
		0 (S.L.antrieb_getr_aktugang)
		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_D}

		(L.L.antrieb_getr_gangvorwahl) 0 >
		{if}
			(L.L.antrieb_getr_gangvorwahl) 4 = !
			{if}
				(T.L.ev_gangwahltaster)
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
			{endif}
			4 (S.L.antrieb_getr_gangvorwahl)
			6 (S.L.antrieb_getr_aktugang)
			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:automatic_M}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gangR)
		{if}

			(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) - - (S.L.antrieb_getr_gangwahlzeitpunkt)
			1 (S.L.antrieb_getr_gangvorwahl)
		{else}
			(L.L.cockpit_gang2_toggle) !
			{if}
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
				5 (S.L.antrieb_getr_gangvorwahl)
			{endif}
		{endif}
		(L.L.cockpit_gang3_toggle) ! (S.L.cockpit_gang3_toggle)
		(L.L.cockpit_gang3) 1 = !
		{if}
			(L.L.cockpit_gang3_toggle)
			{if}
				(T.L.ev_gangwahltaster_old_on)
			{else}
				(T.L.ev_gangwahltaster_old_off)
			{endif}
		{endif}
		6 (S.L.antrieb_getr_aktugang)
		1 (S.L.cockpit_gang3)
	{else}
		(L.L.antrieb_getr_gangvorwahl) 0 >
		{if}
			(L.L.antrieb_getr_gangvorwahl) 4 = !
			{if}
				(T.L.ev_gangwahltaster)
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
			{endif}
			5 (S.L.antrieb_getr_gangvorwahl)
			1 (S.L.cockpit_gang3)
			0 (S.L.cockpit_gang1) (S.L.cockpit_gang2)	
		6 (S.L.antrieb_getr_aktugang)
		{endif}
	{endif}
{end}


{trigger:automatic_M_off}
	(C.L.cockpit_gangwahltaster_alt)
	{if}
		(L.L.cockpit_gang3_toggle) 
		{if}
			0.7 (S.L.cockpit_gang3)
		{else}
			(L.L.cockpit_gang2_toggle) (L.L.cockpit_gangR_toggle) ! &&
			{if}
				(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
				3 (S.L.antrieb_getr_gangvorwahl)
			{else}	
				(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) - - (S.L.antrieb_getr_gangwahlzeitpunkt)
				1 (S.L.antrieb_getr_gangvorwahl)
			{endif}
			0 (S.L.cockpit_gang3)
		{endif}
	{else}
		(L.L.cockpit_gang3) 1 =
		{if}
			0.7 (S.L.cockpit_gang3)
		{endif}	
	{endif}
{end}


{trigger:horn}
	
		(L.L.cockpit_hupe) ! (L.L.elec_busbar_main) &&
		{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) &&
		{if}
			(T.L.ev_hupe_aus)
		{endif}
		0 (S.L.cockpit_hupe)	
	
{end}

{trigger:cp_retarder_direkt_toggle}
	(L.L.cp_retarder_sw_direkt) ! (S.L.cp_retarder_sw_direkt) s1
	(M.L.kippschaltersound)
{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}
	(L.L.cp_fahrerlicht_sw) ! (S.L.cp_fahrerlicht_sw) s1
	1 (S.L.cp_fahrerlicht_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_fahrerlicht_off}
	0 (S.L.cp_fahrerlicht_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_licht_untenrechts}
	(L.L.cp_licht_untenrechts_sw) ! (S.L.cp_licht_untenrechts_sw) s1
	1 (S.L.cp_licht_untenrechts_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_licht_untenrechts_off}
	0 (S.L.cp_licht_untenrechts_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

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

{trigger:cp_licht_unterdeck_toggle}
	(L.L.cp_licht_unterdeck_sw) ! (S.L.cp_licht_unterdeck_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_licht_pax}
	(L.L.cp_licht_pax_sw) ! (S.L.cp_licht_pax_sw) s1
	1 (S.L.cp_licht_pax_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_licht_pax_off}
	0 (S.L.cp_licht_pax_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_licht_night}
	(L.L.cp_licht_night_sw) ! (S.L.cp_licht_night_sw) s1	
	1 (S.L.cp_licht_night_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_licht_night_off}
	0 (S.L.cp_licht_night_sw_2)
	(T.L.ev_kippschalter_aus)
{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)
	{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_wiper_switch)
		{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_wiper_switch)
		{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_wiper_switch)
		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_wiper_switch)
		0 (S.L.cockpit_wischerhebel_x)
	{else}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_heizluefter_toggle}
	(L.L.cp_heizluefter_sw) ! (S.L.cp_heizluefter_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_spiegelheizung_toggle}
	(L.L.cp_spiegelheizung_sw) ! (S.L.cp_spiegelheizung_sw) s1
	(M.L.kippschaltersound)
{end}





{trigger:cp_kneel}
	(L.L.cp_kneel_sw) ! (S.L.cp_kneel_sw) s1
	1 (S.L.cp_kneel_sw_2)
	(T.L.ev_kippschalter_ein)
	
	(L.L.cp_kneel_sw) 1 = (L.L.elec_busbar_main) &&
	{if}
	1 (S.L.kneel_mode)
	{else}
	0 (S.L.kneel_mode)
	{endif}
{end}

{trigger:cp_kneel_off}
	0 (S.L.cp_kneel_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:chasis_reg_up}
	(L.L.cp_chasis_reg) 1 <
	{if}
	(L.L.cp_chasis_reg) 1 + (S.L.cp_chasis_reg)
	{endif}
	1 (S.L.cp_chasis_reg_up)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:chasis_reg_up_off}
	0 (S.L.cp_chasis_reg_up)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:chasis_reg_down}
	(L.L.cp_chasis_reg) -1 >
	{if}
	(L.L.cp_chasis_reg) 1 - (S.L.cp_chasis_reg)
	{endif}
	1 (S.L.cp_chasis_reg_down)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:chasis_reg_down_off}
	0 (S.L.cp_chasis_reg_down)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_schalter_ASR}
	(L.L.cp_ASR_off) ! (S.L.cp_ASR_off) s1
	1 (S.L.cp_ASR_off_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_schalter_ASR_off}
	0 (S.L.cp_ASR_off_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_mirror_heat}
	(L.L.cp_mirror_heat_sw) ! (S.L.cp_mirror_heat_sw) s1
	1 (S.L.cp_mirror_heat_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_mirror_heat_off}
	0 (S.L.cp_mirror_heat_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_windshield_heat}
	(L.L.cp_windshield_heat_sw) ! (S.L.cp_windshield_heat_sw) s1
	1 (S.L.cp_windshield_heat_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_windshield_heat_off}
	0 (S.L.cp_windshield_heat_sw_2)
	(T.L.ev_kippschalter_aus)
{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_up_drag}
	-1 (S.L.cp_rollo_sw)
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_rollo_pos) (L.S.Timegap) 0.3 * - (S.L.cp_rollo_pos)
		0 <
		{if}
			0 (S.L.cp_rollo_pos)
			0 (S.L.cp_rollo_up_speed)
		{else}
		1 (S.L.cp_rollo_up_speed)
		{endif}
	{endif}
{end}

{trigger:cp_rollo_up_off}
	0 (S.L.cp_rollo_sw)
	0 (S.L.cp_rollo_up_speed)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_rollo_down_drag}
	1 (S.L.cp_rollo_sw)
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_rollo_pos) (L.S.Timegap) 0.3 * + (S.L.cp_rollo_pos)
		1 >
		{if}
			1 (S.L.cp_rollo_pos)
			0 (S.L.cp_rollo_down_speed)
		{else}
		1 (S.L.cp_rollo_down_speed)
		{endif}
	{endif}
{end}

{trigger:cp_rollo_down_off}
	0 (S.L.cp_rollo_sw)
	0 (S.L.cp_rollo_down_speed)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_fahrerfenster_up_drag}
	-1 (S.L.cp_fahrerfenster_sw)
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_fahrerfenster_pos) (L.S.Timegap) 0.3 * + (S.L.cp_fahrerfenster_pos)
		0 >
		{if}
			(L.L.cp_fahrerfenster_endanschlag) !
			{if}
				(T.L.ev_window_up_2)
			{endif}
			1 (S.L.cp_fahrerfenster_endanschlag)
			0 (S.L.cp_fahrerfenster_pos)
			0 (S.L.cp_fahrerfenster_up_speed)
		{else}
			0 (S.L.cp_fahrerfenster_endanschlag)
			1 (S.L.cp_fahrerfenster_up_speed)
		{endif}
	{endif}
{end}

{trigger:cp_fahrerfenster_up_off}
	0 (S.L.cp_fahrerfenster_sw)
	0 (S.L.cp_fahrerfenster_up_speed)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_fahrerfenster_down_drag}
	1 (S.L.cp_fahrerfenster_sw)
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_fahrerfenster_pos) (L.S.Timegap) 0.3 * - (S.L.cp_fahrerfenster_pos)
		-1 <
		{if}
			(L.L.cp_fahrerfenster_endanschlag) !
			{if}
				(T.L.ev_window_down_2)
			{endif}
			1 (S.L.cp_fahrerfenster_endanschlag)
			-1 (S.L.cp_fahrerfenster_pos)
			0 (S.L.cp_fahrerfenster_down_speed)
		{else}
			0 (S.L.cp_fahrerfenster_endanschlag)
			1 (S.L.cp_fahrerfenster_down_speed)
		{endif}
	{endif}
{end}

{trigger:cp_fahrerfenster_down_off}
	0 (S.L.cp_fahrerfenster_sw)
	0 (S.L.cp_fahrerfenster_down_speed)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_lightsw_mov_drag}
'		Sonst Rotation (Lichtschalter)

		(L.S.mouse_x) -20 / (L.L.cp_lightsw_rot) + 0 max 4.852 min (S.L.cp_lightsw_rot) s1

'		Stufen:
'		0: Swiatla wylaczone
'		1: Pozycyjne
'		2: Mijania
'		3: Przeciwmglowe tyl
'		4: Przeciwmglowe przod

		l1 0.2 <
		{if}
			0 (S.L.cp_lightsw_rot_mode) 
		{else} 
			l1 0.8 <
			{if}
				1 (S.L.cp_lightsw_rot_mode) 
			{else}
				l1 4.1 <
				{if}
					2 (S.L.cp_lightsw_rot_mode) 
				{else}
					l1 4.5 <
					{if}
						3 (S.L.cp_lightsw_rot_mode) 
					{else}
						4 (S.L.cp_lightsw_rot_mode) 
					{endif}
				{endif}
			{endif}
		{endif}
	{endif}
{end}


{trigger:cp_lightsw_mov_off}

'	Einrasten auf den festen Positionen:
	(L.L.cp_lightsw_rot_mode) s1 0 =
	{if}
		0 (S.L.cp_lightsw_rot)
	{else}
		l1 1 =
		{if}
			0.5 (S.L.cp_lightsw_rot)
		{else}
			l1 2 =
			{if}
				1 (S.L.cp_lightsw_rot)
			{else}
				l1 3 =
				{if}
					4.352 (S.L.cp_lightsw_rot)
				{else}
					4.852 (S.L.cp_lightsw_rot)
				{endif}
			{endif}
		{endif}
	{endif}
	
{end}

{trigger:cp_wheel_col_key_drag}

		(L.S.mouse_y) -10 / (L.L.cp_wheel_col_key) + 0 max 1 min (S.L.cp_wheel_col_key) s1

		l1 0.2 <
		(L.L.engine_on) 0 = &&
		{if}
			0 (S.L.cp_wheel_col_key_mode) (S.L.elec_busbar_main_sw)
		{else} 
			1 (S.L.elec_busbar_main_sw)
			0.9 (S.L.cp_wheel_col_key_mode)
		{endif}
	{endif}
	(T.L.ev_ignition_on)
{end}

{trigger:cp_wheel_col_key_off}
	(L.L.cp_wheel_col_key_mode) (S.L.cp_wheel_col_key)
	0 (S.L.cp_wheel_col_key_antirepeat)	
	(T.L.ev_ignition_off)
{end}

{trigger:kw_m_engine_startbutton}

(L.L.alcolock_pass)
{if}
	(L.L.engine_on) ! (L.L.antrieb_getr_gangwahl) 1 = (L.L.elec_busbar_main) && &&
	{if}
		1 (S.L.engine_on) (S.L.engine_injection_on)
		(T.L.ev_enginestart)
		1 (S.L.engine_starter)
	{endif}	
{endif}
	1 (S.L.cp_taster_anlasser)
{end}

{trigger:kw_m_engine_startbutton_off}
	0 (S.L.cp_taster_anlasser)
{end}

{trigger:kw_m_enginestart}
(L.L.alcolock_pass)
{if}
	(L.L.engine_starter_antirepeat) !
	{if}
		(L.L.engine_on) !
		{if}	
			(L.L.antrieb_getr_gangwahl) 1 = (L.L.elec_busbar_main) && 
			{if}
				1 (S.L.engine_on) (S.L.engine_injection_on)
				(T.L.ev_enginestart)
				1  (S.L.engine_starter)
			{endif}	
			1 (S.L.cp_taster_anlasser) (S.L.engine_starter_antirepeat)
		{else}
			(L.L.elec_busbar_main)
			{if}
				0 (S.L.engine_injection_on) (S.L.engine_idle_control)
				1 (S.L.engine_starter_antirepeat)

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

{trigger:kw_m_enginestart_off}
	0 (S.L.cp_taster_motorabstellung) (S.L.cp_taster_anlasser) (S.L.engine_starter_antirepeat)

{end}


{trigger:kw_m_engineshutdown}
	(L.L.elec_busbar_main)
	{if}
		0 (S.L.engine_injection_on)
	{endif}



	1 (S.L.cp_taster_motorabstellung)
{end}

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

{trigger:cp_batterietrennschalter_toggle}
		(L.L.elec_busbar_main_sw) ! (S.L.elec_busbar_main_sw) 
		
			1 =
			{if}
				0.9 (S.L.cp_wheel_col_key)
				(T.L.ev_ignition_on)
			{else}
				0 (S.L.cp_wheel_col_key)
				1 (S.L.engine_starter_antirepeat)
				(T.L.ev_ignition_off)
			{endif}
			
			(L.L.engine_on) 1 =
			{if}
			0.9 (S.L.cp_wheel_col_key)
			1 (S.L.elec_busbar_main_sw) 
			{endif}
{end}	


{trigger:KR_play}
	(L.L.cockpit_KR_play) 0.1 <
	{if}
		(T.L.ev_kr_play)
	{endif}
	
	(L.L.cp_radio_active) 1 = &&
	{if}
	1 (S.L.cockpit_KR_play) (S.L.Snd_Radio)
	{endif}
	
	(L.L.cp_radio_active) 0 = && (L.L.elec_busbar_main) 0 = &&
	{if}
	0 (S.L.cockpit_KR_play) (S.L.Snd_Radio)
	{endif}
{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)
	{endif}
	(T.L.ev_kr_stop)
{end}


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

{trigger:cp_radio_sw}
	(L.L.elec_busbar_main) 1 =
	{if}
	(L.L.cp_radio_sw) ! (S.L.cp_radio_sw) s1
	{endif}
{end}

{trigger:taster_standheizung}

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

	1 (S.L.cp_taster_standheizung)

	(C.L.auxheat_via_button) !
	{if}
		l1 (M.L.kippschaltersound)
		l0 (S.L.cp_taster_standheizung)
	{endif}
		
{end}

{trigger:taster_standheizung_off}
	
	(L.L.cp_taster_standheizung_target)
	{if}
		0 (S.L.cp_taster_standheizung)
	{else}
		0.6 (S.L.cp_taster_standheizung)
	{endif}

{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_wiper_switch)
				{endif}
				1 (S.L.cp_wischer_wascher_sw)
			{else}
				(L.L.cp_wischer_wascher_sw)
				{if}
					(T.L.ev_wiper_switch)
				{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_wiper_switch)
		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_defrost_drag}
	(L.S.mouse_x) -70 / (L.L.cockpit_heizregler_defrost) + 0 max 1 min (S.L.cockpit_heizregler_defrost)
{end}

{trigger:cp_heizregler_fussraum_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_fussraum) + 0 max 1 min (S.L.cockpit_heizregler_fussraum)
{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_heizregler_bug_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_bug) + 0 max 1 min (S.L.cockpit_heizregler_bug)
{end}

{trigger:cp_heizregler_umluft_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_umluft) + 0 max 1 min (S.L.cockpit_heizregler_umluft) s0

'	Stufen:
'	0: Umluftheizung
'	1: Direktbelüftung
'	2: Frischluftheizung

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

{end}

{trigger:cp_heizregler_umluft_off}
'	(L.L.cockpit_heizregler_ventilation_mode) 2 / (S.L.cockpit_heizregler_umluft)

{end}

{end}

{trigger:cp_animseat_drag}

	1 (S.L.cp_animseat_dragged)
	(L.L.cp_animseat_pos) (S.L.cp_animseat_lastpos)

	(L.S.mouse_x) -500 / (L.L.cp_animseat_pos) + (S.L.cp_animseat_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_animseat_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_animseat_pos)
	{endif}

	(L.L.cp_animseat_pos) (L.L.cp_animseat_lastpos) - (L.S.Timegap) / (S.L.cp_animseat_speed)
{end}


{trigger:cp_animseat_off}
	0 (S.L.cp_animseat_dragged)
{end}


{trigger:cp_szafka_anim}
	(L.L.cp_szafka_anim) ! (S.L.cp_szafka_anim) s1
{end}


{trigger:cp_tacho_card_toggle}
	(L.L.cp_tacho_card) ! (S.L.cp_tacho_card) s1
{end}

{trigger:cp_seatbelt_on}
	(L.L.cp_seatbelt_on) ! (S.L.cp_seatbelt_on)
	
	(L.L.cp_seatbelt_on) 1 =
	{if}
	0 (S.L.cp_seatbelt_off)
	{endif}
	(M.L.seatbeltsound)
{end}

{trigger:cp_seatbelt_off}
	(L.L.cp_seatbelt_off) ! (S.L.cp_seatbelt_off)
	
	(L.L.cp_seatbelt_off) 1 =
	{if}
	0 (S.L.cp_seatbelt_on)
	{endif}
	(M.L.seatbeltsound2)
{end}

{trigger:cp_door_lock}
	(L.L.cp_door_lock_sw) ! (S.L.cp_door_lock_sw) s1
	1 (S.L.cp_door_lock_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_door_lock_off}
	0 (S.L.cp_door_lock_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_mic_toggle}
	(L.L.cp_mic_active_sw) ! (S.L.cp_mic_active_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_driver1}
	1 (S.L.cp_driver1_sw)
	(L.L.cp_displays_antirepeat) ! (S.L.cp_displays_antirepeat) s1
	(M.L.cp_displays)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_driver1_off}
	0 (S.L.cp_driver1_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_driver2}
	(L.L.cp_driver2_sw) ! (S.L.cp_driver2_sw) s1
	1 (S.L.cp_driver2_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_driver2_off}
	0 (S.L.cp_driver2_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_lug_door1}
	(L.L.cp_lug_door1_sw) ! (S.L.cp_lug_door1_sw) s1
	1 (S.L.cp_lug_door1_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_lug_door1_off}
	0 (S.L.cp_lug_door1_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_lug_door2}
	(L.L.cp_lug_door2_sw) ! (S.L.cp_lug_door2_sw) s1
	1 (S.L.cp_lug_door2_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_lug_door2_off}
	0 (S.L.cp_lug_door2_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_wc}
	(L.L.cp_wc_sw) ! (S.L.cp_wc_sw) s1
	1 (S.L.cp_wc_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_wc_off}
	0 (S.L.cp_wc_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_wifi}
	(L.L.cp_wifi_sw) ! (S.L.cp_wifi_sw) s1
	1 (S.L.cp_wifi_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_wifi_off}
	0 (S.L.cp_wifi_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_service}
	(L.L.cp_service_sw) ! (S.L.cp_service_sw) s1
	1 (S.L.cp_service_sw_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_service_off}
	0 (S.L.cp_service_sw_2)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_klima_toggle}
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_klima_sw) ! (S.L.cp_klima_sw) s1
	{endif}
{end}

{trigger:cp_lift_up_toggle}
	(L.L.cp_lift_up_sw) ! (S.L.cp_lift_up_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_lift_down_toggle}
	(L.L.cp_lift_down_sw) ! (S.L.cp_lift_down_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_comp_toggle}
	(L.L.d_cam_visible) (L.L.d_navi_visible) || (L.L.d_radio_visible) ||
	{if}
	0 (S.L.d_cam_visible) (S.L.d_info_visible) (S.L.d_navi_visible) (S.L.d_radio_visible)
	{else}
		(L.L.d_info_visible)
		{if}
		0 (S.L.d_cam_visible) (S.L.d_info_visible) (S.L.d_navi_visible) (S.L.d_radio_visible)
		{else}
		1 (S.L.d_info_visible)
		1 (S.L.comp_lastmode)
		0 (S.L.d_cam_visible) (S.L.d_navi_visible) (S.L.d_radio_visible)
	{endif}
	
	(L.L.d_info_visible) || (L.L.d_cam_visible) || (L.L.d_navi_visible) || (L.L.d_radio_visible) || (L.L.elec_busbar_main) 1 = &&
	{if}
	1 (S.L.cp_comp_active)
	{else}
	0 (S.L.cp_comp_active)
	{endif}
{end}

{trigger:cp_comp_cam_toggle}
	(L.L.d_info_visible) (L.L.d_cam_visible) || (L.L.d_navi_visible) || (L.L.d_radio_visible) ||
	{if}
	1 (S.L.d_cam_visible)
	4 (S.L.comp_lastmode)
	0 (S.L.d_info_visible) (S.L.d_navi_visible) (S.L.d_radio_visible)
	{endif}
{end}

{trigger:cp_comp_navi_toggle}
	(L.L.d_info_visible) (L.L.d_cam_visible) || (L.L.d_navi_visible) || (L.L.d_radio_visible) ||
	{if}
	1 (S.L.d_navi_visible)
	3 (S.L.comp_lastmode)
	0 (S.L.d_cam_visible) (S.L.d_info_visible) (S.L.d_radio_visible)
	{endif}
{end}

{trigger:cp_comp_info_toggle}
	(L.L.d_info_visible) (L.L.d_cam_visible) || (L.L.d_navi_visible) || (L.L.d_radio_visible) ||
	{if}
	1 (S.L.d_info_visible)
	1 (S.L.comp_lastmode)
	0 (S.L.d_cam_visible) (S.L.d_navi_visible) (S.L.d_radio_visible)
	{endif}
{end}

{trigger:cp_comp_radio_toggle}
	(L.L.d_info_visible) (L.L.d_cam_visible) || (L.L.d_navi_visible) || (L.L.d_radio_visible) ||
	{if}
	1 (S.L.d_radio_visible)
	2 (S.L.comp_lastmode)
	0 (S.L.d_cam_visible) (S.L.d_info_visible) (S.L.d_navi_visible) 
	{endif}
{end}

{trigger:cp_wheel_adjust_lock}
	1 (S.L.cp_wheel_adjust_lock_sw)
	(M.L.cp_wheel_adjust)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_wheel_adjust_lock_off}
	0 (S.L.cp_wheel_adjust_lock_sw)
	
	(L.L.elec_busbar_main) 1 =
	(L.L.antrieb_getr_gang) 0 = &&
	(L.L.bremse_feststell) 1 = &&
	(L.L.cp_wheel_adjust_lock) 0 = &&
	{if}
	(T.L.ev_swheel_reg_off)
	{endif}
	
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_wheel_adjust_drag}
	(L.L.cp_wheel_adjust_lock)
	(L.L.antrieb_getr_gang) 0 = &&
	(L.L.bremse_feststell) 1 = &&
	{if}
		(L.S.mouse_y) abs (L.S.mouse_x) abs >=
		{if}
			(L.S.mouse_y) 500 / (L.L.cp_wheel_adjust_trans) + 0 max 0.32 min (S.L.cp_wheel_adjust_trans)
		{else}
			(L.S.mouse_x) -500 / (L.L.cp_wheel_adjust_rot) + 0 max 0.2 min (S.L.cp_wheel_adjust_rot)
		{endif}
	{endif}
{end}

{trigger:cp_wheel_adjust_reset_drag}
	1 (S.L.cp_wheel_adjust_reset_sw)
	
	(L.L.elec_busbar_main) 1 =
	(L.L.cp_wheel_adjust_reset_sw) 1 = &&
	(L.L.cp_wheel_adjust_lock) 1 = &&
	(L.L.antrieb_getr_gang) 0 = &&
	(L.L.bremse_feststell) 1 = &&
	{if}
		(L.L.cp_wheel_adjust_trans) (L.S.Timegap) 0.1 * - (S.L.cp_wheel_adjust_trans)
		0 <
		{if}
			0 (S.L.cp_wheel_adjust_trans)
			0 (S.L.cp_wheel_adjust_trans_speed)
		{else}
			1 (S.L.cp_wheel_adjust_trans_speed)
		{endif}
	{endif}
	
	(L.L.elec_busbar_main) 1 =
	(L.L.cp_wheel_adjust_reset_sw) 1 = &&
	(L.L.cp_wheel_adjust_lock) 1 = &&
	(L.L.antrieb_getr_gang) 0 = &&
	(L.L.bremse_feststell) 1 = &&
	{if}
		(L.L.cp_wheel_adjust_rot) (L.S.Timegap) 0.18 * - (S.L.cp_wheel_adjust_rot)
		0 <
		{if}
			0 (S.L.cp_wheel_adjust_rot)
			0 (S.L.cp_wheel_adjust_rot_speed)
		{else}
			1 (S.L.cp_wheel_adjust_rot_speed)
		{endif}
	{endif}
	
{end}

{trigger:cp_wheel_adjust_reset_off}
	0 (S.L.cp_wheel_adjust_reset_sw)
	0 (S.L.cp_wheel_adjust_trans_speed)
	0 (S.L.cp_wheel_adjust_rot_speed)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_retarder_toggle}
	1 (S.L.cp_retarder_sw) 
		(L.L.cp_retarder_toggle)
		(L.L.cp_retarder_lvl) 3 = ! &&
		{if}
			3 (S.L.cp_retarder_lvl)
		{else}
			1 (S.L.cp_retarder_lvl)
			(L.L.cp_retarder_toggle) ! (S.L.cp_retarder_toggle)
		{endif} 
{end}

{trigger:cp_retarder_toggle_off}
	0 (S.L.cp_retarder_sw)
{end}

{trigger:cp_retarder_lever_drag}
	(L.S.mouse_y) 10 / -1 max 1 min s1 
	0.7 >
	{if}
		1 (S.L.cp_retarder_lever)
		(L.L.cp_retarder_toggle) !
		{if}
			1 (S.L.cp_retarder_toggle) (S.L.cp_retarder_lvl) (S.L.cp_retarder_lever_antirepeat)
		{else}
			(M.L.cp_retarder_lvl)
		{endif}
	{endif}
	l1 -0.7 <
	{if}
		-1 (S.L.cp_retarder_lever)
	{endif}
	
	
	(L.L.cp_retarder_lever_timer) (L.S.Timegap) + (S.L.cp_retarder_lever_timer) 
	
	(L.L.cp_retarder_lever_timer) 0.5 >
	(L.L.cp_retarder_lever) -1 = &&
	{if}
		0 (S.L.cp_retarder_toggle)
	{endif}
{end}

{trigger:cp_retarder_lever_off}
	(L.L.cp_retarder_lever_timer) 0.5 > !
	{if}
		(M.L.cp_retarder_lvl)
	{endif}
	0 (S.L.cp_retarder_lever)
	0 (S.L.cp_retarder_lever_antirepeat) (S.L.cp_retarder_lever_timer)
{end}

{trigger:cp_retarder_plus}
	1 (S.L.cp_retarder_lever)

	(L.L.cp_retarder_toggle) !
	{if}
		1 (S.L.cp_retarder_toggle) (S.L.cp_retarder_lvl) (S.L.cp_retarder_lever_antirepeat)
	{else}
		(M.L.cp_retarder_lvl)
	{endif}
		
	(L.L.cp_retarder_lever_timer) 0.5 >
	(L.L.cp_retarder_lever) -1 = &&
	{if}
		0 (S.L.cp_retarder_toggle)
	{endif}
{end}

{trigger:cp_retarder_plus_off}
	(L.L.cp_retarder_lever_timer) 0.5 > !
	{if}
		(M.L.cp_retarder_lvl)
	{endif}
	0 (S.L.cp_retarder_lever)
	0 (S.L.cp_retarder_lever_antirepeat) (S.L.cp_retarder_lever_timer)
{end}

{trigger:cp_retarder_minus}
	-1 (S.L.cp_retarder_lever)
	
	(M.L.cp_retarder_lvl)
{end}

{trigger:cp_retarder_minus_off}
	(L.L.cp_retarder_lever_timer) 0.5 > !
	{if}
		(M.L.cp_retarder_lvl)
	{endif}
	0 (S.L.cp_retarder_lever)
	0 (S.L.cp_retarder_lever_antirepeat) (S.L.cp_retarder_lever_timer)
{end}

{trigger:blinker_warn}
		(S.L.cp_taster_warnblinker) (L.L.cp_warn_toggle)
	{if}
		(M.L.lights_startblinkgeber)
	{endif}

	1 (S.L.cp_taster_warnblinker)
	1 (S.L.lights_sw_warnblinker_2)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:blinker_warn_off}
	(L.L.lights_sw_warnblinker) 
	{if}
		0 (S.L.cp_taster_warnblinker)
	{else}
		0.6 (S.L.cp_taster_warnblinker)
	{endif}
	
	0 (S.L.lights_sw_warnblinker_2)
	(T.L.ev_kippschalter_aus)
{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.cp_taster_warnblinker) (S.L.cockpit_wischer_drehschalter_mode) 

	0.6 (S.L.cp_taster_warnblinker) (S.L.cp_taster_standheizung)

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

	0.333 (S.L.cockpit_wischer_drehschalter)
	0 (S.L.cp_seatbelt_on)
	
	0 (S.L.d_info_visible) (S.L.d_cam_visible) (S.L.d_navi_visible) (S.L.d_radio_visible)
	10 90 random + 3600 * (S.L.cp_main_display_drv_hours)
	
{end}

'----------------------
'	Frame
'----------------------
{macro:cockpit_frame}
'Ü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_rollo_pos) (F.L.cp_rollo_pos_top) (S.L.cp_rollo_pos_top)
	
	(L.L.cp_rollo_pos) 0.85 > (S.L.cp_rollo_top_visible)

	(M.L.tacho_frame)
	(M.L.tachograph_frame)
	(M.L.radio_frame)
	(M.L.uhr_frame)
	(M.L.pax_clock_frame)
	(M.L.drehzahlmesser_frame)
	(M.L.bremstank_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.klimator_frame)
	(M.L.lightsw_frame)
	(M.L.szafka_frame)
	(M.L.rollo_frame)
	(M.L.engine_thermometer_frame)
	(M.L.pressure_warning_needle_frame)
	(M.L.zentralschmierung_frame)
	(M.L.display_frame)
	(M.L.cockpit_small_display_frame)
	(M.L.swheel_reg_sound)
	(M.L.auto_reverse_cam)
	
	
	(M.L.main_display_frame)
{end}

{macro:tacho_frame}
	(L.L.Velocity) (F.L.cockpit_tacholinie) (L.L.elec_busbar_main) * (S.L.cockpit_tachowinkel)
{end}

{macro:tachograph_frame}

	(L.L.cp_system_init) 0.8 >
	{if}
		(L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh ":" $+
' 	Minute display:
		l0 l1 - 60 * trunc "02" $IntToStrEnh $+ "o  " $+ (S.$.cp_tacho_time)
	{else}
		" " (S.$.cp_tacho_time)
	{endif}

'	Digital speedometer
	(L.L.cp_system_init) 0.8 >
	{if}
		(L.L.engine_on) 1 =
		{if}
			(L.L.Velocity) s0 trunc " 3" $IntToStrEnh "km/h" $+ 
			l0 abs l0 abs trunc - 10 * trunc " 0" $IntToStrEnh $+ (S.$.cp_tacho_speed)
		{else}
			" " (S.$.cp_tacho_speed)
		{endif}
	{else}
		" " (S.$.cp_tacho_speed)
	{endif}
	

'	Digital odometer
	(L.L.cp_system_init) 0.6 >
	{if}
		(L.L.cp_tacho_card_active)
		{if}
			"+# " (L.L.kmcounter_km) s0 trunc " 7" $IntToStrEnh $+ "." $+
			l0 abs l0 abs trunc - 10 * trunc " 1" $IntToStrEnh $+ " #-" $+ (S.$.cp_tacho_odometer)
		{else}
			"card!" (S.$.cp_tacho_odometer)
		{endif}
	{else}
		" " (S.$.cp_tacho_odometer)
	{endif}
	
'	Ignition lock when the card is not inserted
	(L.L.cp_tacho_card) 1 =
	{if}
		1 (S.L.cp_tacho_card_active)
	{endif}
	(L.L.cp_tacho_card) 0 =
	{if}
		(L.L.antrieb_getr_gang) 0 = (L.L.Velocity) 1 < (L.L.Velocity) 1 > || &&
		{if}
			0 (S.L.cp_tacho_card_active)
		{else}
			(L.L.cp_tacho_card_active)
			{if}
				1 (S.L.cp_tacho_card)
			{endif}
		{endif}
	{endif}

'	Driver switch on the dashboard
	
	(L.L.cp_seatbelt_on) !
	(L.L.Velocity) 5 > &&
	(L.L.elec_busbar_main) &&
	{if}
		1
	{else}
		0
	{endif} (S.L.cp_seatbelt_warning)
	
	
{end}

{macro:radio_frame}
'	Switch that activates the radio
	(L.L.cp_radio_sw) 1 =
	{if}
	1 (S.L.cp_radio_active)
	{endif}
	(L.L.cp_radio_sw) 0 =
	{if}
	0 (S.L.cp_radio_active)
	{endif}
	
	(L.L.elec_busbar_main) 0 = 
	{if}
	0 (S.L.cp_radio_active)
	{endif}
{end}

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

{macro:pax_clock_frame}
	(L.L.cp_system_init) 3 >
	{if}
'  	"01:21"
	(L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh ":" $+
' 	Minuty:
  	l0 l1 - 60 * trunc "02" $IntToStrEnh $+ (S.$.cp_gettime)
		{else}
		" " (S.$.cp_gettime)
	{endif}
{end}

{macro:drehzahlmesser_frame}
	(L.L.engine_n) (F.L.cockpit_drehzahllinie) (L.L.elec_busbar_main) * (S.L.cockpit_drehzahlwinkel)
{end}

{macro:bremstank_frame}
	(L.L.elec_busbar_main) 0 =
	(L.L.engine_glowplug_timer) 1.5 < ||
	{if}
		0 (S.L.cockpit_tank01) (S.L.cockpit_tank02)
	{else}
	(L.L.bremse_p_Tank01) (F.L.cp_bremse_tank01) (S.L.cockpit_tank01)
	
	(L.L.bremse_p_Tank02) (F.L.cp_bremse_tank02) (S.L.cockpit_tank02)
	{endif}
{end}

{macro:hupe_frame}
	(L.L.elec_busbar_main)
	{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_lightsw_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_wiper_switch)
	{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_wiper_switch)
	{endif}
	(L.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischer_drehschalter_lastmode)
{end}



{macro:cockpitlights_frame}

'	Störungsmelder
	(L.L.engine_n) 100 <
	(L.L.bremse_p_tank01) 150000 < ||
	(L.L.bremse_p_tank02) 150000 < ||
	(L.L.bremse_p_tank03) 150000 < ||
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_masterfailure)

'	Batterie
	(L.L.elec_busbar_main) (L.L.cockpit_light_init) 1 = &&
	{if}
		1 (S.L.cockpit_light_batterie)
	{else}
		(L.L.engine_n) 400 < (L.L.elec_busbar_main) &&
		{if}
			(L.L.cockpit_light_batterie_timer) (L.S.Timegap) + 4 min (S.L.cockpit_light_batterie_timer)
			4 =
			{if}
			0 (S.L.cockpit_light_batterie_timer)
			{endif}
					
			(L.L.cockpit_light_batterie_timer) 1 <
			{if}
			1 (S.L.cockpit_light_batterie)
			{else}
			0 (S.L.cockpit_light_batterie)
			{endif}
		{else}
			0 (S.L.cockpit_light_batterie_timer)
			0 (S.L.cockpit_light_batterie)
		{endif}
	{endif}
	
	
'	Low air pressure warning
	(L.L.bremse_p_tank01) 300000 <
	(L.L.bremse_p_tank02) 300000 < || (S.L.cp_warning_minor)

'	Kontrolle Feststellbremse
	(L.L.bremse_p_Brzyl_FBA) 650000 <
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_feststellbremse)
	
'	Low fuel warning
	(L.L.engine_tank_content) 40 < (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_lowfuel)

'	Speed warning
	(L.L.Velocity) 80 > (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_speedwarning)
	
	(L.L.cp_speedwarning_played) !
	(L.L.Velocity) 80 > &&
	(L.L.elec_busbar_main) &&
	{if}
		(T.L.ev_speed_warning)
		1 (S.L.cp_speedwarning_played)
	{endif}
	
	(L.L.Velocity) 80 <
	{if}
		0 (S.L.cp_speedwarning_played)
	{endif}

'	Buttons lights and functions
	(L.L.cp_retarder_sw_direkt) (L.L.elec_busbar_main) &&
	(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_licht_pax_sw) (L.L.elec_busbar_main) &&
	(S.L.lights_pax)
	
	(L.L.cp_licht_night_sw) (L.L.elec_busbar_main) &&
	(S.L.lights_night)

	(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_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_heizluefter)
	
	(L.L.cp_spiegelheizung_sw) (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_main) &&
	(S.L.cockpit_light_ASR_off)
	
	(L.L.cp_seatbelt_on) 0 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_seatbelt)
	
	(L.L.cp_warning_oil_temp) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_oil_temp)
	
	(L.L.cp_warning_washfluid_lvl) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_washfluid_lvl)
	
	(L.L.kneel_mode) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_kneel)
	
	(L.L.antrieb_failure_general) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_grbox)
	
	(L.L.engine_failure_general) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_engine)
	
	(L.L.cp_chasis_reg) (L.L.elec_busbar_main) && (L.L.antrieb_getr_gang) 0 = && (L.L.bremse_feststell) 1 = && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_chasis_reg)
	
	(L.L.cp_chasis_reg) (L.L.elec_busbar_main) && (L.L.antrieb_getr_gang) 0 = && (L.L.bremse_feststell) 1 = && abs (S.L.cp_chasis_reg_light)
	
	(L.L.cp_warning_brakes) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_brakes)
	
	(L.L.bremse_feststell) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_stationbrake)
	
	(L.L.cp_warning_minor) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_malf_minor)
	
	(L.L.engine_glowplug) 1 = (L.L.engine_glowplug_timer) (L.L.engine_temperature) (F.L.engine_temp_glowplug) 15 min 2 max < || (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = || 
	(S.L.cockpit_light_glowplug)
	
	(L.L.bremse_ABS_eingriff) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_abs)
	
	(L.L.engine_ASR_eingriff) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_asr)
	
	(L.L.engine_oil_pressure) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_oil_pressure)
	
	(L.L.engine_failure_general) 1 = (L.L.antrieb_failure_general) 1 = && (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_malf_major)
	
	(L.L.lights_fern) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_high_beam)
	
	(L.L.lights_abbl) 1 =
	(L.L.cp_lightsw_rot) 0.8 >= && (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_low_beam)
	
	(L.L.lights_antifog) 1 =
	(L.L.lights_antifog_rear) 1 = ||
	(L.L.cp_lightsw_rot) 4.25 >= && (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_antifog)
	
	(L.L.cp_warning_filter) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_air_filter)
	
	(L.L.bremse_halte) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_bremse_halte)
	
	(L.L.cp_warning_tire_pressure) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_tire_pressure)
	
	(L.L.cp_warning_temp_low) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_temp_low)

	(L.L.lights_blinkgeber) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_blinker)
	
	(L.L.lights_blinker_r) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_blinker_r)
	
	(L.L.lights_blinker_l) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_blinker_l)
	
	(L.L.cp_sunroof) 1 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_sunroof)
	
	(L.L.cp_tacho_card_active) 0 = (L.L.elec_busbar_main) && (L.L.cockpit_light_init) 1 = ||
	(S.L.cockpit_light_tacho)
	
	(L.L.elec_busbar_main) (L.L.cockpit_light_init) 1 = &&
	(S.L.cockpit_light_dummy)

	
	
	(L.L.cp_door_lock_sw) (L.L.elec_busbar_main) && 
	(S.L.cp_door_lock)

	(L.L.cp_mic_active_sw) (L.L.elec_busbar_main) && 
	(S.L.cp_mic_active)

	(L.L.cp_driver1_sw) (L.L.elec_busbar_main) && 
	(S.L.cp_driver1)

	(L.L.cp_driver2_sw) (L.L.elec_busbar_main) &&
	(S.L.cp_driver2)

	(L.L.cp_wc_sw) (L.L.elec_busbar_main) && 
	(S.L.cp_wc)
	
	(L.L.cp_wifi_sw) (L.L.elec_busbar_main) && 
	(S.L.cp_wifi)
	
	(L.L.cp_engine_start_sw) (L.L.elec_busbar_main) && 
	(S.L.cp_engine_start)	

	(L.L.cp_service_sw) (L.L.elec_busbar_main) &&
	(S.L.cp_service)

	(L.L.cp_klima_sw) (L.L.elec_busbar_main) &&
	(S.L.cp_klima_on)

	(L.L.cp_lug_door1_sw) (L.L.elec_busbar_main) &&
	(S.L.cp_lug_door1)

	(L.L.cp_lug_door2_sw) (L.L.elec_busbar_main) &&
	(S.L.cp_lug_door2)
	
	(L.L.cp_windshield_heat_sw) (L.L.elec_busbar_main) &&
	(S.L.cp_windshield_heat)
	
	(L.L.cp_mirror_heat_sw) (L.L.elec_busbar_main) &&
	(S.L.cp_mirror_heat)

'	Steering wheel regulation checklight
	
	(L.L.elec_busbar_main) 0 =
	(L.L.antrieb_getr_gang) 0 > ||
	(L.L.bremse_feststell) 0 = ||
	{if}
		0 (S.L.cp_wheel_adjust_lock)
	{endif}
	
'	Interior displays reset when elec = 0
	
	(L.L.elec_busbar_main) 0 =
	{if}
		0 (S.L.cp_displays)
		0 (S.L.cp_displays_antirepeat)
	{endif}
	
'	Open door beep when driving

	(L.L.door_0) 0 > 
	(L.L.door_1) 0 > ||
	{if}
	1 (S.L.cp_door_open)
	{else}
	0 (S.L.cp_door_open)
	{endif}

	(L.L.elec_busbar_main) 1 =
	(L.L.Velocity) 5 > &&
	(L.L.cp_door_open) 1 = &&
	{if}
	1 (S.L.cp_door_warning)
	{else}
	0 (S.L.cp_door_warning)
	{endif}
{end}

'	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)



{end}

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

	(L.L.elec_busbar_main) !
	{if}
		0 s0
	{endif}

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

{macro:tankuhr_frame}
	(L.L.engine_tank_content) s0

	(L.L.elec_busbar_main) !
	(L.L.engine_glowplug_timer) 1.5 < ||
	{if}
		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.elec_busbar_main) !
	(L.L.engine_glowplug_timer) 1.5 < ||
	{if}
		0 s0
	{else}
		(L.L.engine_temperature) (F.L.cockpit_engine_temperature) s0
	{endif}

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

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

{macro:seatbeltsound}
	l1
	{if}
		(T.L.ev_seatbelt_on)
	{else}
		(T.L.ev_seatbelt_off)
	{endif}	
{end}

{macro:seatbeltsound2}
	l1
	{if}
		(T.L.ev_seatbelt_off)
	{else}
		(T.L.ev_seatbelt_on)
	{endif}	
{end}

{macro:klimator_frame}

'Frontheizgerät:
	(L.L.elec_busbar_main)
	(L.L.cp_klima_on) 1 = &&
	{if}
		(L.L.cp_klimator_sw) s1
	{else}
		0 s1
	{endif}

'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)


'Raumheizgeräte:
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_heizluefter_sw) 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)

'Clock display:	
	(L.L.cp_klima_on) 1 =
	{if}
'  	"01:21"
	(L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh ":" $+
' 	Minuty:
  	l0 l1 - 60 * trunc "02" $IntToStrEnh $+ (S.$.cp_klima_time)
		{else}
		" " (S.$.cp_klima_time)
	{endif}
{end}

{macro:lightsw_frame}
	(L.L.cp_lightsw_rot_lastmode) (L.L.cp_lightsw_rot_mode) = !
	{if}
		(T.L.ev_rotary_sw)
	{endif}
	(L.L.cp_lightsw_rot_mode) (S.L.cp_lightsw_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) * 1 min -1 max s4
	{else}
		l3 (L.S.Timegap) * 1 min -1 max s4
	{endif}


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

{macro:szafka_frame}

	(L.L.cp_szafka_dragged) !
	{if}
		(L.L.cp_szafka_pos) (L.S.Timegap) (L.L.cp_szafka_speed) * + (S.L.cp_szafka_pos)

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

		(L.L.cp_szafka_pos) 0 >
		{if}
			(L.L.cp_szafka_speed) (L.S.Timegap) (L.L.A_Trans_Y) * (L.L.A_Trans_X) /-/ + 0.3 * (L.L.cp_szafka_globalangle) * * + (S.L.cp_szafka_speed) 
		{endif}
	
		(L.L.cp_szafka_speed) s0 (S.L.cp_szafka_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.cp_szafka_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.cp_szafka_speed)
		{endif}

		(L.L.cp_szafka_speed) 0 > (L.L.cp_szafka_lastspeed) 0 < &&
		(L.L.cp_szafka_speed) 0 < (L.L.cp_szafka_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_szafka_speed)
		{endif}	 
	
	{endif}

	(L.L.cp_szafka_pos) 0 > (L.L.cp_szafka_open) ! &&
	{if}
		(T.L.ev_szafka_auf)
		1 (S.L.cp_szafka_open)
	{endif}

	(L.L.cp_szafka_pos) 0 = (L.L.cp_szafka_open) &&
	{if}
		(T.L.ev_szafka_zu)
		0 (S.L.cp_szafka_open)
	{endif}

	(L.L.cp_szafka_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_szafka_globalangle) 
	{endif}
	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)

	

{end}

{macro:rollo_frame}
	(L.L.cp_rollo_pos) 0.914 >
	{if}
	1 (S.L.cp_rollo_1_visible) (S.L.cp_rollo_2_visible) (S.L.cp_rollo_3_visible) (S.L.cp_rollo_4_visible) (S.L.cp_rollo_5_visible) (S.L.cp_rollo_6_visible) (S.L.cp_rollo_7_visible) (S.L.cp_rollo_8_visible) (S.L.cp_rollo_9_visible) (S.L.cp_rollo_10_visible)
	{else}
		(L.L.cp_rollo_pos) 0.812 >
		{if}
		1 (S.L.cp_rollo_1_visible) (S.L.cp_rollo_2_visible) (S.L.cp_rollo_3_visible) (S.L.cp_rollo_4_visible) (S.L.cp_rollo_5_visible) (S.L.cp_rollo_6_visible) (S.L.cp_rollo_7_visible) (S.L.cp_rollo_8_visible) (S.L.cp_rollo_9_visible) 
		0 (S.L.cp_rollo_10_visible)
		{else}
			(L.L.cp_rollo_pos) 0.714 >
			{if}
			1 (S.L.cp_rollo_1_visible) (S.L.cp_rollo_2_visible) (S.L.cp_rollo_3_visible) (S.L.cp_rollo_4_visible) (S.L.cp_rollo_5_visible) (S.L.cp_rollo_6_visible) (S.L.cp_rollo_7_visible) (S.L.cp_rollo_8_visible) 
			0 (S.L.cp_rollo_9_visible) (S.L.cp_rollo_10_visible)
			{else}
				(L.L.cp_rollo_pos) 0.613 >
				{if}
				1 (S.L.cp_rollo_1_visible) (S.L.cp_rollo_2_visible) (S.L.cp_rollo_3_visible) (S.L.cp_rollo_4_visible) (S.L.cp_rollo_5_visible) (S.L.cp_rollo_6_visible) (S.L.cp_rollo_7_visible)
				0 (S.L.cp_rollo_8_visible) (S.L.cp_rollo_9_visible) (S.L.cp_rollo_10_visible)
				{else}
					(L.L.cp_rollo_pos) 0.514 >
					{if}
					1 (S.L.cp_rollo_1_visible) (S.L.cp_rollo_2_visible) (S.L.cp_rollo_3_visible) (S.L.cp_rollo_4_visible) (S.L.cp_rollo_5_visible) (S.L.cp_rollo_6_visible)
					0 (S.L.cp_rollo_7_visible) (S.L.cp_rollo_8_visible) (S.L.cp_rollo_9_visible) (S.L.cp_rollo_10_visible)
					{else}
						(L.L.cp_rollo_pos) 0.413 >
						{if}
						1 (S.L.cp_rollo_1_visible) (S.L.cp_rollo_2_visible) (S.L.cp_rollo_3_visible) (S.L.cp_rollo_4_visible) (S.L.cp_rollo_5_visible)
						0 (S.L.cp_rollo_6_visible) (S.L.cp_rollo_7_visible) (S.L.cp_rollo_8_visible) (S.L.cp_rollo_9_visible) (S.L.cp_rollo_10_visible)
						{else}
							(L.L.cp_rollo_pos) 0.312 >
							{if}
							1 (S.L.cp_rollo_1_visible) (S.L.cp_rollo_2_visible) (S.L.cp_rollo_3_visible) (S.L.cp_rollo_4_visible)
							0 (S.L.cp_rollo_5_visible) (S.L.cp_rollo_6_visible) (S.L.cp_rollo_7_visible) (S.L.cp_rollo_8_visible) (S.L.cp_rollo_9_visible) (S.L.cp_rollo_10_visible)
							{else}
								(L.L.cp_rollo_pos) 0.211 >
								{if}
								1 (S.L.cp_rollo_1_visible) (S.L.cp_rollo_2_visible) (S.L.cp_rollo_3_visible) 
								0 (S.L.cp_rollo_4_visible) (S.L.cp_rollo_5_visible) (S.L.cp_rollo_6_visible) (S.L.cp_rollo_7_visible) (S.L.cp_rollo_8_visible) (S.L.cp_rollo_9_visible) (S.L.cp_rollo_10_visible)
								{else}
									(L.L.cp_rollo_pos) 0.112 >
									{if}
									1 (S.L.cp_rollo_1_visible) (S.L.cp_rollo_2_visible)
									0 (S.L.cp_rollo_3_visible) (S.L.cp_rollo_4_visible) (S.L.cp_rollo_5_visible) (S.L.cp_rollo_6_visible) (S.L.cp_rollo_7_visible) (S.L.cp_rollo_8_visible) (S.L.cp_rollo_9_visible) (S.L.cp_rollo_10_visible)
									{else}
										(L.L.cp_rollo_pos) 0.014 >
										{if}
										1 (S.L.cp_rollo_1_visible)
										0 (S.L.cp_rollo_2_visible) (S.L.cp_rollo_3_visible) (S.L.cp_rollo_4_visible) (S.L.cp_rollo_5_visible) (S.L.cp_rollo_6_visible) (S.L.cp_rollo_7_visible) (S.L.cp_rollo_8_visible) (S.L.cp_rollo_9_visible) (S.L.cp_rollo_10_visible)
										{else}
											0 (S.L.cp_rollo_1_visible) (S.L.cp_rollo_2_visible) (S.L.cp_rollo_3_visible) (S.L.cp_rollo_4_visible) (S.L.cp_rollo_5_visible) (S.L.cp_rollo_6_visible) (S.L.cp_rollo_7_visible) (S.L.cp_rollo_8_visible) (S.L.cp_rollo_9_visible) (S.L.cp_rollo_10_visible)
										{endif}
									{endif}
								{endif}
							{endif}
						{endif}
					{endif}
				{endif}
			{endif}
		{endif}
	{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:display_frame}
	(L.L.elec_busbar_main) !
	{if}
	0 (S.L.d_cam_visible) (S.L.d_info_visible) (S.L.d_navi_visible) (S.L.d_radio_visible)
	{endif}

'	display init delay

	(L.L.elec_busbar_main) 1 =
	{if}
	(L.L.cp_system_init) (L.S.Timegap) + (S.L.cp_system_init)
	{else}
	0 (S.L.cp_system_init)
	{endif}
	
' 	cockpit startup procedure

' 	lights

	(L.L.cp_system_init) 3 < (L.L.elec_busbar_main) 1 = &&
	{if}
	1 (S.L.cockpit_light_init)
	{else}
	0 (S.L.cockpit_light_init)
	{endif}
	
' 	display	init

	(L.L.cp_system_init) 1 > (L.L.cp_system_init) 2 <= (L.L.elec_busbar_main) 1 = && &&
	{if}
	1 (S.L.display_init_ok)
	{else}
	0 (S.L.display_init_ok)
	{endif}
	
' 	display	main

	(L.L.cp_system_init) 2 > (L.L.elec_busbar_main) 1 = &&
	{if}
	1 (S.L.display_main_ok)
	{else}
	0 (S.L.display_main_ok)
	{endif}
	
'	secondary devices init

		(L.L.cp_system_init) 0.4 > (L.L.elec_busbar_main) 1 = &&
		{if}
		1 (S.L.instr_init_1)
		{else}
		0 (S.L.instr_init_1)
		{endif}
		
		(L.L.cp_system_init) 0.6 > (L.L.elec_busbar_main) 1 = &&
		{if}
			1 (S.L.instr_init_2)
		{else}
			0 (S.L.instr_init_2)
		{endif}
			
		(L.L.cp_system_init) 0.8 > (L.L.elec_busbar_main) 1 = &&
		{if}
			1 (S.L.instr_init_3)
		{else}
			0 (S.L.instr_init_3)
		{endif}	

{end}

{macro:cockpit_small_display_frame}
'	Digital thermometer (cabin)
	(L.L.cp_system_init) 1.6 >
		{if}
		(L.L.Cabinair_Temp) s0 trunc " 3" $IntToStrEnh "*C" $+
		(S.$.cockpit_temperatur)
		{else}
		" " (S.$.cockpit_temperatur)
		{endif}
		
'	Digital thermometer (exterior)
	(L.L.cp_system_init) 1.3 >
		{if}
		(L.S.Weather_Temperature) s0 trunc " 3" $IntToStrEnh "*C" $+ 
		(S.$.cockpit_temperatur_ext)
		{else}
		" " (S.$.cockpit_temperatur_ext)
		{endif}
		
'	Digital odometer
	(L.L.elec_busbar_main) 1 =
		{if}
		"" (L.L.kmcounter_km) s0 trunc " 7" $IntToStrEnh $+ "." $+
		l0 abs l0 abs trunc - 10 * trunc " 1" $IntToStrEnh $+ " #-" $+ (S.$.cockpit_odometer)
		{else}
		" " (S.$.cockpit_odometer)
		{endif}
		
'	XX Digital clock
	(L.L.elec_busbar_main) 1 =
	{if}
'  	"01:21"
  	"" (L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh $+ ":" $+
' 	Minuty:
  	l0 l1 - 60 * trunc "02" $IntToStrEnh $+ (S.$.cockpit_clock)
		{else}
		" " (S.$.cockpit_clock)
	{endif}

{end}

{macro:main_display_frame}
	(L.L.engine_on) 
	{if}
		(L.L.cp_main_display_drv_hours) (L.S.Timegap) + (S.L.cp_main_display_drv_hours)
	{endif}

	"#|" (L.L.antrieb_getr_aktugang) 0 =
	{if}
		"N"
	{else}
		(L.L.antrieb_getr_aktugang) -1 =
		{if}
			"R"
		{else}
			(L.L.antrieb_getr_aktugang) $IntToStr
		{endif}
	{endif}
	$+ (S.$.cp_main_display_gear)
	
	(L.L.cp_retarder_toggle) 0 =
	{if}
		0.2138671875 (S.L.display_retarder_textcoordY)
	{else}
		(L.L.cp_retarder_lvl) 1 =
		{if}
			0 (S.L.display_retarder_textcoordY)
		{else}
			(L.L.cp_retarder_lvl) 2 =
			{if}
				0.0712890625 (S.L.display_retarder_textcoordY)
			{else}
				(L.L.cp_retarder_lvl) 3 =
				{if}
					0.142578125 (S.L.display_retarder_textcoordY)
				{endif}
			{endif}
		{endif}
	{endif}
	
	
	
	
	(L.L.engine_cruise_on)
	{if}
		(L.L.engine_cruise_speed) $IntToStr
	{else}
		"-"
	{endif} (S.$.cp_main_display_cruise) 
	
	"Total@" (S.$.cp_main_display_left)
	(L.L.cp_main_display_drv_hours) 3600 / trunc $IntToStr "|h@" $+ (L.L.engine_tank_content) $IntToStr $+ "|l|" $+ (S.$.cp_main_display_right)
		
{end}

{macro:cp_retarder_lvl}
	(L.L.cp_retarder_lever_antirepeat) !
	{if}
		(L.L.cp_retarder_lvl) 3 <
		(L.L.cp_retarder_lever) 1 = &&
		{if}
		(L.L.cp_retarder_lvl) 1 + (S.L.cp_retarder_lvl)
		{endif}
		
		(L.L.cp_retarder_lvl) 1 >
		(L.L.cp_retarder_lever) -1 = &&
		{if}
		(L.L.cp_retarder_lvl) 1 - (S.L.cp_retarder_lvl)
		{endif}
		
		1 (S.L.cp_retarder_lever_antirepeat)
	{endif}
{end}

{macro:cp_wheel_adjust}
	(L.L.elec_busbar_main) 1 =
	(L.L.antrieb_getr_gang) 0 = &&
	(L.L.bremse_feststell) 1 = &&
	(L.L.cp_wheel_adjust_lock) 0 = &&
	{if}
		1 (S.L.cp_wheel_adjust_lock)
		(T.L.ev_swheel_reg_on)
	{else}
		0 (S.L.cp_wheel_adjust_lock)
	{endif}
{end}

{macro:cp_displays}
	(L.L.elec_busbar_main)
	{if}	
		(L.L.cp_displays_antirepeat) 1 = &&
		{if}
			1 (S.L.cp_displays)
		{else}
			0 (S.L.cp_displays)
		{endif}
	{endif}
{end}

{macro:swheel_reg_sound}
	(L.L.cp_wheel_adjust_trans_speed) 1 = 
	(L.L.cp_wheel_adjust_rot_speed) 1 = ||
	{if}
		1 (S.L.swheel_reg_sound)
	{else}
		0 (S.L.swheel_reg_sound)
	{endif}
{end}

{macro:auto_reverse_cam}
	(L.L.cp_comp_active) 1 =
	(L.L.antrieb_getr_gang) -1 = &&
	{if}
			(L.L.d_info_visible) (L.L.d_cam_visible) || (L.L.d_navi_visible) || (L.L.d_radio_visible) ||
			{if}
			1 (S.L.d_cam_visible)
			0 (S.L.d_info_visible) (S.L.d_navi_visible) (S.L.d_radio_visible)
			{endif}
	{endif}
	
	(L.L.cp_comp_active) 1 =
	(L.L.comp_lastmode) 1 = &&
	(L.L.antrieb_getr_gang) -1 > &&
	{if}
		(L.L.d_info_visible) (L.L.d_cam_visible) || (L.L.d_navi_visible) || (L.L.d_radio_visible) ||
		{if}
		1 (S.L.d_info_visible)
		1 (S.L.comp_lastmode)
		0 (S.L.d_cam_visible) (S.L.d_navi_visible) (S.L.d_radio_visible)
		{endif}
	{endif}
	
	(L.L.cp_comp_active) 1 =
	(L.L.comp_lastmode) 2 = &&
	(L.L.antrieb_getr_gang) -1 > &&
	{if}
		(L.L.d_info_visible) (L.L.d_cam_visible) || (L.L.d_navi_visible) || (L.L.d_radio_visible) ||
		{if}
		1 (S.L.d_radio_visible)
		2 (S.L.comp_lastmode)
		0 (S.L.d_cam_visible) (S.L.d_info_visible) (S.L.d_navi_visible) 
		{endif}
	{endif}
	
	(L.L.cp_comp_active) 1 =
	(L.L.comp_lastmode) 3 = &&
	(L.L.antrieb_getr_gang) -1 > &&
	{if}
		(L.L.d_info_visible) (L.L.d_cam_visible) || (L.L.d_navi_visible) || (L.L.d_radio_visible) ||
		{if}
		1 (S.L.d_navi_visible)
		3 (S.L.comp_lastmode)
		0 (S.L.d_cam_visible) (S.L.d_info_visible) (S.L.d_radio_visible)
		{endif}
	{endif}
	
	(L.L.cp_comp_active) 1 =
	(L.L.comp_lastmode) 4 = &&
	(L.L.antrieb_getr_gang) -1 > &&
	{if}
		(L.L.d_info_visible) (L.L.d_cam_visible) || (L.L.d_navi_visible) || (L.L.d_radio_visible) ||
		{if}
		1 (S.L.d_cam_visible)
		4 (S.L.comp_lastmode)
		0 (S.L.d_info_visible) (S.L.d_navi_visible) (S.L.d_radio_visible)
		{endif}
	{endif}
	
{end}