'##############
'Door Script
'##############

'Controls Doors

'(c) 2007-2009 Rüdiger Hülsmann
'(c) 2007-2012 Marcel Kuhnt
'(c) 2011 Markus Rabe
'(c) 2020 fOcUs04 

{trigger:bus_doorfront0}
	1 (S.L.cockpit_tuertaster1)
	(T.L.ev_tuertaster_ein)

	(L.L.elec_busbar_avail) (C.L.elec_busbar_minV) >
	(L.L.bremse_p_tank04) 300000 > &&
	{if}
		1 (S.L.cockpit_tuertaster1_frame)
	{else}
		(T.L.ev_IBIS_piep)
	{endif}
{end}

{trigger:bus_doorfront0_off}
	0 (S.L.cockpit_tuertaster1)
	(T.L.ev_tuertaster_aus)
{end}

{trigger:bus_doorfront1_lock}
'Doorfront1-Verriegelung: Funktioniert nur, wenn der Türflügel auch zu ist:
	(L.L.door_1) 0.05 <
	{if}
		(L.L.door_1_locked) ! (S.L.door_1_locked)
		{if}
			(T.L.ev_doorlock1_on)
		{else}
			(T.L.ev_doorlock1_off)
		{endif}
	{endif}
{end}



'### focus04 Edit



{trigger:bus_doorfront1}

'### Tuer 23 Taster

1 (S.L.cockpit_tuertaster2)
(T.L.ev_tuertaster_ein)

'Tuer kann nur noch geoeffnet/geschlossen werden, wenn:

(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
(L.L.bremse_p_tank04) 550000 > &&
(L.L.cockpit_tuertaster2) &&
(L.L.Velocity) 0.5 < &&
{if}
	(L.L.cockpit_tuertaster2_frame)
	(L.L.haltewunsch_23) 0 = &&
	(L.L.door_2) 0.1 > &&
	{if}
		0 (S.L.cockpit_tuertaster2_frame)			
	{endif}

	(L.L.cockpit_tuertaster2_frame) !
	(L.L.door_2) 0.1 < &&
	{if}
		1 (S.L.bremse_halte)
		1 (S.L.cockpit_tuertaster2_frame)
		0 (S.L.doorMidLastOpen)
		(M.L.trg_bus_dooraft23)
	{endif}
{endif}
{end}

{trigger:bus_doorfront1_off}
	0 (S.L.cockpit_tuertaster2)
	(T.L.ev_tuertaster_aus)
{end}




{trigger:bus_doorfront2}

'### Tuer 45 Taster

(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
(L.L.bremse_p_tank04) 550000 > &&
1 (S.L.cockpit_tuertaster3) &&
(T.L.ev_tuertaster_ein)

'Tuer kann nur noch geoeffnet/geschlossen werden, wenn:

(L.L.cockpit_tuertaster3)
(L.L.Velocity) 0.5 < &&
{if}

	(L.L.cockpit_tuertaster3_frame)
	(L.L.haltewunsch_45) 0 = &&
	(L.L.door_4) 0.1 > &&
	{if}
		0 (S.L.cockpit_tuertaster3_frame)			
	{endif}

	(L.L.cockpit_tuertaster3_frame) !
	(L.L.door_4) 0.1 < &&
	{if}
		1 (S.L.bremse_halte)
		1 (S.L.cockpit_tuertaster3_frame)
		0 (S.L.doorAftLastOpen)
		(M.L.trg_bus_dooraft45)
	{endif}
{endif}
{end}

{trigger:bus_doorfront2_off}
	0 (S.L.cockpit_tuertaster3)
	(T.L.ev_tuertaster_aus)
{end}




'### Zentrales oeffnen und schliessen

{trigger:Door_Central_open}

	1 (S.L.Door_Central_open_anim)
	(T.L.ev_VDV_toggle_on)

(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
(L.L.bremse_p_tank04) 550000 > &&
(L.L.Velocity) 1 < &&
{if}
	1 (S.L.bremse_halte)
	
(L.L.Door_Central_open_anim) 1 =
{if}

	(L.L.doortarget_0) !
	(L.L.doortarget_1) ! || &&
	{if}

		(L.L.tuersperre) 1 =
		(L.L.tuersperre) 0 = ||
		{if}
			(M.L.trg_bus_doorfront0)
		{endif}

		(L.L.tuersperre) -1 =
		(L.L.tuersperre) 0 = ||
		{if}
			(M.L.trg_bus_doorfront1)
		{endif}

	{endif}

		(L.L.cockpit_tuertaster2_frame) !
		(L.L.door_2) 0.1 < &&
		{if}
			1 (S.L.cockpit_tuertaster2_frame)
			0 (S.L.doorMidLastOpen)
			(M.L.trg_bus_dooraft23)
		{endif}

		(L.L.cockpit_tuertaster3_frame) !
		(L.L.door_4) 0.1 < &&
		{if}
			1 (S.L.cockpit_tuertaster3_frame)
			0 (S.L.doorAftLastOpen)
			(M.L.trg_bus_dooraft45)
		{endif}
	{endif}
{endif}

{end}

{trigger:Door_Central_open_off}
	0 (S.L.Door_Central_open_anim)
	(T.L.ev_VDV_toggle_off)
{end}



{trigger:Door_Central_close}

	-1 (S.L.Door_Central_open_anim)
	(T.L.ev_VDV_toggle_on)

'### Central Door opening works only with more then 7.5 bar pressure

(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
(L.L.bremse_p_tank04) 550000 > &&
(L.L.Velocity) 1 < &&
{if}

	(L.L.doortarget_0)
	(L.L.doortarget_1) || &&
	{if}
		(L.L.tuersperre) 1 =
		(L.L.tuersperre) 0 = ||
		{if}
			(M.L.trg_bus_doorfront0)
		{endif}

		(L.L.tuersperre) -1 =
		(L.L.tuersperre) 0 = ||
		{if}
			(M.L.trg_bus_doorfront1)
		{endif}

		0 (S.L.cockpit_tuertaster1_frame)
	{endif}

		(L.L.cockpit_tuertaster2_frame)
		(L.L.haltewunsch_23) 0 = &&
		(L.L.door_2) 0.1 > &&
		{if}
			0 (S.L.cockpit_tuertaster2_frame)			
		{endif}

		(L.L.cockpit_tuertaster3_frame)
		(L.L.haltewunsch_45) 0 = &&
		(L.L.door_4) 0.1 > &&
		{if}
			0 (S.L.cockpit_tuertaster3_frame)			
		{endif}
{endif}
{end}


{trigger:Door_Central_close_off}
	0 (S.L.Door_Central_open_anim)
	(T.L.ev_VDV_toggle_off)
{end}



'### focus04 Edit Ende



{trigger:bus_20h-switch}

	(L.L.20h_switch_pressed) ! (S.L.20h_switch_pressed)

	(L.L.20h_switch_pressed)
	{if}
		(T.L.ev_VDV_on)
		1 (S.L.20h_switch_anim)
	{else}
		(T.L.ev_VDV_off)
		0 (S.L.20h_switch_anim)
	{endif}

{end}

{trigger:bus_20h-switch_off}
'	(T.L.ev_VDV_off)
'	0 (S.L.20h_switch_anim)
'	0 (S.L.20h_switch_pressed)
{end}

{trigger:door_haltewunsch}
	1 (S.L.haltewunsch_23) (S.L.door_haltewunsch_knopfdruck)
{endif}

{end}

{trigger:door_haltewunsch_off}
	0 (S.L.door_haltewunsch_knopfdruck)
{end}

{trigger:door_haltewunsch_2}
	1 (S.L.haltewunsch_45) (S.L.door_haltewunsch_knopfdruck_2)
{end}

{trigger:door_haltewunsch_2_off}
	0 (S.L.door_haltewunsch_knopfdruck_2)
{end}

{trigger:door_kinderwagenwunsch}
	(L.L.door_freigabe) (L.L.door_handsteuerung) ! &&
	{if}
		1 (S.L.door_kinderwagenwunsch)
	{endif}
{end}

{trigger:door0_drag}
	(L.S.mouse_y) (L.S.mouse_x) + 20 / (S.L.doorDragAcc_0)
{end}
{trigger:door1_drag}
	(L.S.mouse_y) (L.S.mouse_x) - 20 / (S.L.doorDragAcc_1)
{end}

{trigger:door2_drag}
	(L.S.mouse_y) (L.S.mouse_x) + 20 / (S.L.doorDragAcc_2)
{end}

{trigger:door3_drag}
	(L.S.mouse_y) (L.S.mouse_x) - 20 / (S.L.doorDragAcc_3)
{end}

{trigger:door4_drag}
	(L.S.mouse_y) (L.S.mouse_x) + 20 / (S.L.doorDragAcc_4)
{end}

{trigger:door5_drag}
	(L.S.mouse_y) (L.S.mouse_x) - 20 / (S.L.doorDragAcc_5)
{end}

{trigger:cp_doorEntriegelung_01}
	(L.L.doorEntriegelung_01) ! (S.L.doorEntriegelung_01)
	{if}
		(T.L.ev_doorEntriegelung_01_on)
	{else}
		(T.L.ev_doorEntriegelung_01_off)
		(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
	{endif}	
{end}

{trigger:cp_doorEntriegelung_23}
	(L.L.doorEntriegelung_23) ! (S.L.doorEntriegelung_23)
	{if}
		(T.L.ev_doorEntriegelung_23_on)
	{else}
		(T.L.ev_doorEntriegelung_23_off)
		(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
	{endif}	
{end}

{trigger:cp_doorEntriegelung_45}
	(L.L.doorEntriegelung_45) ! (S.L.doorEntriegelung_45)
	{if}
		(T.L.ev_doorEntriegelung_45_on)
	{else}
		(T.L.ev_doorEntriegelung_45_off)
		(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
	{endif}	
{end}

{macro:Door_Init}
	(L.L.vis_doortype_v_int) 2 =
	{if}
		0.5 (C.L.door_acc_var) * (C.L.fdoor_acc_schwenk) + (S.L.doorAcc_0)
		0.5 (C.L.door_acc_var) * (C.L.fdoor_acc_schwenk) + (S.L.doorAcc_1)
		0.5 (C.L.door_maxspeed_var) * (C.L.fdoor_maxspeed_schwenk) + (S.L.doorMaxSpeed_0_norm)
		0.5 (C.L.door_maxspeed_var) * (C.L.fdoor_maxspeed_schwenk) + (S.L.doorMaxSpeed_1_norm)
		0.5 (C.L.door0_damper_schwenk) * (S.L.doorDamper_0_kennwert)
		0.5 (C.L.door1_damper_schwenk) * (S.L.doorDamper_1_kennwert)
	{else}
		301 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_acc_var) * (C.L.fdoor_acc) + (S.L.doorAcc_0)
		302 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_acc_var) * (C.L.fdoor_acc) + (S.L.doorAcc_1)
		307 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.fdoor_maxspeed) + (S.L.doorMaxSpeed_0_norm)
		308 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.fdoor_maxspeed) + (S.L.doorMaxSpeed_1_norm)
		313 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door0_damper) * (S.L.doorDamper_0_kennwert)
		314 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door1_damper) * (S.L.doorDamper_1_kennwert)
	{endif}
	(L.L.vis_doortype_m_int) 2 =
	{if}
		0.5 (C.L.door_acc_var) * (C.L.mdoor_acc_schwenk) + (S.L.doorAcc_2)
		0.5 (C.L.door_acc_var) * (C.L.mdoor_acc_schwenk) + (S.L.doorAcc_3)
		0.5 (C.L.door_maxspeed_var) * (C.L.mdoor_maxspeed_schwenk) + (S.L.doorMaxSpeed_2_norm)
		0.5 (C.L.door_maxspeed_var) * (C.L.mdoor_maxspeed_schwenk) + (S.L.doorMaxSpeed_3_norm)
		0.5 (C.L.door2_damper_schwenk) * (S.L.doorDamper_2_kennwert)
		0.5 (C.L.door3_damper_schwenk) * (S.L.doorDamper_3_kennwert)
	{else}
		303 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_acc_var) * (C.L.mdoor_acc) + (S.L.doorAcc_2)
		304 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_acc_var) * (C.L.mdoor_acc) + (S.L.doorAcc_3)
		309 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.mdoor_maxspeed) + (S.L.doorMaxSpeed_2_norm)
		310 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.mdoor_maxspeed) + (S.L.doorMaxSpeed_3_norm)
		315 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door2_damper) * (S.L.doorDamper_2_kennwert)
		316 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door3_damper) * (S.L.doorDamper_3_kennwert)
	{endif}
	(L.L.vis_doortype_h_int) 2 =
	{if}
		0.5 (C.L.door_acc_var) * (C.L.bdoor_acc_schwenk) + (S.L.doorAcc_4)
		0.5 (C.L.door_acc_var) * (C.L.bdoor_acc_schwenk) + (S.L.doorAcc_5)
		0.5 (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed_schwenk) + (S.L.doorMaxSpeed_4_norm)
		0.5 (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed_schwenk) + (S.L.doorMaxSpeed_5_norm)
		0.5 (C.L.door4_damper_schwenk) * (S.L.doorDamper_4_kennwert)
		0.5 (C.L.door5_damper_schwenk) * (S.L.doorDamper_5_kennwert)
	{else}
		305 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_4)
		306 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_5)
		311 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_4_norm)
		312 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_5_norm)
		317 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door4_damper) * (S.L.doorDamper_4_kennwert)
		318 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door5_damper) * (S.L.doorDamper_5_kennwert)
	{endif}
	
	(L.L.vis_doortype_v_int) 2 =
	{if}
		(C.L.door_refl_schwenk) (S.L.doorRefl_0)
		(C.L.door_refl_schwenk) (S.L.doorRefl_1)
	{else}
		(C.L.door_refl) (S.L.doorRefl_0)
		(C.L.door_refl) (S.L.doorRefl_1)
	{endif}
	(L.L.vis_doortype_m_int) 2 =
	{if}
		(C.L.door_refl_schwenk) (S.L.doorRefl_2)
		(C.L.door_refl_schwenk) (S.L.doorRefl_3)
	{else}
		(C.L.door_refl) (S.L.doorRefl_2)
		(C.L.door_refl) (S.L.doorRefl_3)
	{endif}
	(L.L.vis_doortype_h_int) 2 =
	{if}
		(C.L.door_refl_schwenk) (S.L.doorRefl_4)
		(C.L.door_refl_schwenk) (S.L.doorRefl_5)
	{else}
		(C.L.door_refl) (S.L.doorRefl_4)
		(C.L.door_refl) (S.L.doorRefl_5)
	{endif}

	0 (S.L.door0_warten)
	0 (S.L.door0_umkehr)	

	0 (S.L.door0_physblock)
	1 (S.L.door1_physblock)

	0
	(S.L.door_pressure_open_0)
	(S.L.door_pressure_close_0)
	(S.L.door_pressure_open_1)
	(S.L.door_pressure_close_1)
	(S.L.door_pressure_open_2)
	(S.L.door_pressure_close_2)
	(S.L.door_pressure_open_3)
	(S.L.door_pressure_close_3)
	(S.L.door_pressure_open_4)
	(S.L.door_pressure_close_4)
	(S.L.door_pressure_open_5)
	(S.L.door_pressure_close_5)

	(S.L.doorDamper_0) (S.L.doorDamper_1) (S.L.doorDamper_2) (S.L.doorDamper_3) (S.L.doorDamper_4) (S.L.doorDamper_5)

	1 (S.L.doorEntriegelung_doorActive_01)
	1 (S.L.doorEntriegelung_doorActive_23)
	1 (S.L.doorEntriegelung_doorActive_45)
	0 (S.L.cockpit_tuertaster1_frame)
{end}

