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

'Controls Doors

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

'Script Version: 1.1
'Omsi release: 1.0

'Needs:
'- elec
'- articulation

'NrSpecRandom Seed Area:
'301 ... 318

'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
'- Markus Rabe		25.02.2011	D92 Schließverhalten der Hintertür und Einstiegsbeleuchtung ans Vorbild angepasst
'- Markus Rabe		27.02.2011	linker Flügel Vordertür: Abfangeinrichtung eingebaut
'- Marcel Kuhnt		29.06.2011	Integration in Standard-Doorscript
'- Marcel Kuhnt		07.07.2011	Druckluftsimulation inkl. Dämpfer
'- Marcel Kuhnt		09.07.2011	Manuelles Öffnen/Schließen
'- Marcel Kuhnt		10.07.2011	Manuelles Öffnen/Schließen optimiert
'- Marcel Kuhnt		10.07.2011	Mit westdeutscher Türsteuerung versehen und für O305 erweitert
'- Marcel Kuhnt		10.09.2011	Entriegelte Türen => Leuchtende Türlichter
'- Marcel Kuhnt		10.09.2011	Unterschiedliche Dämpfereinstellungen je Türflügel möglich
'- Marcel Kuhnt		09.07.2012	Anpassung an neue Busbar-Logik
'- Marcel Kuhnt		30.10.2012	Mausbewegungsrichtung beim manuellen Bewegen angepasst
'- Marcel Kuhnt		01.11.2012	Türentriegelung jetzt auch für E-Türen
'- Marcel Kuhnt		01.11.2012	E-Türen generieren Leitwert
'- Marcel Kuhnt		02.11.2012	Nach E-Türentriegelungsrücknahme verharren die Türen
'- Marcel Kuhnt		02.11.2012	Dreitürer
'- Marcel Kuhnt		04.11.2012	Türvariation fester Wagennummer zugeordnet
'- Marcel Kuhnt		04.11.2012	Türanforderung mit neuen Variablen
'- Rüdiger Hülsmann	18.11.2012	Zwangs-Haltestellenbremse durch Knickschutz
'- Marcel Kuhnt		16.12.2012	Haltewunsch-Abschaltung durch Vordertür konstantenabhängig
'- Marcel Kuhnt		08.01.2013	Je nach Konstante langsam aufbauender Druck erst nach Türtasterbetätigung nach Deaktivierung der Türentriegelung
'- Marcel Kuhnt		09.01.2013	20h-Schalter funktioniert jetzt auch in Verbindung mit SD-Hstbrems-Sperr-Logik
'- Marcel Kuhnt		09.01.2013	Türleuchten sind jetzt im Lights-Script
'- Marcel Kuhnt		09.01.2013	Außentürtaster nur bei eingelegter Haltestellenbremse wirksam
'- Marcel Kuhnt		09.01.2013	Reversierende Türen bei weggenommener Haltestellenbremse korrigiert
'- Marcel Kuhnt		12.01.2013	Außenelemente korrekt angesteuert (Hst-Schalter + Hst-Bremse)
'- Marcel Kuhnt		13.01.2013	Wagen-Hält-Zeichen erlischt bei Öffnen des rechten vorderen Türflügels mit 20h-Schalter
'- Marcel Kuhnt		14.01.2013	Türaußentaster werden auch von Fahrgästen benutzt
'- Rüdiger Hülsmann	28.10.2013	"needs stopbrake" function debugged
'- Rüdiger Hülsmann	29.10.2013	Keine Freigabe der Haltestellenbremse bei aktiviertem Kneeling

'--------------------------------------------------------------------------------
{trigger:bus_doorfront}
	(L.L.elec_busbar_main) 0 >
	{if}
		(M.L.trg_bus_doorfront0)
	{endif}
	1 (S.L.cockpit_tuertaster0)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:bus_doorfront_off}
	0 (S.L.cockpit_tuertaster0)
	(T.L.ev_tuertaster_aus)
{end}

{trigger:bus_doorfront0}
	(L.L.elec_busbar_main) 0 >
	{if}
		(M.L.trg_bus_doorfront0)
		(M.L.trg_bus_doorfront1)
	{endif}
	1 (S.L.cockpit_tuertaster1)
	(T.L.ev_tuertaster_ein)
{end}

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

{trigger:bus_doorfront0_external}
	(L.L.elec_busbar_avail) (C.L.elec_busbar_minV) >
	{if}
		(M.L.trg_bus_doorfront0)
		(M.L.trg_bus_doorfront1)
	{endif}
{end}

{trigger:bus_doorfront1}
	(L.L.bremse_halte) (L.L.DoorSecu) ||
	(L.L.velocity) 1 < &&
	(L.L.elec_busbar_main) 0 > &&
	{if}
		(M.L.trg_bus_dooraft23)
		(C.L.EasyDoorMode)
		{if}
			(C.L.NbrDoors) 5 >=
			{if}
				(M.L.trg_bus_dooraft45)
				(M.L.trg_bus_dooraft67)
				(M.L.trg_bus_dooraft89)
			{else}
				(C.L.NbrDoors) 4 >=
				{if}
					(M.L.trg_bus_dooraft45)
					(M.L.trg_bus_dooraft67)
				{else}
					(C.L.NbrDoors) 3 >=
					{if}
						(M.L.trg_bus_dooraft45)
					{endif}
				{endif}
			{endif}
		{endif}
	{endif}

	(C.L.EasyDoorMode)
	{if}
		1 (S.L.cockpit_tuertaster3)
		1 (S.L.cockpit_tuertaster4)
		1 (S.L.cockpit_tuertaster5)
	{endif}

	1 (S.L.cockpit_tuertaster2)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:bus_doorfront1_off}
	(C.L.EasyDoorMode)
	{if}
		0 (S.L.cockpit_tuertaster3)
		0 (S.L.cockpit_tuertaster4)
		0 (S.L.cockpit_tuertaster5)
	{endif}

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

{trigger:bus_doorfront2}
	(C.L.NbrDoors) 3 >=
	{if}
		(L.L.bremse_halte) (L.L.DoorSecu) ||
		(L.L.velocity) 1 < &&
		(L.L.elec_busbar_main) 0 > &&
		{if}
			(M.L.trg_bus_dooraft45)

			(C.L.EasyDoorMode)
			{if}
				(M.L.trg_bus_dooraft23)
				(M.L.trg_bus_dooraft67)
				(M.L.trg_bus_dooraft89)
			{endif}
		{endif}

		(C.L.EasyDoorMode)
		{if}
			1 (S.L.cockpit_tuertaster2)
			1 (S.L.cockpit_tuertaster4)
			1 (S.L.cockpit_tuertaster5)
		{endif}

		1 (S.L.cockpit_tuertaster3)
		(T.L.ev_tuertaster_ein)
	{endif}
{end}

{trigger:bus_doorfront2_off}
	(C.L.NbrDoors) 3 >=
	{if}
		(C.L.EasyDoorMode)
		{if}
			0 (S.L.cockpit_tuertaster2)
			0 (S.L.cockpit_tuertaster4)
			0 (S.L.cockpit_tuertaster5)
		{endif}

		0 (S.L.cockpit_tuertaster3)
		(T.L.ev_tuertaster_ein)
	{endif}
{end}

{trigger:bus_doorfront3}
	(C.L.NbrDoors) 4 >=
	{if}
		(L.L.bremse_halte) (L.L.DoorSecu) ||
		(L.L.velocity) 1 < &&
		(L.L.elec_busbar_main) 0 > &&
		{if}
			(M.L.trg_bus_dooraft67)

			(C.L.EasyDoorMode)
			{if}
				(M.L.trg_bus_dooraft23)
				(M.L.trg_bus_dooraft45)
				(M.L.trg_bus_dooraft89)
			{endif}
		{endif}

		(C.L.EasyDoorMode)
		{if}
			1 (S.L.cockpit_tuertaster2)
			1 (S.L.cockpit_tuertaster3)
			1 (S.L.cockpit_tuertaster5)
		{endif}

		1 (S.L.cockpit_tuertaster4)
		(T.L.ev_tuertaster_ein)
	{endif}
{end}

{trigger:bus_doorfront3_off}
	(C.L.NbrDoors) 4 >=
	{if}
		(C.L.EasyDoorMode)
		{if}
			0 (S.L.cockpit_tuertaster2)
			0 (S.L.cockpit_tuertaster3)
			0 (S.L.cockpit_tuertaster5)
		{endif}

		0 (S.L.cockpit_tuertaster4)
		(T.L.ev_tuertaster_ein)
	{endif}
{end}

{trigger:bus_doorfront4}
	(C.L.NbrDoors) 5 >=
	{if}
		(L.L.bremse_halte) (L.L.DoorSecu) ||
		(L.L.velocity) 1 < &&
		(L.L.elec_busbar_main) 0 > &&
		{if}
			(M.L.trg_bus_dooraft89)

			(C.L.EasyDoorMode)
			{if}
				(M.L.trg_bus_dooraft23)
				(M.L.trg_bus_dooraft45)
				(M.L.trg_bus_dooraft67)
			{endif}
		{endif}

		(C.L.EasyDoorMode)
		{if}
			1 (S.L.cockpit_tuertaster2)
			1 (S.L.cockpit_tuertaster3)
			1 (S.L.cockpit_tuertaster4)
		{endif}

		1 (S.L.cockpit_tuertaster5)
		(T.L.ev_tuertaster_ein)
	{endif}
{end}

{trigger:bus_doorfront4_off}
	(C.L.NbrDoors) 5 >=
	{if}
		(C.L.EasyDoorMode)
		{if}
			0 (S.L.cockpit_tuertaster2)
			0 (S.L.cockpit_tuertaster3)
			0 (S.L.cockpit_tuertaster4)
		{endif}

		0 (S.L.cockpit_tuertaster5)
		(T.L.ev_tuertaster_ein)
	{endif}
{end}

{trigger:bus_dooraft}
	(C.L.EasyDoorMode)
	{if}
		(L.L.elec_busbar_main) 0 >
		(L.L.velocity) 1 < &&
		{if}
			(L.L.Automatic)
			{if}
				(L.L.DEV_Mode) ! (S.L.DEV_Mode)
			{endif}
		{endif}
		(L.L.cp_20h_Toogle) ! (S.L.cp_20h_Toogle)
		(M.L.trg_bus_20h-switch)
	{else}
		(L.L.Automatic)
		{if}
			(L.L.bremse_halte) 1 =
			(L.L.elec_busbar_main) 0 > &&
			(L.L.velocity) 1 < &&
			{if}
				(L.L.DEV_Mode) ! (S.L.DEV_Mode)
			{endif}
		{endif}

		(L.L.Automatic)
		{if}
			1 (S.L.cockpit_DEVtaster)
			(T.L.ev_tuertaster_ein)
		{endif}
	{endif}
{end}

