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

'Controls Doors

'(c) 2007-2009 Rüdiger Hülsmann
'(c) 2007-2009 Marcel Kuhnt

'Script Version: 1.1
'Omsi release: 1.0

'Needs:
'- elec

'Revision History:
'- Marcel Kuhnt		13.06.2009	Batterietrennschalter => elec_busbar_main
'- Marcel Kuhnt		21.06.2009	AI-Unterstützung hinzugefügt	
'- Rüdiger Hülsmann	24.10.2009	Ansteuerung des Kinderwagenwunsches modifiziert
'- Rüdiger Hülsmann	19.12.2009	Timer für Ausstiegstür jetzt Timegap-basiert, Bugfix: Tür schließt jetzt nur bei elec_busbar=1
'- RÜdiger Hülsmann	22.09.2010	Door light trigger value set to 0.1
'- RÜdiger Hülsmann	07.11.2010	Door speed based on reservoir pressure, air-operated doors made an option
'- Marcel Kuhnt		08.11.2010	AI procedure closing doors debugged
'- Rüdiger Hülsmann	21.11.2010	Front doors only operable when busbar on
'- Rüdiger Hülsmann	23.12.2010	External front door operation included, option: doors only operable with actual stop brake
'- Rüdiger Hülsmann	31.12.2010	Electric door function debugged
'- Rüdiger Hülsmann	05.01.2011	20h-switch
'- Rüdiger Hülsmann	07.01.2011	Backdoor manual switch sound debugged, 20h switch depending on bus type
'- Rüdiger Hülsmann	19.01.2011	Electric door support
'- Rüdiger Hülsmann	19.01.2011	Electric door support
'- Morozov Maxim	----------	Removed automatical back door. Added ramp animation... etc...
'- Alexey Vasiliev	09.03.2012	Added more doors for Citaro "Private Edition"
'- Ñåðãåé Wizard	14.11.2013	Added automatical back doors. Rework dooraft for citaro 3door
'- Alexey Vasiliev	13.12.2013	Added 4 door for Citaro G
'- Marcos Zane      02.06.2019  Trava de portas para ambos os lados e anjo da guarda
'- Marcos Zane      16.07.2020  Six-door animation and independent action for each door part
'- RedJoker	    10.11.2025  Anti repeat of turniket when a passenger stands on the pathpoint
'--------------------------------------------------------------------------------

{trigger:bus_doorfront0}
    (L.L.door_switch_sides_sw) 0 =
	{if}
        (L.L.door_anjo_da_guarda_off)
        {if}
		    (M.L.trg_bus_doorfront01)
            (L.L.cockpit_tuertaster1) ! (S.L.cockpit_tuertaster1)
        {endif}
    {else}
        (M.L.trg_bus_doorfront23)
        (L.L.cockpit_tuertaster4) ! (S.L.cockpit_tuertaster4)
	{endif}
{end}

{trigger:bus_doorfront0_off}
    (L.L.door_anjo_da_guarda_off) !
    {if}
	    0 (S.L.cockpit_tuertaster1) (S.L.cockpit_tuertaster4)
    {endif}
{end}

{trigger:bus_doorfront1}
	(L.L.door_anjo_da_guarda_off)
    {if}
        (L.L.door_switch_sides_sw) 0 =
	    {if}
	    	(M.L.trg_bus_doorfront45)
            (L.L.cockpit_tuertaster2) ! (S.L.cockpit_tuertaster2)
        {else}
            (M.L.trg_bus_doorfront67)
            (L.L.cockpit_tuertaster5) ! (S.L.cockpit_tuertaster5)
	    {endif}
    {endif}
{end}

{trigger:bus_doorfront1_off}
    (L.L.door_anjo_da_guarda_off) !
    {if}
    	0 (S.L.cockpit_tuertaster2) (S.L.cockpit_tuertaster5)
    {endif}
{end}

{trigger:bus_doorfront2}
	(L.L.door_anjo_da_guarda_off)
    {if}
        (L.L.door_switch_sides_sw) 0 =
	    {if}
	    	(M.L.trg_bus_doorfront89)
            (L.L.cockpit_tuertaster3) ! (S.L.cockpit_tuertaster3)
        {else}
            (M.L.trg_bus_doorfront10_11)
            (L.L.cockpit_tuertaster6) ! (S.L.cockpit_tuertaster6)
	    {endif}
    {endif}
{end}

{trigger:bus_doorfront2_off}
    (L.L.door_anjo_da_guarda_off) !
    {if}
	    0 (S.L.cockpit_tuertaster3) (S.L.cockpit_tuertaster6)
    {endif}
{end}

{trigger:door_switch_sides}
	(M.L.trg_bus_dooraft)
{end}

{trigger:bus_dooraft}
	(M.L.trg_bus_dooraft)
{end}

'{trigger:bus_20h-switch}
'	(L.L.elec_busbar_avail)
'	{if}
'		(M.L.trg_bus_doorfront0)
'		(M.L.trg_bus_doorfront2)
'		(M.L.trg_bus_doorfront4)
'	{endif}
'	1 (S.L.cockpit_tuertaster1)
'	1 (S.L.cockpit_tuertaster2)
'	1 (S.L.cockpit_tuertaster3)
'	 
'{end}

{trigger:door_stop_request_reject}	
        1 (S.L.door_stoprequest_reject)
        (T.L.ev_kippschalter_ein)

            (L.L.elec_busbar_main)
	        {if}
			    0 (S.L.haltewunschlampe) (S.L.haltewunsch)
		    {endif}
{end}

{trigger:door_stop_request_reject_off}	
    0 (S.L.door_stoprequest_reject)
    (T.L.ev_kippschalter_aus)
{end}

{trigger:int_haltewunsch}
	1 (S.L.haltewunsch)
{end}

{trigger:door_haltewunsch}
	1 (S.L.haltewunsch) (S.L.door_haltewunsch_knopfdruck)
{end}

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

{trigger:cp_schalter_kinderwagen}
	(L.L.door_handsteuerung) ! (S.L.door_handsteuerung)
	{if}
		0 (S.L.door_kinderwagenwunsch)
		(T.L.ev_kippschalter_ein)
	{else}
		(T.L.ev_kippschalter_aus)
	{endif}
		
{end}

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

{trigger:door0_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_0) + 1 min 0 max (S.L.doorDragAcc_0)
{end}

{trigger:door1_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_1) + 1 min 0 max (S.L.doorDragAcc_1)
{end}

{trigger:door2_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_2) + 1 min 0 max (S.L.doorDragAcc_2)
{end}

{trigger:door3_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_3) + 1 min 0 max (S.L.doorDragAcc_3)
{end}

{trigger:door4_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_4) + 1 min 0 max (S.L.doorDragAcc_4)
{end}

{trigger:door5_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_5) + 1 min 0 max (S.L.doorDragAcc_5)
{end}

{trigger:door6_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_6) + 1 min 0 max (S.L.doorDragAcc_6)
{end}

{trigger:door7_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_7) + 1 min 0 max (S.L.doorDragAcc_7)
{end}

{trigger:door8_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_8) + 1 min 0 max (S.L.doorDragAcc_8)
{end}

{trigger:door9_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_9) + 1 min 0 max (S.L.doorDragAcc_9)
{end}

{trigger:door10_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_10) + 1 min 0 max (S.L.doorDragAcc_10)
{end}

{trigger:door11_drag}
	(L.S.mouse_x) -400 / (L.L.doorDragAcc_11) + 1 min 0 max (S.L.doorDragAcc_11)
{end}