{macro:Door_Frame}

(L.L.Velocity) 0.1 <
{if}

	(L.L.notheben_armed)
	(L.L.kneel_allowed) &&
	{if}
		(L.L.door_0) 0.95 >
		{if}
			(M.L.trg_bus_doorfront0)
		{endif}
		(L.L.door_1) 0.95 >
		{if}		
			(M.L.trg_bus_doorfront1)
		{endif}
		(L.L.door_2) 0.95 >
		(L.L.door_3) 0.95 > &&
		{if}		
			(M.L.trg_bus_dooraft23)
		{endif}
		(L.L.door_4) 0.95 >
		(L.L.door_5) 0.95 > &&
		{if}		
			(M.L.trg_bus_dooraft45)
		{endif}
		0 (S.L.notheben_armed)
		0 (S.L.kneeling_armed)
		1 (S.L.notheben_initialized)
	{endif}


	(L.L.bremse_halte_sw) !
	(L.L.door_hstbremse_knickschutz) 0 = &&
	(L.L.kneel_timer) 0 = &&
	(L.L.door_freigabe) ! &&
	(L.L.door_0) 0.02 < &&
	(L.L.door_1) 0.02 < &&
	(L.L.door_2) 0.02 < &&
	(L.L.door_3) 0.02 < &&
	(L.L.door_4) 0.02 < &&
	(L.L.door_5) 0.02 < &&
	(L.L.20h_switch_pressed) ! &&
	(L.L.throttle) 0.125 > &&
	(L.L.Velocity) 0.1 < &&
	{if}
		0 (S.L.bremse_halte) (S.L.door2_bremse_halte_sw) (S.L.doorMidLastOpen) (S.L.doorAftLastOpen)
		(T.L.ev_haltebremse_aus)
	{endif}
	
{endif}

	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	(L.L.bremse_p_tank04) 550000 > &&
	{if}
		(L.L.velocity) 0.1 <
		(L.L.cockpit_tuertaster1) &&
		(L.L.cockpit_tuertaster1_frame) &&
		{if}

'### Tuerfluegelsperre

		(L.L.tuersperre) 1 =
		(L.L.tuersperre) 0 = ||
		{if}
			(M.L.trg_bus_doorfront0)
		{endif}

		(L.L.tuersperre) -1 =
		(L.L.tuersperre) 0 = ||
		{if}
			(M.L.trg_bus_doorfront1)
		{endif}

			0 (S.L.cockpit_tuertaster1_frame)
		{endif}
	{endif}

'	Außentürtaster werden von Fahrgästen benutzt:


'### Focus Edit Haltewunsch

'Anforderung mit neuen Variablen:

