'##############
'IBIS Script
'##############

'80s style IBIS (Integrated Board Information System)

'(c) 15.04.2009 Rüdiger Hülsmann
'(c) 17.01.2011 Marcel Kuhnt

'Script Version: 1.1
'Omsi release: 1.0

'Needs:
'- Cockpit (Batterietrennschalter)
'- Door (Haltestellenbremse)

'Revision History:

'- Rüdiger Hülsmann		05.01.2011		File created based on IBIS.osc (last revision 05.01.2011)
'- Marcel Kuhnt			07.01.2011		Don't show busstops if no route	
'- Marcel Kuhnt			17.01.2011		9xx00 => 9xx04 instead of 9xx35!
'- Rüdiger Hülsmann		24.01.2011		Delay display on IBIS
'- Rüdiger Hülsmann		26.01.2011		IBIS blink bug fixed, "+/- 0 min" removed
'- Rüdiger Hülsmann		06.02.2011		Cabin-display init
'- Marcel Kuhnt			24.02.2011		Announcements from string act_busstop

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

'Mypol-Módy:

'	0:	Linka/Cíl
'	1:	Linka/Trasa (JŘ)
'	2:	Zadávání Linky
'	3:	Zadávání Trasy
'	4:	Zadávání Cíle
'	5:	Zadávání služebního hlášení
'	6:	Spouštění MYPOLU
'	7:	Pozice v JŘ (Poloha)

'Vnitřní BUSE Módy:

'	0:	Odhlášena zastávka - Aktuální zastávka/Příští zastávka
'	1:	Odhlášena zastávka, otevřeny dveře - Linka/Směr/Příští zastávka
'	2:	Zobrazení příští zastávky
'	3:	Datum a Čas
'	4:	Zóna
'	5:	Linka/Směr
'	6: 	Přes zastávky



'----------------------
'	Trigger
'----------------------
{trigger:ai_scheduled_settarget}

'Stromversorgung herstellen:
		1 (S.L.elec_busbar_main_sw)	
		1.0 (S.L.elec_V_battery)
		1 (S.L.elec_busbar_main)

'Hier wird das Ziel eingestellt:
		(L.$.SetLineTo) (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni)

		1 (S.L.elec_busbar_main_sw)
		(L.L.AI_target_index) (S.L.IBIS_TerminusIndex) (S.L.target_index_int) s7 (M.V.GetTerminusCode) (S.L.Debug_2) (S.L.IBIS_TerminusCode)
		l7 3 (M.V.GetTerminusString) (S.$.BUSE_Bocni_Cil)
		l7 2 (M.V.GetTerminusString)
		$length 0 =
		{if}
			"" (S.$.BUSE_Celni_2R)
			l7 1 (M.V.GetTerminusString) (S.$.BUSE_Celni_1R)
		{else}
			"" (S.$.BUSE_Celni_1R)
			l7 1 (M.V.GetTerminusString) "@" $+
			l7 2 (M.V.GetTerminusString) $+ (S.$.BUSE_Celni_2R)
		{endif}	

		1 (S.L.Refresh_Strings)
{end}


{trigger:ibis_mypol_SipL}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			(L.L.MYPOL_pozice) 0 >
			{if}
				(L.L.MYPOL_pozice) 1 - (S.L.MYPOL_pozice)
			{endif}
		{endif}

		(L.L.MYPOL_mode) 7 =
		{if}
			(L.L.IBIS_internal_busstop) 0 >
			{if}
				(L.L.IBIS_internal_busstop) 1 - (S.L.IBIS_internal_busstop)
				1 (S.L.Posuv_zpet)
			{endif}
		{endif}
	{endif}

{end}

{trigger:ibis_mypol_SipN}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
	{endif}
	
{end}


{trigger:ibis_mypol_SipP}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
		(L.L.MYPOL_mode) 2 =
		{if}
			(L.L.MYPOL_pozice) 2 <
			{if}
				(L.L.MYPOL_pozice) 1 + (S.L.MYPOL_pozice)
			{endif}
		{endif}

		(L.L.MYPOL_mode) 3 = (L.L.MYPOL_mode) 5 = ||
		{if}
			(L.L.MYPOL_pozice) 1 <
			{if}
				(L.L.MYPOL_pozice) 1 + (S.L.MYPOL_pozice)
			{endif}
		{endif}

		(L.L.MYPOL_mode) 4 =
		{if}
			(L.L.MYPOL_pozice) 3 <
			{if}
				(L.L.MYPOL_pozice) 1 + (S.L.MYPOL_pozice)
			{endif}
		{endif}

		(L.L.MYPOL_mode) 7 =
		{if}
			(L.L.IBIS_internal_busstop) (L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - <
			{if}
				(L.L.IBIS_internal_busstop) 1 + (S.L.IBIS_internal_busstop)
				1 (S.L.Posuv_vpred)
			{endif}
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Hlas}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)

		(L.L.MYPOL_mode) 0 = (L.L.MYPOL_mode) 1 = ||
		{if}
			(L.L.MYPOL_mode) (S.L.MYPOL_mode_prev)
			5 (S.L.MYPOL_mode)
			1 (S.L.Hlas_init)
		{endif}

	{endif}
	
{end}