{macro:Door_Init}
	1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.fdoor_acc) + (S.L.doorAcc_0)
	1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.fdoor_acc) + (S.L.doorAcc_1)
	1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_2)
	1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_3)	
	1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_4)
	1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_5)
	1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_6)
	1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_7)
    1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_8)
    1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_9)
    1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_10)
    1000 random 500 / 1 - (C.L.door_acc_var) * (C.L.bdoor_acc) + (S.L.doorAcc_11)
	
	
	1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.fdoor_maxspeed) + (S.L.doorMaxSpeed_0_norm)
	1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.fdoor_maxspeed) + (S.L.doorMaxSpeed_1_norm)
	1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_2_norm)
	1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_3_norm)	
	1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_4_norm)
	1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_5_norm)	
	1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_6_norm)
	1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_7_norm)
    1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_8_norm)
    1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_9_norm)
    1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_10_norm)
    1000 random 500 / 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_11_norm)
	
	(C.L.door_refl) (S.L.doorRefl_0)
	(C.L.door_refl) (S.L.doorRefl_1)
	(C.L.door_refl) (S.L.doorRefl_2)
	(C.L.door_refl) (S.L.doorRefl_3)
	(C.L.door_refl) (S.L.doorRefl_4)
	(C.L.door_refl) (S.L.doorRefl_5)
	(C.L.door_refl) (S.L.doorRefl_6)
	(C.L.door_refl) (S.L.doorRefl_7)
    (C.L.door_refl) (S.L.doorRefl_8)
    (C.L.door_refl) (S.L.doorRefl_9)
    (C.L.door_refl) (S.L.doorRefl_10)
    (C.L.door_refl) (S.L.doorRefl_11)
    "0000" (S.$.mep_totalpassageiroscatracadosStr)
	
{end}

{macro:Door_Frame}

	(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)
	(M.L.Door6_Calc)
	(M.L.Door7_Calc)
    (M.L.Door8_Calc)
    (M.L.Door9_Calc)
'   (M.L.Door10_Calc)
'    (M.L.Door11_Calc)

'   Pax entry/exit control
	(L.L.door_0) 0.9 > (L.L.door_1) 0.9 > && (S.L.PAX_Entry0_Open) (S.L.PAX_Entry1_Open)
    (L.L.door_2) 0.9 > (L.L.door_3) 0.9 > && (S.L.PAX_Entry2_Open) 
	(L.L.door_4) 0.9 > (L.L.door_5) 0.9 > && (S.L.PAX_Exit0_Open) (S.L.PAX_Exit1_Open)
    (L.L.door_6) 0.9 > (L.L.door_7) 0.9 > && (S.L.PAX_Exit4_Open) (S.L.PAX_Exit5_Open)
    (L.L.door_8) 0.9 > (L.L.door_9) 0.9 > && (S.L.PAX_Exit2_Open) (S.L.PAX_Exit3_Open)

'   Door open indicator
    (L.L.doorTarget_01)
    (L.L.doorTarget_23) ||
    (L.L.doorTarget_45) ||
    (L.L.doorTarget_67) ||
    (L.L.doorTarget_89) ||
    (L.L.doorTarget_10_11) ||
    (S.L.door_indicator_open)



	(M.L.askp)
	13 (M.V.GetHumanCountOnPathLink)
		{if}
		0 (L.L.askp_anti_repeat) = 
		{if}
			1 (S.L.askp_full_anim)
			1 (S.L.askp_anti_repeat)
		{endif}
	{else}
	0 (S.L.askp_anti_repeat)
	{endif}


'   (M.L.askp_2)
'	20 (M.V.GetHumanCountOnPathLink)
'	{if}
'		1 (S.L.askp_full_anim_2)
'	{endif}


'	"Dauerfeuer"-Haltewunsch über Kinderwagenschalter (macht genau dasselbe wie der "trigger:int_haltewunsch"):
	(L.L.door_handsteuerung) (L.L.door_haltewunsch_knopfdruck) ||
	{if}
		1 (S.L.haltewunsch)
	{endif}

'	Setting the stop brake only when the bus is at a standstill:
	(L.L.bremse_halte_sw) (L.L.door_20h_sw) ||
	(L.L.bremse_halte) ! (L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) < && &&
'	(C.L.HST_Bremse_aktiv) &&
	{if}
		(L.L.elec_busbar_main)
		{if}
			(T.L.ev_haltebremse_an)		
			1 (S.L.bremse_halte)
		{endif}
	{endif}

'	(M.L.DoorAft_Open)

'	Türfreigabekriterium

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

'   Door Velocity lock
	(C.L.Door_anjo_da_guarda)
    (L.L.Velocity) (C.L.Tueroeffnung) < &&
    (L.L.cp_limiters_off) ||
    {if}
        1 (S.L.door_anjo_da_guarda_off)
    {else}
        0 (S.L.door_anjo_da_guarda_off)
    {endif}

'	Haltewunschlampe:
	(L.L.haltewunsch) 
    (L.L.door_4) 0.2 < &&
    (L.L.door_6) 0.2 < &&
    (L.L.door_8) 0.2 < &&
    (L.L.door_10) 0.2 < &&
    (L.L.elec_busbar_main) &&
	{if}
		1 (S.L.haltewunschlampe)
	{else}
		0 (S.L.haltewunschlampe) (S.L.haltewunsch)
	{endif}


    (L.L.doorTarget_45)
    (L.L.doorTarget_67) ||
    (L.L.doorTarget_89) ||
    (L.L.doorTarget_10_11) ||
    (L.L.haltewunsch) 0 = &&
    (L.L.haltewunsch_timer) 0 = &&
    (L.L.elec_busbar_main) &&
    {if}
        1 (S.L.door_pax_exited)
        (L.L.haltewunsch_timer) 1 + (S.L.haltewunsch_timer)
    {else}
        (L.L.doorTarget_45) 0 =
        (L.L.doorTarget_67) 0 = &&
        (L.L.doorTarget_89) 0 = &&
        (L.L.doorTarget_10_11) 0 = &&
        (L.L.haltewunsch_timer) 0 > &&
        (L.L.elec_busbar_main) ! ||
        {if}
            0 (S.L.door_pax_exited) (S.L.haltewunsch_timer)
        {endif}
    {endif}

'    (L.L.door_4)
'    (L.L.door_6) ||
'    (L.L.door_8) ||
'    (L.L.door_10) ||
'    (L.L.elec_busbar_main) &&
'    (L.L.haltewunsch) 0 = &&
'    {if}
'        1 (S.L.door_pax_exited)
'    {else}
'        0 (S.L.door_pax_exited)
'    {endif}

'	Abfall des Kinderwagenwunsch-Relais bei fehlender Stromversorgung:

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

'	Druckabhängige Türgeschwindigkeit
	
	(C.L.door_druckluft)
	{if}
		(L.L.doorMaxSpeed_0_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_0)
		(L.L.doorMaxSpeed_1_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_1)
		(L.L.doorMaxSpeed_2_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_2)
		(L.L.doorMaxSpeed_3_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_3)		
		(L.L.doorMaxSpeed_4_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_4)
		(L.L.doorMaxSpeed_5_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_5)		
		(L.L.doorMaxSpeed_6_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_6)
		(L.L.doorMaxSpeed_7_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_7)
        (L.L.doorMaxSpeed_8_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_8)
        (L.L.doorMaxSpeed_9_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_9)
        (L.L.doorMaxSpeed_10_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_10)
        (L.L.doorMaxSpeed_11_norm) (L.L.bremse_p_Tank04) 100000 - 850000 / (S.L.doorMaxSpeed_11)
	{endif}
'----------------------
'	AI process:

    (L.L.AI_Scheduled_AtStation) s0
    1 =
    {if}
'   If doors are to be closed:
	    (L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) <
	    {if}
'       Only if v <maxkmh, otherwise wait
'       Only press the button if not already on
	    	(L.L.bremse_halte_sw) !
	    	{if}
	    		(M.L.trg_bus_bremse_halte)
	    	{endif}
	    	(L.L.doorTarget_01) ! (L.L.door_AI_timer) 0.3 > &&
	    	{if}
	    		(M.L.trg_bus_doorfront01)
	    	{endif}
	    	(L.L.doorTarget_45) ! (L.L.door_AI_timer) 0.6 > (L.L.haltewunsch) && &&
	    	{if}
	    		(M.L.trg_bus_doorfront45)
	    	{endif}
	    	(L.L.doorTarget_67) ! (L.L.door_AI_timer) 0.6 > (L.L.haltewunsch) && &&
	    	{if}
	    		(M.L.trg_bus_doorfront67)
	    	{endif}
	    	(L.L.doorTarget_89) ! (L.L.door_AI_timer) 0.6 > (L.L.haltewunsch) && &&
	    	{if}
	    		(M.L.trg_bus_doorfront89)
	    	{endif}
	    	(L.L.doorTarget_10_11) ! (L.L.door_AI_timer) 0.6 > (L.L.haltewunsch) && &&
	    	{if}
	    		(M.L.trg_bus_doorfront10_11)
	    	{endif}
	    {else}
	    	0 (S.L.door_AI_timer)
	    {endif}
	    (L.L.door_AI_timer) (L.S.Timegap) + (S.L.door_AI_timer)
    {else}
        l0 -1 =
        {if}