(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
{if}

'##########################################################
'### Generellen Haltewunsch während der Fahrt abfangen
'##########################################################

	(L.L.PAX_Exit0_Req)
	(L.L.PAX_Exit1_Req) ||
	(L.L.PAX_Exit2_Req) ||
	(L.L.PAX_Exit3_Req) ||
	(L.L.PAX_Exit4_Req) ||
	{if}
		1 (S.L.haltewunsch)
	{endif}
	
	(L.L.doortarget_0)
	(L.L.doortarget_1) ||
	(L.L.doortarget_23) ||
	(L.L.doortarget_45) ||
	{if}
		0 (S.L.haltewunsch)
	{endif}

'##########################################################

	(L.L.Velocity) 70 <
	{if}

		(L.L.PAX_Exit0_Req)
		(L.L.doortarget_1) ! &&
		(L.L.haltewunsch_01) ! &&	
		{if}
			1 (S.L.haltewunsch_01)
		{endif}

		(L.L.doortarget_1)
		(L.L.doortarget_23) ||
		(L.L.PAX_Exit0_Req) ! &&
		{if}
			0 (S.L.haltewunsch_01)
		{endif}

		(L.L.PAX_Entry2_Req) ||
		(L.L.PAX_Entry3_Req) ||	
		(L.L.auto_door2_int) 1 = &&
		{if}
			1 (S.L.haltewunsch_23_ext)
		{else}	
			0 (S.L.haltewunsch_23_ext)
		{endif}

		(L.L.haltewunsch_23_ext)
		(L.L.PAX_Exit1_Req) ||
		(L.L.PAX_Exit2_Req) ||
		(L.L.haltewunsch_23) ||
		{if}
			1 (S.L.haltewunsch_23)
		{endif}

		(L.L.haltewunsch_45)
		(L.L.door_haltewunsch_knopfdruck_2) ||	
		(L.L.PAX_Exit3_Req) ||
		(L.L.PAX_Exit4_Req) ||
		(L.L.Pax_Entry4_Req) ||
		(L.L.Pax_Entry5_Req) ||
		{if}	
			1 (S.L.haltewunsch_45)
		{endif}
	{endif}
{endif}


'### einsteigende Fahrgäste sollen warten bis aussteigende fertig sind


(L.L.Velocity) 0.1 <
{if}

	(L.L.door_1) 0.9 >
	(L.L.Pax_Exit0_Req) ! &&
	{if}
		1 (S.L.PAX_Entry1_Open)
		0 (S.L.haltewunsch_01)
	{else}
		0 (S.L.PAX_Entry1_Open)
	{endif}


	(L.L.door_2) 0.9 >
	(L.L.Pax_Exit1_Req) ! &&

	{if}
		1 (S.L.PAX_Entry2_Open)
		0 (S.L.haltewunsch_23)
	{else}
		0 (S.L.PAX_Entry2_Open)
	{endif}

	(L.L.door_3) 0.9 >
	(L.L.Pax_Exit2_Req) ! &&
	{if}
		1 (S.L.PAX_Entry3_Open)
		0 (S.L.haltewunsch_23)
	{else}
		0 (S.L.PAX_Entry3_Open)
	{endif}


	(L.L.door_4) 0.9 >
	(L.L.Pax_Exit3_Req) ! &&
	{if}
		1 (S.L.PAX_Entry4_Open)
		0 (S.L.haltewunsch_45)
	{else}
		0 (S.L.PAX_Entry4_Open)
	{endif}

	(L.L.door_5) 0.9 >
	(L.L.Pax_Exit4_Req) ! &&
	{if}
		1 (S.L.PAX_Entry5_Open)
		0 (S.L.haltewunsch_45)
	{else}
		0 (S.L.PAX_Entry5_Open)
	{endif}

{endif}


'	Haltewunschlampe:
		
	(L.L.haltewunsch) (L.L.haltewunsch_01) (L.L.haltewunsch_23) (L.L.haltewunsch_45) || || || (S.L.haltewunschlampe_all)
		
		(L.L.haltewunschlampe_all)
		(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
		{if}

'	Bing:		
			(L.L.haltewunsch_01) (L.L.prev_haltewunsch_01) !
			(L.L.haltewunsch_23) (L.L.prev_haltewunsch_23) ! ||
			(L.L.haltewunsch_45) (L.L.prev_haltewunsch_45) ! || 
			{if}
				(T.L.ev_stop)
			{endif}

			(L.L.vis_Innenanzeige_int) !
			{if}
				1 (S.L.haltewunschlampe_innenanzeige)
			{else}
				0 (S.L.haltewunschlampe_innenanzeige)
			{endif}
		{else}
			0 (S.L.haltewunschlampe_innenanzeige) (S.L.haltewunsch) (S.L.haltewunsch_01) (S.L.haltewunsch_23) (S.L.zufall_kinderwagenwunsch) (S.L.door_kinderwagenwunsch) (S.L.haltewunsch_45)
		{endif}

		(L.L.haltewunsch_01) (S.L.prev_haltewunsch_01)
		(L.L.haltewunsch_23) (S.L.prev_haltewunsch_23)
		(L.L.haltewunsch_45) (S.L.prev_haltewunsch_45)



'### Focus Edit Haltewunsch Ende


(L.L.Velocity) 0.1 <
{if}

'Bei E-Türen die "active"-Variable der Entriegelung nachführen:
	(L.L.vis_doortype_v_int) !
	{if}
		(L.L.doorEntriegelung_01) (L.L.doorEntriegelung_E_active_01) s0 (L.L.elec_busbar_avail) (C.L.elec_busbar_minV) > ! && || s1
		l0 = !
		{if}
			l1
			{if}
				(T.L.ev_doorEntriegelung_01_active_on)
				0 (S.L.doorEntriegelung_doorActive_01)
			{else}
				(T.L.ev_doorEntriegelung_01_active_off)
			{endif}
		{endif}
		l1 (S.L.doorEntriegelung_E_active_01)
	{endif}
	(L.L.vis_doortype_m_int) !
	{if}
		(L.L.doorEntriegelung_23) (L.L.doorEntriegelung_E_active_23) s0 (L.L.elec_busbar_avail) (C.L.elec_busbar_minV) > ! && || s1
		l0 = !
		{if}
			l1
			{if}
				(T.L.ev_doorEntriegelung_23_active_on)
				0 (S.L.doorEntriegelung_doorActive_23)
			{else}
				(T.L.ev_doorEntriegelung_23_active_off)
			{endif}
		{endif}
		l1 (S.L.doorEntriegelung_E_active_23)
	{endif}
	(L.L.vis_doortype_h_int) !
	{if}
		(L.L.doorEntriegelung_45) (L.L.doorEntriegelung_E_active_45) s0 (L.L.elec_busbar_avail) (C.L.elec_busbar_minV) > ! && || s1
		l0 = !
		{if}
			l1
			{if}
				(T.L.ev_doorEntriegelung_45_active_on)
				0 (S.L.doorEntriegelung_doorActive_45)
			{else}
				(T.L.ev_doorEntriegelung_45_active_off)
			{endif}
		{endif}
		l1 (S.L.doorEntriegelung_E_active_45)
	{endif}

	(M.L.DoorMidCalc)
	(M.L.Door0_Calc)
	(M.L.Door1_Calc)
	(M.L.DoorAftCalc)
	(M.L.Door2_Calc)
	(M.L.Door3_Calc)
	(M.L.Door4_Calc)
	(M.L.Door5_Calc)

	0
	(S.L.doorDragAcc_0)
	(S.L.doorDragAcc_1)
	(S.L.doorDragAcc_2)
	(S.L.doorDragAcc_3)
	(S.L.doorDragAcc_4)
	(S.L.doorDragAcc_5)


	
	(L.L.door_0) 0.9 > (S.L.PAX_Entry0_Open)
	(L.L.door_1) 0.9 > (S.L.PAX_Exit0_Open)
	(L.L.door_2) 0.9 > (S.L.PAX_Exit1_Open)
	(L.L.door_3) 0.9 > (S.L.PAX_Exit2_Open)
	(L.L.door_4) 0.9 > (S.L.PAX_Exit3_Open)
	(L.L.door_5) 0.9 > (S.L.PAX_Exit4_Open)
	



'	Setzen der Haltestellenbremse erst bei Stillstand des Busses:

	(L.L.bremse_halte_sw)
	(L.L.20h_switch_pressed) ||
	(L.L.door_hstbremse_knickschutz) ||
	(L.L.door_0) 0 > ||
	(L.L.door_1) 0 > ||
	(L.L.door_2) 0 > ||
	(L.L.door_4) 0 > ||
	(L.L.bremse_halte) ! &&
	(L.L.Velocity) 0.5 < &&
	{if}
		(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
		{if}
			(T.L.ev_haltebremse_an)		
			1 (S.L.bremse_halte)
		{endif}
	{endif}

'	Anhand dieser Bedingungen kann nun die Automatiktür geöffnet werden:

	(M.L.DoorMid_Open)
	(M.L.DoorAft_Open)
	

'	Türfreigabekriterium

	(L.L.bremse_halte_sw) (L.L.bremse_halte) && (S.L.door_freigabe)


'	Abfall des Kinderwagenwunsch-Relais bei fehlender Stromversorgung:

	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) <
	{if}
		0 (S.L.door_kinderwagenwunsch) (S.L.zufall_kinderwagenwunsch)
	{endif}

'	Zufälliges zusätzliches Aufleuchten des Kinderwagenwunsches bei Haltewunsch:

	(L.L.haltewunsch_23) 1 =
	(L.L.zufall_kinderwagenwunsch) 0 = &&
	(L.S.Time) 72000 < (L.S.Time) 28800 > && &&
	{if}
		10 random (S.L.zufall_kinderwagenwunsch)
		(L.L.zufall_kinderwagenwunsch) 9 >=
		{if}
			1 (S.L.door_kinderwagenwunsch)
		{endif}
	{endif}

'	Beleuchtung der Einstiege

'	Ausgelagert in Lights-Script

'	Türsperre setzen:

' in s6 ist die verfügbare Druckmenge:
	(L.L.bremse_p_Tank04) 100000 - 850000 / s6



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



' Zunächst die Türentriegelungen:

	(L.L.doorEntriegelung_01)
	{if}
'Tür ist entlüftet:
		-2 (S.L.doorEntriegelung_doorActive_01)
	{else}
		(C.L.door_safe_reactivating) !
		{if}
'Tür steht unter Druck:
			1 (S.L.doorEntriegelung_doorActive_01)
		{else}
			(L.L.doorEntriegelung_doorActive_01) -2 =
			{if}
'Tür ist "vorbereitet":
				-1 (S.L.doorEntriegelung_doorActive_01)
			{endif}
		{endif}
	{endif}



	(L.L.doorEntriegelung_23)
	{if}
'Tür ist entlüftet:
		-2 (S.L.doorEntriegelung_doorActive_23)
	{else}
		(C.L.door_safe_reactivating) !
		{if}
'Tür steht unter Druck:
			1 (S.L.doorEntriegelung_doorActive_23)
		{else}
			(L.L.doorEntriegelung_doorActive_23) -2 =
			{if}
'Tür ist "vorbereitet":
				-1 (S.L.doorEntriegelung_doorActive_23)
			{endif}
		{endif}
	{endif}




	(L.L.doorEntriegelung_45)
	{if}
'Tür ist entlüftet:
		-2 (S.L.doorEntriegelung_doorActive_45)
	{else}
		(C.L.door_safe_reactivating) !
		{if}
'Tür steht unter Druck:
			1 (S.L.doorEntriegelung_doorActive_45)
		{else}
		(L.L.doorEntriegelung_doorActive_45) -2 =
			{if}
'Tür ist "vorbereitet":
				-1 (S.L.doorEntriegelung_doorActive_45)
			{endif}
		{endif}
	{endif}

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

'Druck laaaaangsam aufbauen (sofern nötig):

	(L.L.doorEntriegelung_doorActive_01) s1 0 >= l1 0.99 < &&
	{if}
		1 s0 0.1 s2 s3 (M.L.traegheit) (S.L.doorEntriegelung_doorActive_01)
		(L.L.doorEntriegelung_doorActive_01) 0.8 >
		{if}
			(T.L.ev_doorEntriegelung_01_off_final)
			1 (S.L.doorEntriegelung_doorActive_01)
		{endif}
	{endif}

	(L.L.doorEntriegelung_doorActive_23) s1 0 >= l1 0.99 < &&
	{if}
		1 s0 0.1 s2 s3 (M.L.traegheit) (S.L.doorEntriegelung_doorActive_23)
		(L.L.doorEntriegelung_doorActive_23) 0.8 >
		{if}
			(T.L.ev_doorEntriegelung_23_off_final)
			1 (S.L.doorEntriegelung_doorActive_23)
		{endif}
	{endif}

	(L.L.doorEntriegelung_doorActive_45) s1 0 >= l1 0.99 < &&
	{if}
		1 s0 0.1 s2 s3 (M.L.traegheit) (S.L.doorEntriegelung_doorActive_45)
		(L.L.doorEntriegelung_doorActive_45) 0.8 >
		{if}
			(T.L.ev_doorEntriegelung_45_off_final)
			1 (S.L.doorEntriegelung_doorActive_45)
		{endif}
	{endif}


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


	(L.L.doorEntriegelung_doorActive_01) 0 <=
	{if}
		0 s5
	{else}
		(L.L.doortarget_0) ! s5 !
	{endif}

	(L.L.doorEntriegelung_doorActive_01) l6 * * s0
	(L.L.door_pressure_open_0) s1
	1 s2 1 s3
	(M.L.traegheit) (S.L.door_pressure_open_0)

	(L.L.door_pressure_close_0) s1
	l5 (L.L.doorEntriegelung_doorActive_01) l6 * * s0
	(M.L.traegheit) (S.L.door_pressure_close_0)

'.....................

	(L.L.doorEntriegelung_doorActive_01) 0 <=
	{if}
		0 s5
	{else}
		(L.L.doortarget_1) ! s5 !
	{endif}

	l6 (L.L.doorEntriegelung_doorActive_01) * * s0
	(L.L.door_pressure_open_1) s1
	1 s2 1 s3
	(M.L.traegheit) (S.L.door_pressure_open_1)

	(L.L.door_pressure_close_1) s1
	l5 (L.L.doorEntriegelung_doorActive_01) l6 * * s0
	(M.L.traegheit) (S.L.door_pressure_close_1)

'.....................

	(L.L.doorEntriegelung_doorActive_23) 0 <=
	{if}
		0 s5
	{else}
		(L.L.doortarget_23) ! s5 !
	{endif}

	(L.L.doorEntriegelung_doorActive_23) l6 * * s0
	(L.L.door_pressure_open_2) s1
	1 s2 1 s3
	(M.L.traegheit) (S.L.door_pressure_open_2)

	(L.L.door_pressure_close_2) s1
	(L.L.doorEntriegelung_doorActive_23) l5 l6 * * s0
	(M.L.traegheit) (S.L.door_pressure_close_2)

'.....................

	(L.L.doorEntriegelung_doorActive_23) 0 <=
	{if}
		0 s5
	{else}
		(L.L.doortarget_23) ! s5 !
	{endif}

	(L.L.doorEntriegelung_doorActive_23) l6 * * s0
	(L.L.door_pressure_open_3) s1
	1 s2 1 s3
	(M.L.traegheit) (S.L.door_pressure_open_3)

	(L.L.door_pressure_close_3) s1
	(L.L.doorEntriegelung_doorActive_23) l5 l6 * * s0
	(M.L.traegheit) (S.L.door_pressure_close_3)

'.....................

	(L.L.doorEntriegelung_doorActive_45) 0 <=
	{if}
		0 s5
	{else}
		(L.L.doortarget_45) ! s5 !
	{endif}

	(L.L.doorEntriegelung_doorActive_45) l6 * * s0
	(L.L.door_pressure_open_4) s1
	1 s2 1 s3
	(M.L.traegheit) (S.L.door_pressure_open_4)

	(L.L.door_pressure_close_4) s1
	(L.L.doorEntriegelung_doorActive_45) l5 l6 * * s0
	(M.L.traegheit) (S.L.door_pressure_close_4)

'.....................

	(L.L.doorEntriegelung_doorActive_45) 0 <=
	{if}
		0 s5
	{else}
		(L.L.doortarget_45) ! s5 !
	{endif}

	(L.L.doorEntriegelung_doorActive_45) l6 * * s0
	(L.L.door_pressure_open_5) s1
	1 s2 1 s3
	(M.L.traegheit) (S.L.door_pressure_open_5)

	(L.L.door_pressure_close_5) s1
	(L.L.doorEntriegelung_doorActive_45) l5 l6 * * s0
	(M.L.traegheit) (S.L.door_pressure_close_5)

'.....................

	l6 (L.L.doorEntriegelung_doorActive_01) 0 max * (S.L.door_pressure_factor_01)
	l6 (L.L.doorEntriegelung_doorActive_23) 0 max * (S.L.door_pressure_factor_23)
	l6 (L.L.doorEntriegelung_doorActive_45) 0 max * (S.L.door_pressure_factor_45)

'###############################################################################################
' Dämpferverhalten:
	(L.L.vis_doortype_v_int) 2 =
	{if}
		(L.L.doorSpeed_0) 0 >
		{if}
			(L.L.door_0) (F.L.damper_f_open_schwenk)
		{else}
			(L.L.door_0) (F.L.damper_f_close_schwenk)
		{endif}
		(L.L.doorSpeed_0) * s0

		(L.L.doorEntriegelung_01)
		{if}
			l0
		{else}
			(L.L.doorDamper_0) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_0)

'........................

		(L.L.doorSpeed_1) 0 >
		{if}
			(L.L.door_1) (F.L.damper_f_open_schwenk)
		{else}
			(L.L.door_1) (F.L.damper_f_close_schwenk)
		{endif}
		(L.L.doorSpeed_1) * s0

		(L.L.doorEntriegelung_01)
		{if}
			l0
		{else}
			(L.L.doorDamper_1) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_1)
	{else}
		(L.L.doorSpeed_0) 0 >
		{if}
			(L.L.door_0) (F.L.damper_f_open)
		{else}
			(L.L.door_0) (F.L.damper_f_close)
		{endif}
		(L.L.doorSpeed_0) * s0

		(L.L.doorEntriegelung_01)
		{if}
			l0
		{else}
			(L.L.doorDamper_0) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_0)

'........................

		(L.L.doorSpeed_1) 0 >
		{if}
			(L.L.door_1) (F.L.damper_f_open)
		{else}
			(L.L.door_1) (F.L.damper_f_close)
		{endif}
		(L.L.doorSpeed_1) * s0

		(L.L.doorEntriegelung_01)
		{if}
			l0
		{else}
			(L.L.doorDamper_1) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_1)
	{endif}