{trigger:bus_dooraft_off}
	(L.L.Automatic)
	{if}
		0 (S.L.cockpit_DEVtaster)
		(T.L.ev_tuertaster_aus)
	{endif}
{end}

{trigger:bus_20h-switch}
	(C.L.EasyDoorMode)
	{if}
		(L.L.elec_busbar_main) 0 >
		(L.L.velocity) 1 < &&
		{if}
			(L.L.Automatic)
			{if}
				(L.L.DEV_Mode) ! (S.L.DEV_Mode)
			{endif}
		{endif}
		(L.L.cp_20h_Toogle) ! (S.L.cp_20h_Toogle)
		(M.L.trg_bus_20h-switch)
	{else}
		(L.L.cp_20h_Toogle) ! (S.L.cp_20h_Toogle)
		(L.L.cp_H_sw) ! (S.L.cp_H_sw)

'		(L.L.cp_H_sw) !
'		(L.L.cp_20h_Toogle) ! ||
'		{if}
			(M.L.trg_bus_20h-switch)
'		{endif}

'		(L.L.cp_20h_Toogle)
'		{if}
'			0 (S.L.cp_H_sw)
'		{endif}

		(L.L.door_20h_sw) 0 =
		{if}
			0 (S.L.DEV_Mode)
		{endif}
		(T.L.ev_tuertaster_ein)
		1 (S.L.cp_H_toogle_sw)
	{endif}
{end}

{trigger:bus_20h-switch_off}
	0 (S.L.cp_H_toogle_sw)
	(T.L.ev_tuertaster_aus)
{end}

{trigger:BrakeValve-switch}
	(L.L.cp_20h_Toogle) ! (S.L.cp_20h_Toogle)

	(L.L.cp_H_sw) !
	{if}
		(M.L.trg_bus_20h-switch)
	{endif}

	(L.L.cp_20h_Toogle)
	{if}
		0 (S.L.cp_H_sw)
	{endif}

	(L.L.door_20h_sw) 0 =
	{if}
		0 (S.L.DEV_Mode)
	{endif}
{end}

{trigger:cp_H-switch}
	(L.L.cp_H_sw) ! (S.L.cp_H_sw)
	1 (S.L.cp_H_toogle_sw)

	(L.L.cp_20h_Toogle) !
	{if}
		(M.L.trg_bus_20h-switch)
	{endif}

	(L.L.door_20h_sw) 0 =
	{if}
		0 (S.L.DEV_Mode)
	{endif}
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_H-switch_off}
	0 (S.L.cp_H_toogle_sw)
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_runningman_toggle}
	1 (S.L.cockpit_DoorReUp)
	(T.L.ev_tuertaster_ein)

	(L.L.doorEntriegelung_01)
	{if}
		(T.L.ev_doorEntriegelung_01_off)
	{endif}

	(L.L.doorEntriegelung_23)
	{if}
		(T.L.ev_doorEntriegelung_23_off)
	{endif}

	(L.L.doorEntriegelung_45)
	{if}
		(T.L.ev_doorEntriegelung_45_off)
	{endif}

	(L.L.doorEntriegelung_67)
	{if}
		(T.L.ev_doorEntriegelung_67_off)
	{endif}

	(L.L.doorEntriegelung_89)
	{if}
		(T.L.ev_doorEntriegelung_89_off)
	{endif}

	0 (S.L.doorEntriegelung_01)
	0 (S.L.doorEntriegelung_23)
	0 (S.L.doorEntriegelung_45)
	0 (S.L.doorEntriegelung_67)
	0 (S.L.doorEntriegelung_89)
{end}

{trigger:cp_runningman_toggle_off}
	0 (S.L.cockpit_DoorReUp)
	(T.L.ev_tuertaster_aus)
{end}

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

{trigger:DoorSecu_toggle}
	(C.L.EMI)
	{if}
		(L.L.DoorSecu) ! (S.L.DoorSecu) s1
		{if}
			(T.L.ev_kippschalter_ein)
		{else}
			(T.L.ev_kippschalter_aus)
		{endif}
	{else}
		(L.L.DoorSecu) ! (S.L.DoorSecu)
		1 (S.L.DoorSecu_sw)
		(T.L.ev_tuertaster_ein)
	{endif}
{end}

{trigger:DoorSecu_toggle_off}
	(C.L.EMI) !
	{if}
		(L.L.DoorSecu)
		{if}
			0.6 (S.L.DoorSecu_sw)
		{else}
			0 (S.L.DoorSecu_sw)
		{endif}
		(T.L.ev_tuertaster_aus)
	{endif}
{end}

{trigger:door_haltewunsch}
	(L.L.StopRequest_Cancel) !
	{if}
		(L.L.DEV_Mode)
		(L.L.door_2) 0.1 < &&
		(L.L.door_3) 0.1 < &&
		{if}
			(M.L.trg_bus_dooraft23)
		{else}
			1 (S.L.haltewunsch) (S.L.door_haltewunsch_knopfdruck)
		{endif}
	{endif}
{end}

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

{trigger:door_haltewunsch_2}
	(L.L.StopRequest_Cancel) !
	{if}
		(L.L.DEV_Mode)
		(L.L.door_4) 0.1 < &&
		(L.L.door_5) 0.1 < &&
		{if}
			(M.L.trg_bus_dooraft45)
		{else}
			1 (S.L.haltewunsch_2) (S.L.door_haltewunsch_2_knopfdruck)
		{endif}
	{endif}
{end}

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

{trigger:door_haltewunsch_3}
	(L.L.StopRequest_Cancel) !
	{if}
		(L.L.DEV_Mode)
		(L.L.door_6) 0.1 < &&
		(L.L.door_7) 0.1 < &&
		{if}
			(M.L.trg_bus_dooraft67)
		{else}
			1 (S.L.haltewunsch_3) (S.L.door_haltewunsch_3_knopfdruck)
		{endif}
	{endif}
{end}

{trigger:door_haltewunsch_3_off}
	0 (S.L.door_haltewunsch_3_knopfdruck)
{end}

{trigger:door_haltewunsch_4}
	(L.L.StopRequest_Cancel) !
	{if}
		(L.L.DEV_Mode)
		(L.L.door_8) 0.1 < &&
		(L.L.door_9) 0.1 < &&
		{if}
			(M.L.trg_bus_dooraft89)
		{else}
			1 (S.L.haltewunsch_4) (S.L.door_haltewunsch_4_knopfdruck)
		{endif}
	{endif}
{end}

{trigger:door_haltewunsch_4_off}
	0 (S.L.door_haltewunsch_4_knopfdruck)
{end}


{trigger:door_aussenoeffner}
	(L.L.DEV_Mode)
	{if}
		1 (S.L.haltewunsch)
	{endif}
{end}

{trigger:door_aussenoeffner_2}
	(L.L.DEV_Mode)
	{if}
		1 (S.L.haltewunsch_2)
	{endif}
{end}

{trigger:door_aussenoeffner_3}
	(L.L.DEV_Mode)
	{if}
		1 (S.L.haltewunsch_3)
	{endif}
{end}

{trigger:door_aussenoeffner_4}
	(L.L.DEV_Mode)
	{if}
		1 (S.L.haltewunsch_4)
	{endif}
{end}

{trigger:StopRequest_Cancel}
	(L.L.StopRequest_Cancel) ! (S.L.StopRequest_Cancel)
	1 (S.L.StopRequest_Cancel_sw)
	0 (S.L.haltewunsch) (S.L.haltewunsch_2) (S.L.haltewunsch_3) (S.L.haltewunsch_4) (S.L.haltewunschlampe) (S.L.haltewunschlampe_2) (S.L.haltewunschlampe_3) (S.L.haltewunschlampe_4) (S.L.haltewunschlampe_all)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:StopRequest_Cancel_off}
	(L.L.StopRequest_Cancel)
	{if}
		0.6 (S.L.StopRequest_Cancel_sw)
	{else}
		0 (S.L.StopRequest_Cancel_sw)
	{endif}
	(T.L.ev_tuertaster_aus)
{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:door6_drag}
	(L.S.mouse_y) (L.S.mouse_x) - 20 / (S.L.doorDragAcc_6)
{end}

{trigger:door7_drag}
	(L.S.mouse_y) (L.S.mouse_x) + 20 / (S.L.doorDragAcc_7)
{end}

{trigger:door8_drag}
	(L.S.mouse_y) (L.S.mouse_x) - 20 / (S.L.doorDragAcc_8)
{end}

{trigger:door9_drag}
	(L.S.mouse_y) (L.S.mouse_x) + 20 / (S.L.doorDragAcc_9)
{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)
		(C.L.door_druckluft)
		{if}
			(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
	{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)
		(C.L.door_druckluft)
		{if}
			(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
	{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)
		(C.L.door_druckluft)
		{if}
			(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
	{endif}	
{end}

{trigger:cp_doorEntriegelung_67}
	(L.L.doorEntriegelung_67) ! (S.L.doorEntriegelung_67)
	{if}
		(T.L.ev_doorEntriegelung_67_on)
	{else}
		(T.L.ev_doorEntriegelung_67_off)
		(C.L.door_druckluft)
		{if}
			(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
	{endif}	
{end}

{trigger:cp_doorEntriegelung_89}
	(L.L.doorEntriegelung_89) ! (S.L.doorEntriegelung_89)
	{if}
		(T.L.ev_doorEntriegelung_89_on)
	{else}
		(T.L.ev_doorEntriegelung_89_off)
		(C.L.door_druckluft)
		{if}
			(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
		{endif}
	{endif}	
{end}


{macro:Door_Init}

	0 (S.L.DEV_Mode)

	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)
	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)
	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)
	307 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_acc_var) * (C.L.bdoor2_acc) + (S.L.doorAcc_6)
	308 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_acc_var) * (C.L.bdoor2_acc) + (S.L.doorAcc_7)
	309 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_acc_var) * (C.L.bdoor3_acc) + (S.L.doorAcc_8)
	310 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_acc_var) * (C.L.bdoor3_acc) + (S.L.doorAcc_9)

	311 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.fdoor_maxspeed) + (S.L.doorMaxSpeed_0_norm)
	312 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.fdoor_maxspeed) + (S.L.doorMaxSpeed_1_norm)
	313 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.mdoor_maxspeed) + (S.L.doorMaxSpeed_2_norm)
	314 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.mdoor_maxspeed) + (S.L.doorMaxSpeed_3_norm)
	315 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_4_norm)
	316 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.bdoor_maxspeed) + (S.L.doorMaxSpeed_5_norm)
	317 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.bdoor2_maxspeed) + (S.L.doorMaxSpeed_6_norm)
	318 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.bdoor2_maxspeed) + (S.L.doorMaxSpeed_7_norm)
	319 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.bdoor3_maxspeed) + (S.L.doorMaxSpeed_8_norm)
	320 (M.V.NrSpecRandom) 2 * 1 - (C.L.door_maxspeed_var) * (C.L.bdoor3_maxspeed) + (S.L.doorMaxSpeed_9_norm)