{trigger:ibis_mypol_Ent}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)

		(L.L.MYPOL_mode) 1 =
		{if}
			(M.L.hlaseni_akt_zastavky)
		{endif}

		(L.L.MYPOL_mode) 2 =
		{if}
			(L.$.MYPOL_znak1) (L.$.MYPOL_znak2) $+ (L.$.MYPOL_znak3) $+ (S.$.MYPOL_Linka)
			
			(L.L.Mypol_cislice_1) 100 *
			(L.L.Mypol_cislice_2) 10 * +
			(L.L.Mypol_cislice_3) +
			(S.L.Mypol_cislo_linky)

			"0000" (S.$.MYPOL_cil) 0 (S.L.MYPOL_cislo_cile) (S.L.IBIS_TerminusIndex) (S.L.target_index_int)
			0 (S.L.MYPOL_mode)
			0 (S.L.zastavka_odhlasena)
			(M.L.BUSE_linka_frame)
			(M.L.BUSE_cil_frame)
		{endif}

		(L.L.MYPOL_mode) 4 =
		{if}
			(L.$.MYPOL_znak1) (L.$.MYPOL_znak2) $+ (L.$.MYPOL_znak3) $+ (L.$.MYPOL_znak4) $+
			(S.$.MYPOL_cil)
			
			(L.L.Mypol_cislice_1) 1000 *
			(L.L.Mypol_cislice_2) 100 * +
			(L.L.Mypol_cislice_3) 10 * +
			(L.L.Mypol_cislice_4) +
			(S.L.MYPOL_cislo_cile)

			(M.V.GetTerminusIndex)
			0 <
			{if}
				"0000" (S.$.MYPOL_cil)
				0 (S.L.IBIS_TerminusIndex) (S.L.target_index_int)
			{else}
				(L.L.MYPOL_cislo_cile) (M.V.GetTerminusIndex)
				(S.L.IBIS_TerminusIndex) (S.L.target_index_int)
			{endif}
			0 (S.L.MYPOL_mode)
			0 (S.L.zastavka_odhlasena)

			(M.L.BUSE_linka_frame)
			(M.L.BUSE_cil_frame)
		{endif}

		(L.L.MYPOL_mode) 3 =
		{if}
			(L.$.MYPOL_znak1) (L.$.MYPOL_znak2) $+
			(S.$.MYPOL_trasa)
			
			(L.L.Mypol_cislice_1) 10 *
			(L.L.Mypol_cislice_2) +
			(S.L.MYPOL_cislo_trasy)

			(L.L.Mypol_cislo_linky) 100 * (L.L.Mypol_cislo_trasy) +
			(M.V.GetRouteIndex) s0
			l0 0 <
			{if}
				"0000" (S.$.MYPOL_cil)
				0 (S.L.IBIS_TerminusIndex) (S.L.target_index_int)
				0 (S.L.MYPOL_mode)
			{else}
				1 (S.L.MYPOL_mode)
				0 (S.L.Cas_odchylka)
				(M.L.Nastav_trasu)
				0 (S.L.IBIS_busstop)
				-1 (S.L.IBIS_busstop_TT)
				0 (S.L.MYPOL_zastavka_ok)
				0 (S.L.Pocet_pres)
			{endif}
		{endif}

		(L.L.MYPOL_mode) 5 =
		{if}
			(L.$.MYPOL_znak1) (L.$.MYPOL_znak2) $+ (S.$.MYPOL_pracovni1)
			"01" $=
			{if}
				1 (S.L.Linka_smer_hlasit)
				0 (S.L.Linka_smer_timer)
				0 (S.L.Linka_smer_time)
				1 (S.L.Linka_smer_rucne)
			{else}
				"..\..\Ansagen\" (L.$.yard) $+ "\Sluzebni\" $+
				(L.$.MYPOL_pracovni1) $+ ".wav" $+
				(T.F.ev_IBIS_Ansagen)
			{endif}
			(L.L.MYPOL_mode_prev) (S.L.MYPOL_mode)
		{endif}

		(L.L.MYPOL_mode) 7 =
		{if}
			1 (S.L.MYPOL_mode)
			(L.L.IBIS_internal_busstop) (S.L.IBIS_busstop)
			0 (S.L.MYPOL_zastavka_ok)
			0 (S.L.Zastavka_odhlasena)
			2 (S.L.BUSE_int_mode)
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Del}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = ||
		(L.L.MYPOL_mode) 5 = ||
		{if}
			(L.L.MYPOL_mode_prev) (S.L.MYPOL_mode)
		{endif}
		(L.L.MYPOL_mode) 7 =
		{if}
			1 (S.L.MYPOL_mode)
			(L.L.IBIS_busstop_TT_Zal) (S.L.IBIS_busstop_TT)
			0 (S.L.MYPOL_zastavka_ok)
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Key0}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			"0" (S.$.MYPOL_cislo) 0 (S.L.Mypol_cislice)
			(M.L.Zadat_cislo_frame)
		{endif}
	
		(L.L.MYPOL_mode) 1 =
		{if}
			(M.L.hlaseni_akt_zastavky)
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Key1}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			"1" (S.$.MYPOL_cislo) 1 (S.L.Mypol_cislice)
			(M.L.Zadat_cislo_frame)
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Key2}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
		(L.L.MYPOL_mode) 1 =
		{if}
			(L.L.Cas_odchylka) ! (S.L.Cas_odchylka)
		{endif}

		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			"2" (S.$.MYPOL_cislo) 2 (S.L.Mypol_cislice)
			(M.L.Zadat_cislo_frame)
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Key3}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)

		(L.L.MYPOL_mode) 0 = (L.L.MYPOL_mode) 1 = ||
		{if}
			(L.L.MYPOL_mode) (S.L.MYPOL_mode_prev)
			4 (S.L.MYPOL_mode)
			1 (S.L.Cil_init)
		{endif}

		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			"3" (S.$.MYPOL_cislo) 3 (S.L.Mypol_cislice)
			(M.L.Zadat_cislo_frame)
		{endif}
	{endif}
	
{end}
	
{trigger:ibis_mypol_Key4}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)

		(L.L.MYPOL_mode) 0 = (L.L.MYPOL_mode) 1 = ||
		{if}
			(L.L.MYPOL_mode) (S.L.MYPOL_mode_prev)
			2 (S.L.MYPOL_mode)
			1 (S.L.Linka_init)
		{endif}

		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			"4" (S.$.MYPOL_cislo) 4 (S.L.Mypol_cislice)
			(M.L.Zadat_cislo_frame)
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Key5}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)

		(L.L.MYPOL_mode) 0 = (L.L.MYPOL_mode) 1 = ||
		{if}
			(L.L.MYPOL_mode) (S.L.MYPOL_mode_prev)
			3 (S.L.MYPOL_mode)
			1 (S.L.Trasa_init)
		{endif}

		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			"5" (S.$.MYPOL_cislo) 5 (S.L.Mypol_cislice)
			(M.L.Zadat_cislo_frame)
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Key6}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)

		(L.L.MYPOL_mode) 1 =
		{if}
			7 (S.L.MYPOL_mode)
			(L.L.IBIS_busstop) (S.L.IBIS_internal_busstop)
			(L.L.IBIS_busstop_TT) (S.L.IBIS_busstop_TT_zal)
			1 (S.L.Poloha_init)
		{endif}		

		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			"6" (S.$.MYPOL_cislo) 6 (S.L.Mypol_cislice)
			(M.L.Zadat_cislo_frame)
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Key7}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			"7" (S.$.MYPOL_cislo) 7 (S.L.Mypol_cislice)
			(M.L.Zadat_cislo_frame)
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Key8}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			"8" (S.$.MYPOL_cislo) 8 (S.L.Mypol_cislice)
			(M.L.Zadat_cislo_frame)
		{endif}
	{endif}
	
{end}

{trigger:ibis_mypol_Key9}

	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
		(L.L.MYPOL_mode) 2 = (L.L.MYPOL_mode) 4 = || (L.L.MYPOL_mode) 3 = || (L.L.MYPOL_mode) 5 = ||
		{if}
			"9" (S.$.MYPOL_cislo) 9 (S.L.Mypol_cislice)
			(M.L.Zadat_cislo_frame)
		{endif}
	{endif}
	
{end}


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

{macro:IBIS_init}
	"     " (S.$.IBIS_Complex_Line)
	"" (S.$.Mypol_text) (S.$.Mypol_cil) (S.$.Mypol_H_cas) (S.$.Mypol_H_zona)
	"" (S.$.BUSE_IntL) (S.$.BUSE_Int1) (S.$.BUSE_Int2) (S.$.BUSE_Linka)
	"" (S.$.BUSE_Bocni_Cil) (S.$.BUSE_Bocni_Pres) (S.$.BUSE_Celni_1R) (S.$.BUSE_Celni_2R)
	-1 (S.L.IBIS_RouteIndex)
	
{end}


'----------------------
'	Frame
'----------------------