'           If doors are to be closed:
'           Only press the button if not already off:
	        (L.L.doorTarget_01)
	        {if}
	        	(M.L.trg_bus_doorfront01)
	        	0 (S.L.door_AI_timer)
	        {endif}
	        (L.L.doorTarget_01) (L.L.door_AI_timer) 0.3 > &&
	        {if}
	        	(M.L.trg_bus_doorfront01)
	        {endif}
	        (L.L.doorTarget_23) (L.L.door_AI_timer) 0.3 > &&
	        {if}
	        	(M.L.trg_bus_doorfront23)
	        {endif}
	        (L.L.doorTarget_45) (L.L.door_AI_timer) 0.3 > &&
	        {if}
	        	(M.L.trg_bus_doorfront45)
	        {endif}
	        (L.L.doorTarget_67) (L.L.door_AI_timer) 0.3 > &&
	        {if}
	        	(M.L.trg_bus_doorfront67)
	        {endif}
            (L.L.doorTarget_89) (L.L.door_AI_timer) 0.3 > &&
	        {if}
	        	(M.L.trg_bus_doorfront89)
	        {endif}

'           Only remove the stop brake when all doors are closed. Then also release the bus according to AI:
	        (L.L.door_0) 0.1 <
	        (L.L.door_1) 0.1 < &&
	        (L.L.door_2) 0.1 < &&	
            (L.L.door_3) 0.1 < &&
	        (L.L.door_4) 0.1 < &&
	        (L.L.door_5) 0.1 < &&	
	        (L.L.door_6) 0.1 < &&
	        (L.L.door_7) 0.1 < &&
	        {if}
	        	(L.L.bremse_halte_sw) (L.L.door_AI_timer) 0.3 > &&
	        	{if}
	        		(M.L.trg_bus_bremse_halte)
	        	{endif}
	        	(L.L.bremse_halte_sw) !
	        	{if}
	        		0 (S.L.AI_Scheduled_AtStation)
	        	{endif}
	        {else}
'           If one of the doors is open and the stop brake is off, apply it immediately
		        (L.L.bremse_halte_sw) !
		        {if}
		        	(M.L.trg_bus_bremse_halte)
		        {endif}
		        (L.L.doorTarget_01) !
		        (L.L.doorTarget_23) ! &&
		        (L.L.doorTarget_45) ! &&
		        (L.L.doorTarget_67) ! &&
		        (L.L.doorTarget_89) ! &&
                (L.L.doorTarget_10_11) ! &&
		        {if}
		        	0 (S.L.door_AI_timer)
		        {endif}
	        {endif}
	        (L.L.door_AI_timer) (L.S.Timegap) + (S.L.door_AI_timer)
        {endif}
    {endif}
'----------------------
{end}

{macro:askp}

	(L.L.askp_full_anim) (L.L.elec_busbar_main) && (S.L.askp_green_light)
	
	(L.L.askp_full_anim) ! (L.L.elec_busbar_main) && (S.L.askp_red_light)
	
	(L.L.askp_full_anim)
	{if}
		(L.L.askp_rot) 120		<
		{if}
			(L.L.askp_rot) (L.S.Timegap) 240 * + (S.L.askp_rot)
		{else}
			0 (S.L.askp_rot) (S.L.askp_full_anim)
		{endif}
	{endif}
	
	(L.L.askp_full_anim) (L.L.askp_full_anim_last) ! &&
	{if}
	
		(L.L.mep_totalpassageiroscatracados) 1 + (S.L.mep_totalpassageiroscatracados)
		(L.L.mep_totalpassageiroscatracados) $IntToStr (S.$.mep_totalpassageiroscatracadosStr)
			
		(T.L.ev_turniket)
	{endif}
	
	(L.L.askp_full_anim) (S.L.askp_full_anim_last)
{end}


{macro:askp_2}

	(L.L.askp_full_anim_2) (L.L.elec_busbar_main) && (S.L.askp_green_light_2)
	
	(L.L.askp_full_anim_2) ! (L.L.elec_busbar_main) && (S.L.askp_red_light_2)
	
	(L.L.askp_full_anim_2)
	{if}
		(L.L.askp_rot_2) 120 <
		{if}
			(L.L.askp_rot_2) (L.S.Timegap) 240 * + (S.L.askp_rot_2)
		{else}
			0 (S.L.askp_rot_2) (S.L.askp_full_anim_2)
		{endif}
	{endif}
	
	(L.L.askp_full_anim_2) (L.L.askp_full_anim_last_2) ! &&
	{if}
		(L.L.mep_totalpassageiroscatracados) 1 + (S.L.mep_totalpassageiroscatracados)
		(L.L.mep_totalpassageiroscatracados) $IntToStr (S.$.mep_totalpassageiroscatracadosStr)	
		(T.L.ev_turniket)
	{endif}
	
	(L.L.askp_full_anim_2) (S.L.askp_full_anim_last_2)
{end}


'-----------------------------
' DOOR 0 -------- 2 PARTS
'-----------------------------

{macro:Door0_Calc}

	(L.L.doorTarget_01)
	{if}
		(L.L.door_0) (F.L.door_0_opn_speed) (S.L.doorMaxSpeed_0)
	{else}
		(L.L.door_0) (F.L.door_0_cls_speed) (S.L.doorMaxSpeed_0)
	{endif}
	(C.L.fdoor_acc) (S.L.doorAcc_0)

	(C.L.electric_doors)
	{if}


		(L.L.doorTarget_01) ! (L.L.doorSpeed_0) s0 abs 0.05 > (L.L.door_0) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_0) <
			{if}
				(L.L.doorSpeed_0) (L.L.doorAcc_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}
			(L.L.door_0) (L.L.doorSpeed_0) (L.S.Timegap) * + (S.L.door_0)
		{else}
			(L.L.doorSpeed_0) abs 0.05 > (L.L.door_0) 1 < || (L.L.doorTarget_01) &&
			{if}
				l0 (L.L.doorMaxSpeed_0) <
				{if}
					(L.L.doorSpeed_0) (L.L.doorAcc_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}
				(L.L.door_0) (L.L.doorSpeed_0) (L.S.Timegap) * + (S.L.door_0)
			{else}
				0 (S.L.doorSpeed_0)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_01) ! (L.L.doorSpeed_0) s0 abs 0.05 > (L.L.door_0) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_0) <
			{if}
				(L.L.doorSpeed_0) (L.L.doorAcc_0) (L.S.Timegap) * - (S.L.doorSpeed_0)
			{endif}
			(L.L.door_0) (L.L.doorSpeed_0) (L.S.Timegap) * + (S.L.door_0)
		{else}
			(L.L.doorSpeed_0) abs 0.05 > (L.L.door_0) 1 < || (L.L.doorTarget_01) &&
			{if}
				l0 (L.L.doorMaxSpeed_0) <
				{if}
					(L.L.doorSpeed_0) (L.L.doorAcc_0) (L.S.Timegap) * + (S.L.doorSpeed_0) 
				{endif}
				(L.L.door_0) (L.L.doorSpeed_0) (L.S.Timegap) * + (S.L.door_0)
			{else}
				0 (S.L.doorSpeed_0)
			{endif}
		{endif}
	{endif}

	(L.L.door_0) 1 >
	{if}
		(T.L.ev_doorhitopen_0)
		1 (S.L.door_0)
		(L.L.doorSpeed_0) /-/ (L.L.doorRefl_0) * (S.L.doorSpeed_0)
	{else}
		(L.L.door_0) 0 <
		{if}
			(T.L.ev_doorhitclose_0)
			0 (S.L.door_0)
			(L.L.doorSpeed_0) /-/ (L.L.doorRefl_0) * (S.L.doorSpeed_0)
		{endif}
	{endif}
{end}