'Beim Dämpfer wird der Wert bis auf 40% reduziert statt eine Varianz verwendet:
	321 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door0_damper) * (S.L.doorDamper_0_kennwert)
	322 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door1_damper) * (S.L.doorDamper_1_kennwert)
	323 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door2_damper) * (S.L.doorDamper_2_kennwert)
	324 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door3_damper) * (S.L.doorDamper_3_kennwert)
	325 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door4_damper) * (S.L.doorDamper_4_kennwert)
	326 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door5_damper) * (S.L.doorDamper_5_kennwert)
	327 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door5_damper) * (S.L.doorDamper_6_kennwert)
	328 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door5_damper) * (S.L.doorDamper_7_kennwert)
	329 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door5_damper) * (S.L.doorDamper_8_kennwert)
	330 (M.V.NrSpecRandom) 0.9 * 0.1 + (C.L.door5_damper) * (S.L.doorDamper_9_kennwert)

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

	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.door_pressure_open_6)
	(S.L.door_pressure_close_6)
	(S.L.door_pressure_open_7)
	(S.L.door_pressure_close_7)
	(S.L.door_pressure_open_8)
	(S.L.door_pressure_close_8)
	(S.L.door_pressure_open_9)
	(S.L.door_pressure_close_9)

	(S.L.doorDamper_0) (S.L.doorDamper_1) (S.L.doorDamper_2) (S.L.doorDamper_3) (S.L.doorDamper_4) (S.L.doorDamper_5) (S.L.doorDamper_6) (S.L.doorDamper_7) (S.L.doorDamper_8) (S.L.doorDamper_9)

	1 (S.L.doorEntriegelung_doorActive_01)
	1 (S.L.doorEntriegelung_doorActive_23)
	1 (S.L.doorEntriegelung_doorActive_45)
	1 (S.L.doorEntriegelung_doorActive_67)
	1 (S.L.doorEntriegelung_doorActive_89)
{end}

{macro:Door_Frame}

'Doors malfunction
	(L.L.doorEntriegelung_01)
	{if}
		(L.S.GetTime) 1 % 0.5 < &&
		(S.L.cp_Door1)
	{else}
		(L.L.door_0) 0.1 >
		(L.L.door_1) 0.1 > &&
		{if}
			1 (S.L.cp_Door1)
		{else}
			0 (S.L.cp_Door1)
		{endif}
	{endif}

	(L.L.doorEntriegelung_23)
	{if}
		(L.S.GetTime) 1 % 0.5 < &&
		(S.L.cp_Door2)
	{else}
		(L.L.door_2) 0.1 >
		(L.L.door_3) 0.1 > &&
		{if}
			1 (S.L.cp_Door2)
		{else}
			0 (S.L.cp_Door2)
		{endif}
	{endif}

	(L.L.doorEntriegelung_45)
	{if}
		(L.S.GetTime) 1 % 0.5 < &&
		(S.L.cp_Door3)
	{else}
		(L.L.door_4) 0.1 >
		(L.L.door_5) 0.1 > &&
		{if}
			1 (S.L.cp_Door3)
		{else}
			0 (S.L.cp_Door3)
		{endif}
	{endif}

	(L.L.doorEntriegelung_67)
	{if}
		(L.S.GetTime) 1 % 0.5 < &&
		(S.L.cp_Door4)
	{else}
		(L.L.door_6) 0.1 >
		(L.L.door_7) 0.1 > &&
		{if}
			1 (S.L.cp_Door4)
		{else}
			0 (S.L.cp_Door4)
		{endif}
	{endif}

	(L.L.doorEntriegelung_89)
	{if}
		(L.S.GetTime) 1 % 0.5 < &&
		(S.L.cp_Door5)
	{else}
		(L.L.door_8) 0.1 >
		(L.L.door_9) 0.1 > &&
		{if}
			1 (S.L.cp_Door5)
		{else}
			0 (S.L.cp_Door5)
		{endif}
	{endif}

	(L.L.cp_Door1) (L.L.elec_busbar_main) *
	(S.L.cp_DoorLight1)

	(L.L.cp_Door2) (L.L.elec_busbar_main) *
	(S.L.cp_DoorLight2)

	(L.L.cp_Door3) (L.L.elec_busbar_main) *
	(S.L.cp_DoorLight3)

	(L.L.cp_Door4) (L.L.elec_busbar_main) *
	(S.L.cp_DoorLight4)

	(L.L.cp_Door5) (L.L.elec_busbar_main) *
	(S.L.cp_DoorLight5)

'Anforderung mit neuen Variablen:

	(L.L.haltewunsch)   (L.L.PAX_Exit0_Req) (L.L.PAX_Exit1_Req) || || (S.L.haltewunsch)
	(L.L.haltewunsch_2) (L.L.PAX_Exit2_Req) (L.L.PAX_Exit3_Req) || || (S.L.haltewunsch_2)
	(L.L.haltewunsch_3) (L.L.PAX_Exit4_Req) (L.L.PAX_Exit5_Req) || || (S.L.haltewunsch_3)
	(L.L.haltewunsch_4) (L.L.PAX_Exit6_Req) (L.L.PAX_Exit7_Req) || || (S.L.haltewunsch_4)

'Bei E-Türen die "active"-Variable der Entriegelung nachführen:
	(C.L.electric_doors)
	{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_off)
			{else}
				(T.L.ev_doorEntriegelung_01_active_on)
				0 (S.L.doorEntriegelung_doorActive_01)
			{endif}
		{endif}
		l1 (S.L.doorEntriegelung_E_active_01)

		(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_off)
			{else}
				(T.L.ev_doorEntriegelung_23_active_on)
				0 (S.L.doorEntriegelung_doorActive_23)
			{endif}
		{endif}
		l1 (S.L.doorEntriegelung_E_active_23)

		(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_off)
			{else}
				(T.L.ev_doorEntriegelung_45_active_on)
				0 (S.L.doorEntriegelung_doorActive_45)
			{endif}
		{endif}
		l1 (S.L.doorEntriegelung_E_active_45)

		(L.L.doorEntriegelung_67) (L.L.doorEntriegelung_E_active_67) s0 (L.L.elec_busbar_avail) (C.L.elec_busbar_minV) > ! && || s1
		l0 = !
		{if}
			l1
			{if}
				(T.L.ev_doorEntriegelung_67_active_off)
			{else}
				(T.L.ev_doorEntriegelung_67_active_on)
				0 (S.L.doorEntriegelung_doorActive_67)
			{endif}
		{endif}
		l1 (S.L.doorEntriegelung_E_active_67)

		(L.L.doorEntriegelung_89) (L.L.doorEntriegelung_E_active_89) s0 (L.L.elec_busbar_avail) (C.L.elec_busbar_minV) > ! && || s1
		l0 = !
		{if}
			l1
			{if}
				(T.L.ev_doorEntriegelung_89_active_off)
			{else}
				(T.L.ev_doorEntriegelung_89_active_on)
				0 (S.L.doorEntriegelung_doorActive_89)
			{endif}
		{endif}
		l1 (S.L.doorEntriegelung_E_active_89)
	{endif}
	


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

	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)
	(S.L.doorDragAcc_6)
	(S.L.doorDragAcc_7)
	(S.L.doorDragAcc_8)
	(S.L.doorDragAcc_9)

	(L.L.door_0) 0.9 > (S.L.PAX_Entry0_Open)
	(L.L.door_1) 0.9 > (S.L.PAX_Entry1_Open)	
	(L.L.door_2) 0.9 > (L.L.door_3) 0.9 > && (S.L.PAX_Exit0_Open) (S.L.PAX_Exit1_Open) (S.L.PAX_Entry2_Open) (S.L.PAX_Entry3_Open)
	(L.L.door_4) 0.9 > (L.L.door_5) 0.9 > && (S.L.PAX_Exit2_Open) (S.L.PAX_Exit3_Open) (S.L.PAX_Entry4_Open) (S.L.PAX_Entry5_Open)	
	(L.L.door_6) 0.9 > (L.L.door_7) 0.9 > && (S.L.PAX_Exit4_Open) (S.L.PAX_Exit5_Open) (S.L.PAX_Entry6_Open) (S.L.PAX_Entry7_Open)
	(L.L.door_8) 0.9 > (L.L.door_9) 0.9 > && (S.L.PAX_Exit6_Open) (S.L.PAX_Exit7_Open) (S.L.PAX_Entry6_Open) (S.L.PAX_Entry7_Open)

'	"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}

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

	(L.L.DEV_Mode) (L.L.PAX_Entry2_Req) (L.L.PAX_Entry3_Req) || &&
	{if}
		1 (S.L.haltewunsch)
	{endif}

	(L.L.DEV_Mode) (L.L.PAX_Entry4_Req) (L.L.PAX_Entry5_Req) || &&
	{if}
		1 (S.L.haltewunsch_2)
	{endif}

	(L.L.DEV_Mode) (L.L.PAX_Entry6_Req) (L.L.PAX_Entry7_Req) || &&
	{if}
		1 (S.L.haltewunsch_3)
	{endif}

	(L.L.DEV_Mode) (L.L.PAX_Entry6_Req) (L.L.PAX_Entry7_Req) || &&
	{if}
		1 (S.L.haltewunsch_4)
	{endif}


'	Setzen der Haltestellenbremse erst bei Stillstand des Busses:
	(L.L.bremse_halte_sw) (L.L.door_20h_sw) (L.L.door_hstbremse_knickschutz) || ||
	(L.L.bremse_halte) ! (L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) < && &&
	{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)
	(M.L.DoorAft2_Open)
	(M.L.DoorAft3_Open)

'	Türfreigabekriterium
	(L.L.bremse_halte_sw) (L.L.bremse_halte) && (S.L.door_freigabe)