'........................
	(L.L.vis_doortype_m_int) 2 =
	{if}
		(L.L.doorSpeed_2) 0 >
		{if}
			(L.L.door_2) (F.L.damper_m_open_schwenk)
		{else}
			(L.L.door_2) (F.L.damper_m_close_schwenk)
		{endif}
		(L.L.doorSpeed_2) * s0

		(L.L.doorEntriegelung_23)
		{if}
			l0
		{else}
			(L.L.doorDamper_2) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_2)

'........................

		(L.L.doorSpeed_3) 0 >
		{if}
			(L.L.door_3) (F.L.damper_m_open_schwenk)
		{else}
			(L.L.door_3) (F.L.damper_m_close_schwenk)
		{endif}
		(L.L.doorSpeed_3) * s0

		(L.L.doorEntriegelung_23)
		{if}
			l0
		{else}
			(L.L.doorDamper_3) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_3)
	{else}
		(L.L.doorSpeed_2) 0 >
		{if}
			(L.L.door_2) (F.L.damper_m_open)
		{else}
			(L.L.door_2) (F.L.damper_m_close)
		{endif}
		(L.L.doorSpeed_2) * s0

		(L.L.doorEntriegelung_23)
		{if}
			l0
		{else}
			(L.L.doorDamper_2) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_2)

'........................

		(L.L.doorSpeed_3) 0 >
		{if}
			(L.L.door_3) (F.L.damper_m_open)
		{else}
			(L.L.door_3) (F.L.damper_m_close)
		{endif}
		(L.L.doorSpeed_3) * s0

		(L.L.doorEntriegelung_23)
		{if}
			l0
		{else}
			(L.L.doorDamper_3) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_3)
	{endif}

	(L.L.vis_doortype_h_int) 2 =
	{if}
		(L.L.doorSpeed_4) 0 >
		{if}
			(L.L.door_4) (F.L.damper_b_open_schwenk)
		{else}
			(L.L.door_4) (F.L.damper_b_close_schwenk)
		{endif}
		(L.L.doorSpeed_4) * s0

		(L.L.doorEntriegelung_45)
		{if}
			l0
		{else}
			(L.L.doorDamper_4) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_4)

'........................

		(L.L.doorSpeed_5) 0 >
		{if}
			(L.L.door_5) (F.L.damper_b_open_schwenk)
		{else}
			(L.L.door_5) (F.L.damper_b_close_schwenk)
		{endif}
		(L.L.doorSpeed_5) * s0

		(L.L.doorEntriegelung_45)
		{if}
			l0
		{else}
			(L.L.doorDamper_5) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_5)
	{else}
		(L.L.doorSpeed_4) 0 >
		{if}
			(L.L.door_4) (F.L.damper_b_open)
		{else}
			(L.L.door_4) (F.L.damper_b_close)
		{endif}
		(L.L.doorSpeed_4) * s0

		(L.L.doorEntriegelung_45)
		{if}
			l0
		{else}
			(L.L.doorDamper_4) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_4)

'........................

		(L.L.doorSpeed_5) 0 >
		{if}
			(L.L.door_5) (F.L.damper_b_open)
		{else}
			(L.L.door_5) (F.L.damper_b_close)
		{endif}
		(L.L.doorSpeed_5) * s0

		(L.L.doorEntriegelung_45)
		{if}
			l0
		{else}
			(L.L.doorDamper_5) s1
			3 s2 3 s3
			(M.L.traegheit)
		{endif}
		(S.L.doorDamper_5)
	{endif}
'###############################################################################################
'	Gegenseitiges Blockieren der Türflügel:

'	Die jeweilige Tür wird dadurch blockiert, dass ihr Öffnungsgrad kleiner ist als der des anderen Flügels ist, der selbst aber schon fast zu und nicht blockiert sein muss:

	(C.L.door_blocking) 
	{if}

		(L.L.door0_physblock)
		{if}
			(L.L.door_0) (L.L.door_1) (C.L.door_blocking_diff) + < (L.L.door_1) (C.L.door_blocking_area) < && (L.L.door1_physblock) ! && (S.L.door0_physblock)
		{else}
			(L.L.door_0) (L.L.door_1) < (L.L.door_1) (C.L.door_blocking_area) < && (L.L.door1_physblock) ! && (S.L.door0_physblock)
		{endif}

		(L.L.door1_physblock)
		{if}
			(L.L.door_1) (L.L.door_0) (C.L.door_blocking_diff) + < (L.L.door_0) (C.L.door_blocking_area) < && (L.L.door0_physblock) ! && (S.L.door1_physblock)
		{else}
			(L.L.door_1) (L.L.door_0) < (L.L.door_0) (C.L.door_blocking_area) < && (L.L.door0_physblock) ! && (S.L.door1_physblock)
		{endif}
	{else}
		0 (S.L.door0_physblock) (S.L.door1_physblock)
	{endif}


'###############################################################################################
'###############################################################################################
'	KI / AI-Ablauf:

(L.L.AI_Scheduled_AtStation) s0 1 =
{if}
	(L.L.Velocity) 0.1 <
	{if}
		
		1 (S.L.bremse_halte_sw) (S.L.door_freigabe) (S.L.bremse_halte) (S.L.door2_bremse_halte_sw)

		(L.L.Pax_Entry0_Req)
		(L.L.Pax_Entry1_Req) ||
		(L.L.Pax_Exit0_Req) ||
		(L.L.doortarget_0) ! &&
		{if}
			(M.L.trg_bus_doorfront0)
			(M.L.trg_bus_doorfront1)
		{endif}

		(L.L.haltewunsch_23)
		(L.L.PAX_Entry2_Req) ||
		(L.L.PAX_Entry3_Req) ||
		{if}
			(M.L.DoorMid_Open)
		{endif}

		(L.L.haltewunsch_45)
		{if}
			(M.L.DoorAft_Open)
		{endif}
	{endif}
{else}
	l0 -1 =
	{if}
		(L.L.doortarget_0)
		{if}
			(M.L.trg_bus_doorfront0)
			(M.L.trg_bus_doorfront1)
		{endif}
		

		(L.L.door_0) 0.1 <
		(L.L.door_1) 0.1 < &&
		(L.L.door_2) 0.1 < &&
		(L.L.door_4) 0.1 < &&
		{if}
			0 (S.L.AI_Scheduled_AtStation)
		{endif}
	0 (S.L.bremse_halte_sw) (S.L.bremse_feststell_sw) (S.L.door_freigabe) (S.L.bremse_halte) (S.L.door2_bremse_halte_sw) (S.L.doortarget_23)
	{endif}
{endif}

{endif}

{end}
'###############################################################################################
' Door Calc Türenpaar 1
'###############################################################################################


{macro:Door0_Calc}
	(L.L.vis_doortype_v_int) 2 =
	{if}
'Hubverriegelung
		(L.L.doortarget_0)
		(L.L.door_0_hub) 1 <= && 
		{if}
'Volllaufen lassen über Timegap, Entriegelung
		(L.L.door_0_hub) (C.L.door_0_hub_speed) 5 / (L.S.Timegap) * + 1 min (S.L.door_0_hub)
		{else}
			(L.L.doortarget_0) !
			(L.L.door_0_hub) &&
			(L.L.door_0) ! &&
			(L.L.door_1) ! &&
			{if}
'Volllaufen lassen über Timegap, Verriegelung
				(L.L.door_0_hub) (C.L.door_0_hub_speed) 5 / (L.S.Timegap) * - 0 max (S.L.door_0_hub)
			{endif}
		{endif}
	{endif}
	
	
	    (L.L.doorEntriegelung_doorActive_01)
		(L.L.doorEntriegelung_01) ||
	    {if}

		(L.L.doortarget_0)
		{if}
			(L.L.vis_doortype_v_int) 1 =
			{if}
				(L.L.door_0) (F.L.door_0_opn_speed_schiebe) (S.L.doorMaxSpeed_0)
			{else}
				(L.L.vis_doortype_v_int) 2 =
				{if}
					(L.L.door_0) (F.L.door_0_opn_speed_schwenk) (S.L.doorMaxSpeed_0)
				{else}
					(L.L.door_0) (F.L.door_0_opn_speed) (S.L.doorMaxSpeed_0)
				{endif}
			{endif}			
		{else}
			(L.L.vis_doortype_v_int) 1 =
			{if}
				(L.L.door_0) (F.L.door_0_cls_speed_schiebe) (S.L.doorMaxSpeed_0)
			{else}
				(L.L.vis_doortype_v_int) 2 =
				{if}
					(L.L.door_0) (F.L.door_0_cls_speed_schwenk) (S.L.doorMaxSpeed_0)
				{else}
					(L.L.door_0) (F.L.door_0_cls_speed) (S.L.doorMaxSpeed_0)
				{endif}
			{endif}	
		{endif}

			(L.L.vis_doortype_v_int) 2 =
			{if}
				(C.L.fdoor_acc_schwenk) (S.L.doorAcc_0)
			{else}
				(C.L.fdoor_acc) (S.L.doorAcc_0)
			{endif}

		(L.L.doortarget_0) ! (L.L.doorSpeed_0) s0 abs 0.05 > (L.L.door_0) 0 > || && 
		(L.L.doorEntriegelung_01) ||
		{if}
			(L.L.door_0_hub) 0.8 >
			(L.L.vis_doortype_v_int) ! ||
			(L.L.vis_doortype_v_int) 1 = ||
			{if}
				l0 /-/ (L.L.doorMaxSpeed_0) <
				{if}
						(L.L.doorEntriegelung_01)
						{if}
							(L.L.doorSpeed_0) (L.L.doorDragAcc_0) (L.S.Timegap) * - (S.L.doorSpeed_0)
						{else}
							(L.L.doorSpeed_0) (L.L.doorAcc_0) (L.S.Timegap) * - (S.L.doorSpeed_0)
						{endif}
				{else}
						(L.L.doorEntriegelung_01)
						{if}
							(L.L.doorSpeed_0) (L.L.doorDragAcc_0) (L.S.Timegap) * + (S.L.doorSpeed_0)
						{else}
							(L.L.doorSpeed_0) (L.L.doorAcc_0) (L.S.Timegap) * + (S.L.doorSpeed_0)
						{endif}
				{endif}
				(L.L.door_0) (L.L.doorSpeed_0) (L.S.Timegap) * + (S.L.door_0)
			{endif}
		{else}
			(L.L.doorSpeed_0) abs 0.05 > (L.L.door_0) 1 < || (L.L.doortarget_0) &&
			{if}
				(L.L.door_0_hub) 0.5 >
				(L.L.vis_doortype_v_int) ! ||
				(L.L.vis_doortype_v_int) 1 = ||
				{if}
					l0 (L.L.doorMaxSpeed_0) <
					{if}
							(L.L.doorEntriegelung_01)
							{if}
								(L.L.doorSpeed_0) (L.L.doorDragAcc_0) (L.S.Timegap) * + (S.L.doorSpeed_0)
							{else}
								(L.L.doorSpeed_0) (L.L.doorAcc_0) (L.S.Timegap) * + (S.L.doorSpeed_0)
							{endif}
					{else}
							(L.L.doorEntriegelung_01)
							{if}
								(L.L.doorSpeed_0) (L.L.doorDragAcc_0) (L.S.Timegap) * - (S.L.doorSpeed_0)
							{else}
								(L.L.doorSpeed_0) (L.L.doorAcc_0) (L.S.Timegap) * - (S.L.doorSpeed_0)
							{endif}
					{endif}