{macro:IBIS_frame}
	
	(M.L.Hodiny_mypol_frame)
	(M.L.BUSE_vnitrni_frame)
	(M.L.BUSE_pres_frame)


	(L.L.elec_busbar_main)
	{if}
		(L.L.MYPOL_mode) 6 =
		{if}
			(L.L.MYPOL_start_timer) !
			{if}
				1 (S.L.MYPOL_start_timer)
				0 (S.L.MYPOL_start_time)
				"                @BIOS 2.2 c 2002 " (S.$.Mypol_text)
			{else}
				(L.L.MYPOL_start_time) (L.S.TimeGap) + (S.L.MYPOL_start_time)
				4 >
				{if}
					0 (S.L.MYPOL_start_timer)
					0 (S.L.MYPOL_mode)
					0 (S.L.Zastavka_odhlasena)

					"000" (S.$.MYPOL_linka)
					
					"0000" (S.$.MYPOL_cil)
					0 (S.L.IBIS_TerminusIndex) (S.L.target_index_int)

					"00" (S.$.MYPOL_trasa)

					(T.L.ev_IBIS-startupsound)
				{endif}
			{endif}
		{endif}

		(L.L.MYPOL_mode) 0 =
		{if}
			(L.L.IBIS_TerminusIndex) 0 (M.V.GetTerminusString)
			10 $SetLengthL
			" 00:00" $+ "@" $+ "  " $+ 
			(L.$.MYPOL_linka) $+
			(L.$.Mypol_cil) $+
			(L.$.Mypol_zona) $+
			(L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh $+ ":" $+
			l0 l1 - 60 * trunc "02" $IntToStrEnh $+
			(S.$.Mypol_text)
		{endif}

		(L.L.MYPOL_mode) 1 =
		{if}
			(L.L.IBIS_Busstop_index) 0 (M.V.GetBusstopString)
			10 $SetLengthL
			(L.L.Cas_odchylka) 0 =
			{if}
				" " $+
				(L.L.IBIS_busstop_TT) (M.V.GetTTBusstopDep) 3600 / s0
				l0 24 >= {if} l0 24 - s0 {endif}
				l0 trunc s1 
				"02" $IntToStrEnh $+ ":" $+
				l0 l1 - 60 * s0 trunc s1
				l0 l1 - 60 * trunc
				30 >=
				{if}
					l1 1 + s1
				{endif}
				l1 "02" $IntToStrEnh $+
			{else}
				(L.L.IBIS_busstop_TT) (M.V.GetTTBusstopDep) s0
				l0 86400 >=
				{if} l0 86400 - s0 {endif}
				l0 (L.S.Time) - s3
				0 >
				{if}
					"-" $+
				{else}
					" " $+
				{endif}

				l3 abs 3600 / s0 trunc s1
				l0 l1 - 60 * s0 trunc s1 "02" $IntToStrEnh $+ ":" $+
				l0 l1 - 60 * trunc "02" $IntToStrEnh $+
			{endif}
			"@" $+
			(L.$.MYPOL_trasa) $+
			(L.$.MYPOL_linka) $+
			(L.$.MYPOL_cil) $+
			(L.$.MYPOL_zona) $+
			(L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh $+ ":" $+
			l0 l1 - 60 * trunc "02" $IntToStrEnh $+
			(S.$.Mypol_text)
		{endif}

		(L.L.MYPOL_mode) 2 =
		{if}
			(L.L.Linka_init) 1 =
			{if}
				0 (S.L.Mypol_cislice_1) (S.L.Mypol_cislice_2) (S.L.Mypol_cislice_3)
				"0" (S.$.MYPOL_znak1) (S.$.MYPOL_znak2) (S.$.MYPOL_znak3)
				0 (S.L.MYPOL_pozice)
				0 (S.L.Linka_init)
			{endif}
			
			"  LINKA: " (L.$.MYPOL_znak1) $+ (L.$.MYPOL_znak2) $+ (L.$.MYPOL_znak3) $+ "    " $+
			"@" $+
			(S.$.Mypol_text)
		{endif}

		(L.L.MYPOL_mode) 3 =
		{if}
			(L.L.Trasa_init) 1 =
			{if}
				0 (S.L.Mypol_cislice_1) (S.L.Mypol_cislice_2)
				"0" (S.$.MYPOL_znak1) (S.$.MYPOL_znak2)
				0 (S.L.zastavka_odhlasena)
				0 (S.L.MYPOL_pozice)
				0 (S.L.Trasa_init)
			{endif}

			"  TRASA: " (L.$.MYPOL_znak1) $+ (L.$.MYPOL_znak2) $+ "     " $+
			"@" $+
			(S.$.Mypol_text)
		{endif}

		(L.L.MYPOL_mode) 4 =
		{if}
			(L.L.Cil_init) 1 =
			{if}
				0 (S.L.Mypol_cislice_1) (S.L.Mypol_cislice_2) (S.L.Mypol_cislice_3) (S.L.Mypol_cislice_4)
				"0" (S.$.MYPOL_znak1) (S.$.MYPOL_znak2) (S.$.MYPOL_znak3) (S.$.MYPOL_znak4)
				0 (S.L.MYPOL_pozice)
				0 (S.L.Cil_init)
			{endif}
			"  CÍL: " (L.$.MYPOL_znak1) $+ (L.$.MYPOL_znak2) $+ (L.$.MYPOL_znak3) $+ (L.$.MYPOL_znak4) $+ "     " $+
			"@" $+
			(S.$.Mypol_text)
		{endif}

		(L.L.MYPOL_mode) 5 =
		{if}
			(L.L.Hlas_init) 1 =
			{if}
				"0" (S.$.MYPOL_znak1) (S.$.MYPOL_znak2)
				0 (S.L.MYPOL_pozice)
				0 (S.L.Hlas_init)
			{endif}
			"HLÁŠENÍ: " (L.$.MYPOL_znak1) $+ (L.$.MYPOL_znak2) $+ "     @" $+
			(S.$.Mypol_text)
		{endif}

		(L.L.MYPOL_mode) 7 =
		{if}
			(L.L.IBIS_Busstop_index) 0 (M.V.GetBusstopString)
			10 $SetLengthL
			"      @" $+
			"   < POLOHA >   " $+
			(S.$.Mypol_text)
		{endif}


	{else}
		"" (S.$.Mypol_text) (S.$.Mypol_cil) (S.$.Mypol_H_cas) (S.$.Mypol_H_zona)
		"" (S.$.BUSE_IntL) (S.$.BUSE_Int1) (S.$.BUSE_Int2) (S.$.BUSE_Linka)
		"" (S.$.BUSE_Bocni_Cil) (S.$.BUSE_Bocni_Pres) (S.$.BUSE_Celni_1R) (S.$.BUSE_Celni_2R)
		6 (S.L.Mypol_mode)
	{endif}

'Nastaveni zastavky
	(L.L.MYPOL_zastavka_ok) 0 =
	{if}
		(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop) (M.V.GetRouteBusstopIdent) (S.$.act_busstop)
		(M.V.GetBusstopIndex) (S.L.IBIS_busstop_index)
	
		(L.$.act_busstop) 1 $SetLengthL (S.$.MYPOL_znak1)

		(L.$.MYPOL_znak1) "#" $=
		(L.$.MYPOL_znak1) "§" $= ||
		(L.$.MYPOL_znak1) "!" $= ||
		{if}
			(L.$.MYPOL_znak1) "#" $=
			{if}
				(L.$.act_busstop) 4 $SetLengthL 3 $SetLengthR (S.$.MYPOL_linka)
				(L.$.act_busstop) 4 $SetLengthR (S.$.MYPOL_pracovni2) (S.$.MYPOL_cil)
			
				(L.$.MYPOL_pracovni2) 1 $SetLengthL (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.Mypol_cislice_2) 1000 * (S.L.Cislo_cile_interni)
				(L.$.MYPOL_pracovni2) 2 $SetLengthL 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.Cislo_cile_interni) (L.L.Mypol_cislice_2) 100 * + (S.L.Cislo_cile_interni)
				(L.$.MYPOL_pracovni2) 3 $SetLengthL 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.Cislo_cile_interni) (L.L.Mypol_cislice_2) 10 * + (S.L.Cislo_cile_interni)
				(L.$.MYPOL_pracovni2) 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.Cislo_cile_interni) (L.L.Mypol_cislice_2) + (S.L.Cislo_cile_interni)
				(L.L.Cislo_cile_interni) (M.V.GetTerminusIndex) (S.L.Cislo_cile_interni)

				(M.L.BUSE_linka_frame)
				(M.L.BUSE_cil_frame)
			{endif}

			(L.$.MYPOL_znak1) "§" $=
			{if}
				(L.$.act_busstop) $length 1 - s0 0 =
				{if}
					0 (S.L.Pocet_pres)
				{else}
					l0 2 >=
					{if}
						(L.$.act_busstop) 2 $SetLengthL 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.Mypol_cislice_2) 10 * (S.L.IBIS_internal_busstop)
						(L.$.act_busstop) 3 $SetLengthL 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.IBIS_internal_busstop) (L.L.Mypol_cislice_2) + (S.L.IBIS_internal_busstop)
						(L.L.IBIS_RouteIndex)  (L.L.IBIS_internal_busstop) (M.V.GetRouteBusstopIdent)
						(M.V.GetBusstopIndex) 1 (M.V.GetBusstopString)
						(S.$.Pres_1)
						1 (S.L.Pocet_pres)
					l0 4 >=
					{if}
						(L.$.act_busstop) 4 $SetLengthL 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.Mypol_cislice_2) 10 * (S.L.IBIS_internal_busstop)
						(L.$.act_busstop) 5 $SetLengthL 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.IBIS_internal_busstop) (L.L.Mypol_cislice_2) + (S.L.IBIS_internal_busstop)
						(L.L.IBIS_RouteIndex)  (L.L.IBIS_internal_busstop) (M.V.GetRouteBusstopIdent)
						(M.V.GetBusstopIndex) 1 (M.V.GetBusstopString)
						(S.$.Pres_2)
						2 (S.L.Pocet_pres)
					{endif}
					l0 6 >=
					{if}
						(L.$.act_busstop) 6 $SetLengthL 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.Mypol_cislice_2) 10 * (S.L.IBIS_internal_busstop)
						(L.$.act_busstop) 7 $SetLengthL 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.IBIS_internal_busstop) (L.L.Mypol_cislice_2) + (S.L.IBIS_internal_busstop)
						(L.L.IBIS_RouteIndex)  (L.L.IBIS_internal_busstop) (M.V.GetRouteBusstopIdent)
						(M.V.GetBusstopIndex) 1 (M.V.GetBusstopString)
						(S.$.Pres_3)
						3 (S.L.Pocet_pres)
					{endif}
					l0 8 =
					{if}
						(L.$.act_busstop) 8 $SetLengthL 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.Mypol_cislice_2) 10 * (S.L.IBIS_internal_busstop)
						(L.$.act_busstop) 1 $SetLengthR (S.$.MYPOL_znak2) (M.L.Zpracuj_cislici) (L.L.IBIS_internal_busstop) (L.L.Mypol_cislice_2) + (S.L.IBIS_internal_busstop)
						(L.L.IBIS_RouteIndex)  (L.L.IBIS_internal_busstop) (M.V.GetRouteBusstopIdent)
						(M.V.GetBusstopIndex) 1 (M.V.GetBusstopString)
						(S.$.Pres_4)
						4 (S.L.Pocet_pres)
					{endif}
					{endif}
					0 (S.L.Pres_time)
				{endif}
			{endif}

			(L.$.MYPOL_znak1) "!" $=
			{if}
				(L.$.act_busstop) 2 $SetLengthR (S.$.MYPOL_hlas)
				(L.$.MYPOL_hlas) "00" $= !
				(L.$.MYPOL_hlas) "01" $= ! &&
				{if}
					1 (S.L.Sluzebni_hlaseni)
					0 (S.L.Sluzebni_hlaseni_time)
				{endif}
			{endif}

			(L.L.IBIS_busstop) 1 + (S.L.IBIS_busstop)
		{else}
			1 (S.L.MYPOL_zastavka_ok)
			0 (S.L.IBIS_busstop_search)
			-1 (S.L.IBIS_busstop_TT_zal)
			0 (S.L.MYPOL_zastavka_TT)
		{endif}
	{endif}

	1 (S.L.Refresh_Strings)


	(L.L.Posuv_zpet) 1 =
	{if}
		(L.L.IBIS_RouteIndex) (L.L.IBIS_internal_busstop) (M.V.GetRouteBusstopIdent) (S.$.act_busstop)
		(M.V.GetBusstopIndex) (S.L.IBIS_busstop_index)
	
		(L.$.act_busstop) 1 $SetLengthL (S.$.MYPOL_znak1)

		(L.$.MYPOL_znak1) "#" $=
		(L.$.MYPOL_znak1) "§" $= ||
		(L.$.MYPOL_znak1) "!" $= ||
		{if}
			(L.L.IBIS_internal_busstop) 0 >
			{if}
				(L.L.IBIS_internal_busstop) 1 - (S.L.IBIS_internal_busstop)
			{else}
				(L.$.MYPOL_znak1) "#" $=
				(L.$.MYPOL_znak1) "§" $= ||
				(L.$.MYPOL_znak1) "!" $= ||
				(L.L.IBIS_internal_busstop) 0 = &&
				{if}
					0 (S.L.Posuv_zpet)
					1 (S.L.Posuv_vpred)
				{endif}
			{endif}
		{else}
			0 (S.L.Posuv_zpet)
		{endif}
	{endif}

	(L.L.Posuv_vpred) 1 =
	{if}
		(L.L.IBIS_RouteIndex) (L.L.IBIS_internal_busstop) (M.V.GetRouteBusstopIdent) (S.$.act_busstop)
		(M.V.GetBusstopIndex) (S.L.IBIS_busstop_index)
	
		(L.$.act_busstop) 1 $SetLengthL (S.$.MYPOL_znak1)

		(L.$.MYPOL_znak1) "#" $=
		(L.$.MYPOL_znak1) "§" $= ||
		(L.$.MYPOL_znak1) "!" $= ||
		{if}
			(L.L.IBIS_internal_busstop) (L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - <
			{if}
				(L.L.IBIS_internal_busstop) 1 + (S.L.IBIS_internal_busstop)
			{endif}
		{else}
			0 (S.L.Posuv_vpred)
		{endif}
	{endif}

	1 (S.L.Refresh_Strings)

'Hlaseni pristi zastavky
	(L.L.Zastavka_odhlasena)
	{if}
		(L.L.Pristi_zastavka_timer)
		{if}
			(L.L.Pristi_zastavka_time) (L.S.TimeGap) + (S.L.Pristi_zastavka_time)
			12 >
			{if}
				(L.L.IBIS_busstop) (L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - <
				{if}
					(L.L.IBIS_busstop) 1 + (S.L.IBIS_busstop)
					0 (S.L.MYPOL_zastavka_ok)
					1 (S.L.Hlasit_pristi)
				{else}
					(L.L.MYPOL_cislo_trasy) s5
					2 % 0.5 >
					{if}
						l5 1 + s6
					{else}
						l5 1 - s6
					{endif}
					(L.L.MYPOL_cislo_linky) 100 * l6 +
					(M.V.GetRouteIndex) s0
					0 >=
					{if}
						1 (S.L.MYPOL_mode)
						0 (S.L.Cas_odchylka)
						(M.L.Nastav_trasu)
						0 (S.L.IBIS_busstop)
						-1 (S.L.IBIS_busstop_TT)
						0 (S.L.MYPOL_zastavka_ok)
						0 (S.L.Pocet_pres)
						l6 (S.L.Mypol_cislo_trasy) s1

						l1 10 / trunc s2 "1" $IntToStr (S.$.MYPOL_znak1)
						l1 l2 10 * - trunc "1" $IntToStr (S.$.MYPOL_znak2)
						(L.$.MYPOL_znak1) (L.$.MYPOL_znak2) $+
						(S.$.MYPOL_trasa)
					{else}
						(L.L.MYPOL_cislo_linky) 100 * l5 +
						(M.V.GetRouteIndex) s0
						1 (S.L.MYPOL_mode)
						0 (S.L.Cas_odchylka)
						(M.L.Nastav_trasu)
						0 (S.L.IBIS_busstop)
						-1 (S.L.IBIS_busstop_TT)
						0 (S.L.MYPOL_zastavka_ok)
						0 (S.L.Pocet_pres)
					{endif}
				{endif}

				0 (S.L.Zastavka_odhlasena)
				0 (S.L.Pristi_zastavka_timer)
			{endif}
			
			(L.L.door_12) 0.2 > (L.L.door_22) 0.2 > || (L.L.door_32) 0.2 > ||
			{if}
				0 (S.L.Pristi_zastavka_timer)
				1 (S.L.BUSE_int_mode)
				0 (S.L.BUSE_int_time)
			{endif}
		{else}
			(L.L.door_12) 0.2 < (L.L.door_22) 0.2 < && (L.L.door_32) 0.2 < &&
			{if}
				(L.L.IBIS_busstop) (L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - <
				{if}
					(L.L.IBIS_busstop) 1 + (S.L.IBIS_busstop)
					0 (S.L.MYPOL_zastavka_ok)
					1 (S.L.Hlasit_pristi)
				{else}
					(L.L.MYPOL_cislo_trasy) s5
					2 % 0.5 >
					{if}
						l5 1 + s6
					{else}
						l5 1 - s6
					{endif}
					(L.L.MYPOL_cislo_linky) 100 * l6 +
					(M.V.GetRouteIndex) s0
					0 >=
					{if}
						1 (S.L.MYPOL_mode)
						0 (S.L.Cas_odchylka)
						(M.L.Nastav_trasu)
						0 (S.L.IBIS_busstop)
						-1 (S.L.IBIS_busstop_TT)
						0 (S.L.MYPOL_zastavka_ok)
						0 (S.L.Pocet_pres)
						l6 (S.L.Mypol_cislo_trasy) s1

						l1 10 / trunc s2 "1" $IntToStr (S.$.MYPOL_znak1)
						l1 l2 10 * - trunc "1" $IntToStr (S.$.MYPOL_znak2)
						(L.$.MYPOL_znak1) (L.$.MYPOL_znak2) $+
						(S.$.MYPOL_trasa)
					{else}
						(L.L.MYPOL_cislo_linky) 100 * l5 +
						(M.V.GetRouteIndex) s0
						1 (S.L.MYPOL_mode)
						0 (S.L.Cas_odchylka)
						(M.L.Nastav_trasu)
						0 (S.L.IBIS_busstop)
						-1 (S.L.IBIS_busstop_TT)
						0 (S.L.MYPOL_zastavka_ok)
						0 (S.L.Pocet_pres)
					{endif}
				{endif}

				0 (S.L.Zastavka_odhlasena)
				0 (S.L.Pristi_zastavka_timer)
			{endif}
		{endif}
	{endif}

	(L.L.Hlasit_pristi) (L.L.MYPOL_zastavka_ok) &&
	{if}
		"..\..\Ansagen\" (L.$.yard) $+ "\" $+
		(L.L.IBIS_Busstop_Index) 2 (M.V.GetBusstopString) $+
		"_#next.wav" $+

		0 (S.L.Hlasit_pristi)
		(L.L.Linka_smer_hlasit) (L.L.Linka_smer_time) 0 = &&
		{if}
			0 (S.L.Linka_smer_hlasit) (S.L.Linka_smer_timer)
		{endif}
		2 (S.L.BUSE_int_mode)
		0 (S.L.BUSE_int_time)

		(T.F.ev_IBIS_Ansagen)
	{endif}

'Hlaseni linka/smer
	(L.L.Linka_smer_hlasit) 1 =
	{if}
		(L.L.door_12) 0.2 > (L.L.door_22) 0.2 > || (L.L.door_32) 0.2 > ||
		(L.L.Linka_smer_rucne) 1 = ||
		(L.L.Linka_smer_timer) 0 = &&
		{if}
			1 (S.L.Linka_smer_timer)

			"..\..\Ansagen\" (L.$.yard) $+ "\Linka\" $+
			(L.$.MYPOL_linka) $+ ".wav" $+
			(T.F.ev_IBIS_Ansagen_ext)
		{endif}
	
		(L.L.Linka_smer_timer) 1 =
		{if}
			(L.L.Linka_smer_time) (L.S.TimeGap) + (S.L.Linka_smer_time)
			4 >
			{if}
				"..\..\Ansagen\" (L.$.yard) $+ "\Smer\" $+
				(L.$.MYPOL_cil) $+ ".wav" $+
				(T.F.ev_IBIS_Ansagen_ext)

				0 (S.L.Linka_smer_timer)
				0 (S.L.Linka_smer_hlasit)
				0 (S.L.Linka_smer_rucne)
			{endif}
		{endif}
	{endif}

'Sluzebni hlaseni
	(L.L.Sluzebni_hlaseni)
	{if}
		(L.L.Sluzebni_hlaseni_time) (L.S.TimeGap) + (S.L.Sluzebni_hlaseni_time)
		10 >
		{if}
			"..\..\Ansagen\" (L.$.yard) $+ "\Sluzebni\" $+
			(L.$.MYPOL_hlas) $+ ".wav" $+
			(T.F.ev_IBIS_Ansagen)
			0 (S.L.Sluzebni_hlaseni)
		{endif}
	{endif}

'Cas odjezdu ze zastavky
	(L.L.MYPOL_zastavka_TT) !
	{if}
		(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop_search) (M.V.GetRouteBusstopIdent) (S.$.act_busstop)
			
		(L.$.act_busstop) 1 $SetLengthL (S.$.MYPOL_znak1)

		(L.$.MYPOL_znak1) "#" $= !
		(L.$.MYPOL_znak1) "§" $= ! &&
		(L.$.MYPOL_znak1) "!" $= ! &&
		{if}
			(L.L.IBIS_busstop_TT_zal) 1 + (S.L.IBIS_busstop_TT_zal)
		{endif}

		(L.L.IBIS_busstop_search) (L.L.IBIS_busstop) =
		{if}
			1 (S.L.MYPOL_zastavka_TT)
			(L.L.IBIS_busstop_TT_zal) (S.L.IBIS_busstop_TT)
		{endif}

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

'----------------------
'	Macros
'----------------------

{macro:Zpracuj_cislici}
		(L.$.Mypol_znak2) "0" $= {if} 0 (S.L.Mypol_cislice_2) {endif}
		(L.$.Mypol_znak2) "1" $= {if} 1 (S.L.Mypol_cislice_2) {endif}
		(L.$.Mypol_znak2) "2" $= {if} 2 (S.L.Mypol_cislice_2) {endif}
		(L.$.Mypol_znak2) "3" $= {if} 3 (S.L.Mypol_cislice_2) {endif}
		(L.$.Mypol_znak2) "4" $= {if} 4 (S.L.Mypol_cislice_2) {endif}
		(L.$.Mypol_znak2) "5" $= {if} 5 (S.L.Mypol_cislice_2) {endif}
		(L.$.Mypol_znak2) "6" $= {if} 6 (S.L.Mypol_cislice_2) {endif}
		(L.$.Mypol_znak2) "7" $= {if} 7 (S.L.Mypol_cislice_2) {endif}
		(L.$.Mypol_znak2) "8" $= {if} 8 (S.L.Mypol_cislice_2) {endif}
		(L.$.Mypol_znak2) "9" $= {if} 9 (S.L.Mypol_cislice_2) {endif}
{end}

{macro:Hodiny_mypol_frame}
	(L.L.elec_busbar_main) (L.L.Mypol_mode) 6 = ! &&
	{if}
		(L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh ":" $+
		l0 l1 - 60 * trunc "02" $IntToStrEnh $+
		(S.$.Mypol_H_cas)
		
		(L.L.Mypol_mode) 0 =
		{if}
			"  " (S.$.Mypol_zona) (S.$.Mypol_H_zona)
		{endif}

		(L.L.Mypol_mode) 1 =
		{if}		
			(L.L.Zona_pocet) 0 =
			{if}
				"  " (S.$.MYPOL_H_zona)
			{endif}
			(L.L.Zona_pocet) 1 =
			{if}
				(L.$.MYPOL_H_zona1) (S.$.MYPOL_H_zona)
			{endif}
			(L.L.Zona_pocet) 2 =
			{if}
				(L.L.Zona_time) (L.S.TimeGap) + (S.L.Zona_time) s0
				4 <
				{if}
					(L.$.MYPOL_H_zona1) (S.$.MYPOL_H_zona)
				{endif}
				l0 4 > l0 8 < &&
				{if}
					(L.$.MYPOL_H_zona2) (S.$.MYPOL_H_zona)
				{endif}
				l0 8 >
				{if}
					0 (S.L.Zona_time)
				{endif}
			{endif}
		{endif}
	{endif}
{end}

{macro:BUSE_vnitrni_frame}
	(L.L.elec_busbar_main) (L.L.Mypol_mode) 6 = ! &&
	{if}
		(L.L.Mypol_mode) 0 =
		{if}
			(L.$.BUSE_IntL_Interni) (S.$.BUSE_IntL)
			(L.L.IBIS_TerminusIndex) 4 (M.V.GetTerminusString) (S.$.BUSE_Int1)
			"" (S.$.BUSE_Int2)
		{endif}

		(L.L.Mypol_mode) 1 =
		{if}
			(L.L.BUSE_int_time) (L.S.TimeGap) + (S.L.BUSE_int_time)

			(L.L.BUSE_int_mode) 0 =
			{if}
				"z" (S.$.BUSE_IntL)
				(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop) (M.V.GetRouteBusstopIdent)
				(M.V.GetBusstopIndex) 1 (M.V.GetBusstopString) (S.$.BUSE_Int1)
				(L.L.IBIS_busstop) (L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - <
				{if}
					"" (S.$.BUSE_Int2)
				{else}
					"Konečná zastávka" (S.$.BUSE_Int2)
				{endif}
			{endif}
			
			(L.L.BUSE_int_mode) 1 =
			{if}
				(L.$.BUSE_IntL_Interni) (S.$.BUSE_IntL)
				(L.L.Cislo_cile_interni) 4 (M.V.GetTerminusString) (S.$.BUSE_Int1)
				(L.L.IBIS_busstop) (L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - <
				{if}
					(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop) (M.V.GetRouteBusstopIdent)
					(M.V.GetBusstopIndex) 1 (M.V.GetBusstopString) (S.$.BUSE_Int2)
				{else}
					"Konečná zastávka" (S.$.BUSE_Int2)
				{endif}
			{endif}

			(L.L.BUSE_int_mode) 2 =
			{if}
				(L.$.BUSE_IntL_Interni) (S.$.BUSE_IntL)
				"Příští zastávka:" (S.$.BUSE_Int1)
				(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop) (M.V.GetRouteBusstopIdent)
				(M.V.GetBusstopIndex) 1 (M.V.GetBusstopString) (S.$.BUSE_Int2)
				(L.L.BUSE_int_time) 3 >
				{if}
					0 (S.L.BUSE_int_time) 
					3 (S.L.BUSE_int_mode)
				{endif}
			{endif}
			
			(L.L.BUSE_int_mode) 3 =
			{if}
				(L.$.BUSE_IntL_Interni) (S.$.BUSE_IntL)
				"Datum a čas:" (S.$.BUSE_Int1)
				(L.S.Day) "02" $IntToStrEnh "." $+
				(L.S.Month) "02" $IntToStrEnh $+ "." $+
				(L.S.Year) "04" $IntToStrEnh $+ "  " $+
				(L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh $+ ":" $+
				l0 l1 - 60 * trunc "02" $IntToStrEnh $+ (S.$.BUSE_Int2)
				(L.L.BUSE_int_time) 3 >
				{if}
					0 (S.L.BUSE_int_time) 
					4 (S.L.BUSE_int_mode)
				{endif}
			{endif}
			
			(L.L.BUSE_int_mode) 4 =
			{if}
				(L.$.BUSE_IntL_Interni) (S.$.BUSE_IntL)
				"Zóna:" (S.$.BUSE_Int1)
				(L.L.Zona_pocet) 0 >
				{if}
					(L.$.MYPOL_H_zona1) 
					(L.L.Zona_pocet) 1 >
					{if}
						"  " $+ (L.$.MYPOL_H_zona2) $+ 
					{endif}
				{else}
					5 (S.L.BUSE_int_mode)
				{endif}
				(S.$.BUSE_Int2)

				(L.L.BUSE_int_time) 3 >
				{if}
					0 (S.L.BUSE_int_time) 
					5 (S.L.BUSE_int_mode)
				{endif}
			{endif}

			(L.L.BUSE_int_mode) 5 =
			{if}
				(L.$.BUSE_IntL_Interni) (S.$.BUSE_IntL)
				(L.L.Cislo_cile_interni) 4 (M.V.GetTerminusString) (S.$.BUSE_Int1)
				"" (S.$.BUSE_Int2)
				(L.L.BUSE_int_time) 3 >
				{if}
					0 (S.L.BUSE_int_time) 
					6 (S.L.BUSE_int_mode)
				{endif}
			{endif}

			(L.L.BUSE_int_mode) 6 =
			{if}
				(L.$.BUSE_IntL_Interni) (S.$.BUSE_IntL)
				"Přes zastávky:" (S.$.BUSE_Int1)
				
				(L.L.Pocet_pres) 0 =
				{if}
					0 (S.L.BUSE_int_time) 
					2 (S.L.BUSE_int_mode)
				{endif}

				(L.L.BUSE_int_time) 3 <
				{if}
					(L.$.Pres_1) (S.$.BUSE_Int2)
				{endif}

				(L.L.BUSE_int_time) 3 > (L.L.BUSE_int_time) 6 < &&
				{if}
					(L.L.Pocet_pres) 1 =
					{if}
						0 (S.L.BUSE_int_time) 
						2 (S.L.BUSE_int_mode)
					{endif}
					(L.$.Pres_2) (S.$.BUSE_Int2)
				{endif}

				(L.L.BUSE_int_time) 6 > (L.L.BUSE_int_time) 9 < &&
				{if}
					(L.L.Pocet_pres) 2 =
					{if}
						0 (S.L.BUSE_int_time) 
						2 (S.L.BUSE_int_mode)
					{endif}
					(L.$.Pres_3) (S.$.BUSE_Int2)
				{endif}

				(L.L.BUSE_int_time) 9 > (L.L.BUSE_int_time) 12 < &&
				{if}
					(L.L.Pocet_pres) 3 =
					{if}
						0 (S.L.BUSE_int_time) 
						2 (S.L.BUSE_int_mode)
					{endif}
					(L.$.Pres_4) (S.$.BUSE_Int2)
				{endif}

				(L.L.Pocet_pres) 4 = (L.L.BUSE_int_time) 12 > &&
				{if}
					0 (S.L.BUSE_int_time) 
					2 (S.L.BUSE_int_mode)
				{endif}
			{endif}
		{endif}
	{endif}
{end}

{macro:Zadat_cislo_frame}
	(L.L.MYPOL_mode) 2 =
	{if}
		(L.L.MYPOL_pozice) 0 = {if} (L.$.MYPOL_cislo) (S.$.MYPOL_znak1) (L.L.Mypol_cislice) (S.L.Mypol_cislice_1) {endif}
		(L.L.MYPOL_pozice) 1 = {if} (L.$.MYPOL_cislo) (S.$.MYPOL_znak2) (L.L.Mypol_cislice) (S.L.Mypol_cislice_2) {endif}
		(L.L.MYPOL_pozice) 2 = {if} (L.$.MYPOL_cislo) (S.$.MYPOL_znak3) (L.L.Mypol_cislice) (S.L.Mypol_cislice_3) {endif}

		(L.L.MYPOL_pozice) 2 <
		{if}
			(L.L.MYPOL_pozice) 1 + (S.L.MYPOL_pozice)
		{endif}
	{endif}

	(L.L.MYPOL_mode) 3 = (L.L.MYPOL_mode) 5 = ||
	{if}
		(L.L.MYPOL_pozice) 0 = {if} (L.$.MYPOL_cislo) (S.$.MYPOL_znak1) (L.L.Mypol_cislice) (S.L.Mypol_cislice_1) {endif}
		(L.L.MYPOL_pozice) 1 = {if} (L.$.MYPOL_cislo) (S.$.MYPOL_znak2) (L.L.Mypol_cislice) (S.L.Mypol_cislice_2) {endif}

		(L.L.MYPOL_pozice) 1 <
		{if}
			(L.L.MYPOL_pozice) 1 + (S.L.MYPOL_pozice)
		{endif}
	{endif}

	(L.L.MYPOL_mode) 4 =
	{if}
		(L.L.MYPOL_pozice) 0 = {if} (L.$.MYPOL_cislo) (S.$.MYPOL_znak1) (L.L.Mypol_cislice) (S.L.Mypol_cislice_1) {endif}
		(L.L.MYPOL_pozice) 1 = {if} (L.$.MYPOL_cislo) (S.$.MYPOL_znak2) (L.L.Mypol_cislice) (S.L.Mypol_cislice_2) {endif}
		(L.L.MYPOL_pozice) 2 = {if} (L.$.MYPOL_cislo) (S.$.MYPOL_znak3) (L.L.Mypol_cislice) (S.L.Mypol_cislice_3) {endif}
		(L.L.MYPOL_pozice) 3 = {if} (L.$.MYPOL_cislo) (S.$.MYPOL_znak4) (L.L.Mypol_cislice) (S.L.Mypol_cislice_4) {endif}

		(L.L.MYPOL_pozice) 3 <
		{if}
			(L.L.MYPOL_pozice) 1 + (S.L.MYPOL_pozice)
		{endif}
	{endif}
{end}

{macro:Nastav_trasu}
	l0 (S.L.IBIS_RouteIndex)
	(M.V.GetRouteTerminusIndex) (S.L.IBIS_TerminusIndex) (S.L.Cislo_cile_interni) (S.L.target_index_int)
	(M.V.GetTerminusCode) (S.L.IBIS_TerminusCode) s1
	2 (S.L.BUSE_int_mode)
	0 (S.L.BUSE_int_time)


	l1 1000 / trunc s2 "1" $IntToStr (S.$.MYPOL_znak1)
	l1 l2 1000 * - s1 100 / trunc s2 "1" $IntToStr (S.$.MYPOL_znak2)
	l1 l2 100 * - s1 10 / trunc s2 "1" $IntToStr (S.$.MYPOL_znak3)
	l1 l2 10 * - trunc "1" $IntToStr (S.$.MYPOL_znak4)

	(L.$.MYPOL_znak1) (L.$.MYPOL_znak2) $+ (L.$.MYPOL_znak3) $+ (L.$.MYPOL_znak4) $+
	(S.$.MYPOL_cil)

	(M.L.BUSE_linka_frame)
	(M.L.BUSE_cil_frame)

	0 (S.L.Zona_pocet)
	"  " (S.$.MYPOL_zona)
{end}

{macro:hlaseni_akt_zastavky}

	(L.L.Zastavka_odhlasena) !
	{if}
		"..\..\Ansagen\" (L.$.yard) $+ "\" $+
		(L.L.IBIS_Busstop_Index) 2 (M.V.GetBusstopString) $+
		(L.L.IBIS_busstop) (L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - =
		{if}
			"_#terminus" $+
		{endif}
		".wav" $+
		(T.F.ev_IBIS_Ansagen)

		1 (S.L.Zastavka_odhlasena)
		0 (S.L.BUSE_int_mode)
		0 (S.L.BUSE_int_time)
		1 (S.L.Pristi_zastavka_timer)
		0 (S.L.Pristi_zastavka_time)


		(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop) (M.V.GetRouteBusstopIdent)
		(M.V.GetBusstopIndex) 4 (M.V.GetBusstopString)
		"1" $= (L.L.IBIS_busstop) (L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - < &&
		{if}
			1 (S.L.Linka_smer_hlasit)
			0 (S.L.Linka_smer_time) (S.L.Linka_smer_timer)
		{endif}

		(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop) (M.V.GetRouteBusstopIdent)
		(M.V.GetBusstopIndex) 3 (M.V.GetBusstopString) (S.$.MYPOL_pracovni1)
		(L.$.MYPOL_pracovni1) $length 2 / (S.L.Zona_pocet) s3
		0 =
		{if}
			"  " (S.$.MYPOL_zona)
		{endif}
		l3 1 >=
		{if}
			(L.$.MYPOL_pracovni1) 2 $SetLengthL
			(S.$.MYPOL_H_zona1) (S.$.MYPOL_zona)
		{endif}
		l3 2 =
		{if}
			(L.$.MYPOL_pracovni1) 2 $SetLengthR
			(S.$.MYPOL_H_zona2)
		{endif}
		0 (S.L.Zona_time)

		
	{endif}
{end}

{macro:BUSE_cil_frame}
	(L.L.elec_busbar_main) (L.L.Mypol_mode) 6 = ! &&
	{if}
		(L.L.Mypol_mode) 0 =
		{if}
			(L.L.IBIS_TerminusIndex) s7 3 (M.V.GetTerminusString) (S.$.BUSE_Bocni_Cil)
			l7 2 (M.V.GetTerminusString)
			$length 0 =
			{if}
				"" (S.$.BUSE_Celni_2R)
				l7 1 (M.V.GetTerminusString) (S.$.BUSE_Celni_1R)
			{else}
				"" (S.$.BUSE_Celni_1R)
				l7 1 (M.V.GetTerminusString) "@" $+
				l7 2 (M.V.GetTerminusString) $+ (S.$.BUSE_Celni_2R)
			{endif}
		{endif}

		(L.L.Mypol_mode) 1 =
		{if}
			(L.L.Cislo_cile_interni) s7 3 (M.V.GetTerminusString) (S.$.BUSE_Bocni_Cil)
			l7 2 (M.V.GetTerminusString)
			$length 0 =
			{if}
				"" (S.$.BUSE_Celni_2R)
				l7 1 (M.V.GetTerminusString) (S.$.BUSE_Celni_1R)
			{else}
				"" (S.$.BUSE_Celni_1R)
				l7 1 (M.V.GetTerminusString) "@" $+
				l7 2 (M.V.GetTerminusString) $+ (S.$.BUSE_Celni_2R)
			{endif}
		{endif}

	{endif}
{end}

{macro:BUSE_pres_frame}
	(L.L.elec_busbar_main) (L.L.Mypol_mode) 6 = ! &&
	{if}
		(L.L.Mypol_mode) 0 =
		{if}
			"" (S.$.BUSE_Bocni_Pres)
		{endif}

		(L.L.Mypol_mode) 1 =
		{if}
			(L.L.Pocet_pres) 0 =
			{if}
				"" (S.$.BUSE_Bocni_Pres)
			{else}
				(L.L.Pres_Time) (L.S.TimeGap) + (S.L.Pres_Time)
				(L.L.Pres_Time) 3 <
				{if}
					"přes zastávky:" (S.$.BUSE_Bocni_Pres)
				{endif}

				(L.L.Pres_Time) 3 > (L.L.Pres_Time) 5 < &&
				{if}	
					(L.$.Pres_1) (S.$.BUSE_Bocni_Pres)
				{endif}
				
				(L.L.Pres_Time) 5 > (L.L.Pres_Time) 7 < &&
				{if}	
					(L.L.Pocet_pres) 1 =
					{if}
						0 (S.L.Pres_Time)
					{else}
						(L.$.Pres_2) (S.$.BUSE_Bocni_Pres)
					{endif}
				{endif}

				(L.L.Pres_Time) 7 > (L.L.Pres_Time) 9 < &&
				{if}	
					(L.L.Pocet_pres) 2 =
					{if}
						0 (S.L.Pres_Time)
					{else}
						(L.$.Pres_3) (S.$.BUSE_Bocni_Pres)
					{endif}
				{endif}

				(L.L.Pres_Time) 9 > (L.L.Pres_Time) 11 < &&
				{if}	
					(L.L.Pocet_pres) 3 =
					{if}
						0 (S.L.Pres_Time)
					{else}
						(L.$.Pres_4) (S.$.BUSE_Bocni_Pres)
					{endif}
				{endif}
		
				(L.L.Pres_Time) 11 >
				{if}
					0 (S.L.Pres_Time)
				{endif}
			{endif}
		{endif}
	{endif}
{end}

{macro:BUSE_linka_frame}
	(L.L.elec_busbar_main) (L.L.Mypol_mode) 6 = ! &&
	{if}
		(L.$.MYPOL_linka) 1 $SetLengthL "0" $=
		{if}
			(L.$.MYPOL_linka) 2 $SetLengthR 1 $SetLengthL "0" $=
			{if}
				(L.$.MYPOL_linka) 1 $SetLengthR (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni)
			{else}
				(L.$.MYPOL_linka) 2 $SetLengthR (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni)
			{endif}
		{else}
			(L.$.MYPOL_linka) (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni)
		{endif}

'Vše
		(L.$.MYPOL_linka) "000" $= {if} "" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}

'Praha
		(L.$.yard) "Praha" $=
		{if}
			(L.$.MYPOL_linka) "780" $= {if} "GB" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}
			(L.$.MYPOL_linka) "998" $= {if} "^" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}
			(L.$.MYPOL_linka) "999" $= {if} "d" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}
		{endif}

'Berlin-Spandau
		(L.$.yard) "Spandau" $=
		{if}
			(L.$.MYPOL_linka) "992" $= {if} "92E" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}
			(L.$.MYPOL_linka) "913" $= {if} "13N" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}
			(L.$.MYPOL_linka) "999" $= {if} "^" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}
		{endif}

'Grundorf
		(L.$.yard) "Grundorf" $=
		{if}
			(L.$.MYPOL_linka) "173" $= {if} "73E" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}
			(L.$.MYPOL_linka) "273" $= {if} "N73" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}
			(L.$.MYPOL_linka) "999" $= {if} "^" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}
		{endif}

'Querfurt
		(L.$.yard) "Querfurt" $=
		{if}
			(L.$.MYPOL_linka) "999" $= {if} "^" (S.$.BUSE_Linka) (S.$.BUSE_IntL_Interni) {endif}
		{endif}

	{endif}
{end}