'	Haltewunschlampe:
	(L.L.haltewunsch)
			(L.L.door_0) 0.2 < (C.L.door_stop_request_killed_by_front_door) ! ||
			(L.L.door_1) 0.2 < (L.L.door_20h_sw) ! || &&
			(L.L.door_2) 0.2 < &&
			(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > && &&
	{if}
		1 (S.L.haltewunschlampe)
	{else}
		0 (S.L.haltewunschlampe) (S.L.haltewunsch)
	{endif}

	(L.L.haltewunsch_2)
			(L.L.door_0) 0.2 < (C.L.door_stop_request_killed_by_front_door) ! ||
			(L.L.door_1) 0.2 < (L.L.door_20h_sw) ! || &&
			(L.L.door_4) 0.2 < &&
			(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > && &&
	{if}
		1 (S.L.haltewunschlampe_2)
	{else}
		0 (S.L.haltewunschlampe_2) (S.L.haltewunsch_2)
	{endif}

	(L.L.haltewunsch_3)
			(L.L.door_0) 0.2 < (C.L.door_stop_request_killed_by_front_door) ! ||
			(L.L.door_1) 0.2 < (L.L.door_20h_sw) ! || &&
			(L.L.door_6) 0.2 < &&
			(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > && &&
	{if}
		1 (S.L.haltewunschlampe_3)
	{else}
		0 (S.L.haltewunschlampe_3) (S.L.haltewunsch_3)
	{endif}

	(L.L.haltewunsch_4)
			(L.L.door_0) 0.2 < (C.L.door_stop_request_killed_by_front_door) ! ||
			(L.L.door_1) 0.2 < (L.L.door_20h_sw) ! || &&
			(L.L.door_8) 0.2 < &&
			(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > && &&
	{if}
		1 (S.L.haltewunschlampe_4)
	{else}
		0 (S.L.haltewunschlampe_4) (S.L.haltewunsch_4)
	{endif}

	(L.L.haltewunschlampe) (L.L.haltewunschlampe_2) (L.L.haltewunschlampe_3) (L.L.haltewunschlampe_4) || || || (S.L.haltewunschlampe_all)

'	Bing:

	(L.L.haltewunsch) (L.L.haltewunsch_2) (L.L.haltewunsch_3) (L.L.haltewunsch_4) || || || (L.L.prev_haltewunsch) ! && (L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
	{if}
		(L.L.DEV_Mode) !
		{if}
			(T.L.ev_stop)
		{endif}
	{endif}		

	(L.L.haltewunsch) (L.L.haltewunsch_2) (L.L.haltewunsch_3) (L.L.haltewunsch_4) || || || (S.L.prev_haltewunsch)

'	Door closed sound
	(L.L.door_2) 0 =
	(L.L.door_3) 0 = &&
	(L.L.door_4) 0 = &&
	(L.L.door_5) 0 = &&
	(L.L.door_6) 0 = &&
	(L.L.door_7) 0 = &&
	(L.L.door_8) 0 = &&
	(L.L.door_9) 0 = &&
	(L.L.DEV_Mode) ! &&
	(L.L.doors_closed) ! &&
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
	{if}
		(T.L.ev_doors_closed)
	{endif}

	(L.L.door_2) 0 =
	(L.L.door_3) 0 = &&
	(L.L.door_4) 0 = &&
	(L.L.door_5) 0 = &&
	(L.L.door_6) 0 = &&
	(L.L.door_7) 0 = &&
	(L.L.door_8) 0 = &&
	(L.L.door_9) 0 = &&
	(L.L.DEV_Mode) ! &&
	(S.L.doors_closed)

'	Beleuchtung der Einstiege

'	Ausgelagert in Lights-Script


'###############################################################################################
'	Druckluftverhalten:

(C.L.door_druckluft)
{if}

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


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


	(L.L.doorEntriegelung_89)
	{if}
'Tür ist entlüftet:
		-2 (S.L.doorEntriegelung_doorActive_89)
	{else}
	(C.L.door_safe_reactivating) !
	{if}
'Tür steht unter Druck:
		1 (S.L.doorEntriegelung_doorActive_89)
	{else}
	(L.L.doorEntriegelung_doorActive_89) -2 =
	{if}
'Tür ist "vorbereitet":
		-1 (S.L.doorEntriegelung_doorActive_89)
	{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_67) s1 0 >= l1 0.99 < &&
	{if}
		1 s0 0.1 s2 s3 (M.L.traegheit) (S.L.doorEntriegelung_doorActive_67)
		(L.L.doorEntriegelung_doorActive_67) 0.8 >
		{if}
			(T.L.ev_doorEntriegelung_67_off_final)
			1 (S.L.doorEntriegelung_doorActive_67)
		{endif}
	{endif}

	(L.L.doorEntriegelung_doorActive_89) s1 0 >= l1 0.99 < &&
	{if}
		1 s0 0.1 s2 s3 (M.L.traegheit) (S.L.doorEntriegelung_doorActive_89)
		(L.L.doorEntriegelung_doorActive_89) 0.8 >
		{if}
			(T.L.ev_doorEntriegelung_89_off_final)
			1 (S.L.doorEntriegelung_doorActive_89)
		{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)

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

	(L.L.doorEntriegelung_doorActive_67) 0 <=
	{if}
		0 s5
	{else}
		(L.L.doorTarget_67) ! s5 !
	{endif}

	(L.L.doorEntriegelung_doorActive_67) l6 * * s0
	(L.L.door_pressure_open_6) s1
	1 s2 1 s3
	(M.L.traegheit) (S.L.door_pressure_open_6)

	(L.L.door_pressure_close_6) s1
	(L.L.doorEntriegelung_doorActive_67) l5 l6 * * s0
	(M.L.traegheit) (S.L.door_pressure_close_6)

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

	(L.L.doorEntriegelung_doorActive_67) 0 <=
	{if}
		0 s5
	{else}
		(L.L.doorTarget_67) ! s5 !
	{endif}

	(L.L.doorEntriegelung_doorActive_67) l6 * * s0
	(L.L.door_pressure_open_7) s1
	1 s2 1 s3
	(M.L.traegheit) (S.L.door_pressure_open_7)

	(L.L.door_pressure_close_7) s1
	(L.L.doorEntriegelung_doorActive_67) l5 l6 * * s0
	(M.L.traegheit) (S.L.door_pressure_close_7)


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

	(L.L.doorEntriegelung_doorActive_89) 0 <=
	{if}
		0 s5
	{else}
		(L.L.doorTarget_89) ! s5 !
	{endif}

	(L.L.doorEntriegelung_doorActive_89) l6 * * s0
	(L.L.door_pressure_open_8) s1
	1 s2 1 s3
	(M.L.traegheit) (S.L.door_pressure_open_8)

	(L.L.door_pressure_close_8) s1
	(L.L.doorEntriegelung_doorActive_89) l5 l6 * * s0
	(M.L.traegheit) (S.L.door_pressure_close_8)

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

	(L.L.doorEntriegelung_doorActive_89) 0 <=
	{if}
		0 s5
	{else}
		(L.L.doorTarget_89) ! s5 !
	{endif}

	(L.L.doorEntriegelung_doorActive_89) l6 * * s0
	(L.L.door_pressure_open_9) s1
	1 s2 1 s3
	(M.L.traegheit) (S.L.door_pressure_open_9)

	(L.L.door_pressure_close_9) s1
	(L.L.doorEntriegelung_doorActive_89) l5 l6 * * s0
	(M.L.traegheit) (S.L.door_pressure_close_9)


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

	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)
	l6 (L.L.doorEntriegelung_doorActive_67) 0 max * (S.L.door_pressure_factor_67)
	l6 (L.L.doorEntriegelung_doorActive_89) 0 max * (S.L.door_pressure_factor_89)

{endif}

'###############################################################################################
' Dämpferverhalten:

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

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

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

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

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

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

	(L.L.doorSpeed_6) 0 >
	{if}
		(L.L.door_6) (F.L.damper_b2_open)
	{else}
		(L.L.door_6) (F.L.damper_b2_close)
	{endif}
	(L.L.doorSpeed_6) * s0

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

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

	(L.L.doorSpeed_7) 0 >
	{if}
		(L.L.door_7) (F.L.damper_b2_open)
	{else}
		(L.L.door_7) (F.L.damper_b2_close)
	{endif}
	(L.L.doorSpeed_7) * s0

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


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

	(L.L.doorSpeed_8) 0 >
	{if}
		(L.L.door_8) (F.L.damper_b3_open)
	{else}
		(L.L.door_8) (F.L.damper_b3_close)
	{endif}
	(L.L.doorSpeed_8) * s0

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

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

	(L.L.doorSpeed_9) 0 >
	{if}
		(L.L.door_9) (F.L.damper_b3_open)
	{else}
		(L.L.door_9) (F.L.damper_b3_close)
	{endif}
	(L.L.doorSpeed_9) * s0

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



'###############################################################################################
'	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}


'###############################################################################################
'###############################################################################################
'	AI-Ablauf:

(L.L.AI_Scheduled_AtStation) s0
1 =
{if}
'If doors need to be opened:
	(L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) <
	{if}
'Only if v < maxkmh, otherwise wait
'Only press the button if it is not already on
		(L.L.bremse_halte_sw) !
		{if}
			(M.L.trg_bus_dooraft)
			1 (S.L.cp_20h_Toogle)
			1 (S.L.DEV_Mode)
		{endif}

		(L.L.doorTarget_0) ! (L.L.door_AI_timer) 0.3 > &&
		{if}
			(M.L.trg_bus_doorfront0)
		{endif}
		(L.L.doorTarget_1) ! (L.L.door_AI_timer) 0.6 > &&
		{if}
			(M.L.trg_bus_doorfront1)
		{endif}

		(L.L.Automatic) !
		{if}
			(L.L.haltewunsch)
			(L.L.doorTarget_23) ! (L.L.door_AI_timer) 0.6 > && &&
			{if}
				(M.L.trg_bus_dooraft23)
			{endif}

			(L.L.haltewunsch_2)
			(L.L.doorTarget_45) ! (L.L.door_AI_timer) 0.6 > && &&
			{if}
				(M.L.trg_bus_dooraft45)
			{endif}

			(L.L.haltewunsch_3)
			(L.L.doorTarget_67) ! (L.L.door_AI_timer) 0.6 > && &&
			{if}
				(M.L.trg_bus_dooraft67)
			{endif}

			(L.L.haltewunsch_4)
			(L.L.doorTarget_89) ! (L.L.door_AI_timer) 0.6 > && &&
			{if}
				(M.L.trg_bus_dooraft89)
			{endif}
		{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 should be closed:
'Only press the button if it is not already off:
	(L.L.doorTarget_1)
	{if}
		(M.L.trg_bus_doorfront1)
		0 (S.L.door_AI_timer)
	{endif}
	(L.L.doorTarget_0) (L.L.door_AI_timer) 0.3 > &&
	{if}
		(M.L.trg_bus_doorfront0)
	{endif}

	(L.L.Automatic) !
	{if}
		(L.L.doorTarget_23) (L.L.door_AI_timer) 0.3 > &&
		{if}
			(M.L.trg_bus_dooraft23)
		{endif}
		(L.L.doorTarget_45) (L.L.door_AI_timer) 0.3 > &&
		{if}
			(M.L.trg_bus_dooraft45)
		{endif}
		(L.L.doorTarget_67) (L.L.door_AI_timer) 0.3 > &&
		{if}
			(M.L.trg_bus_dooraft67)
		{endif}
		(L.L.doorTarget_89) (L.L.door_AI_timer) 0.3 > &&
		{if}
			(M.L.trg_bus_dooraft89)
		{endif}
	{endif}

'Do not remove the bus stop brake until all doors are closed. Only then release the bus AI-wise:
	(L.L.door_2) 0.1 <
	(L.L.door_4) 0.1 <
	(L.L.door_6) 0.1 <
	(L.L.door_8) 0.1 <
'If one of the doors is open and the bus stop brake is off, engage it immediately
	(L.L.bremse_halte_sw) (L.L.door_AI_timer) 0.3 > &&
	{if}
		(M.L.trg_bus_dooraft)
		0 (S.L.cp_20h_Toogle)
		0 (S.L.DEV_Mode)
	{endif}

	(L.L.bremse_halte_sw) !
	{if}
		0 (S.L.AI_Scheduled_AtStation)
	{endif}

	(L.L.doorTarget_0) !
	(L.L.doorTarget_1) ! &&
	(L.L.doorTarget_23) ! &&
	(L.L.doorTarget_45) ! &&
	(L.L.doorTarget_67) ! &&
	(L.L.doorTarget_89) ! &&
	{if}
		0 (S.L.door_AI_timer)
	{endif}
	(L.L.door_AI_timer) (L.S.Timegap) + (S.L.door_AI_timer)
{endif}
{endif}

44 (M.V.GetHumanCountOnPathLink) 0 > 
	{if}
		1 (S.L.PAX_Exit4_Req) (S.L.haltewunsch_3)
	{else}
		0 (S.L.PAX_Exit4_Req) (S.L.PAX_Entry6_Req)
	{endif}

47 (M.V.GetHumanCountOnPathLink) 0 > 
	{if}
		1 (S.L.PAX_Exit5_Req) (S.L.haltewunsch_3)
	{else}
		0 (S.L.PAX_Exit5_Req) (S.L.PAX_Entry6_Req)
	{endif}

52 (M.V.GetHumanCountOnPathLink) 0 > 
	{if}
		1 (S.L.PAX_Exit6_Req) (S.L.haltewunsch_4)
	{else}
		0 (S.L.PAX_Exit6_Req) (S.L.PAX_Entry7_Req)
	{endif}

55 (M.V.GetHumanCountOnPathLink) 0 > 
	{if}
		1 (S.L.PAX_Exit7_Req) (S.L.haltewunsch_4)
	{else}
		0 (S.L.PAX_Exit7_Req) (S.L.PAX_Entry7_Req)
	{endif}
{end}

'###############################################################################################
' Door Calc Türenpaar 1
'###############################################################################################

{macro:Door0_Calc}
	(C.L.electric_doors) (L.L.doorEntriegelung_E_active_01) ! &&
	{if}
	    (L.L.doorEntriegelung_doorActive_01)
	    {if}

		(L.L.doorTarget_0)
		{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)

		(L.L.doorTarget_0) ! (L.L.doorSpeed_0) s0 abs 0.05 > (L.L.door_0) 0 > || && 
		{if}
			(C.L.thinking_doors)
			{if}
				(L.L.doorTarget_1) !
				(L.L.door_1) 0 > &&
				(L.L.door_1) (L.L.door_0) - 0.25 /-/ > &&
				(L.L.door_1) (L.L.door_0) - 0.25 < &&
				(L.L.door_0) 0.15 > &&
				{if}
					(L.L.door0_warten) 1 =
					{if}
						0 (S.L.doorSpeed_0)
						0.20 (S.L.door_0)
					{else}
						(L.L.door_0) 0.25 >
						{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.door0_umkehr) 1 =
							{if}
								0.1 (S.L.doorMaxSpeed_0)
								(L.L.doorSpeed_0) (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)
									(L.L.door_0) 0.20 >
									{if}
										1 (S.L.door0_warten)
									{endif}
							{else}
								0.2 (S.L.doorMaxSpeed_0)
								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)
									(L.L.door_0) 0.18 <
									{if}
										1 (S.L.door0_umkehr)
									{endif}
							{endif}
						{endif}
					{endif}
				{else}
					(L.L.door_0) (F.L.door_0_cls_speed) (S.L.doorMaxSpeed_0)
					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)
				{endif}
	
			{else}
				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)
			{endif}
		{else}
			(L.L.doorSpeed_0) abs 0.05 > (L.L.door_0) 1 < || (L.L.doorTarget_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}

'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)
					(T.L.ev_doortriggeropen_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}

		(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}
'Pneumatisch: .................................
	{else}
		(L.L.doorTarget_0) ! (L.L.doorSpeed_0) s0 abs 0.05 > (L.L.door_0) 0 > || (L.L.doorDragAcc_0) 0 = ! || && 
		{if}
			(L.L.doorSpeed_0) (L.L.doorAcc_0) (L.L.door_pressure_close_0) * (L.L.doorDragAcc_0) - (L.S.Timegap) * - 
				(L.L.doorDamper_0) (L.L.doorDamper_0_kennwert) (L.S.Timegap) * * -
				(S.L.doorSpeed_0)
			(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.doorDragAcc_0) 0 = ! || (L.L.doorTarget_0) &&
			{if}
				(L.L.doorSpeed_0) (L.L.doorAcc_0) (L.L.door_pressure_open_0) * (L.L.doorDragAcc_0) + (L.S.Timegap) * +
					(L.L.doorDamper_0) (L.L.doorDamper_0_kennwert) (L.S.Timegap) * * -
					(S.L.doorSpeed_0) 

'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)
				{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}
'Nur, wenn nicht verriegelt:
	(C.L.electric_doors) (L.L.door_1_locked) ! && (L.L.doorEntriegelung_E_active_01) ! &&
	{if}
	    (L.L.doorEntriegelung_doorActive_01)
	    {if}
		(L.L.doorTarget_1)
		{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_1) ! (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)
			(L.L.door_1) 0.01 <
			{if}
				0 (S.L.door0_warten)
				0 (S.L.door0_umkehr)
			{endif}

		{else}
			(L.L.doorSpeed_1) abs 0.05 > (L.L.door_1) 1 < || (L.L.doorTarget_1) &&
			{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}

'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)
					(T.L.ev_doortriggeropen_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}
		(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}
'Pneumatisch: .................................
	{else}
		(L.L.doorTarget_1) ! (L.L.doorSpeed_1) s0 abs 0.05 > (L.L.door_1) 0 > || (L.L.doorDragAcc_1) 0 = ! || && (L.L.door_1_locked) ! &&
		{if}
			(L.L.doorSpeed_1) (L.L.doorAcc_1) (L.L.door_pressure_close_1) (L.L.doorDragAcc_1) - * (L.S.Timegap) * -
				(L.L.doorDamper_1) (L.L.doorDamper_1_kennwert) (L.S.Timegap) * * -
				(S.L.doorSpeed_1)
			(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.doorDragAcc_1) 0 = ! || (L.L.doorTarget_1) && (L.L.door_1_locked) ! &&
			{if}
				(L.L.doorSpeed_1) (L.L.doorAcc_1) (L.L.door_pressure_open_1) (L.L.doorDragAcc_1) + * (L.S.Timegap) * +
					(L.L.doorDamper_1) (L.L.doorDamper_1_kennwert) (L.S.Timegap) * * -
					(S.L.doorSpeed_1) 

'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)
				{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_1)
		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_1)
			0 (S.L.door_1)
			(L.L.doorSpeed_1) /-/ (L.L.doorRefl_1) * (S.L.doorSpeed_1)
		{endif}
	{endif}
{end}

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

{macro:DoorMid_Open}

(L.L.DEV_Mode) 1 =
{if}	
	(L.L.haltewunsch) (L.L.bremse_halte) &&
	(L.L.door_handsteuerung) ||
	(L.L.doorEntriegelung_E_active_23) (C.L.electric_doors) && ! &&
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
	{if}
		(L.L.doorTarget_23) !
		(L.L.bremse_halte)
		(L.L.door_2) 0 >
		(L.L.door_3) 0 > || || &&
		{if}
			(T.L.ev_doortriggeropen_2)
			1 (S.L.doorTarget_23)
			(C.L.door_druckluft)
			{if}
				(L.L.doorEntriegelung_doorActive_23) -1 =
				{if}
					0 (S.L.doorEntriegelung_doorActive_23)
				{endif}
				(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
			{endif}
		{else}
			1 (S.L.doorEntriegelung_doorActive_23)
		{endif}
		0 (S.L.doorMidLastOpen)

		(C.L.EMI)
		{if}
			0 (S.L.doorTarget_23_delay)
		{endif}	
	{endif}		
{endif}
{end}

{macro:DoorAft_Open}

(L.L.DEV_Mode) 1 =
{if}	
	(L.L.haltewunsch_2) (L.L.bremse_halte) &&
	(L.L.door_handsteuerung_2) ||
	(L.L.doorEntriegelung_E_active_45) (C.L.electric_doors) && ! &&
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
	{if}
		(L.L.doorTarget_45) !
		(L.L.bremse_halte)
		(L.L.door_4) 0 >
		(L.L.door_5) 0 > || || &&
		{if}
			(T.L.ev_doortriggeropen_4)
			1 (S.L.doorTarget_45)
			(C.L.door_druckluft)
			{if}
				(L.L.doorEntriegelung_doorActive_45) -1 =
				{if}
					0 (S.L.doorEntriegelung_doorActive_45)
				{endif}
				(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
			{endif}
		{else}
			1 (S.L.doorEntriegelung_doorActive_45)
		{endif}
		0 (S.L.doorAftLastOpen)

		(C.L.EMI)
		{if}
			0 (S.L.doorTarget_45_delay)
		{endif}
	{endif}
{endif}
{end}

{macro:DoorAft2_Open}

(L.L.DEV_Mode) 1 =
{if}	
	(L.L.haltewunsch_3) (L.L.bremse_halte) &&
	(L.L.door_handsteuerung_3) ||
	(L.L.doorEntriegelung_E_active_67) (C.L.electric_doors) && ! &&
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
	{if}
		(L.L.doorTarget_67) !
		(L.L.bremse_halte)
		(L.L.door_6) 0 >
		(L.L.door_7) 0 > || || &&
		{if}
			(T.L.ev_doortriggeropen_6)
			1 (S.L.doorTarget_67)
			(C.L.door_druckluft)
			{if}
				(L.L.doorEntriegelung_doorActive_67) -1 =
				{if}
					0 (S.L.doorEntriegelung_doorActive_67)
				{endif}
				(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
			{endif}
		{else}
			1 (S.L.doorEntriegelung_doorActive_67)
		{endif}
		0 (S.L.doorAftLastOpen2)

		(C.L.EMI)
		{if}
			0 (S.L.doorTarget_67_delay)
		{endif}
	{endif}
{endif}
{end}

{macro:DoorAft3_Open}

(L.L.DEV_Mode) 1 =
{if}	
	(L.L.haltewunsch_4) (L.L.bremse_halte) &&
	(L.L.door_handsteuerung_4) ||
	(L.L.doorEntriegelung_E_active_89) (C.L.electric_doors) && ! &&
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
	{if}
		(L.L.doorTarget_89) !
		(L.L.bremse_halte)
		(L.L.door_8) 0 >
		(L.L.door_9) 0 > || || &&
		{if}
			(T.L.ev_doortriggeropen_8)
			1 (S.L.doorTarget_89)
			(C.L.door_druckluft)
			{if}
				(L.L.doorEntriegelung_doorActive_89) -1 =
				{if}
					0 (S.L.doorEntriegelung_doorActive_89)
				{endif}
				(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
			{endif}
		{else}
			1 (S.L.doorEntriegelung_doorActive_89)
		{endif}
		0 (S.L.doorAftLastOpen3)

		(C.L.EMI)
		{if}
			0 (S.L.doorTarget_89_delay)
		{endif}
	{endif}
{endif}
{end}

{macro:DoorAftCalc}
	(L.L.bremse_halte_sw) !
	(L.L.door_20h_sw) ! && 
	(L.L.door_hstbremse_knickschutz) ! &&
	(L.L.bremse_kneeling) ! && s0

	l0
	(L.L.door_2) 0 = &&
	(L.L.door_3) 0 = &&
	s0

'	l0
	(L.L.door_4) 0 = &&
	(L.L.door_5) 0 = &&
	(L.L.door_6) 0 = &&
	(L.L.door_7) 0 = &&
	(L.L.door_8) 0 = &&
	(L.L.door_9) 0 = &&
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) <= ||
	(L.L.bremse_halte) &&
	{if}
		0 (S.L.bremse_halte) (S.L.doorMidLastOpen)
		(T.L.ev_haltebremse_aus)
	{endif}


	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	{if}
		(L.L.DEV_Mode)
		{if}
			(L.L.doorMidLastOpen) (L.S.Timegap) + (S.L.doorMidLastOpen)
			(L.L.doorAftLastOpen) (L.S.Timegap) + (S.L.doorAftLastOpen)
			(L.L.doorAftLastOpen2) (L.S.Timegap) + (S.L.doorAftLastOpen2)
			(L.L.doorAftLastOpen3) (L.S.Timegap) + (S.L.doorAftLastOpen3)
		{else}
			0 (S.L.doorAftLastOpen) (S.L.doorMidLastOpen) (S.L.doorAftLastOpen2) (S.L.doorAftLastOpen3)
		{endif}

	(L.L.DEV_Mode) 1 =
	{if}
		(L.L.doorTarget_23)
		(L.L.doorMidLastOpen) (C.L.doorMidOpenTime) > &&
		{if}
			(C.L.door_delay) 0 >
			{if}
				(L.L.doorTarget_23_delay) 0 =
				{if}
					(C.L.EMI)
					{if}
						(T.L.ev_tuer2_piep)
					{endif}
					1 (S.L.doorTarget_23_delay)
				{endif}
				(L.L.doorTarget_23_delay_timer) (L.S.Timegap) + (C.L.door_delay) min (S.L.doorTarget_23_delay_timer)
				(C.L.door_delay) =
				{if}
					(T.L.ev_doortriggerclose_2)
					(C.L.EMI)
					{if}
						(T.L.ev_tuer2_piep)
					{endif}
					0 (S.L.doorTarget_23) (S.L.doorTarget_23_delay_timer)
					(C.L.door_druckluft)
					{if}
						(L.L.doorEntriegelung_doorActive_23) -1 =
						{if}
							0 (S.L.doorEntriegelung_doorActive_23)
						{endif}
						(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
					{endif}
				{endif}
			{else}
				(T.L.ev_doortriggerclose_2)
				0 (S.L.doorTarget_23)
				(C.L.door_druckluft)
				{if}
					(L.L.doorEntriegelung_doorActive_23) -1 =
					{if}
						0 (S.L.doorEntriegelung_doorActive_23)
					{endif}
					(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
				{endif}
			{endif}
		{endif}

		(L.L.doorTarget_45)
		(L.L.doorAftLastOpen) (C.L.doorAftOpenTime) > &&
		{if}
			(C.L.door_delay) 0 >
			{if}
				(L.L.doorTarget_45_delay) 0 =
				{if}
					(C.L.EMI)
					{if}
						(T.L.ev_tuer3_piep)
					{endif}
					1 (S.L.doorTarget_45_delay)
				{endif}
				(L.L.doorTarget_45_delay_timer) (L.S.Timegap) + (C.L.door_delay) min (S.L.doorTarget_45_delay_timer)
				(C.L.door_delay) =
				{if}
					(T.L.ev_doortriggerclose_4)
					(C.L.EMI)
					{if}
						(T.L.ev_tuer3_piep)
					{endif}
					0 (S.L.doorTarget_45) (S.L.doorTarget_45_delay_timer)
					(C.L.door_druckluft)
					{if}
						(L.L.doorEntriegelung_doorActive_45) -1 =
						{if}
							0 (S.L.doorEntriegelung_doorActive_45)
						{endif}
						(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
					{endif}
				{endif}
			{else}
				(T.L.ev_doortriggerclose_4)
				0 (S.L.doorTarget_45)
				(C.L.door_druckluft)
				{if}
					(L.L.doorEntriegelung_doorActive_45) -1 =
					{if}
						0 (S.L.doorEntriegelung_doorActive_45)
					{endif}
					(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
				{endif}
			{endif}
		{endif}

		(L.L.doorTarget_67)
		(L.L.doorAftLastOpen2) (C.L.doorAftOpenTime) > &&
		{if}
			(C.L.door_delay) 0 >
			{if}
				(L.L.doorTarget_67_delay) 0 =
				{if}
					(C.L.EMI)
					{if}
						(T.L.ev_tuer4_piep)
					{endif}
					1 (S.L.doorTarget_67_delay)
				{endif}
				(L.L.doorTarget_67_delay_timer) (L.S.Timegap) + (C.L.door_delay) min (S.L.doorTarget_67_delay_timer)
				(C.L.door_delay) =
				{if}
					(T.L.ev_doortriggerclose_6)
					(C.L.EMI)
					{if}
						(T.L.ev_tuer4_piep)
					{endif}
					0 (S.L.doorTarget_67) (S.L.doorTarget_67_delay_timer)
					(C.L.door_druckluft)
					{if}
						(L.L.doorEntriegelung_doorActive_67) -1 =
						{if}
							0 (S.L.doorEntriegelung_doorActive_67)
						{endif}
						(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
					{endif}
				{endif}
			{else}
				(T.L.ev_doortriggerclose_6)
				0 (S.L.doorTarget_67)
				(C.L.door_druckluft)
				{if}
					(L.L.doorEntriegelung_doorActive_67) -1 =
					{if}
						0 (S.L.doorEntriegelung_doorActive_67)
					{endif}
					(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
				{endif}
			{endif}
		{endif}

		(L.L.doorTarget_89)
		(L.L.doorAftLastOpen3) (C.L.doorAftOpenTime) > &&
		{if}
			(C.L.door_delay) 0 >
			{if}
				(L.L.doorTarget_89_delay) 0 =
				{if}
					(C.L.EMI)
					{if}
						(T.L.ev_tuer5_piep)
					{endif}
					1 (S.L.doorTarget_89_delay)
				{endif}
				(L.L.doorTarget_89_delay_timer) (L.S.Timegap) + (C.L.door_delay) min (S.L.doorTarget_89_delay_timer)
				(C.L.door_delay) =
				{if}
					(T.L.ev_doortriggerclose_8)
					(C.L.EMI)
					{if}
						(T.L.ev_tuer5_piep)
					{endif}
					0 (S.L.doorTarget_89) (S.L.doorTarget_89_delay_timer)
					(C.L.door_druckluft)
					{if}
						(L.L.doorEntriegelung_doorActive_89) -1 =
						{if}
							0 (S.L.doorEntriegelung_doorActive_89)
						{endif}
						(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
					{endif}
				{endif}
			{else}
				(T.L.ev_doortriggerclose_8)
				0 (S.L.doorTarget_89)
				(C.L.door_druckluft)
				{if}
					(L.L.doorEntriegelung_doorActive_89) -1 =
					{if}
						0 (S.L.doorEntriegelung_doorActive_89)
					{endif}
					(L.L.bremse_p_Tank04) 100000 - 0.94 * 100000 + (S.L.bremse_p_Tank04)
				{endif}
			{endif}
		{endif}
	{endif}

	(L.L.door_2) 1 = (L.L.door_2) 1 = ||
	{if}
		(L.L.doorMidLastOpen) (L.S.Timegap) + {else} 0
	{endif}
	(S.L.DoorMidLastOpen)

	(L.L.door_4) 1 = (L.L.door_5) 1 = ||
	{if}
		(L.L.doorAftLastOpen) (L.S.Timegap) + {else} 0
	{endif}
	(S.L.DoorAftLastOpen)

	(L.L.door_6) 1 = (L.L.door_7) 1 = ||
	{if}
		(L.L.doorAftLastOpen2) (L.S.Timegap) + {else} 0
	{endif}
	(S.L.DoorAftLastOpen2)

	(L.L.door_8) 1 = (L.L.door_9) 1 = ||
	{if}
		(L.L.doorAftLastOpen3) (L.S.Timegap) + {else} 0
	{endif}
	(S.L.DoorAftLastOpen3)

	{else}
		0 (S.L.doorMidLastOpen) (S.L.doorAftLastOpen) (S.L.doorAftLastOpen2) (S.L.doorAftLastOpen3)
	{endif}
{end}

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

{macro:Door2_Calc}
	(C.L.electric_doors) (L.L.doorEntriegelung_E_active_23) ! &&
	{if}
	    (L.L.doorEntriegelung_doorActive_23)
	    {if}
		(L.L.doorTarget_23)
		{if}
			(L.L.door_2) (F.L.door_2_opn_speed) (S.L.doorMaxSpeed_2)
		{else}
			(L.L.door_2) (F.L.door_2_cls_speed) (S.L.doorMaxSpeed_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}
			(L.L.tuer2_piep_antirepeat) 1 + (S.L.tuer2_piep_antirepeat)
			1 =
			{if}
				(T.L.ev_doortriggerclose_2)
			{endif}
			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}
		(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}
'Pneumatisch: .................................
	{else}
		(L.L.doorTarget_23) ! (L.L.doorSpeed_2) s0 abs 0.05 > (L.L.door_2) 0 > || (L.L.doorDragAcc_2) 0 = ! || && 
		{if}
			(L.L.doorSpeed_2) (L.L.doorAcc_2) (L.L.door_pressure_close_2) (L.L.doorDragAcc_2) - * (L.S.Timegap) * -
				(L.L.doorDamper_2) (L.L.doorDamper_2_kennwert) (L.S.Timegap) * * -
				(S.L.doorSpeed_2)
			(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.doorDragAcc_2) 0 = ! || (L.L.doorTarget_23) &&
			{if}
				(L.L.doorSpeed_2) (L.L.doorAcc_2) (L.L.door_pressure_open_2) (L.L.doorDragAcc_2) + * (L.S.Timegap) * +
					(L.L.doorDamper_2) (L.L.doorDamper_2_kennwert) (L.S.Timegap) * * -
					(S.L.doorSpeed_2) 
				(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_2)
		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_2)
			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) (L.L.doorEntriegelung_E_active_23) ! &&
	{if}
	    (L.L.doorEntriegelung_doorActive_23)
	    {if}
		(L.L.doorTarget_23)
		{if}
			(L.L.door_3) (F.L.door_3_opn_speed) (S.L.doorMaxSpeed_3)
		{else}
			(L.L.door_3) (F.L.door_3_cls_speed) (S.L.doorMaxSpeed_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}
		(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}
'Pneumatisch: .................................
	{else}
		(L.L.doorTarget_23) ! (L.L.doorSpeed_3) s0 abs 0.05 > (L.L.door_3) 0 > || (L.L.doorDragAcc_3) 0 = ! || && 
		{if}
			(L.L.doorSpeed_3) (L.L.doorAcc_3) (L.L.door_pressure_close_3) (L.L.doorDragAcc_3) - * (L.S.Timegap) * -
				(L.L.doorDamper_3) (L.L.doorDamper_3_kennwert) (L.S.Timegap) * * -
				(S.L.doorSpeed_3)
			(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.doorDragAcc_3) 0 = ! || (L.L.doorTarget_23) &&
			{if}
				(L.L.doorSpeed_3) (L.L.doorAcc_3) (L.L.door_pressure_open_3) (L.L.doorDragAcc_3) + * (L.S.Timegap) * +
					(L.L.doorDamper_3) (L.L.doorDamper_3_kennwert) (L.S.Timegap) * * -
					(S.L.doorSpeed_3) 
				(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_3)
		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_3)
			0 (S.L.door_3)
			(L.L.doorSpeed_3) /-/ (L.L.doorRefl_3) * (S.L.doorSpeed_3)
		{endif}
	{endif}
{end}

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

{macro:Door4_Calc}
	(C.L.electric_doors) (L.L.doorEntriegelung_E_active_45) ! &&
	{if}
	    (L.L.doorEntriegelung_doorActive_45)
	    {if}
		(L.L.doorTarget_45)
		{if}
			(L.L.door_4) (F.L.door_4_opn_speed) (S.L.doorMaxSpeed_4)
		{else}
			(L.L.door_4) (F.L.door_4_cls_speed) (S.L.doorMaxSpeed_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_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}
			(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}
		(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}
'Pneumatisch: .................................
	{else}
		(L.L.doorTarget_45) ! (L.L.doorSpeed_4) s0 abs 0.05 > (L.L.door_4) 0 > || (L.L.doorDragAcc_4) 0 = ! || && 
		{if}
			(L.L.doorSpeed_4) (L.L.doorAcc_4) (L.L.door_pressure_close_4) (L.L.doorDragAcc_4) - * (L.S.Timegap) * -
				(L.L.doorDamper_4) (L.L.doorDamper_4_kennwert) (L.S.Timegap) * * -
				(S.L.doorSpeed_4)
			(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.doorDragAcc_4) 0 = ! || (L.L.doorTarget_45) &&
			{if}
				(L.L.doorSpeed_4) (L.L.doorAcc_4) (L.L.door_pressure_open_4) (L.L.doorDragAcc_4) + * (L.S.Timegap) * +
					(L.L.doorDamper_4) (L.L.doorDamper_4_kennwert) (L.S.Timegap) * * -
					(S.L.doorSpeed_4) 
				(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_4)
		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_4)
			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) (L.L.doorEntriegelung_E_active_45) ! &&
	{if}
	    (L.L.doorEntriegelung_doorActive_45)
	    {if}
		(L.L.doorTarget_45)
		{if}
			(L.L.door_5) (F.L.door_5_opn_speed) (S.L.doorMaxSpeed_5)
		{else}
			(L.L.door_5) (F.L.door_5_cls_speed) (S.L.doorMaxSpeed_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}
		(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}
'Pneumatisch: .................................
	{else}
		(L.L.doorTarget_45) ! (L.L.doorSpeed_5) s0 abs 0.05 > (L.L.door_5) 0 > || (L.L.doorDragAcc_5) 0 = ! || && 
		{if}
			(L.L.doorSpeed_5) (L.L.doorAcc_5) (L.L.door_pressure_close_5) (L.L.doorDragAcc_5) - * (L.S.Timegap) * -
				(L.L.doorDamper_5) (L.L.doorDamper_5_kennwert) (L.S.Timegap) * * -
				(S.L.doorSpeed_5)
			(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.doorDragAcc_5) 0 = ! || (L.L.doorTarget_45) &&
			{if}
				(L.L.doorSpeed_5) (L.L.doorAcc_5) (L.L.door_pressure_open_5) (L.L.doorDragAcc_5) + * (L.S.Timegap) * +
					(L.L.doorDamper_5) (L.L.doorDamper_5_kennwert) (L.S.Timegap) * * -
					(S.L.doorSpeed_5) 
				(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_5)
		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_5)
			0 (S.L.door_5)
			(L.L.doorSpeed_5) /-/ (L.L.doorRefl_5) * (S.L.doorSpeed_5)
		{endif}
	{endif}
{end}

'###############################################################################################
' Door Calc Türenpaar 4
'###############################################################################################

{macro:Door6_Calc}
	(C.L.electric_doors) (L.L.doorEntriegelung_E_active_67) ! &&
	{if}
	    (L.L.doorEntriegelung_doorActive_67)
	    {if}
		(L.L.doorTarget_67)
		{if}
			(L.L.door_6) (F.L.door_6_opn_speed) (S.L.doorMaxSpeed_6)
		{else}
			(L.L.door_6) (F.L.door_6_cls_speed) (S.L.doorMaxSpeed_6)
		{endif}

		(C.L.bdoor2_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}
		(L.L.elec_busbar_Rinv_summe)
			(L.L.doorSpeed_6) abs (C.L.door_Rinv) * +
		(S.L.elec_busbar_Rinv_summe)
	    {else}
		0 (S.L.doorSpeed_6)
	    {endif}
'Pneumatisch: .................................
	{else}
		(L.L.doorTarget_67) ! (L.L.doorSpeed_6) s0 abs 0.05 > (L.L.door_6) 0 > || (L.L.doorDragAcc_6) 0 = ! || && 
		{if}
			(L.L.doorSpeed_6) (L.L.doorAcc_6) (L.L.door_pressure_close_6) (L.L.doorDragAcc_6) - * (L.S.Timegap) * -
				(L.L.doorDamper_6) (L.L.doorDamper_6_kennwert) (L.S.Timegap) * * -
				(S.L.doorSpeed_6)
			(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.doorDragAcc_6) 0 = ! || (L.L.doorTarget_67) &&
			{if}
				(L.L.doorSpeed_6) (L.L.doorAcc_6) (L.L.door_pressure_open_6) (L.L.doorDragAcc_6) + * (L.S.Timegap) * +
					(L.L.doorDamper_6) (L.L.doorDamper_6_kennwert) (L.S.Timegap) * * -
					(S.L.doorSpeed_6) 
				(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_6)
		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_6)
			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) (L.L.doorEntriegelung_E_active_67) ! &&
	{if}
	    (L.L.doorEntriegelung_doorActive_67)
	    {if}
		(L.L.doorTarget_67)
		{if}
			(L.L.door_7) (F.L.door_7_opn_speed) (S.L.doorMaxSpeed_7)
		{else}
			(L.L.door_7) (F.L.door_7_cls_speed) (S.L.doorMaxSpeed_7)
		{endif}

		(C.L.bdoor2_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}
		(L.L.elec_busbar_Rinv_summe)
			(L.L.doorSpeed_7) abs (C.L.door_Rinv) * +
		(S.L.elec_busbar_Rinv_summe)
	    {else}
		0 (S.L.doorSpeed_7)
	    {endif}
'Pneumatisch: .................................
	{else}
		(L.L.doorTarget_67) ! (L.L.doorSpeed_7) s0 abs 0.05 > (L.L.door_7) 0 > || (L.L.doorDragAcc_7) 0 = ! || && 
		{if}
			(L.L.doorSpeed_7) (L.L.doorAcc_7) (L.L.door_pressure_close_7) (L.L.doorDragAcc_7) - * (L.S.Timegap) * -
				(L.L.doorDamper_7) (L.L.doorDamper_7_kennwert) (L.S.Timegap) * * -
				(S.L.doorSpeed_7)
			(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.doorDragAcc_7) 0 = ! || (L.L.doorTarget_67) &&
			{if}
				(L.L.doorSpeed_7) (L.L.doorAcc_7) (L.L.door_pressure_open_7) (L.L.doorDragAcc_7) + * (L.S.Timegap) * +
					(L.L.doorDamper_7) (L.L.doorDamper_7_kennwert) (L.S.Timegap) * * -
					(S.L.doorSpeed_7) 
				(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_7)
		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_7)
			0 (S.L.door_7)
			(L.L.doorSpeed_7) /-/ (L.L.doorRefl_7) * (S.L.doorSpeed_7)
		{endif}
	{endif}

{end}

'###############################################################################################
' Door Calc Türenpaar 5
'###############################################################################################

{macro:Door8_Calc}
	(C.L.electric_doors) (L.L.doorEntriegelung_E_active_89) ! &&
	{if}
	    (L.L.doorEntriegelung_doorActive_89)
	    {if}
		(L.L.doorTarget_89)
		{if}
			(L.L.door_8) (F.L.door_8_opn_speed) (S.L.doorMaxSpeed_8)
		{else}
			(L.L.door_8) (F.L.door_8_cls_speed) (S.L.doorMaxSpeed_8)
		{endif}

		(C.L.bdoor3_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}
		(L.L.elec_busbar_Rinv_summe)
			(L.L.doorSpeed_8) abs (C.L.door_Rinv) * +
		(S.L.elec_busbar_Rinv_summe)
	    {else}
		0 (S.L.doorSpeed_8)
	    {endif}
'Pneumatisch: .................................
	{else}
		(L.L.doorTarget_89) ! (L.L.doorSpeed_8) s0 abs 0.05 > (L.L.door_8) 0 > || (L.L.doorDragAcc_8) 0 = ! || && 
		{if}
			(L.L.doorSpeed_8) (L.L.doorAcc_8) (L.L.door_pressure_close_8) (L.L.doorDragAcc_8) - * (L.S.Timegap) * -
				(L.L.doorDamper_8) (L.L.doorDamper_8_kennwert) (L.S.Timegap) * * -
				(S.L.doorSpeed_8)
			(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.doorDragAcc_8) 0 = ! || (L.L.doorTarget_89) &&
			{if}
				(L.L.doorSpeed_8) (L.L.doorAcc_8) (L.L.door_pressure_open_8) (L.L.doorDragAcc_8) + * (L.S.Timegap) * +
					(L.L.doorDamper_8) (L.L.doorDamper_8_kennwert) (L.S.Timegap) * * -
					(S.L.doorSpeed_8) 
				(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_8)
		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_8)
			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) (L.L.doorEntriegelung_E_active_89) ! &&
	{if}
	    (L.L.doorEntriegelung_doorActive_89)
	    {if}
		(L.L.doorTarget_89)
		{if}
			(L.L.door_9) (F.L.door_9_opn_speed) (S.L.doorMaxSpeed_9)
		{else}
			(L.L.door_9) (F.L.door_9_cls_speed) (S.L.doorMaxSpeed_9)
		{endif}

		(C.L.bdoor3_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}
		(L.L.elec_busbar_Rinv_summe)
			(L.L.doorSpeed_9) abs (C.L.door_Rinv) * +
		(S.L.elec_busbar_Rinv_summe)
	    {else}
		0 (S.L.doorSpeed_9)
	    {endif}