{macro:Door1_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_01)
		{if}
			(L.L.door_1) (F.L.door_1_opn_speed) (S.L.doorMaxSpeed_1)
		{else}
			(L.L.door_1) (F.L.door_1_cls_speed) (S.L.doorMaxSpeed_1)
		{endif}

		(C.L.fdoor_acc) (S.L.doorAcc_1)

		(L.L.doorTarget_01) ! (L.L.doorSpeed_1) s0 abs 0.05 > (L.L.door_1) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_1) <
			{if}
				(L.L.doorSpeed_1) (L.L.doorAcc_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}
			(L.L.door_1) (L.L.doorSpeed_1) (L.S.Timegap) * + (S.L.door_1)
		{else}
			(L.L.doorSpeed_1) abs 0.05 > (L.L.door_1) 1 < || (L.L.doorTarget_01) &&
			{if}
				l0 (L.L.doorMaxSpeed_1) <
				{if}
					(L.L.doorSpeed_1) (L.L.doorAcc_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}
				(L.L.door_1) (L.L.doorSpeed_1) (L.S.Timegap) * + (S.L.door_1)
			{else}
				0 (S.L.doorSpeed_1)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_01) ! (L.L.doorSpeed_1) s0 abs 0.05 > (L.L.door_1) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_1) <
			{if}
				(L.L.doorSpeed_1) (L.L.doorAcc_1) (L.S.Timegap) * - (S.L.doorSpeed_1)
			{endif}
			(L.L.door_1) (L.L.doorSpeed_1) (L.S.Timegap) * + (S.L.door_1)
		{else}
			(L.L.doorSpeed_1) abs 0.05 > (L.L.door_1) 1 < || (L.L.doorTarget_01) &&
			{if}
				l0 (L.L.doorMaxSpeed_1) <
				{if}
					(L.L.doorSpeed_1) (L.L.doorAcc_1) (L.S.Timegap) * + (S.L.doorSpeed_1) 
				{endif}
				(L.L.door_1) (L.L.doorSpeed_1) (L.S.Timegap) * + (S.L.door_1)
			{else}
				0 (S.L.doorSpeed_1)
			{endif}
		{endif}
	{endif}
	(L.L.door_1) 1 >
	{if}
		(T.L.ev_doorhitopen_0)
		1 (S.L.door_1)
		(L.L.doorSpeed_1) /-/ (L.L.doorRefl_1) * (S.L.doorSpeed_1)
	{else}
		(L.L.door_1) 0 <
		{if}
			(T.L.ev_doorhitclose_0)
			0 (S.L.door_1)
			(L.L.doorSpeed_1) /-/ (L.L.doorRefl_1) * (S.L.doorSpeed_1)
		{endif}
	{endif}
{end}


{macro:DoorAftCalc}

	(L.L.bremse_halte_sw) !
	(L.L.door_0) 0.25 < &&
	(L.L.door_2) 0.25 < &&
	(L.L.door_5) 0.25 < &&
	(L.L.elec_busbar_main) ! ||
	(L.L.bremse_halte) &&
	{if}
		0 (S.L.bremse_halte) 
		0 (S.L.doorAftLastOpen) (S.L.doorAftLastOpen1)
		(T.L.ev_haltebremse_aus)
	{endif}


{end}

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


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

{macro:DoorAft_Open}
	
  	(L.L.PAX_Exit0_Req)
	(L.L.PAX_Exit1_Req) ||
	(L.L.bremse_halte) &&
   {if}
      (L.L.doorTarget_23) !
      (L.L.bremse_halte_sw) &&
      {if}
	(T.L.ev_doortriggeropen_2)
         1 (S.L.doorTarget_23)
         (C.L.door_druckluft)
         {if}
         (L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
         {endif}
      {endif}
      0 (S.L.doorAftLastOpen)      
   {endif}

	(L.L.PAX_Exit2_Req)
	(L.L.PAX_Exit3_Req) ||
	(L.L.bremse_halte) &&
   {if}
      (L.L.doorTarget_45) !
      (L.L.bremse_halte_sw) &&
      {if}
	(T.L.ev_doortriggeropen_5)
         1 (S.L.doorTarget_45)
         (C.L.door_druckluft)
         {if}
         (L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
         {endif}
      {endif}
      0 (S.L.doorAftLastOpen1)
   {endif}
   
   (L.L.PAX_Exit4_Req)
	(L.L.PAX_Exit5_Req) ||
	(L.L.bremse_halte) &&
   {if}
      (L.L.doorTarget_67) !
      (L.L.bremse_halte_sw) &&
      {if}
	(T.L.ev_doortriggeropen_6)
         1 (S.L.doorTarget_67)
         (C.L.door_druckluft)
         {if}
         (L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
         {endif}
      {endif}
      0 (S.L.doorAftLastOpen1)
   {endif}

    (L.L.elec_busbar_main)
	{if}
		(L.L.bremse_halte)
		{if}
			(L.L.doorAftLastOpen) (L.S.Timegap) + (S.L.doorAftLastOpen)
			(L.L.doorAftLastOpen1) (L.S.Timegap) + (S.L.doorAftLastOpen1)
		{endif}

		(L.L.doorTarget_23)
		(L.L.doorAftLastOpen) (C.L.doorAftOpenTime) > &&
		{if}
			(T.L.ev_doortriggerclose_2)
			0 (S.L.doorTarget_23)
			(C.L.door_druckluft)
			{if}
			(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
			{endif}
		{endif}
	{endif}

		(L.L.doorTarget_45)
		(L.L.doorAftLastOpen1) (C.L.doorAftOpenTime) > &&
		{if}
			(T.L.ev_doortriggerclose_5)
			0 (S.L.doorTarget_45)
			(C.L.door_druckluft)
			{if}
			(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
			{endif}
		{endif}
	{endif}
	
		(L.L.doorTarget_67)
		(L.L.doorAftLastOpen1) (C.L.doorAftOpenTime) > &&
		{if}
			(T.L.ev_doortriggerclose_6)
			0 (S.L.doorTarget_67)
			(C.L.door_druckluft)
			{if}
			(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
			{endif}
		{endif}
	{endif}

{end}

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

'-----------------------------
' DOOR 1 -------- 2 PARTS
'-----------------------------

{macro:Door2_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_23)
		{if}
			(L.L.door_2) (F.L.door_2_opn_speed) (S.L.doorMaxSpeed_2)
			(L.L.door_2) (F.L.door_2_opn_speed_2) (S.L.door_2)
		{else}
			(L.L.door_2) (F.L.door_2_cls_speed) (S.L.doorMaxSpeed_2)
			(L.L.door_2) (F.L.door_2_cls_speed_2) (S.L.door_2)
		{endif}

		(C.L.bdoor_acc) (S.L.doorAcc_2)

		(L.L.doorTarget_23) ! (L.L.doorSpeed_2) s0 abs 0.05 > (L.L.door_2) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_2) <
			{if}
				(L.L.doorSpeed_2) (L.L.doorAcc_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}
			(L.L.door_2) (L.L.doorSpeed_2) (L.S.Timegap) * + (S.L.door_2)
		{else}
			(L.L.doorSpeed_2) abs 0.05 > (L.L.door_2) 1 < || (L.L.doorTarget_23) &&
			{if}
				l0 (L.L.doorMaxSpeed_2) <
				{if}
					(L.L.doorSpeed_2) (L.L.doorAcc_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}
				(L.L.door_2) (L.L.doorSpeed_2) (L.S.Timegap) * + (S.L.door_2)
			{else}
				0 (S.L.doorSpeed_2)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_23) ! (L.L.doorSpeed_2) s0 abs 0.05 > (L.L.door_2) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_2) <
			{if}
				(L.L.doorSpeed_2) (L.L.doorAcc_2) (L.S.Timegap) * - (S.L.doorSpeed_2)
			{endif}
			(L.L.door_2) (L.L.doorSpeed_2) (L.S.Timegap) * + (S.L.door_2)
		{else}
			(L.L.doorSpeed_2) abs 0.05 > (L.L.door_2) 1 < || (L.L.doorTarget_23) &&
			{if}
				l0 (L.L.doorMaxSpeed_2) <
				{if}
					(L.L.doorSpeed_2) (L.L.doorAcc_2) (L.S.Timegap) * + (S.L.doorSpeed_2) 
				{endif}
				(L.L.door_2) (L.L.doorSpeed_2) (L.S.Timegap) * + (S.L.door_2)
			{else}
				0 (S.L.doorSpeed_2)
			{endif}
		{endif}
	{endif}

	(L.L.door_2) 1 >
	{if}
		(T.L.ev_doorhitopen_1)
		1 (S.L.door_2)
		(L.L.doorSpeed_2) /-/ (L.L.doorRefl_2) * (S.L.doorSpeed_2)
	{else}
		(L.L.door_2) 0 <
		{if}
			(T.L.ev_doorhitclose_1)
			0 (S.L.door_2)
			(L.L.doorSpeed_2) /-/ (L.L.doorRefl_2) * (S.L.doorSpeed_2)
		{endif}
	{endif}
{end}

{macro:Door3_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_23)
		{if}
			(L.L.door_3) (F.L.door_3_opn_speed) (S.L.doorMaxSpeed_3)
			(L.L.door_3) (F.L.door_3_opn_speed_2) (S.L.door_3)
		{else}
			(L.L.door_3) (F.L.door_3_cls_speed) (S.L.doorMaxSpeed_3)
			(L.L.door_3) (F.L.door_3_cls_speed_2) (S.L.door_3)
		{endif}

		(C.L.bdoor_acc) (S.L.doorAcc_3)

		(L.L.doorTarget_23) ! (L.L.doorSpeed_3) s0 abs 0.05 > (L.L.door_3) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_3) <
			{if}
				(L.L.doorSpeed_3) (L.L.doorAcc_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}
			(L.L.door_3) (L.L.doorSpeed_3) (L.S.Timegap) * + (S.L.door_3)
		{else}
			(L.L.doorSpeed_3) abs 0.05 > (L.L.door_3) 1 < || (L.L.doorTarget_23) &&
			{if}
				l0 (L.L.doorMaxSpeed_3) <
				{if}
					(L.L.doorSpeed_3) (L.L.doorAcc_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}
				(L.L.door_3) (L.L.doorSpeed_3) (L.S.Timegap) * + (S.L.door_3)
			{else}
				0 (S.L.doorSpeed_3)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_23) ! (L.L.doorSpeed_3) s0 abs 0.05 > (L.L.door_3) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_3) <
			{if}
				(L.L.doorSpeed_3) (L.L.doorAcc_3) (L.S.Timegap) * - (S.L.doorSpeed_3)
			{endif}
			(L.L.door_3) (L.L.doorSpeed_3) (L.S.Timegap) * + (S.L.door_3)
		{else}
			(L.L.doorSpeed_3) abs 0.05 > (L.L.door_3) 1 < || (L.L.doorTarget_23) &&
			{if}
				l0 (L.L.doorMaxSpeed_3) <
				{if}
					(L.L.doorSpeed_3) (L.L.doorAcc_3) (L.S.Timegap) * + (S.L.doorSpeed_3) 
				{endif}
				(L.L.door_3) (L.L.doorSpeed_3) (L.S.Timegap) * + (S.L.door_3)
			{else}
				0 (S.L.doorSpeed_3)
			{endif}
		{endif}
	{endif}

	(L.L.door_3) 1 >
	{if}
		(T.L.ev_doorhitopen_1)
		1 (S.L.door_3)
		(L.L.doorSpeed_3) /-/ (L.L.doorRefl_3) * (S.L.doorSpeed_3)
	{else}
		(L.L.door_3) 0 <
		{if}
			(T.L.ev_doorhitclose_1)
			0 (S.L.door_3)
			(L.L.doorSpeed_3) /-/ (L.L.doorRefl_3) * (S.L.doorSpeed_3)
		{endif}
	{endif}