'Falls die Tür durch den anderen Flügel blockiert wird, geht sie nur gaaanz langsam auf:
					(L.L.door_1) (L.L.door_0) < (L.L.door0_physblock) &&
					{if}
						(C.L.door_blocking_speed) (S.L.doorSpeed_0)
						(L.L.vis_doortype_v_int) 0 =
						{if}
							(L.L.doorEntriegelung_01) !
							{if}
								(T.L.ev_doortriggeropen_0)
							{endif}
						{else}
							(L.L.vis_doortype_v_int) 1 =
							{if}
								(L.L.doorEntriegelung_01) !
								{if}
									(T.L.ev_doortriggeropen_0_schieb)
								{endif}
							{else}
								(L.L.doorEntriegelung_01) !
								{if}
									(T.L.ev_doortriggeropen_0_schwenk)
								{endif}
							{endif}
						{endif}
					{endif}
					(L.L.door_0) (L.L.doorSpeed_0) (L.S.Timegap) * + (S.L.door_0)
				{endif}
			{else}
				0 (S.L.doorSpeed_0)
			{endif}
		{endif}

		(L.L.elec_busbar_Rinv_summe)
			(L.L.doorSpeed_0) abs (C.L.door_Rinv) * +
		(S.L.elec_busbar_Rinv_summe)
	    {else}
		0 (S.L.doorSpeed_0)
	    {endif}

	(L.L.door_0) 1 >
	{if}
		(L.L.vis_doortype_v_int) !
		{if}
			(L.L.doorEntriegelung_01) !
			{if}
				(T.L.ev_doorhitopen_0)
			{endif}
		{else}
			(L.L.vis_doortype_v_int) 1 =
			{if}
				(L.L.doorEntriegelung_01) !
				{if}
					(T.L.ev_doorhitopen_0_schieb)
				{endif}
			{else}
				(L.L.doorEntriegelung_01) !
				{if}
					(T.L.ev_doorhitopen_0_schwenk)
				{endif}
			{endif}
		{endif}
		1 (S.L.door_0)
		(L.L.doorSpeed_0) /-/ (L.L.doorRefl_0) * (S.L.doorSpeed_0)
	{else}
		(L.L.door_0) 0 <
		{if}
			(L.L.vis_doortype_v_int) !
			{if}
				(L.L.doorEntriegelung_01) !
				{if}
					(T.L.ev_doorhitclose_0)
				{endif}
			{else}
				(L.L.vis_doortype_v_int) 1 =
				{if}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doorhitclose_0_schieb)
					{endif}
				{else}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doorhitclose_0_schwenk)
					{endif}
				{endif}
			{endif}
			0 (S.L.door_0)
			(L.L.doorSpeed_0) /-/ (L.L.doorRefl_0) * (S.L.doorSpeed_0)
		{endif}
	{endif}
	(L.L.door_0) (F.L.door_klappe) (S.L.door_0_klappe)
	(L.L.door_0) (F.L.door_stange) (S.L.door_0_stange)
	(L.L.door_0) (F.L.door_schiebe) (S.L.door_0_schiebe)
	(L.L.door_0) (F.L.door_trapez_v) (S.L.door_0_trapez)
{end}

{macro:Door1_Calc}

	(L.L.vis_doortype_v_int) 2 =
	{if}
'Hubverriegelung
		(L.L.doortarget_1)
		(L.L.door_1_hub) 1 <= &&
		{if}
'Volllaufen lassen über Timegap, Entriegelung
		(L.L.door_1_hub) (C.L.door_1_hub_speed) 5 / (L.S.Timegap) * + 1 min (S.L.door_1_hub)
		{else}
			(L.L.doortarget_1) !
			(L.L.door_1_hub) &&
			(L.L.door_1) ! &&
			(L.L.door_0) ! &&
			{if}
'Volllaufen lassen über Timegap, Verriegelung
				(L.L.door_1_hub) (C.L.door_1_hub_speed) 5 / (L.S.Timegap) * - 0 max (S.L.door_1_hub)
			{endif}
		{endif}
	{endif}
	
'Nur, wenn nicht verriegelt:
	(L.L.door_1_locked) !
	{if}
	    (L.L.doorEntriegelung_doorActive_01)
		(L.L.doorEntriegelung_01) ||
	    {if}
		(L.L.doortarget_1)
		{if}
			(L.L.vis_doortype_v_int) 1 =
			{if}
				(L.L.door_1) (F.L.door_1_opn_speed_schiebe) (S.L.doorMaxSpeed_1)
			{else}
				(L.L.vis_doortype_v_int) 2 =
				{if}
					(L.L.door_1) (F.L.door_1_opn_speed_schwenk) (S.L.doorMaxSpeed_1)
				{else}
					(L.L.door_1) (F.L.door_1_opn_speed) (S.L.doorMaxSpeed_1)
				{endif}
			{endif}			
		{else}
			(L.L.vis_doortype_v_int) 1 =
			{if}
				(L.L.door_1) (F.L.door_1_cls_speed_schiebe) (S.L.doorMaxSpeed_1)
			{else}
				(L.L.vis_doortype_v_int) 2 =
				{if}
					(L.L.door_1) (F.L.door_1_cls_speed_schwenk) (S.L.doorMaxSpeed_1)
				{else}
					(L.L.door_1) (F.L.door_1_cls_speed) (S.L.doorMaxSpeed_1)
				{endif}
			{endif}	
		{endif}

		(L.L.vis_doortype_v_int) 2 =
		{if}
			(C.L.fdoor_acc_schwenk) (S.L.doorAcc_1)
		{else}
			(C.L.fdoor_acc) (S.L.doorAcc_1)
		{endif}

		(L.L.doortarget_1) ! (L.L.doorSpeed_1) s0 abs 0.05 > (L.L.door_1) 0 > || && 
		(L.L.doorEntriegelung_01) ||
		{if}
			(L.L.door_1_hub) 0.8 >
			(L.L.vis_doortype_v_int) ! ||
			(L.L.vis_doortype_v_int) 1 = ||
			{if}
				l0 /-/ (L.L.doorMaxSpeed_1) <
				{if}
					(L.L.doorEntriegelung_01)
					{if}
						(L.L.doorSpeed_1) (L.L.doorDragAcc_1) (L.S.Timegap) * - (S.L.doorSpeed_1)
					{else}
						(L.L.doorSpeed_1) (L.L.doorAcc_1) (L.S.Timegap) * - (S.L.doorSpeed_1)
					{endif}
				{else}
					(L.L.doorEntriegelung_01)
					{if}
						(L.L.doorSpeed_1) (L.L.doorDragAcc_1) (L.S.Timegap) * + (S.L.doorSpeed_1)
					{else}
						(L.L.doorSpeed_1) (L.L.doorAcc_1) (L.S.Timegap) * + (S.L.doorSpeed_1)
					{endif}
				{endif}
				(L.L.door_1) (L.L.doorSpeed_1) (L.S.Timegap) * + (S.L.door_1)
				(L.L.door_1) 0.01 <
				{if}
					0 (S.L.door0_warten)
					0 (S.L.door0_umkehr)
				{endif}
			{endif}
		{else}
			(L.L.doorSpeed_1) abs 0.05 > (L.L.door_1) 1 < || (L.L.doortarget_1) &&
			(L.L.doorEntriegelung_01) ||
			{if}
				(L.L.door_1_hub) 0.5 >
				(L.L.vis_doortype_v_int) ! ||
				(L.L.vis_doortype_v_int) 1 = ||
				{if}
					l0 (L.L.doorMaxSpeed_1) <
					{if}
						(L.L.doorEntriegelung_01)
						{if}
							(L.L.doorSpeed_1) (L.L.doorDragAcc_1) (L.S.Timegap) * + (S.L.doorSpeed_1)
						{else}
							(L.L.doorSpeed_1) (L.L.doorAcc_1) (L.S.Timegap) * + (S.L.doorSpeed_1)
						{endif}
					{else}
						(L.L.doorEntriegelung_01)
						{if}
							(L.L.doorSpeed_1) (L.L.doorDragAcc_1) (L.S.Timegap) * - (S.L.doorSpeed_1)
						{else}
							(L.L.doorSpeed_1) (L.L.doorAcc_1) (L.S.Timegap) * - (S.L.doorSpeed_1)
						{endif} 
					{endif}

'Falls die Tür durch den anderen Flügel blockiert wird, geht sie nur gaaanz langsam auf:
					(L.L.door_0) (L.L.door_1) < (L.L.door1_physblock) &&
					{if}
						(C.L.door_blocking_speed) (S.L.doorSpeed_1)
						(L.L.vis_doortype_v_int) 0 =
						{if}
							(L.L.doorEntriegelung_01) !
							{if}
								(T.L.ev_doortriggeropen_1)
							{endif}
						{else}
							(L.L.vis_doortype_v_int) 1 =
							{if}
								(L.L.doorEntriegelung_01) !
								{if}
									(T.L.ev_doortriggeropen_1_schieb)
								{endif}
							{else}
								(L.L.doorEntriegelung_01) !
								{if}
									(T.L.ev_doortriggeropen_1_schwenk)
								{endif}
							{endif}
						{endif}
					{endif}

					(L.L.door_1) (L.L.doorSpeed_1) (L.S.Timegap) * + (S.L.door_1)
				{endif}
			{else}
				0 (S.L.doorSpeed_1)
			{endif}
		{endif}
		(L.L.elec_busbar_Rinv_summe)
			(L.L.doorSpeed_1) abs (C.L.door_Rinv) * +
		(S.L.elec_busbar_Rinv_summe)
	    {else}
		0 (S.L.doorSpeed_1)
	    {endif}
	{endif}
	(L.L.door_1) 1 >
	{if}
		(L.L.vis_doortype_v_int) !
		{if}
			(L.L.doorEntriegelung_01) !
			{if}
				(T.L.ev_doorhitopen_0)
			{endif}
		{else}
			(L.L.vis_doortype_v_int) 1 =
			{if}
				(L.L.doorEntriegelung_01) !
				{if}
					(T.L.ev_doorhitopen_0_schieb)
				{endif}
			{else}
				(L.L.doorEntriegelung_01) !
				{if}
					(T.L.ev_doorhitopen_0_schwenk)
				{endif}	
			{endif}
		{endif}
		1 (S.L.door_1)
		(L.L.doorSpeed_1) /-/ (L.L.doorRefl_1) * (S.L.doorSpeed_1)
	{else}
		(L.L.door_1) 0 <
		{if}
			(L.L.vis_doortype_v_int) !
			{if}
				(L.L.doorEntriegelung_01) !
				{if}
					(T.L.ev_doorhitclose_0)
				{endif}
			{else}
				(L.L.vis_doortype_v_int) 1 =
				{if}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doorhitclose_0_schieb)
					{endif}
				{else}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doorhitclose_0_schwenk)
					{endif}	
				{endif}
			{endif}
			0 (S.L.door_1)
			(L.L.doorSpeed_1) /-/ (L.L.doorRefl_1) * (S.L.doorSpeed_1)
		{endif}
	{endif}
	(L.L.door_1) (F.L.door_klappe) (S.L.door_1_klappe)
	(L.L.door_1) (F.L.door_stange) (S.L.door_1_stange)
	(L.L.door_1) (F.L.door_schiebe) (S.L.door_1_schiebe)
	(L.L.door_1) (F.L.door_trapez_h) (S.L.door_1_trapez)
{end}

'###############################################################################################
' Hintertürautomatiken
'###############################################################################################

'### Tuer 23 open