'Pneumatisch: .................................
	{else}
		(L.L.doorTarget_89) ! (L.L.doorSpeed_9) s0 abs 0.05 > (L.L.door_9) 0 > || (L.L.doorDragAcc_9) 0 = ! || && 
		{if}
			(L.L.doorSpeed_9) (L.L.doorAcc_9) (L.L.door_pressure_close_9) (L.L.doorDragAcc_9) - * (L.S.Timegap) * -
				(L.L.doorDamper_9) (L.L.doorDamper_9_kennwert) (L.S.Timegap) * * -
				(S.L.doorSpeed_9)
			(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.doorDragAcc_9) 0 = ! || (L.L.doorTarget_89) &&
			{if}
				(L.L.doorSpeed_9) (L.L.doorAcc_9) (L.L.door_pressure_open_9) (L.L.doorDragAcc_9) + * (L.S.Timegap) * +
					(L.L.doorDamper_9) (L.L.doorDamper_9_kennwert) (L.S.Timegap) * * -
					(S.L.doorSpeed_9) 
				(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_9)
		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_9)
			0 (S.L.door_9)
			(L.L.doorSpeed_9) /-/ (L.L.doorRefl_9) * (S.L.doorSpeed_9)
		{endif}
	{endif}

{end}

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

{macro:trg_bus_doorfront0}
	(L.L.doorEntriegelung_E_active_01) (C.L.electric_doors) && !
	{if}
		(L.L.doorTarget_0) ! (S.L.doorTarget_0) 
		{if}
			(T.L.ev_doortriggeropen_0)
		{else}
			(T.L.ev_doortriggerclose_0)
		{endif}
		(C.L.door_druckluft)
		{if}
			(L.L.doorEntriegelung_doorActive_01) -1 =
			{if}
				0 (S.L.doorEntriegelung_doorActive_01)
			{else}
				1 (S.L.doorEntriegelung_doorActive_01)
			{endif}	
			(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
		{else}
			1 (S.L.doorEntriegelung_doorActive_01)
		{endif}
	{endif}
{end}

{macro:trg_bus_doorfront1}
	(L.L.doorEntriegelung_E_active_01) (C.L.electric_doors) && !
	{if}
		(L.L.doorTarget_1) ! (S.L.doorTarget_1) 
		{if}
			(T.L.ev_doortriggeropen_1)
		{else}
			(T.L.ev_doortriggerclose_1)
		{endif}	
		(C.L.door_druckluft)
		{if}
			(L.L.doorEntriegelung_doorActive_01) -1 =
			{if}
				0 (S.L.doorEntriegelung_doorActive_01)
			{else}
				1 (S.L.doorEntriegelung_doorActive_01)
			{endif}	
			(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
		{else}
			1 (S.L.doorEntriegelung_doorActive_01)
		{endif}
	{endif}
{end}

{macro:trg_bus_dooraft23}
	(L.L.doorEntriegelung_E_active_23) (C.L.electric_doors) && !
	{if}
		(L.L.doorTarget_23) ! (S.L.doorTarget_23) 
		{if}
			(T.L.ev_doortriggeropen_2)
			(C.L.EMI)
			{if}
				0 (S.L.doorTarget_23_delay)
			{endif}
		{else}
			4 (S.L.doorMidLastOpen)
			(T.L.ev_doortriggerclose_2)

			(C.L.EMI)
			(L.L.DEV_Mode) &&
			{if}
				(T.L.ev_tuer2_piep)
			{endif}
		{endif}

		(C.L.door_druckluft)
		{if}
			(L.L.doorEntriegelung_doorActive_23) -1 =
			{if}
				0 (S.L.doorEntriegelung_doorActive_23)
			{endif}
			(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
		{else}
			1 (S.L.doorEntriegelung_doorActive_23)
		{endif}
	{endif}
{end}

{macro:trg_bus_dooraft45}
	(L.L.doorEntriegelung_E_active_45) (C.L.electric_doors) && !
	{if}
		(L.L.doorTarget_45) ! (S.L.doorTarget_45) 
		{if}
			(T.L.ev_doortriggeropen_4)
			(C.L.EMI)
			{if}
				0 (S.L.doorTarget_45_delay)
			{endif}
		{else}
			4 (S.L.doorAftLastOpen)
			(T.L.ev_doortriggerclose_4)

			(C.L.EMI)
			(L.L.DEV_Mode) &&
			{if}
				(T.L.ev_tuer3_piep)
			{endif}
		{endif}
		(C.L.door_druckluft)
		{if}
			(L.L.doorEntriegelung_doorActive_45) -1 =
			{if}
				0 (S.L.doorEntriegelung_doorActive_45)
			{endif}
			(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
		{else}
			1 (S.L.doorEntriegelung_doorActive_45)
		{endif}
	{endif}
{end}

{macro:trg_bus_dooraft67}
	(L.L.doorEntriegelung_E_active_67) (C.L.electric_doors) && !
	{if}
		(L.L.doorTarget_67) ! (S.L.doorTarget_67) 
		{if}
			(T.L.ev_doortriggeropen_6)
			(C.L.EMI)
			{if}
				0 (S.L.doorTarget_67_delay)
			{endif}
		{else}
			4 (S.L.doorAftLastOpen2)
			(T.L.ev_doortriggerclose_6)

			(C.L.EMI)
			(L.L.DEV_Mode) &&
			{if}
				(T.L.ev_tuer4_piep)
			{endif}
		{endif}
		(C.L.door_druckluft)
		{if}
			(L.L.doorEntriegelung_doorActive_67) -1 =
			{if}
				0 (S.L.doorEntriegelung_doorActive_67)
			{endif}
			(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
		{else}
			1 (S.L.doorEntriegelung_doorActive_67)
		{endif}
	{endif}
{end}

{macro:trg_bus_dooraft89}
	(L.L.doorEntriegelung_E_active_89) (C.L.electric_doors) && !
	{if}
		(L.L.doorTarget_89) ! (S.L.doorTarget_89) 
		{if}
			(T.L.ev_doortriggeropen_8)
			(C.L.EMI)
			{if}
				0 (S.L.doorTarget_89_delay)
			{endif}
		{else}
			4 (S.L.doorAftLastOpen3)
			(T.L.ev_doortriggerclose_8)

			(C.L.EMI)
			(L.L.DEV_Mode) &&
			{if}
				(T.L.ev_tuer5_piep)
			{endif}
		{endif}
		(C.L.door_druckluft)
		{if}
			(L.L.doorEntriegelung_doorActive_89) -1 =
			{if}
				0 (S.L.doorEntriegelung_doorActive_89)
			{endif}
			(L.L.bremse_p_Tank04) 100000 - 0.96 * 100000 + (S.L.bremse_p_Tank04)
		{else}
			1 (S.L.doorEntriegelung_doorActive_89)
		{endif}
	{endif}
{end}

{macro:trg_bus_dooraft}
	(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}

{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:door_malf_cyc_dec}
	(L.L.door_malf_autobdoor_remcyc) s0 0 >=
	{if}
		0 (S.L.door_malf_autobdoor_closingOK)
		l0 1 - (S.L.door_malf_autobdoor_remcyc) s0
		l0 0 < (L.L.door_malf_autobdoor_reopen_prob) 0 < &&
		{if}
			100 random (S.L.door_malf_autobdoor_reopen_prob)
		{endif}
	{else}
		(L.L.door_malf_autobdoor_closingOK) -1.5 >
		{if}
			0 (S.L.door_malf_autobdoor_closingOK)
		{endif}
	{endif}
{end}

{macro:door_malf_autobdoor_reopen}
	(L.L.door_malf_autobdoor_remcyc) 0 <
	(L.L.door_malf_autobdoor_closingOK) 0.5 <
	(L.L.door_2) s0 0.5 < l0 0.1 > && && &&
	{if}
		100 random (L.L.door_malf_autobdoor_reopen_prob) <
		(L.L.door_malf_autobdoor_closingOK) -0.5 < ||
		{if}
			1 (S.L.haltewunsch)
			(L.L.door_malf_autobdoor_reopen_prob) 50 random 25 + >
			(L.L.door_malf_autobdoor_closingOK) s0 -1.5 < ||
			l0 -1.5 <
			l0 -0.5 > || &&
			{if}
				-2 (S.L.door_malf_autobdoor_closingOK)
			{else}
				-1 (S.L.door_malf_autobdoor_closingOK)
			{endif}
		{else}
			1 (S.L.door_malf_autobdoor_closingOK)
		{endif}
	{endif}
{end}

{macro:door_lifetimeinit}
	(C.L.door_malf_autobdoor_livetime_cyc) random (L.L.wearlifespan) * (S.L.door_malf_autobdoor_remcyc)
	-1 (S.L.door_malf_autobdoor_reopen_prob)
{end}

{macro:door_repair}
	(L.L.door_malf_autobdoor_reopen_prob) 0 >
	{if}
		(C.L.door_malf_autobdoor_livetime_cyc) random (S.L.door_malf_autobdoor_remcyc)  
		-1 (S.L.door_malf_autobdoor_reopen_prob)
	{endif}
{end}

{macro:door_repair_timecalc}

'Berechnung der Zeit, die benötigt wird, um die Schäden zu reparieren:

	s0

	(L.L.door_malf_autobdoor_reopen_prob) 0 > 5 * l0 + s0

	l0
{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}