{end}

'-----------------------------
' DOOR 2 -------- 2 PARTS
'-----------------------------

{macro:Door4_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_45)
		{if}
			(L.L.door_4) (F.L.door_4_opn_speed) (S.L.doorMaxSpeed_4)
			(L.L.door_4) (F.L.door_4_opn_speed_2) (S.L.door_4)
		{else}
			(L.L.door_4) (F.L.door_4_cls_speed) (S.L.doorMaxSpeed_4)
			(L.L.door_4) (F.L.door_4_cls_speed_2) (S.L.door_4)
		{endif}

		(C.L.bdoor_acc) (S.L.doorAcc_4)

		(L.L.doorTarget_45) ! (L.L.doorSpeed_4) s0 abs 0.05 > (L.L.door_4) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_3) <
			{if}
				(L.L.doorSpeed_4) (L.L.doorAcc_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}
			(L.L.door_4) (L.L.doorSpeed_4) (L.S.Timegap) * + (S.L.door_4)
		{else}
			(L.L.doorSpeed_4) abs 0.05 > (L.L.door_4) 1 < || (L.L.doorTarget_45) &&
			{if}
				l0 (L.L.doorMaxSpeed_4) <
				{if}
					(L.L.doorSpeed_4) (L.L.doorAcc_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}
				(L.L.door_4) (L.L.doorSpeed_4) (L.S.Timegap) * + (S.L.door_4)
			{else}
				0 (S.L.doorSpeed_4)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_45) ! (L.L.doorSpeed_4) s0 abs 0.05 > (L.L.door_4) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_4) <
			{if}
				(L.L.doorSpeed_4) (L.L.doorAcc_4) (L.S.Timegap) * - (S.L.doorSpeed_4)
			{endif}
			(L.L.door_4) (L.L.doorSpeed_4) (L.S.Timegap) * + (S.L.door_4)
		{else}
			(L.L.doorSpeed_4) abs 0.05 > (L.L.door_4) 1 < || (L.L.doorTarget_45) &&
			{if}
				l0 (L.L.doorMaxSpeed_4) <
				{if}
					(L.L.doorSpeed_4) (L.L.doorAcc_4) (L.S.Timegap) * + (S.L.doorSpeed_4) 
				{endif}
				(L.L.door_4) (L.L.doorSpeed_4) (L.S.Timegap) * + (S.L.door_4)
			{else}
				0 (S.L.doorSpeed_4)
			{endif}
		{endif}
	{endif}

	(L.L.door_4) 1 >
	{if}
		(T.L.ev_doorhitopen_2)
		1 (S.L.door_4)
		(L.L.doorSpeed_4) /-/ (L.L.doorRefl_4) * (S.L.doorSpeed_4)
	{else}
		(L.L.door_4) 0 <
		{if}
			(T.L.ev_doorhitclose_2)
			0 (S.L.door_4)
			(L.L.doorSpeed_4) /-/ (L.L.doorRefl_4) * (S.L.doorSpeed_4)
		{endif}
	{endif}

{end}

{macro:Door5_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_45)
		{if}
			(L.L.door_5) (F.L.door_5_opn_speed) (S.L.doorMaxSpeed_5)
			(L.L.door_5) (F.L.door_5_opn_speed_2) (S.L.door_5)
		{else}
			(L.L.door_5) (F.L.door_5_cls_speed) (S.L.doorMaxSpeed_5)
			(L.L.door_5) (F.L.door_5_cls_speed_2) (S.L.door_5)
		{endif}

		(C.L.bdoor_acc) (S.L.doorAcc_5)

		(L.L.doorTarget_45) ! (L.L.doorSpeed_5) s0 abs 0.05 > (L.L.door_5) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_5) <
			{if}
				(L.L.doorSpeed_5) (L.L.doorAcc_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}
			(L.L.door_5) (L.L.doorSpeed_5) (L.S.Timegap) * + (S.L.door_5)
		{else}
			(L.L.doorSpeed_5) abs 0.05 > (L.L.door_5) 1 < || (L.L.doorTarget_45) &&
			{if}
				l0 (L.L.doorMaxSpeed_5) <
				{if}
					(L.L.doorSpeed_5) (L.L.doorAcc_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}
				(L.L.door_5) (L.L.doorSpeed_5) (L.S.Timegap) * + (S.L.door_5)
			{else}
				0 (S.L.doorSpeed_5)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_45) ! (L.L.doorSpeed_5) s0 abs 0.05 > (L.L.door_5) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_5) <
			{if}
				(L.L.doorSpeed_5) (L.L.doorAcc_5) (L.S.Timegap) * - (S.L.doorSpeed_5)
			{endif}
			(L.L.door_5) (L.L.doorSpeed_5) (L.S.Timegap) * + (S.L.door_5)
		{else}
			(L.L.doorSpeed_5) abs 0.05 > (L.L.door_5) 1 < || (L.L.doorTarget_45) &&
			{if}
				l0 (L.L.doorMaxSpeed_5) <
				{if}
					(L.L.doorSpeed_5) (L.L.doorAcc_5) (L.S.Timegap) * + (S.L.doorSpeed_5) 
				{endif}
				(L.L.door_5) (L.L.doorSpeed_5) (L.S.Timegap) * + (S.L.door_5)
			{else}
				0 (S.L.doorSpeed_5)
			{endif}
		{endif}
	{endif}

	(L.L.door_5) 1 >
	{if}
		(T.L.ev_doorhitopen_2)
		1 (S.L.door_5)
		(L.L.doorSpeed_5) /-/ (L.L.doorRefl_5) * (S.L.doorSpeed_5)
	{else}
		(L.L.door_5) 0 <
		{if}
			(T.L.ev_doorhitclose_2)
			0 (S.L.door_5)
			(L.L.doorSpeed_5) /-/ (L.L.doorRefl_5) * (S.L.doorSpeed_5)
		{endif}
	{endif}