{macro:DoorMid_Open}

	
	(L.L.PAX_Entry2_Req)
	(L.L.PAX_Entry3_Req) ||
	(L.L.PAX_Exit1_Req) ||
	(L.L.PAX_Exit2_Req) ||
	(L.L.door_haltewunsch_knopfdruck) ||
	(L.L.haltewunsch_23) ||
	(L.L.bremse_halte) &&
	(L.L.doorEntriegelung_E_active_45) (C.L.electric_doors) && ! &&
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
	(L.L.bremse_p_tank04) 550000 > &&
	(L.L.door2_bremse_halte_sw) &&
	{if}
		(L.L.doortarget_23) !
		(L.L.door_2) 0 > ||
		(L.L.door_3) 0 > || &&
		(L.L.bremse_halte) &&
		{if}
			(L.L.vis_doortype_m_int) !
			{if}
				(L.L.doortarget_23) !
				{if}
					(T.L.ev_doortriggeropen_2)
				{endif}
			{else}
				(L.L.vis_doortype_m_int) 1 =
				{if}
					(L.L.doortarget_23) !
					{if}
						(T.L.ev_doortriggeropen_2_schieb)
					{endif}
				{else}
					(L.L.doortarget_23) !
					{if}
						(T.L.ev_doortriggeropen_2_schwenk)
					{endif}
				{endif}
			{endif}
			1 (S.L.doortarget_23)
				(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
				0 (S.L.door_haltewunsch_knopfdruck)
		{else}
			1 (S.L.doorEntriegelung_doorActive_23)
		{endif}
		0 (S.L.doorMidLastOpen)	
	{endif}


{end}

'### Tuer 23 close

{macro:DoorMidCalc}

	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	(L.L.bremse_p_tank04) 550000 > &&
	{if}

'### Tuerverzoegerung Mitte

		(L.L.cockpit_tuertaster2_frame) !
		(L.L.bremse_halte) &&
		{if}
			(L.L.doorMidLastOpen) (L.S.Timegap) + (S.L.doorMidLastOpen)
			
		{endif}

		(L.L.doortarget_23)
		(L.L.doorMidLastOpen) (C.L.DD_Door_delay_23) > &&
		{if}
			(L.L.trigger_antirepeat23) 1 + (S.L.trigger_antirepeat23)
			(L.L.trigger_antirepeat23) 1 =
			{if}
				(L.L.vis_doorwarn_int)
				{if}
					(T.L.ev_doorwarn)
				{endif}
			{endif}

			(L.L.doorwarn_timer_mid) (L.S.Timegap) + 1.5 min (S.L.doorwarn_timer_mid) 1.5 =
			(L.L.vis_doorwarn_int) ! ||
			{if}
				(L.L.vis_doortype_m_int) !
				{if}
					(T.L.ev_doortriggerclose_2)
				{else}
					(L.L.vis_doortype_m_int) 1 =
					{if}
						(T.L.ev_doortriggerclose_2_schieb)
					{else}
						(T.L.ev_doortriggerclose_2_schwenk)
					{endif}
				{endif}
				
				0 (S.L.doortarget_23)
				0 (S.L.trigger_antirepeat23)
				(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
			{endif}
		{else}
			0 (S.L.doorwarn_timer_mid)
		{endif}
	{endif}
{end}

'### Tuer 45 open

{macro:DoorAft_Open}
	(L.L.PAX_Entry4_Req)
	(L.L.PAX_Entry5_Req) ||
	(L.L.PAX_Exit3_Req) ||
	(L.L.PAX_Exit4_Req) ||
	(L.L.door_haltewunsch_knopfdruck_2) ||
	(L.L.haltewunsch_45) ||
	(L.L.bremse_halte) &&
	(L.L.doorEntriegelung_E_active_45) (C.L.electric_doors) && ! &&
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
	(L.L.bremse_p_tank04) 550000 > &&
	{if}
		(L.L.doortarget_45) !
		(L.L.bremse_halte_sw)
		(L.L.door_4) 0 >
		(L.L.door_5) 0 > || || &&
		{if}
			(L.L.vis_doortype_h_int) !
			{if}
				(T.L.ev_doortriggeropen_4)
			{else}
				(L.L.vis_doortype_h_int) 1 =
				{if}
					(T.L.ev_doortriggeropen_4_schieb)
				{else}
					(T.L.ev_doortriggeropen_4_schwenk)
				{endif}
			{endif}
			1 (S.L.doortarget_45)
			(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
			0 (S.L.door_haltewunsch_knopfdruck_2)
		{else}
			1 (S.L.doorEntriegelung_doorActive_45)
		{endif}
		0 (S.L.doorAftLastOpen)		
	{endif}
{end}

'### Tuer 45 close

{macro:DoorAftCalc}


	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	(L.L.bremse_p_tank04) 550000 > &&
	{if}

'### Tuerverzoegerung Hinten

		(L.L.cockpit_tuertaster3_frame) !
		(L.L.bremse_halte) &&
		{if}
			(L.L.doorAftLastOpen) (L.S.Timegap) + (S.L.doorAftLastOpen)
		{endif}

		(L.L.doortarget_45)
		(L.L.doorAftLastOpen) (C.L.DD_Door_delay_45) > &&
		{if}
			(L.L.trigger_antirepeat45) 1 + (S.L.trigger_antirepeat45)
			(L.L.trigger_antirepeat45) 1 =
			{if}
				(L.L.vis_doorwarn_int)
				{if}
					(T.L.ev_doorwarn2)
				{endif}
			{endif}
			(L.L.doorwarn2_timer) (L.S.Timegap) + 1.5 min (S.L.doorwarn2_timer) 1.5 =
			(L.L.vis_doorwarn_int) ! ||
			{if}
				(L.L.vis_doortype_h_int) !
				{if}
					(T.L.ev_doortriggerclose_4)
				{else}
					(L.L.vis_doortype_h_int) 1 =
					{if}
						(T.L.ev_doortriggerclose_4_schieb)
					{else}
						(T.L.ev_doortriggerclose_4_schwenk)
					{endif}
				{endif}
				0 (S.L.doortarget_45)
				0 (S.L.trigger_antirepeat45)
				(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
			{endif}
		{else}
			0 (S.L.doorwarn2_timer)
		{endif}
	{endif}
{end}

'###############################################################################################
' Door Calc Türenpaar 2
'###############################################################################################

{macro:Door2_Calc}
	
	    (L.L.doorEntriegelung_doorActive_23)
		(L.L.doorEntriegelung_23) ||
	    {if}
		(L.L.doortarget_23)
		{if}
			(L.L.vis_doortype_m_int) 1 =
			{if}
				(L.L.door_2) (F.L.door_2_opn_speed_schiebe) (S.L.doorMaxSpeed_2)
			{else}
				(L.L.vis_doortype_m_int) 2 =
				{if}
					(L.L.door_2) (F.L.door_2_opn_speed_schwenk) (S.L.doorMaxSpeed_2)
				{else}
					(L.L.door_2) (F.L.door_2_opn_speed) (S.L.doorMaxSpeed_2)
				{endif}
			{endif}
		{else}
			(L.L.vis_doortype_m_int) 1 =
			{if}
				(L.L.door_2) (F.L.door_2_cls_speed_schiebe) (S.L.doorMaxSpeed_2)
			{else}
				(L.L.vis_doortype_m_int) 2 =
				{if}
					(L.L.door_2) (F.L.door_2_cls_speed_schwenk) (S.L.doorMaxSpeed_2)
				{else}
					(L.L.door_2) (F.L.door_2_cls_speed) (S.L.doorMaxSpeed_2)
				{endif}
			{endif}
		{endif}

		(L.L.vis_doortype_m_int) 2 =
		{if}
			(C.L.mdoor_acc_schwenk) (S.L.doorAcc_2)
		{else}
			(C.L.mdoor_acc) (S.L.doorAcc_2)
		{endif}

		(L.L.doortarget_23) ! (L.L.doorSpeed_2) s0 abs 0.05 > (L.L.door_2) 0 > || && 
		(L.L.doorEntriegelung_23) ||
		{if}
'			(L.L.door_2_hub) 0.8 >
			(L.L.vis_doortype_m_int) ! ||
			(L.L.vis_doortype_m_int) 1 = ||
			{if}
				(L.L.tuer2_piep_antirepeat) 1 + (S.L.tuer2_piep_antirepeat)
				1 =
				{if}
					(L.L.vis_doortype_m_int) !
					{if}
						(L.L.doorEntriegelung_23) !
						{if}
							(T.L.ev_doortriggerclose_2)
						{endif}
					{else}
						(L.L.vis_doortype_m_int) 1 =
						{if}
							(L.L.doorEntriegelung_23) !
							{if}
								(T.L.ev_doortriggerclose_2_schieb)
							{endif}
						{else}
							(L.L.doorEntriegelung_23) !
							{if}
								(T.L.ev_doortriggerclose_2_schwenk)
							{endif}
						{endif}
					{endif}
				{endif}
				l0 /-/ (L.L.doorMaxSpeed_2) <
				{if}
					(L.L.doorEntriegelung_23)
					{if}
						(L.L.doorSpeed_2) (L.L.doorDragAcc_2) (L.S.Timegap) * - (S.L.doorSpeed_2)
					{else}
						(L.L.doorSpeed_2) (L.L.doorAcc_2) (L.S.Timegap) * - (S.L.doorSpeed_2)
					{endif}
				{else}
					(L.L.doorEntriegelung_23)
					{if}
						(L.L.doorSpeed_2) (L.L.doorDragAcc_2) (L.S.Timegap) * + (S.L.doorSpeed_2)
					{else}
						(L.L.doorSpeed_2) (L.L.doorAcc_2) (L.S.Timegap) * + (S.L.doorSpeed_2)
					{endif}
				{endif}
				(L.L.door_2) (L.L.doorSpeed_2) (L.S.Timegap) * + (S.L.door_2)
			{endif}
		{else}
			0 (S.L.tuer2_piep_antirepeat)
			(L.L.doorSpeed_2) abs 0.05 > (L.L.door_2) 1 < || (L.L.doortarget_23) &&
			(L.L.doorEntriegelung_23) ||
			{if}
'				(L.L.door_2_hub) 0.5 >
				(L.L.vis_doortype_m_int) ! ||
				(L.L.vis_doortype_m_int) 1 = ||
				{if}
					l0 (L.L.doorMaxSpeed_2) <
					{if}
						(L.L.doorEntriegelung_23)
						{if}
							(L.L.doorSpeed_2) (L.L.doorDragAcc_2) (L.S.Timegap) * + (S.L.doorSpeed_2)
						{else}
							(L.L.doorSpeed_2) (L.L.doorAcc_2) (L.S.Timegap) * + (S.L.doorSpeed_2)
						{endif}
					{else}
						(L.L.doorEntriegelung_23)
						{if}
							(L.L.doorSpeed_2) (L.L.doorDragAcc_2) (L.S.Timegap) * - (S.L.doorSpeed_2)
						{else}
							(L.L.doorSpeed_2) (L.L.doorAcc_2) (L.S.Timegap) * - (S.L.doorSpeed_2)
						{endif}
					{endif}
					(L.L.door_2) (L.L.doorSpeed_2) (L.S.Timegap) * + (S.L.door_2)
				{endif}
			{else}
				0 (S.L.doorSpeed_2)
			{endif}
		{endif}
		(L.L.elec_busbar_Rinv_summe)
			(L.L.doorSpeed_2) abs (C.L.door_Rinv) * +
		(S.L.elec_busbar_Rinv_summe)
	    {else}
		0 (S.L.doorSpeed_2)
	    {endif}

	(L.L.door_2) 1 >
	{if}
		(L.L.vis_doortype_m_int) !
		{if}
			(L.L.doorEntriegelung_23) !
			{if}
				(T.L.ev_doorhitopen_2)
			{endif}
		{else}
			(L.L.vis_doortype_m_int) 1 =
			{if}
				(L.L.doorEntriegelung_23) !
				{if}
					(T.L.ev_doorhitopen_2_schieb)
				{endif}
			{else}
				(L.L.doorEntriegelung_23) !
				{if}
					(T.L.ev_doorhitopen_2_schwenk)
				{endif}	
			{endif}
		{endif}
		1 (S.L.door_2)
		(L.L.doorSpeed_2) /-/ (L.L.doorRefl_2) * (S.L.doorSpeed_2)
	{else}
		(L.L.door_2) 0 <
		{if}
			(L.L.vis_doortype_m_int) !
			{if}
				(L.L.doorEntriegelung_23) !
				{if}
					(T.L.ev_doorhitclose_2)
				{endif}
			{else}
				(L.L.vis_doortype_m_int) 1 =
				{if}
					(L.L.doorEntriegelung_23) !
					{if}
						(T.L.ev_doorhitclose_2_schieb)
					{endif}
				{else}
					(L.L.doorEntriegelung_23) !
					{if}
						(T.L.ev_doorhitclose_2_schwenk)
					{endif}	
				{endif}
			{endif}
			0 (S.L.door_2)
			(L.L.doorSpeed_2) /-/ (L.L.doorRefl_2) * (S.L.doorSpeed_2)
		{endif}
	{endif}
	(L.L.door_2) (F.L.door_klappe) (S.L.door_2_klappe)
	(L.L.door_2) (F.L.door_stange) (S.L.door_2_stange)
	(L.L.door_2) (F.L.door_schiebe) (S.L.door_2_schiebe)
	(L.L.door_2) (F.L.door_trapez_v) (S.L.door_2_trapez)
{end}

{macro:Door3_Calc}
	
	    (L.L.doorEntriegelung_doorActive_23)
	    (L.L.doorEntriegelung_23) ||
	    {if}
		(L.L.doortarget_23)
		{if}
			(L.L.vis_doortype_m_int) 1 =
			{if}
				(L.L.door_3) (F.L.door_3_opn_speed_schiebe) (S.L.doorMaxSpeed_3)
			{else}
				(L.L.vis_doortype_m_int) 2 =
				{if}
					(L.L.door_3) (F.L.door_3_opn_speed_schwenk) (S.L.doorMaxSpeed_3)
				{else}
					(L.L.door_3) (F.L.door_3_opn_speed) (S.L.doorMaxSpeed_3)
				{endif}
			{endif}
		{else}
			(L.L.vis_doortype_m_int) 1 =
			{if}
				(L.L.door_3) (F.L.door_3_cls_speed_schiebe) (S.L.doorMaxSpeed_3)
			{else}
				(L.L.vis_doortype_m_int) 2 =
				{if}
					(L.L.door_3) (F.L.door_3_cls_speed_schwenk) (S.L.doorMaxSpeed_3)
				{else}
					(L.L.door_3) (F.L.door_3_cls_speed) (S.L.doorMaxSpeed_3)
				{endif}
			{endif}
		{endif}

		(L.L.vis_doortype_m_int) 2 =
		{if}
			(C.L.mdoor_acc_schwenk) (S.L.doorAcc_3)
		{else}
			(C.L.mdoor_acc) (S.L.doorAcc_3)
		{endif}
		

		(L.L.doortarget_23) ! (L.L.doorSpeed_3) s0 abs 0.05 > (L.L.door_3) 0 > || && 
		(L.L.doorEntriegelung_23) ||
		{if}
'			(L.L.door_3_hub) 0.8 >
			(L.L.vis_doortype_m_int) ! ||
			(L.L.vis_doortype_m_int) 1 = ||
			{if}
				l0 /-/ (L.L.doorMaxSpeed_3) <
				{if}
					(L.L.doorEntriegelung_23)
					{if}
						(L.L.doorSpeed_3) (L.L.doorDragAcc_3) (L.S.Timegap) * - (S.L.doorSpeed_3)
					{else}
						(L.L.doorSpeed_3) (L.L.doorAcc_3) (L.S.Timegap) * - (S.L.doorSpeed_3)
					{endif}
				{else}
					(L.L.doorEntriegelung_23)
					{if}
						(L.L.doorSpeed_3) (L.L.doorDragAcc_3) (L.S.Timegap) * + (S.L.doorSpeed_3)
					{else}
						(L.L.doorSpeed_3) (L.L.doorAcc_3) (L.S.Timegap) * + (S.L.doorSpeed_3)
					{endif}
				{endif}
				(L.L.door_3) (L.L.doorSpeed_3) (L.S.Timegap) * + (S.L.door_3)
			{endif}
		{else}
			(L.L.doorSpeed_3) abs 0.05 > (L.L.door_3) 1 < || (L.L.doortarget_23) &&
			(L.L.doorEntriegelung_23) ||
			{if}
'				(L.L.door_3_hub) 0.5 >
				(L.L.vis_doortype_m_int) ! ||
				(L.L.vis_doortype_m_int) 1 = ||
				{if}
					l0 (L.L.doorMaxSpeed_3) <
					{if}
						(L.L.doorEntriegelung_23)
						{if}
							(L.L.doorSpeed_3) (L.L.doorDragAcc_3) (L.S.Timegap) * + (S.L.doorSpeed_3)
						{else}
							(L.L.doorSpeed_3) (L.L.doorAcc_3) (L.S.Timegap) * + (S.L.doorSpeed_3)
						{endif}
					{else}
						(L.L.doorEntriegelung_23)
						{if}
							(L.L.doorSpeed_3) (L.L.doorDragAcc_3) (L.S.Timegap) * - (S.L.doorSpeed_3)
						{else}
							(L.L.doorSpeed_3) (L.L.doorAcc_3) (L.S.Timegap) * - (S.L.doorSpeed_3)
						{endif}
					{endif}
					(L.L.door_3) (L.L.doorSpeed_3) (L.S.Timegap) * + (S.L.door_3)
				{endif}
			{else}
				0 (S.L.doorSpeed_3)
			{endif}
		{endif}
		(L.L.elec_busbar_Rinv_summe)
			(L.L.doorSpeed_3) abs (C.L.door_Rinv) * +
		(S.L.elec_busbar_Rinv_summe)
	    {else}
		0 (S.L.doorSpeed_3)
	    {endif}

	(L.L.door_3) 1 >
	{if}
		(L.L.vis_doortype_m_int) !
		{if}
			(L.L.doorEntriegelung_23) !
			{if}
				(T.L.ev_doorhitopen_3)
			{endif}
		{else}
			(L.L.vis_doortype_m_int) 1 =
			{if}
				(L.L.doorEntriegelung_23) !
				{if}
					(T.L.ev_doorhitopen_3_schieb)
				{endif}
			{else}
				(L.L.doorEntriegelung_23) !
				{if}
					(T.L.ev_doorhitopen_3_schwenk)
				{endif}
			{endif}
		{endif}
		1 (S.L.door_3)
		(L.L.doorSpeed_3) /-/ (L.L.doorRefl_3) * (S.L.doorSpeed_3)
	{else}
		(L.L.door_3) 0 <
		{if}
			(L.L.vis_doortype_m_int) !
			{if}
				(L.L.doorEntriegelung_23) !
				{if}
					(T.L.ev_doorhitclose_3)
				{endif}
			{else}
				(L.L.vis_doortype_m_int) 1 =
				{if}
					(L.L.doorEntriegelung_23) !
					{if}
						(T.L.ev_doorhitclose_3_schieb)
					{endif}
				{else}
					(L.L.doorEntriegelung_23) !
					{if}
						(T.L.ev_doorhitclose_3_schwenk)
					{endif}	
				{endif}
			{endif}
			0 (S.L.door_3)
			(L.L.doorSpeed_3) /-/ (L.L.doorRefl_3) * (S.L.doorSpeed_3)
		{endif}
	{endif}
	(L.L.door_3) (F.L.door_klappe) (S.L.door_3_klappe)
	(L.L.door_3) (F.L.door_stange) (S.L.door_3_stange)
	(L.L.door_3) (F.L.door_schiebe) (S.L.door_3_schiebe)
	(L.L.door_3) (F.L.door_trapez_h) (S.L.door_3_trapez)

{end}

'###############################################################################################
' Door Calc Türenpaar 3
'###############################################################################################

{macro:Door4_Calc}
	
	    (L.L.doorEntriegelung_doorActive_45)
		(L.L.doorEntriegelung_45) ||
	    {if}
		(L.L.doortarget_45)
		{if}
			(L.L.vis_doortype_h_int) 1 =
			{if}
				(L.L.door_4) (F.L.door_4_opn_speed_schiebe) (S.L.doorMaxSpeed_4)
			{else}
				(L.L.vis_doortype_h_int) 2 =
				{if}
					(L.L.door_4) (F.L.door_4_opn_speed_schwenk) (S.L.doorMaxSpeed_4)
				{else}
					(L.L.door_4) (F.L.door_4_opn_speed) (S.L.doorMaxSpeed_4)
				{endif}
			{endif}
		{else}
			(L.L.vis_doortype_h_int) 1 =
			{if}
				(L.L.door_4) (F.L.door_4_cls_speed_schiebe) (S.L.doorMaxSpeed_4)
			{else}
				(L.L.vis_doortype_h_int) 2 =
				{if}
					(L.L.door_4) (F.L.door_4_cls_speed_schwenk) (S.L.doorMaxSpeed_4)
				{else}
					(L.L.door_4) (F.L.door_4_cls_speed) (S.L.doorMaxSpeed_4)
				{endif}
			{endif}
		{endif}

		(L.L.vis_doortype_h_int) 2 =
		{if}
			(C.L.bdoor_acc_schwenk) (S.L.doorAcc_4)
		{else}
			(C.L.bdoor_acc) (S.L.doorAcc_4)
		{endif}

		(L.L.doortarget_45) ! (L.L.doorSpeed_4) s0 abs 0.05 > (L.L.door_4) 0 > || && 
		(L.L.doorEntriegelung_45) ||
		{if}
'			(L.L.door_4_hub) 0.8 >
			(L.L.vis_doortype_h_int) ! ||
			(L.L.vis_doortype_h_int) 1 = ||
			{if}
				l0 /-/ (L.L.doorMaxSpeed_4) <
				{if}
					(L.L.doorEntriegelung_45)
					{if}
						(L.L.doorSpeed_4) (L.L.doorDragAcc_4) (L.S.Timegap) * - (S.L.doorSpeed_4)
					{else}
						(L.L.doorSpeed_4) (L.L.doorAcc_4) (L.S.Timegap) * - (S.L.doorSpeed_4)
					{endif}
				{else}
					(L.L.doorEntriegelung_45)
					{if}
						(L.L.doorSpeed_4) (L.L.doorDragAcc_4) (L.S.Timegap) * + (S.L.doorSpeed_4)
					{else}
						(L.L.doorSpeed_4) (L.L.doorAcc_4) (L.S.Timegap) * + (S.L.doorSpeed_4)
					{endif}
				{endif}
				(L.L.door_4) (L.L.doorSpeed_4) (L.S.Timegap) * + (S.L.door_4)
			{endif}
		{else}
			(L.L.doorSpeed_4) abs 0.05 > (L.L.door_4) 1 < || (L.L.doortarget_45) &&
			(L.L.doorEntriegelung_45) ||
			{if}
'				(L.L.door_4_hub) 0.5 >
				(L.L.vis_doortype_h_int) ! ||
				(L.L.vis_doortype_h_int) 1 = ||
				{if}
					l0 (L.L.doorMaxSpeed_4) <
					{if}
						(L.L.doorEntriegelung_45)
						{if}
							(L.L.doorSpeed_4) (L.L.doorDragAcc_4) (L.S.Timegap) * + (S.L.doorSpeed_4)
						{else}
							(L.L.doorSpeed_4) (L.L.doorAcc_4) (L.S.Timegap) * + (S.L.doorSpeed_4)
						{endif}
					{else}
						(L.L.doorEntriegelung_45)
						{if}
							(L.L.doorSpeed_4) (L.L.doorDragAcc_4) (L.S.Timegap) * - (S.L.doorSpeed_4)
						{else}
							(L.L.doorSpeed_4) (L.L.doorAcc_4) (L.S.Timegap) * - (S.L.doorSpeed_4)
						{endif}
					{endif}
					(L.L.door_4) (L.L.doorSpeed_4) (L.S.Timegap) * + (S.L.door_4)
				{endif}
			{else}
				0 (S.L.doorSpeed_4)
			{endif}
		{endif}
		(L.L.elec_busbar_Rinv_summe)
			(L.L.doorSpeed_4) abs (C.L.door_Rinv) * +
		(S.L.elec_busbar_Rinv_summe)
	    {else}
		0 (S.L.doorSpeed_4)
	    {endif}

	(L.L.door_4) 1 >
	{if}
		(L.L.vis_doortype_h_int) !
		{if}
			(L.L.doorEntriegelung_45) !
			{if}
				(T.L.ev_doorhitopen_4)
			{endif}
		{else}
			(L.L.vis_doortype_h_int) 1 =
			{if}
				(L.L.doorEntriegelung_45) !
				{if}
					(T.L.ev_doorhitopen_4_schieb)
				{endif}
			{else}
				(L.L.doorEntriegelung_45) !
				{if}
					(T.L.ev_doorhitopen_4_schwenk)
				{endif}	
			{endif}
		{endif}
		1 (S.L.door_4)
		(L.L.doorSpeed_4) /-/ (L.L.doorRefl_4) * (S.L.doorSpeed_4)
	{else}
		(L.L.door_4) 0 <
		{if}
			(L.L.vis_doortype_h_int) !
			{if}
				(L.L.doorEntriegelung_45) !
				{if}
					(T.L.ev_doorhitclose_4)
				{endif}
			{else}
				(L.L.vis_doortype_h_int) 1 =
				{if}
					(L.L.doorEntriegelung_45) !
					{if}
						(T.L.ev_doorhitclose_4_schieb)
					{endif}
				{else}
					(L.L.doorEntriegelung_45) !
					{if}
						(T.L.ev_doorhitclose_4_schwenk)
					{endif}
				{endif}
			{endif}
			0 (S.L.door_4)
			(L.L.doorSpeed_4) /-/ (L.L.doorRefl_4) * (S.L.doorSpeed_4)
		{endif}
	{endif}
	(L.L.door_4) (F.L.door_klappe) (S.L.door_4_klappe)
	(L.L.door_4) (F.L.door_stange) (S.L.door_4_stange)
	(L.L.door_4) (F.L.door_schiebe) (S.L.door_4_schiebe)
	(L.L.door_4) (F.L.door_trapez_v) (S.L.door_4_trapez)
{end}

{macro:Door5_Calc}
	
	    (L.L.doorEntriegelung_doorActive_45)
		(L.L.doorEntriegelung_45) ||
	    {if}
		(L.L.doortarget_45)
		{if}
			(L.L.vis_doortype_h_int) 1 =
			{if}
				(L.L.door_5) (F.L.door_5_opn_speed_schiebe) (S.L.doorMaxSpeed_5)
			{else}
				(L.L.vis_doortype_h_int) 2 =
				{if}
					(L.L.door_5) (F.L.door_5_opn_speed_schwenk) (S.L.doorMaxSpeed_5)
				{else}
					(L.L.door_5) (F.L.door_5_opn_speed) (S.L.doorMaxSpeed_5)
				{endif}
			{endif}
		{else}
			(L.L.vis_doortype_h_int) 1 =
			{if}
				(L.L.door_5) (F.L.door_5_cls_speed_schiebe) (S.L.doorMaxSpeed_5)
			{else}
				(L.L.vis_doortype_h_int) 2 =
				{if}
					(L.L.door_5) (F.L.door_5_cls_speed_schwenk) (S.L.doorMaxSpeed_5)
				{else}
					(L.L.door_5) (F.L.door_5_cls_speed) (S.L.doorMaxSpeed_5)
				{endif}
			{endif}
		{endif}

		(L.L.vis_doortype_h_int) 2 =
		{if}
			(C.L.bdoor_acc_schwenk) (S.L.doorAcc_5)
		{else}
			(C.L.bdoor_acc) (S.L.doorAcc_5)
		{endif}

		(L.L.doortarget_45) ! (L.L.doorSpeed_5) s0 abs 0.05 > (L.L.door_5) 0 > || && 
		(L.L.doorEntriegelung_45) ||
		{if}
'			(L.L.door_5_hub) 0.8 >
			(L.L.vis_doortype_h_int) ! ||
			(L.L.vis_doortype_h_int) 1 = ||
			{if}
				l0 /-/ (L.L.doorMaxSpeed_5) <
				{if}
					(L.L.doorEntriegelung_45)
					{if}
						(L.L.doorSpeed_5) (L.L.doorDragAcc_5) (L.S.Timegap) * - (S.L.doorSpeed_5)
					{else}
						(L.L.doorSpeed_5) (L.L.doorAcc_5) (L.S.Timegap) * - (S.L.doorSpeed_5)
					{endif}
				{else}
					(L.L.doorEntriegelung_45)
					{if}
						(L.L.doorSpeed_5) (L.L.doorDragAcc_5) (L.S.Timegap) * + (S.L.doorSpeed_5)
					{else}
						(L.L.doorSpeed_5) (L.L.doorAcc_5) (L.S.Timegap) * + (S.L.doorSpeed_5)
					{endif}
				{endif}
				(L.L.door_5) (L.L.doorSpeed_5) (L.S.Timegap) * + (S.L.door_5)
			{endif}
		{else}
			(L.L.doorSpeed_5) abs 0.05 > (L.L.door_5) 1 < || (L.L.doortarget_45) &&
			(L.L.doorEntriegelung_45) ||
			{if}
'				(L.L.door_5_hub) 0.5 >
				(L.L.vis_doortype_h_int) ! ||
				(L.L.vis_doortype_h_int) 1 = ||
				{if}
					l0 (L.L.doorMaxSpeed_5) <
					{if}
						(L.L.doorEntriegelung_45)
						{if}
							(L.L.doorSpeed_5) (L.L.doorDragAcc_5) (L.S.Timegap) * + (S.L.doorSpeed_5)
						{else}
							(L.L.doorSpeed_5) (L.L.doorAcc_5) (L.S.Timegap) * + (S.L.doorSpeed_5)
						{endif}  
					{else}
						(L.L.doorEntriegelung_45)
						{if}
							(L.L.doorSpeed_5) (L.L.doorDragAcc_5) (L.S.Timegap) * - (S.L.doorSpeed_5)
						{else}
							(L.L.doorSpeed_5) (L.L.doorAcc_5) (L.S.Timegap) * - (S.L.doorSpeed_5)
						{endif} 
					{endif}
					(L.L.door_5) (L.L.doorSpeed_5) (L.S.Timegap) * + (S.L.door_5)
				{endif}
			{else}
				0 (S.L.doorSpeed_5)
			{endif}
		{endif}
		(L.L.elec_busbar_Rinv_summe)
			(L.L.doorSpeed_5) abs (C.L.door_Rinv) * +
		(S.L.elec_busbar_Rinv_summe)
	    {else}
		0 (S.L.doorSpeed_5)
	    {endif}

	(L.L.door_5) 1 >
	{if}
		(L.L.vis_doortype_h_int) !
		{if}
			(L.L.doorEntriegelung_45) !
			{if}
				(T.L.ev_doorhitopen_5)
			{endif}
		{else}
			(L.L.vis_doortype_h_int) 1 =
			{if}
				(L.L.doorEntriegelung_45) !
				{if}
					(T.L.ev_doorhitopen_5_schieb)
				{endif}
			{else}
				(L.L.doorEntriegelung_45) !
				{if}
					(T.L.ev_doorhitopen_5_schwenk)
				{endif}	
			{endif}
		{endif}
		1 (S.L.door_5)
		(L.L.doorSpeed_5) /-/ (L.L.doorRefl_5) * (S.L.doorSpeed_5)
	{else}
		(L.L.door_5) 0 <
		{if}
			(L.L.vis_doortype_h_int) !
			{if}
				(L.L.doorEntriegelung_45) !
				{if}
					(T.L.ev_doorhitclose_5)
				{endif}
			{else}
				(L.L.vis_doortype_h_int) 1 =
				{if}
					(L.L.doorEntriegelung_45) !
					{if}
						(T.L.ev_doorhitclose_5_schieb)
					{endif}
				{else}
					(L.L.doorEntriegelung_45) !
					{if}
						(T.L.ev_doorhitclose_5_schwenk)
					{endif}
				{endif}
			{endif}
			0 (S.L.door_5)
			(L.L.doorSpeed_5) /-/ (L.L.doorRefl_5) * (S.L.doorSpeed_5)
		{endif}
	{endif}
	(L.L.door_5) (F.L.door_klappe) (S.L.door_5_klappe)
	(L.L.door_5) (F.L.door_stange) (S.L.door_5_stange)
	(L.L.door_5) (F.L.door_schiebe) (S.L.door_5_schiebe)
	(L.L.door_5) (F.L.door_trapez_h) (S.L.door_5_trapez)
{end}


'###############################################################################################

{macro:trg_bus_doorfront0}

	(L.L.doorEntriegelung_E_active_01) (C.L.electric_doors) && !
	(L.L.doorEntriegelung_01) ||
	(L.L.Door_leaf_lock_anim_up) ! &&
	{if}
		(L.L.doortarget_0) ! (S.L.doortarget_0) 
		{if}
			(L.L.vis_doortype_v_int) !
			{if}
				(L.L.doorEntriegelung_01) !
				{if}
					(T.L.ev_doortriggeropen_0)
				{endif}
			{else}
				(L.L.vis_doortype_v_int) 1 =
				{if}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doortriggeropen_0_schieb)
					{endif}
				{else}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doortriggeropen_0_schwenk)
					{endif}
				{endif}
			{endif}
		{else}
			(L.L.vis_doortype_v_int) !
			{if}
				(L.L.doorEntriegelung_01) !
				{if}
					(T.L.ev_doortriggerclose_0)
				{endif}
			{else}
				(L.L.vis_doortype_v_int) 1 =
				{if}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doortriggerclose_0_schieb)
					{endif}
				{else}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doortriggerclose_0_schwenk)
					{endif}
				{endif}
			{endif}
		{endif}
		(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
		1 (S.L.doorEntriegelung_doorActive_01)
	{endif}
{end}

{macro:trg_bus_doorfront1}

	(L.L.doorEntriegelung_E_active_01) (C.L.electric_doors) && !
	(L.L.doorEntriegelung_01) ||
	(L.L.Door_leaf_lock_anim_dn) ! &&
	{if}
		(L.L.doortarget_1) ! (S.L.doortarget_1) 
		{if}
			(L.L.vis_doortype_v_int) !
			{if}
				(L.L.doorEntriegelung_01) !
				{if}
					(T.L.ev_doortriggeropen_0)
				{endif}
			{else}
				(L.L.vis_doortype_v_int) 1 =
				{if}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doortriggeropen_0_schieb)
					{endif}
				{else}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doortriggeropen_0_schwenk)
					{endif}
				{endif}
			{endif}
		{else}
			(L.L.vis_doortype_v_int) !
			{if}
				(L.L.doorEntriegelung_01) !
				{if}
					(T.L.ev_doortriggerclose_0)
				{endif}
			{else}
				(L.L.vis_doortype_v_int) 1 =
				{if}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doortriggerclose_0_schieb)
					{endif}
				{else}
					(L.L.doorEntriegelung_01) !
					{if}
						(T.L.ev_doortriggerclose_0_schwenk)
					{endif}
				{endif}
			{endif}
		{endif}	
		(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
		1 (S.L.doorEntriegelung_doorActive_01)
	{endif}
{end}

{macro:trg_bus_dooraft23}

	(L.L.doorEntriegelung_E_active_23) (C.L.electric_doors) && !
	(L.L.doorEntriegelung_23) ||
	(L.L.bremse_halte) &&
	(L.L.bremse_p_tank04) 550000 > &&
	{if}
		(L.L.doortarget_23) !
		{if}
			1 (S.L.doortarget_23)
			(L.L.doorEntriegelung_23) !
			{if}
				(L.L.vis_doortype_h_int) !
				{if}
					(T.L.ev_doortriggeropen_2)
				{else}
					(L.L.vis_doortype_h_int) 1 =
					{if}
						(T.L.ev_doortriggeropen_2_schieb)
					{else}
						(T.L.ev_doortriggeropen_2_schwenk)
					{endif}
				{endif}
			{endif}
		{else}
			(L.L.cockpit_tuertaster2_frame) !
			{if}
				0 (S.L.doortarget_23)
				(L.L.doorEntriegelung_23) !
				{if}
					(L.L.vis_doortype_h_int) !
					{if}
						(T.L.ev_doortriggerclose_2)
					{else}
						(L.L.vis_doortype_h_int) 1 =
						{if}
							(T.L.ev_doortriggerclose_2_schieb)
						{else}
							(T.L.ev_doortriggerclose_2_schwenk)
						{endif}
					{endif}
				{endif}
			{endif}
		{endif}
			(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
			1 (S.L.doorEntriegelung_doorActive_23)
	{endif}
{end}

{macro:trg_bus_dooraft45}

	(L.L.doorEntriegelung_E_active_45) (C.L.electric_doors) && !
	(L.L.doorEntriegelung_45) ||
	(L.L.bremse_halte) &&
	(L.L.bremse_p_tank04) 550000 > &&
	{if}
		(L.L.doortarget_45) !
		{if}
			1 (S.L.doortarget_45)
			(L.L.doorEntriegelung_45) !
			{if}
				(L.L.vis_doortype_h_int) !
				{if}
					(T.L.ev_doortriggeropen_4)
				{else}
					(L.L.vis_doortype_h_int) 1 =
					{if}
						(T.L.ev_doortriggeropen_4_schieb)
					{else}
						(T.L.ev_doortriggeropen_4_schwenk)
					{endif}
				{endif}
			{endif}
		{else}
			(L.L.cockpit_tuertaster3_frame) !
			{if}
				0 (S.L.doortarget_45)
				(L.L.doorEntriegelung_45) !
				{if}
					(L.L.vis_doortype_h_int) !
					{if}
						(T.L.ev_doortriggerclose_4)
					{else}
						(L.L.vis_doortype_h_int) 1 =
						{if}
							(T.L.ev_doortriggerclose_4_schieb)
						{else}
							(T.L.ev_doortriggerclose_4_schwenk)
						{endif}
					{endif}
				{endif}
			{endif}
		{endif}
			(L.L.bremse_p_Tank04) 50000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
			1 (S.L.doorEntriegelung_doorActive_45)
	{endif}
{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}