{end}

'-----------------------------
' DOOR 3 -------- 2 PARTS
'-----------------------------

{macro:Door6_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_67)
		{if}
			(L.L.door_6) (F.L.door_6_opn_speed) (S.L.doorMaxSpeed_6)
			(L.L.door_6) (F.L.door_6_opn_speed_2) (S.L.door_6)
		{else}
			(L.L.door_6) (F.L.door_6_cls_speed) (S.L.doorMaxSpeed_6)
			(L.L.door_6) (F.L.door_6_cls_speed_2) (S.L.door_6)
		{endif}

		(C.L.bdoor_acc) (S.L.doorAcc_6)

		(L.L.doorTarget_67) ! (L.L.doorSpeed_6) s0 abs 0.05 > (L.L.door_6) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_6) <
			{if}
				(L.L.doorSpeed_6) (L.L.doorAcc_6) (L.S.Timegap) * - (S.L.doorSpeed_6)
			{else}
				(L.L.doorSpeed_6) (L.L.doorAcc_6) (L.S.Timegap) * + (S.L.doorSpeed_6)
			{endif}
			(L.L.door_6) (L.L.doorSpeed_6) (L.S.Timegap) * + (S.L.door_6)
		{else}
			(L.L.doorSpeed_6) abs 0.05 > (L.L.door_6) 1 < || (L.L.doorTarget_67) &&
			{if}
				l0 (L.L.doorMaxSpeed_6) <
				{if}
					(L.L.doorSpeed_6) (L.L.doorAcc_6) (L.S.Timegap) * + (S.L.doorSpeed_6) 
				{else}
					(L.L.doorSpeed_6) (L.L.doorAcc_6) (L.S.Timegap) * - (S.L.doorSpeed_6) 
				{endif}
				(L.L.door_6) (L.L.doorSpeed_6) (L.S.Timegap) * + (S.L.door_6)
			{else}
				0 (S.L.doorSpeed_6)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_67) ! (L.L.doorSpeed_6) s0 abs 0.05 > (L.L.door_6) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_6) <
			{if}
				(L.L.doorSpeed_6) (L.L.doorAcc_6) (L.S.Timegap) * - (S.L.doorSpeed_6)
			{endif}
			(L.L.door_6) (L.L.doorSpeed_6) (L.S.Timegap) * + (S.L.door_6)
		{else}
			(L.L.doorSpeed_6) abs 0.05 > (L.L.door_6) 1 < || (L.L.doorTarget_67) &&
			{if}
				l0 (L.L.doorMaxSpeed_6) <
				{if}
					(L.L.doorSpeed_6) (L.L.doorAcc_6) (L.S.Timegap) * + (S.L.doorSpeed_6) 
				{endif}
				(L.L.door_6) (L.L.doorSpeed_6) (L.S.Timegap) * + (S.L.door_6)
			{else}
				0 (S.L.doorSpeed_6)
			{endif}
		{endif}
	{endif}

	(L.L.door_6) 1 >
	{if}
		(T.L.ev_doorhitopen_3)
		1 (S.L.door_6)
		(L.L.doorSpeed_6) /-/ (L.L.doorRefl_6) * (S.L.doorSpeed_6)
	{else}
		(L.L.door_6) 0 <
		{if}
			(T.L.ev_doorhitclose_3)
			0 (S.L.door_6)
			(L.L.doorSpeed_6) /-/ (L.L.doorRefl_6) * (S.L.doorSpeed_6)
		{endif}
	{endif}

{end}

{macro:Door7_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_67)
		{if}
			(L.L.door_7) (F.L.door_7_opn_speed) (S.L.doorMaxSpeed_7)
			(L.L.door_7) (F.L.door_7_opn_speed_2) (S.L.door_7)
		{else}
			(L.L.door_7) (F.L.door_7_cls_speed) (S.L.doorMaxSpeed_7)
			(L.L.door_7) (F.L.door_7_cls_speed_2) (S.L.door_7)
		{endif}

		(C.L.bdoor_acc) (S.L.doorAcc_7)

		(L.L.doorTarget_67) ! (L.L.doorSpeed_7) s0 abs 0.05 > (L.L.door_7) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_7) <
			{if}
				(L.L.doorSpeed_7) (L.L.doorAcc_7) (L.S.Timegap) * - (S.L.doorSpeed_7)
			{else}
				(L.L.doorSpeed_7) (L.L.doorAcc_7) (L.S.Timegap) * + (S.L.doorSpeed_7)
			{endif}
			(L.L.door_7) (L.L.doorSpeed_7) (L.S.Timegap) * + (S.L.door_7)
		{else}
			(L.L.doorSpeed_7) abs 0.05 > (L.L.door_7) 1 < || (L.L.doorTarget_67) &&
			{if}
				l0 (L.L.doorMaxSpeed_7) <
				{if}
					(L.L.doorSpeed_7) (L.L.doorAcc_7) (L.S.Timegap) * + (S.L.doorSpeed_7) 
				{else}
					(L.L.doorSpeed_7) (L.L.doorAcc_7) (L.S.Timegap) * - (S.L.doorSpeed_7) 
				{endif}
				(L.L.door_7) (L.L.doorSpeed_7) (L.S.Timegap) * + (S.L.door_7)
			{else}
				0 (S.L.doorSpeed_7)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_67) ! (L.L.doorSpeed_7) s0 abs 0.05 > (L.L.door_7) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_7) <
			{if}
				(L.L.doorSpeed_7) (L.L.doorAcc_7) (L.S.Timegap) * - (S.L.doorSpeed_7)
			{endif}
			(L.L.door_7) (L.L.doorSpeed_7) (L.S.Timegap) * + (S.L.door_7)
		{else}
			(L.L.doorSpeed_7) abs 0.05 > (L.L.door_7) 1 < || (L.L.doorTarget_67) &&
			{if}
				l0 (L.L.doorMaxSpeed_7) <
				{if}
					(L.L.doorSpeed_7) (L.L.doorAcc_7) (L.S.Timegap) * + (S.L.doorSpeed_7) 
				{endif}
				(L.L.door_7) (L.L.doorSpeed_7) (L.S.Timegap) * + (S.L.door_7)
			{else}
				0 (S.L.doorSpeed_7)
			{endif}
		{endif}
	{endif}

	(L.L.door_7) 1 >
	{if}
		(T.L.ev_doorhitopen_3)
		1 (S.L.door_7)
		(L.L.doorSpeed_7) /-/ (L.L.doorRefl_7) * (S.L.doorSpeed_7)
	{else}
		(L.L.door_7) 0 <
		{if}
			(T.L.ev_doorhitclose_3)
			0 (S.L.door_7)
			(L.L.doorSpeed_7) /-/ (L.L.doorRefl_7) * (S.L.doorSpeed_7)
		{endif}
	{endif}

{end}

'-----------------------------
' DOOR 4 -------- 2 PARTS
'-----------------------------

{macro:Door8_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_89)
		{if}
			(L.L.door_8) (F.L.door_8_opn_speed) (S.L.doorMaxSpeed_8)
			(L.L.door_8) (F.L.door_8_opn_speed_2) (S.L.door_8)
		{else}
			(L.L.door_8) (F.L.door_8_cls_speed) (S.L.doorMaxSpeed_8)
			(L.L.door_8) (F.L.door_8_cls_speed_2) (S.L.door_8)
		{endif}

		(C.L.bdoor_acc) (S.L.doorAcc_8)

		(L.L.doorTarget_89) ! (L.L.doorSpeed_8) s0 abs 0.05 > (L.L.door_8) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_8) <
			{if}
				(L.L.doorSpeed_8) (L.L.doorAcc_8) (L.S.Timegap) * - (S.L.doorSpeed_8)
			{else}
				(L.L.doorSpeed_8) (L.L.doorAcc_8) (L.S.Timegap) * + (S.L.doorSpeed_8)
			{endif}
			(L.L.door_8) (L.L.doorSpeed_8) (L.S.Timegap) * + (S.L.door_8)
		{else}
			(L.L.doorSpeed_8) abs 0.05 > (L.L.door_8) 1 < || (L.L.doorTarget_89) &&
			{if}
				l0 (L.L.doorMaxSpeed_8) <
				{if}
					(L.L.doorSpeed_8) (L.L.doorAcc_8) (L.S.Timegap) * + (S.L.doorSpeed_8) 
				{else}
					(L.L.doorSpeed_8) (L.L.doorAcc_8) (L.S.Timegap) * - (S.L.doorSpeed_8) 
				{endif}
				(L.L.door_8) (L.L.doorSpeed_8) (L.S.Timegap) * + (S.L.door_8)
			{else}
				0 (S.L.doorSpeed_8)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_89) ! (L.L.doorSpeed_8) s0 abs 0.05 > (L.L.door_8) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_8) <
			{if}
				(L.L.doorSpeed_8) (L.L.doorAcc_8) (L.S.Timegap) * - (S.L.doorSpeed_8)
			{endif}
			(L.L.door_8) (L.L.doorSpeed_8) (L.S.Timegap) * + (S.L.door_8)
		{else}
			(L.L.doorSpeed_8) abs 0.05 > (L.L.door_8) 1 < || (L.L.doorTarget_89) &&
			{if}
				l0 (L.L.doorMaxSpeed_8) <
				{if}
					(L.L.doorSpeed_8) (L.L.doorAcc_8) (L.S.Timegap) * + (S.L.doorSpeed_8) 
				{endif}
				(L.L.door_8) (L.L.doorSpeed_8) (L.S.Timegap) * + (S.L.door_8)
			{else}
				0 (S.L.doorSpeed_8)
			{endif}
		{endif}
	{endif}

	(L.L.door_8) 1 >
	{if}
		(T.L.ev_doorhitopen_4)
		1 (S.L.door_8)
		(L.L.doorSpeed_8) /-/ (L.L.doorRefl_8) * (S.L.doorSpeed_8)
	{else}
		(L.L.door_8) 0 <
		{if}
			(T.L.ev_doorhitclose_4)
			0 (S.L.door_8)
			(L.L.doorSpeed_8) /-/ (L.L.doorRefl_8) * (S.L.doorSpeed_8)
		{endif}
	{endif}

{end}

{macro:Door9_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_89)
		{if}
			(L.L.door_9) (F.L.door_9_opn_speed) (S.L.doorMaxSpeed_9)
			(L.L.door_9) (F.L.door_9_opn_speed_2) (S.L.door_9)
		{else}
			(L.L.door_9) (F.L.door_9_cls_speed) (S.L.doorMaxSpeed_9)
			(L.L.door_9) (F.L.door_9_cls_speed_2) (S.L.door_9)
		{endif}

		(C.L.bdoor_acc) (S.L.doorAcc_9)

		(L.L.doorTarget_89) ! (L.L.doorSpeed_9) s0 abs 0.05 > (L.L.door_9) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_9) <
			{if}
				(L.L.doorSpeed_9) (L.L.doorAcc_9) (L.S.Timegap) * - (S.L.doorSpeed_9)
			{else}
				(L.L.doorSpeed_9) (L.L.doorAcc_9) (L.S.Timegap) * + (S.L.doorSpeed_9)
			{endif}
			(L.L.door_9) (L.L.doorSpeed_9) (L.S.Timegap) * + (S.L.door_9)
		{else}
			(L.L.doorSpeed_9) abs 0.05 > (L.L.door_9) 1 < || (L.L.doorTarget_89) &&
			{if}
				l0 (L.L.doorMaxSpeed_9) <
				{if}
					(L.L.doorSpeed_9) (L.L.doorAcc_9) (L.S.Timegap) * + (S.L.doorSpeed_9) 
				{else}
					(L.L.doorSpeed_9) (L.L.doorAcc_9) (L.S.Timegap) * - (S.L.doorSpeed_9) 
				{endif}
				(L.L.door_9) (L.L.doorSpeed_9) (L.S.Timegap) * + (S.L.door_9)
			{else}
				0 (S.L.doorSpeed_9)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_89) ! (L.L.doorSpeed_9) s0 abs 0.05 > (L.L.door_9) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_9) <
			{if}
				(L.L.doorSpeed_9) (L.L.doorAcc_9) (L.S.Timegap) * - (S.L.doorSpeed_9)
			{endif}
			(L.L.door_9) (L.L.doorSpeed_9) (L.S.Timegap) * + (S.L.door_9)
		{else}
			(L.L.doorSpeed_9) abs 0.05 > (L.L.door_9) 1 < || (L.L.doorTarget_89) &&
			{if}
				l0 (L.L.doorMaxSpeed_9) <
				{if}
					(L.L.doorSpeed_9) (L.L.doorAcc_9) (L.S.Timegap) * + (S.L.doorSpeed_9) 
				{endif}
				(L.L.door_9) (L.L.doorSpeed_9) (L.S.Timegap) * + (S.L.door_9)
			{else}
				0 (S.L.doorSpeed_9)
			{endif}
		{endif}
	{endif}

	(L.L.door_9) 1 >
	{if}
		(T.L.ev_doorhitopen_4)
		1 (S.L.door_9)
		(L.L.doorSpeed_9) /-/ (L.L.doorRefl_9) * (S.L.doorSpeed_9)
	{else}
		(L.L.door_9) 0 <
		{if}
			(T.L.ev_doorhitclose_4)
			0 (S.L.door_9)
			(L.L.doorSpeed_9) /-/ (L.L.doorRefl_9) * (S.L.doorSpeed_9)
		{endif}
	{endif}

{end}

'-----------------------------
' DOOR 5 -------- 2 PARTS
'-----------------------------

{macro:Door10_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_10_11)
		{if}
			(L.L.door_10) (F.L.door_10_opn_speed) (S.L.doorMaxSpeed_10)
			(L.L.door_10) (F.L.door_10_opn_speed_2) (S.L.door_10)
		{else}
			(L.L.door_10) (F.L.door_10_cls_speed) (S.L.doorMaxSpeed_10)
			(L.L.door_10) (F.L.door_10_cls_speed_2) (S.L.door_10)
		{endif}

		(C.L.bdoor_acc) (S.L.doorAcc_10)

		(L.L.doorTarget_10_11) ! (L.L.doorSpeed_10) s0 abs 0.05 > (L.L.door_10) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_10) <
			{if}
				(L.L.doorSpeed_10) (L.L.doorAcc_10) (L.S.Timegap) * - (S.L.doorSpeed_10)
			{else}
				(L.L.doorSpeed_10) (L.L.doorAcc_10) (L.S.Timegap) * + (S.L.doorSpeed_10)
			{endif}
			(L.L.door_10) (L.L.doorSpeed_10) (L.S.Timegap) * + (S.L.door_10)
		{else}
			(L.L.doorSpeed_10) abs 0.05 > (L.L.door_10) 1 < || (L.L.doorTarget_10_11) &&
			{if}
				l0 (L.L.doorMaxSpeed_10) <
				{if}
					(L.L.doorSpeed_10) (L.L.doorAcc_10) (L.S.Timegap) * + (S.L.doorSpeed_10) 
				{else}
					(L.L.doorSpeed_10) (L.L.doorAcc_10) (L.S.Timegap) * - (S.L.doorSpeed_10) 
				{endif}
				(L.L.door_10) (L.L.doorSpeed_10) (L.S.Timegap) * + (S.L.door_10)
			{else}
				0 (S.L.doorSpeed_10)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_10_11) ! (L.L.doorSpeed_10) s0 abs 0.05 > (L.L.door_10) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_10) <
			{if}
				(L.L.doorSpeed_10) (L.L.doorAcc_10) (L.S.Timegap) * - (S.L.doorSpeed_10)
			{endif}
			(L.L.door_10) (L.L.doorSpeed_10) (L.S.Timegap) * + (S.L.door_10)
		{else}
			(L.L.doorSpeed_10) abs 0.05 > (L.L.door_10) 1 < || (L.L.doorTarget_10_11) &&
			{if}
				l0 (L.L.doorMaxSpeed_10) <
				{if}
					(L.L.doorSpeed_10) (L.L.doorAcc_10) (L.S.Timegap) * + (S.L.doorSpeed_10) 
				{endif}
				(L.L.door_10) (L.L.doorSpeed_10) (L.S.Timegap) * + (S.L.door_10)
			{else}
				0 (S.L.doorSpeed_10)
			{endif}
		{endif}
	{endif}

	(L.L.door_10) 1 >
	{if}
		(T.L.ev_doorhitopen_5)
		1 (S.L.door_10)
		(L.L.doorSpeed_10) /-/ (L.L.doorRefl_10) * (S.L.doorSpeed_10)
	{else}
		(L.L.door_10) 0 <
		{if}
			(T.L.ev_doorhitclose_5)
			0 (S.L.door_10)
			(L.L.doorSpeed_10) /-/ (L.L.doorRefl_10) * (S.L.doorSpeed_10)
		{endif}
	{endif}

{end}


{macro:Door11_Calc}
	(C.L.electric_doors)
	{if}
		(L.L.doorTarget_10_11)
		{if}
			(L.L.door_11) (F.L.door_11_opn_speed) (S.L.doorMaxSpeed_11)
			(L.L.door_11) (F.L.door_11_opn_speed_2) (S.L.door_11)
		{else}
			(L.L.door_11) (F.L.door_11_cls_speed) (S.L.doorMaxSpeed_11)
			(L.L.door_11) (F.L.door_11_cls_speed_2) (S.L.door_11)
		{endif}

		(C.L.bdoor_acc) (S.L.doorAcc_11)

		(L.L.doorTarget_10_11) ! (L.L.doorSpeed_11) s0 abs 0.05 > (L.L.door_11) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_11) <
			{if}
				(L.L.doorSpeed_11) (L.L.doorAcc_11) (L.S.Timegap) * - (S.L.doorSpeed_11)
			{else}
				(L.L.doorSpeed_11) (L.L.doorAcc_11) (L.S.Timegap) * + (S.L.doorSpeed_11)
			{endif}
			(L.L.door_11) (L.L.doorSpeed_11) (L.S.Timegap) * + (S.L.door_11)
		{else}
			(L.L.doorSpeed_11) abs 0.05 > (L.L.door_11) 1 < || (L.L.doorTarget_10_11) &&
			{if}
				l0 (L.L.doorMaxSpeed_11) <
				{if}
					(L.L.doorSpeed_11) (L.L.doorAcc_11) (L.S.Timegap) * + (S.L.doorSpeed_11) 
				{else}
					(L.L.doorSpeed_11) (L.L.doorAcc_11) (L.S.Timegap) * - (S.L.doorSpeed_11) 
				{endif}
				(L.L.door_11) (L.L.doorSpeed_11) (L.S.Timegap) * + (S.L.door_11)
			{else}
				0 (S.L.doorSpeed_11)
			{endif}
		{endif}
	{else}
		(L.L.doorTarget_10_11) ! (L.L.doorSpeed_11) s0 abs 0.05 > (L.L.door_11) 0 > || && 
		{if}
			l0 /-/ (L.L.doorMaxSpeed_11) <
			{if}
				(L.L.doorSpeed_11) (L.L.doorAcc_11) (L.S.Timegap) * - (S.L.doorSpeed_11)
			{endif}
			(L.L.door_11) (L.L.doorSpeed_11) (L.S.Timegap) * + (S.L.door_11)
		{else}
			(L.L.doorSpeed_11) abs 0.05 > (L.L.door_11) 1 < || (L.L.doorTarget_10_11) &&
			{if}
				l0 (L.L.doorMaxSpeed_11) <
				{if}
					(L.L.doorSpeed_11) (L.L.doorAcc_11) (L.S.Timegap) * + (S.L.doorSpeed_11) 
				{endif}
				(L.L.door_11) (L.L.doorSpeed_11) (L.S.Timegap) * + (S.L.door_11)
			{else}
				0 (S.L.doorSpeed_11)
			{endif}
		{endif}
	{endif}

	(L.L.door_11) 1 >
	{if}
		(T.L.ev_doorhitopen_5)
		1 (S.L.door_11)
		(L.L.doorSpeed_11) /-/ (L.L.doorRefl_11) * (S.L.doorSpeed_11)
	{else}
		(L.L.door_11) 0 <
		{if}
			(T.L.ev_doorhitclose_5)
			0 (S.L.door_11)
			(L.L.doorSpeed_11) /-/ (L.L.doorRefl_11) * (S.L.doorSpeed_11)
		{endif}
	{endif}

{end}


{macro:trg_bus_doorfront01}
    (L.L.Door_Error_Count) 1 + (S.L.Door_Error_Count)
	(L.L.doorTarget_01) ! (S.L.doorTarget_01) 
	{if}
		(T.L.ev_doortriggeropen_0)
	{else}
		(T.L.ev_doortriggerclose_0)
	{endif}
		(C.L.door_druckluft)
		{if}
		(L.L.bremse_p_Tank04) 100000 - 0.98 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
{end}

{macro:trg_bus_doorfront23}
    (L.L.Door2_Error_Count) 1 + (S.L.Door2_Error_Count)
	(L.L.doorTarget_23) ! (S.L.doorTarget_23) 
	{if}
		(T.L.ev_doortriggeropen_1)
	{else}
		(T.L.ev_doortriggerclose_1)
	{endif}	
		(C.L.door_druckluft)
		{if}
		(L.L.bremse_p_Tank04) 100000 - 0.98 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
{end}

{macro:trg_bus_doorfront45}
    (L.L.Door3_Error_Count) 1 + (S.L.Door3_Error_Count)
	(L.L.doorTarget_45) ! (S.L.doorTarget_45) 
	{if}
		(T.L.ev_doortriggeropen_2)
	{else}
		(T.L.ev_doortriggerclose_2)
	{endif}	
		(C.L.door_druckluft)
		{if}
		(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
{end}

{macro:trg_bus_doorfront67}
    (L.L.Door4_Error_Count) 1 + (S.L.Door4_Error_Count)
	(L.L.doorTarget_67) ! (S.L.doorTarget_67) 
	{if}
		(T.L.ev_doortriggeropen_3)
	{else}
		(T.L.ev_doortriggerclose_3)
	{endif}	
		(C.L.door_druckluft)
		{if}
		(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
{end}

{macro:trg_bus_doorfront89}
    (L.L.Door5_Error_Count) 1 + (S.L.Door5_Error_Count)
	(L.L.doorTarget_89) ! (S.L.doorTarget_89) 
	{if}
		(T.L.ev_doortriggeropen_4)
	{else}
		(T.L.ev_doortriggerclose_4)
	{endif}	
		(C.L.door_druckluft)
		{if}
		(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
{end}


{macro:trg_bus_doorfront10_11}
    (L.L.Door6_Error_Count) 1 + (S.L.Door6_Error_Count)
	(L.L.doorTarget_10_11) ! (S.L.doorTarget_10_11) 
	{if}
		(T.L.ev_doortriggeropen_5)
	{else}
		(T.L.ev_doortriggerclose_5)
	{endif}	
		(C.L.door_druckluft)
		{if}
		(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
{end}




{macro:trg_bus_dooraft}
	(L.L.door_switch_sides_sw) ! (S.L.door_switch_sides_sw)
	(T.L.ev_doorSwitchSides_air)
{end}

{macro:trg_bus_20h-switch}
	(L.L.door_20h_sw) ! (S.L.door_20h_sw)
	
	(L.L.door_20h_sw)
	{if}
		(T.L.ev_haltebremse_sw_an)
	{else}
		(T.L.ev_haltebremse_sw_aus)
	{endif}	
{end}

{macro:trg_bus_bremse_halte}
	(L.L.bremse_halte_sw) ! (S.L.bremse_halte_sw)
	(L.L.bremse_halte_sw)
	{if}
		(T.L.ev_haltebremse_sw_an)
	{else}
		(T.L.ev_haltebremse_sw_aus)
	{endif}
{end}