'##############
'Mikroelektronika I.
'##############

'Needs:
'- Cockpit (Batterietrennschalter)
'- Door (Haltestellenbremse)
'- 'Mikroelektronika II.
'- 'Mikroelektronika III.

'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
'- Daniel94				17.07.2012		Projížďení zastávek na panelu BUSE
'- Marty515        		25.07.2012		Přidána diagnostika pro celý bus
'- Marty515        		01.08.2012		Upraveno pro CZ kasu
'- Marty515        		25.12.2012		Opraveno tl. enter
'- Daniel94				25.12.2012		Boční panel BUSE /přes zastávky/
'- Daniel94				30.07.2013		Kasa -> Boot, Login
'- Daniel94				03.08.2013		Oprava zadávání menu kasy
'- Daniel94				11.08.2013		"Další linkaspoj", odhlášení + oprava bugů
'- Marty515				17.09.2013		Korekce

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

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

{trigger:IBIS_setmode_linie_kurs}

	(L.L.elec_busbar_main)
	{if}
		0 (S.L.IBIS_input) (S.L.IBIS_input_count)
		1 (S.L.IBIS_mode)
		(T.L.ev_IBIS_piep)
	{endif}
	
{end}

{trigger:IBIS_setmode_route}

	(L.L.elec_busbar_main)
	{if}
		0 (S.L.IBIS_input) (S.L.IBIS_input_count)
		2 (S.L.IBIS_mode)
		(T.L.ev_IBIS_piep)
	{endif}
	
{end}

{trigger:IBIS_setmode_ziel}

	(L.L.elec_busbar_main)
	{if}
		0 (S.L.IBIS_input) (S.L.IBIS_input_count)
		3 (S.L.IBIS_mode)
		(T.L.ev_IBIS_piep)
	{endif}
	
{end}

{trigger:IBIS_eingabe}
	(L.L.kasa_login) 0.1 >
	{if}
		0 (S.L.kasa_login_ps)

		(L.L.kasa_login) 1 =
		(L.$.kasa_pin_inv) "0961" $= &&
		{if}
			2 (S.L.kasa_login)
			"" (S.$.kasa_pin) (S.$.kasa_pin_inv)
		{else}
			(L.L.kasa_login) 1 =
			{if}
				"" (S.$.kasa_pin) (S.$.kasa_pin_inv)
			{endif}
		{endif}
		
		(L.L.kasa_login) 2 =
		(L.$.kasa_pin_inv) "1352" $= &&
		{if}
			3 (S.L.kasa_login)
			"" (S.$.kasa_pin) (S.$.kasa_pin_inv)
		{else}
			(L.L.kasa_login) 2 =
			{if}
				"" (S.$.kasa_pin) (S.$.kasa_pin_inv)
			{endif}
		{endif}
		
		(L.L.kasa_login) 3 =
		(L.$.kasa_pin_inv) "4946" $= &&
		{if}
			0 (S.L.kasa_login)
			1 (S.L.navigator_menu) (S.L.kasa_boot_ok) 
			"" (S.$.kasa_pin) (S.$.kasa_pin_inv)
		{else}
			(L.L.kasa_login) 3 =
			{if}
				"" (S.$.kasa_pin) (S.$.kasa_pin_inv)
			{endif}
		{endif}
	{else}
		(T.L.ev_IBIS_piep)
		(L.L.navigator_menu_visible)
		(L.L.hlasenivisible) 1 =  ||
		{if}
		0 (S.L.ticketprinter_button_enter)
		
		{else}
		
				(L.L.elec_busbar_main) 
				(L.L.ticketprinter_ticket_preselection) -1 > &&
				(L.L.ticketprinter_druckt) ! &&
				(L.L.ticketprinter_ticket_pos) 0 = &&
				{if}
					(L.L.ticketprinter_ticket_preselection) (S.L.ticketprinter_ticket_selection)
					1 (S.L.ticketprinter_druckt)
					-1 (S.L.ticketprinter_ticket_preselection)
					(T.L.ev_printer_printing)
				{endif}
				(L.L.ticketprinter_button_enter) !
				{if}
					(T.L.ev_printer_button_on)
				{endif}
				1 (S.L.ticketprinter_button_enter)
		{endif}
	
	

	
		(L.L.navigator_menu_visible)
		{if}
'***********************
' Eingabe Linie/Kurs: Ââîä ěŕđřđóňŕ
'***********************
			(L.L.IBIS_mode) 1 =
			{if}
				0 (S.L.IBIS_mode)
				(T.L.ev_IBIS_piep)
' Input teilen...

			(L.L.IBIS_input) s0 (S.L.IBIS_Linie_Complex)

			100 / trunc

			(S.L.IBIS_LinieKurs)

			l0 100 %

			(S.L.IBIS_Linie_Suffix)

'ANNAX-Test:
'			7 (S.L.IBIS_mode)

' Entwerter umstellen:
			(T.L.ev_IBIS_entwerter)
			(M.L.IBIS_SetComplexLineString)

		{else}
'***********************
' Eingabe Route:
'***********************
		(L.L.IBIS_mode) 2 =
		{if}
			(L.L.IBIS_input) s0 (S.L.IBIS_Route)

' Das Folgende soll künftig erst nach "Route" gemacht werden!
			(L.L.IBIS_LinieKurs) 100 * l0 + (M.V.GetRouteIndex) s1
			0 <
			{if}
' Falls kleiner 0, also -1, dann fehlerhaft, dann nicht übernehmen sondern Fehlermeldung ausgeben:
				4 (S.L.IBIS_mode)
'		Blinker aktivieren:
				1 (S.L.IBIS_BlinkOn) (S.L.IBIS_BlinkInitial)
				(L.S.GetTime) (S.L.IBIS_BlinkTimer)
'		Fehler-piepen
				(T.L.ev_IBIS_pieperror)
			{else}
				(T.L.ev_IBIS_piep)
				(M.L.IBIS_SetRoute)
' Bushaltestellen zurücksetzen:
				0 (S.L.IBIS_busstop)			
				(M.L.IBIS_RefreshBusstop)

'ANNAX-Test:
'				7 (S.L.IBIS_mode)

				8 (S.L.IBIS_mode)

' Entwerter umstellen:
				(T.L.ev_IBIS_entwerter)
				(L.L.IBIS_busstop_entwerter_soll) (S.L.IBIS_busstop_entwerter_ist)
			{endif}
		{else}
'***********************
' Eingabe Ziel:
'***********************
		(L.L.IBIS_mode) 3 =
		{if}
' Eingabe ist der Terminus-Code
			(L.L.IBIS_input) (S.L.IBIS_TerminusCode)
' Daraus wird noch der Terminus-Index generiert:
			(M.V.GetTerminusIndex) s0
			0 <
			{if}
' Falls kleiner 0, also -1, dann fehlerhaft, dann nicht übernehmen sondern Fehlermeldung ausgeben:
				6 (S.L.IBIS_mode)
'		Blinker aktivieren:
				1 (S.L.IBIS_BlinkOn) (S.L.IBIS_BlinkInitial)
				(L.S.GetTime) (S.L.IBIS_BlinkTimer)
'		Fehler-piepen
				(T.L.ev_IBIS_pieperror)
			{else}
				8 (S.L.IBIS_mode)
				(T.L.ev_IBIS_piep)
				l0 (S.L.IBIS_TerminusIndex)
				(M.L.IBIS_RefreshTerminusText)
'ANNAX-Test:
'				5 (S.L.IBIS_mode)
			{endif}
		{endif}
		{endif}
		{endif}
	{endif}
	

	{endif}	
	
		(L.L.SLHLA_select) 0 =
		(L.L.hlasenivisible) 1 = &&
			{if}
			(T.L.SLHLA_001)
			{else}
			
			{endif}
			
		(L.L.SLHLA_select) 1 =
		(L.L.hlasenivisible) 1 = &&
			{if}
			(T.L.SLHLA_002)
			{endif}
			
					(L.L.SLHLA_select) 2 =
		(L.L.hlasenivisible) 1 = &&
			{if}
			(T.L.SLHLA_003)
			{endif}
			
					(L.L.SLHLA_select) 3 =
		(L.L.hlasenivisible) 1 = &&
			{if}
			(T.L.SLHLA_004)
			{endif}
			
					(L.L.SLHLA_select) 4 =
		(L.L.hlasenivisible) 1 = &&
			{if}
			(T.L.SLHLA_005)
			{endif}
			
								(L.L.SLHLA_select) 5 =
		(L.L.hlasenivisible) 1 = &&
			{if}
			(T.L.SLHLA_006)
			{endif}
			
								(L.L.SLHLA_select) 6 =
		(L.L.hlasenivisible) 1 = &&
			{if}
			(T.L.SLHLA_007)
			{endif}
			
								(L.L.SLHLA_select) 7 =
		(L.L.hlasenivisible) 1 = &&
			{if}
			(T.L.SLHLA_008)
			{endif}
			
			0 (S.L.hlasenivisible) 

	0 (S.L.IBIS_input) (S.L.IBIS_input_count) (S.L.IBIS_mode)
	
{end}

{trigger:IBIS_1}
	(L.L.kasa_login) 0.1 >
	{if}
	(L.L.kasa_login_ps) 4 < &&
		{if}
		(L.L.kasa_login_ps) 1 + (S.L.kasa_login_ps)
			(L.$.kasa_pin) "." $+ (S.$.kasa_pin)
			(T.L.ev_IBIS_piep)
			(L.$.kasa_pin_inv) "1" $+ (S.$.kasa_pin_inv)
		{endif}
	{else}
	1 (M.L.IBIS_Zahlentasten)
	{endif}
{end}


{trigger:IBIS_2}
	(L.L.kasa_login) 0.1 >
	{if}
	(L.L.kasa_login_ps) 4 < &&
		{if}
		(L.L.kasa_login_ps) 1 + (S.L.kasa_login_ps)
			(L.$.kasa_pin) "." $+ (S.$.kasa_pin)
			(T.L.ev_IBIS_piep)
			(L.$.kasa_pin_inv) "2" $+ (S.$.kasa_pin_inv)
		{endif}
	{else}
	2 (M.L.IBIS_Zahlentasten)
	{endif}
{end}

{trigger:IBIS_3}
	(L.L.kasa_login) 0.1 >
	{if}
	(L.L.kasa_login_ps) 4 < &&
		{if}
		(L.L.kasa_login_ps) 1 + (S.L.kasa_login_ps)
			(L.$.kasa_pin) "." $+ (S.$.kasa_pin)
			(T.L.ev_IBIS_piep)
			(L.$.kasa_pin_inv) "3" $+ (S.$.kasa_pin_inv)
		{endif}
	{else}
	3 (M.L.IBIS_Zahlentasten)
	{endif}
{end}

{trigger:IBIS_4}
	(L.L.kasa_login) 0.1 >
	{if}
	(L.L.kasa_login_ps) 4 < &&
		{if}
		(L.L.kasa_login_ps) 1 + (S.L.kasa_login_ps)
			(L.$.kasa_pin) "." $+ (S.$.kasa_pin)
			(T.L.ev_IBIS_piep)
			(L.$.kasa_pin_inv) "4" $+ (S.$.kasa_pin_inv)
		{endif}
	{else}
	4 (M.L.IBIS_Zahlentasten)
	{endif}
{end}

{trigger:IBIS_5}
	(L.L.kasa_login) 0.1 >
	{if}
	(L.L.kasa_login_ps) 4 < &&
		{if}
		(L.L.kasa_login_ps) 1 + (S.L.kasa_login_ps)
			(L.$.kasa_pin) "." $+ (S.$.kasa_pin)
			(T.L.ev_IBIS_piep)
			(L.$.kasa_pin_inv) "5" $+ (S.$.kasa_pin_inv)
		{endif}
	{else}
	5 (M.L.IBIS_Zahlentasten)
	{endif}
{end}

{trigger:IBIS_6}
	(L.L.kasa_login) 0.1 >
	{if}
	(L.L.kasa_login_ps) 4 < &&
		{if}
		(L.L.kasa_login_ps) 1 + (S.L.kasa_login_ps)
			(L.$.kasa_pin) "." $+ (S.$.kasa_pin)
			(T.L.ev_IBIS_piep)
			(L.$.kasa_pin_inv) "6" $+ (S.$.kasa_pin_inv)
		{endif}
	{else}
	6 (M.L.IBIS_Zahlentasten)
	{endif}
{end}

{trigger:IBIS_7}
	(L.L.kasa_login) 0.1 >
	{if}
	(L.L.kasa_login_ps) 4 < &&
		{if}
		(L.L.kasa_login_ps) 1 + (S.L.kasa_login_ps)
			(L.$.kasa_pin) "." $+ (S.$.kasa_pin)
			(T.L.ev_IBIS_piep)
			(L.$.kasa_pin_inv) "7" $+ (S.$.kasa_pin_inv)
		{endif}
	{else}
	7 (M.L.IBIS_Zahlentasten)
	{endif}
{end}

{trigger:IBIS_8}
	(L.L.kasa_login) 0.1 >
	{if}
	(L.L.kasa_login_ps) 4 < &&
		{if}
		(L.L.kasa_login_ps) 1 + (S.L.kasa_login_ps)
			(L.$.kasa_pin) "." $+ (S.$.kasa_pin)
			(T.L.ev_IBIS_piep)
			(L.$.kasa_pin_inv) "8" $+ (S.$.kasa_pin_inv)
		{endif}
	{else}
	8 (M.L.IBIS_Zahlentasten)
	{endif}
{end}

{trigger:IBIS_9}
	(L.L.kasa_login) 0.1 >
	{if}
	(L.L.kasa_login_ps) 4 < &&
		{if}
		(L.L.kasa_login_ps) 1 + (S.L.kasa_login_ps)
			(L.$.kasa_pin) "." $+ (S.$.kasa_pin)
			(T.L.ev_IBIS_piep)
			(L.$.kasa_pin_inv) "9" $+ (S.$.kasa_pin_inv)
		{endif}
	{else}
	9 (M.L.IBIS_Zahlentasten)
	{endif}
{end}

{trigger:IBIS_0}
	(L.L.kasa_login) 0.1 >
	{if}
	(L.L.kasa_login_ps) 4 < &&
		{if}
		(L.L.kasa_login_ps) 1 + (S.L.kasa_login_ps)
			(L.$.kasa_pin) "." $+ (S.$.kasa_pin)
			(T.L.ev_IBIS_piep)
			(L.$.kasa_pin_inv) "0" $+ (S.$.kasa_pin_inv)
		{endif}
	{else}
	0 (M.L.IBIS_Zahlentasten)
	{endif}
{end}

{trigger:IBIS_loeschen}
(L.L.navigator_menu_visible) 1 =
{if}
	0 (S.L.IBIS_input) (S.L.IBIS_input_count)
	(T.L.ev_IBIS_piep)
	
{endif}

(L.L.navigator_menu_visible) 0 =
{if}
	(L.L.elec_busbar_main)
	{if}
		(T.L.ev_IBIS_piep)
		
		0 (S.L.IBIS_mode)
	{endif}
{endif}
{end}

{trigger:IBIS_vor}
(L.L.navigator_menu_visible) 1 =
{if}
	(L.L.navigator_menu_select) 2 <
	{if}
		(L.L.navigator_menu_select) 1 + (S.L.navigator_menu_select)
		0 (S.L.IBIS_input) (S.L.IBIS_input_count)
		(T.L.ev_IBIS_piep)
	{endif}
	

	
{endif}

(L.L.navigator_menu_visible) 0 =
{if}

		(L.L.SLHLA_select) 7 <
		{if}
		(L.L.SLHLA_select) 1 + (S.L.SLHLA_select)
		(T.L.ev_IBIS_piep)
	{endif}
	
	
	(L.L.elec_busbar_main) (L.L.IBIS_mode) s0 0 = l0 8 = || &&
	{if}
		(L.L.IBIS_busstop) 1 + (S.L.IBIS_busstop)
		(M.L.IBIS_RefreshBusstop)
		(T.L.ev_IBIS_piep)
'		Nullsetzen des Timers für den Zeilenwechsel der LCD-Innenanzeige
		0 (S.L.IBIS_LCD-zeilentimer) (S.L.IBIS_LCD-zeile)
		(M.L.IBIS_LCD-refresh)
		
	{endif}
{endif}
{end}

{trigger:IBIS_vor_stumm}
	(L.L.ds_visible) 1 =
	{if}
		1 (S.L.ds_ok)
		(M.L.IBIS_RefreshBusstop)
	{else}
		(L.L.elec_busbar_main) (L.L.IBIS_mode) s0 0 = l0 8 = || &&
		{if}
			(L.L.IBIS_busstop) 1 + (S.L.IBIS_busstop)
			(M.L.IBIS_RefreshBusstop)
			(M.L.IBIS_PlayAnnouncement)
'			Nullsetzen des Timers für den Zeilenwechsel der LCD-Innenanzeige
			0 (S.L.IBIS_LCD-zeilentimer) (S.L.IBIS_LCD-zeile)
			(M.L.IBIS_LCD-refresh)	
		{endif}
	{endif}
	(T.L.ev_IBIS_piep)
{end}

{trigger:IBIS_rueck}
(L.L.navigator_menu_visible) 1 =
	{if}
	(L.L.navigator_menu_select) 0 >
	{if}
		(L.L.navigator_menu_select) 1 - (S.L.navigator_menu_select)
		0 (S.L.IBIS_input) (S.L.IBIS_input_count)
		(T.L.ev_IBIS_piep)
	{endif}
	

	
{endif}

(L.L.navigator_menu_visible) 0 =
{if}

	(L.L.SLHLA_select) 0 >
	{if}
		(L.L.SLHLA_select) 1 - (S.L.SLHLA_select)
		(T.L.ev_IBIS_piep)
	{endif}
	
	
	(L.L.elec_busbar_main) (L.L.IBIS_mode) s0 0 = l0 8 = || &&
	{if}
		(L.L.IBIS_busstop) 0 > &&
		{if}
			(L.L.IBIS_busstop) 1 - (S.L.IBIS_busstop)
			(M.L.IBIS_RefreshBusstop) 
'			Nullsetzen des Timers für den Zeilenwechsel der LCD-Innenanzeige
			0 (S.L.IBIS_LCD-zeilentimer) (S.L.IBIS_LCD-zeile)
			(M.L.IBIS_LCD-refresh)
		{endif}
		(T.L.ev_IBIS_piep)
{endif}
	{endif}
{end}

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

{macro:IBIS_init}
	"     " (S.$.IBIS_Complex_Line)
	-1 (S.L.IBIS_RouteIndex)
	"00000" (S.$.kasa_turnus)
	"00" (S.$.kasa_linka)
	"000" (S.$.kasa_cil)
	(M.L.pres_zastavky)
{end}


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

{macro:IBIS_frame}
	


	(L.L.elec_busbar_main)
	{if}

'----------------
'Anfangsmelodie
		(L.L.IBIS_energy_last) !
		{if}
			(T.L.ev_IBIS-startupsound)
			1 (S.L.diagnostika_sw) (S.L.diagnostika_sw2) (S.L.diagnostika_sw3) (S.L.diagnostika_sw4) (S.L.ABS_SEL_TEST)
			0 (S.L.IBIS_mode)
		{endif}

'----------------
'Blinker laufen lassen:

		(L.L.IBIS_BlinkTimer) s0 0 <
		{if}
			(L.S.GetTime) (S.L.IBIS_BlinkTimer) s0
		{endif}

' Wenn Zeit abgelaufen:
		(L.S.GetTime) l0 - s0
		1.2 > (L.L.IBIS_BlinkInitial) && l0 0.833 > ||
		{if}
			(L.L.IBIS_BlinkOn) ! (S.L.IBIS_BlinkOn)
			0 (S.L.IBIS_BlinkInitial)
			(L.S.GetTime) (S.L.IBIS_BlinkTimer)
		{endif}



'----------------
'Entwerter-Weiterschaltung:
		(L.L.IBIS_busstop_entwerter_ist) (L.L.IBIS_busstop_entwerter_soll) = ! (L.L.bremse_halte) &&
		{if}
			(L.L.IBIS_busstop_entwerter_soll) (S.L.IBIS_busstop_entwerter_ist)
			(T.L.ev_IBIS_entwerter_weiter)
		{endif}


'----------------
'Display-Darstellung:
		
		(L.L.IBIS_mode) 1 =
		{if}
			"Cislo linky:"
			(L.L.IBIS_input_count) 0 =
			{if}
				(L.$.IBIS_Complex_Line) $+
			{else}
				" " 5 (L.L.IBIS_input_count) - $* $+ (L.L.IBIS_input) "0" (L.L.IBIS_input_count) $IntToStr $+ $IntToStrEnh $+ 
			{endif}
		{else}
		(L.L.IBIS_mode) 2 =
		{if}
			"Cislo turnusu:" " " 2 (L.L.IBIS_input_count) - $* $+ (L.L.IBIS_input) "0" (L.L.IBIS_input_count) $IntToStr $+ $IntToStrEnh $+ 
		{else}
		(L.L.IBIS_mode) 3 =
		{if}
			"Cislo zastavky:" " " 3 (L.L.IBIS_input_count) - $* $+ (L.L.IBIS_input) "0" (L.L.IBIS_input_count) $IntToStr $+ $IntToStrEnh $+ 
		{else}
		(L.L.IBIS_mode) 4 =
		{if}
			(L.L.IBIS_BlinkOn)
			{if}
				" Chybny kod  "
			{else}
				""
			{endif}
		{else}
		(L.L.IBIS_mode) 6 =
		{if}
			(L.L.IBIS_BlinkOn)
			{if}
				"   Chybny kod    "
			{else}
				""
			{endif}
		{else}
'Testweise den Inhalt der Annax anzeigen:
'		(L.L.IBIS_mode) 5 =
'		{if}
'			(L.$.Matrix_Right)
'		{else}
'Testweise den Inhalt der Linien-Annax anzeigen:
'		(L.L.IBIS_mode) 7 =
'		{if}
'			"--" (L.$.Matrix_Nr) $+ "--" $+ 12 $SetLengthL 16 $SetLengthR
'		{else}
'Anzeigen des Zielschild-Textes auf dem IBIS:
		(L.L.IBIS_mode) 8 =
		{if}
			(L.$.IBIS_terminus_name) 20 $SetLengthL
		{else}
		(L.L.IBIS_mode) 9 =
		{if}
'			"13.11.84   01:21"

'		Tag:
			(L.S.Day) "02" $IntToStrEnh "." $+
'		Monat:
			(L.S.Month) "02" $IntToStrEnh $+ "." $+
'		Jahr:
			(L.S.Year) $IntToStr 2 $SetLengthR $+ "       " $+
'		Stunden:
			(L.S.Time) 3600 / s0 trunc s1 "02" $IntToStrEnh $+ ":" $+
'		Minuten:
			l0 l1 - 60 * trunc "02" $IntToStrEnh $+

'####################################
' RBL-TESTS
'####################################
'Zielschildautomatik:

'		(M.V.GetTTTerminusIndex) (S.L.IBIS_TerminusIndex)
'		(M.V.GetTTLineString) 3 $SetLengthL (S.$.Matrix_Nr) 3 $SetLengthL 20 $SetLengthL

'Verspätung anzeigen:
'
'		"Verspätung: "
'		(M.V.GetTTDelay) 60 / s0
'		0 <
'		{if}
'			"-" $+ l0 /-/ s0
'		{else}
'			" " $+
'		{endif}
'		Minuten:
'			l0 trunc s1 "02" $IntToStrEnh $+ ":" $+
'		Sekunden:
'			l0 l1 - 60 * trunc "02" $IntToStrEnh $+
'
'Haltestellenname/-zeit anzeigen:
'		(M.V.GetTTBusstopIndex) s2 (M.V.GetTTBusstopName)
'		""
'		Stunden:
'			l2 (M.V.GetTTBusstopArr) 3600 / s0 trunc s1 "02" $IntToStrEnh $+ ":" $+
'		Minuten:
'			l0 l1 - 60 * trunc "02" $IntToStrEnh $+
'		" / " $+
'		Stunden:
'			l2 (M.V.GetTTBusstopDep) 3600 / s0 trunc s1 "02" $IntToStrEnh $+ ":" $+
'		Minuten:
'			l0 l1 - 60 * trunc "02" $IntToStrEnh $+
'
'####################################
' Ende RBL-TESTS
'####################################


			20 $SetLengthL
		{else}
			(L.$.IBIS_busstop_name) 20 $SetLengthL
		{endif}
		{endif}
'		{endif}
'		{endif}
		{endif}
		{endif}
		{endif}
		{endif}
		{endif}

		"@" $+

		
'Linie/Kurs:
		(L.$.IBIS_Complex_Line) $+ " " $+
'Route:
		(L.L.IBIS_Route) "02" $IntToStrEnh $+ " " $+
'Terminus:
		(L.L.IBIS_TerminusCode) "03" $IntToStrEnh $+
		" " $+
'Zone / Entwerter:
		(L.L.IBIS_busstop_entwerter_ist) " 4" $IntToStrEnh $+ " " $+

		(L.L.IBIS_Route) 2 % 0.5 >
		{if}
			"A" $+
		{else}
			"B" $+
		{endif}
		" " $+
	{else}
		"" (S.$.IBIS) (S.$.IBIS_cabindisplay)
	{endif}

	(S.$.IBIS)

	(L.L.IBIS_mode) 2 = !
	{if}
	(L.L.IBIS_Route) "02" $IntToStrEnh (S.$.kasa_linka)
	{endif}


'Anzeigen der aktuellen Fahrplanlage:

	(L.L.elec_busbar_main)
	{if}
		""
		(M.V.GetTTDelay) s1 60 / s0

'		Minuten:
		l0 abs trunc " 2" $IntToStrEnh $+  
		(S.$.IBIS_Delay_min)
		
		(L.$.IBIS_Delay_min) 0 =
			{if}
				""
				"99" $+ (S.$.IBIS_Delay_min)


			{endif}		
		

'		Zehntelminuten:
		l0 abs l0 abs trunc - 60 * " 2"  $IntToStrEnh 
		(S.$.IBIS_Delay_sec)

		l1 abs 6 >=
		{if}
			l0 0 >
			{if}
				" Zpozdení "
			{else}
				" Do odjezdu "
			{endif}
		{else}
			" "
		{endif}
		(S.$.IBIS_Delay_state)
	{else}
		"" (S.$.IBIS_Delay_sec) (S.$.IBIS_Delay_state) (S.$.IBIS_Delay_min)
	{endif}



'Omsi sagen, dass die Strings-Ausgaben aktualisiert werden sollen:
	1 (S.L.Refresh_Strings)


'----------------
'Microphon-Taster:
	(L.L.Snd_Microphone) (L.L.IBIS_LastMicro) ! && (L.L.ds_visible) 0 = &&
	{if}
		(L.L.IBIS_busstop) 1 + (S.L.IBIS_busstop)
		(M.L.IBIS_RefreshBusstop)
		(M.L.IBIS_PlayAnnouncement)

'		Nullsetzen des Timers für den Zeilenwechsel der LCD-Innenanzeige
		0 (S.L.IBIS_LCD-zeilentimer) (S.L.IBIS_LCD-zeile)
		(M.L.IBIS_LCD-refresh)
	{endif}
	(L.L.Snd_Microphone) (S.L.IBIS_LastMicro)

'----------------
'Last energy:
	(L.L.elec_busbar_main) (S.L.IBIS_energy_last)

'----------------
'LCD-Anzeigetimer hochlaufen lassen
	(L.L.IBIS_LCD-zeilentimer) (L.S.Timegap) + (S.L.IBIS_LCD-zeilentimer)
	4 >
	(L.L.elec_busbar_main) &&
	{if}
		(L.L.IBIS_LCD-zeile) ! (S.L.IBIS_LCD-zeile)
		0 (S.L.IBIS_LCD-zeilentimer)
		(M.L.IBIS_LCD-refresh)
	{endif}





{end}

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

{macro:IBIS_RefreshBusstop}
				0 (M.V.GetTTBusstopDep) 3600 / s0 24 > 
				{if}
				l0 24 - (S.L.casdjr)
				{else}
				l0 (S.L.casdjr)
				{endif}


	(L.L.IBIS_RouteIndex) 0 <
	{if}
		"" (S.$.act_busstop)
	{else}
		(L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) (L.L.IBIS_busstop) <=
		{if}
			0 (S.L.IBIS_busstop)

			(L.L.IBIS_Route) 1 = {if} "02" (S.$.kasa_linka_dalsi) {else} "01" (S.$.kasa_linka_dalsi) {endif}
			1 (S.L.ds_visible)
			"" "  Další linkaspoj" "@" $+
			(L.$.kasa_turnus) $+ " - " $+ (L.$.kasa_linka_dalsi) $+ "@" $+
			"  Odjezd:  " $+
			
				(L.L.casdjr) s0 trunc s1 "02" $IntToStrEnh $+ ":" $+ l0 l1 - 60 * s1 trunc s0 l1 l0 - 0.9994 > {if} l0 1 + {else} l0 {endif} "02" $IntToStrEnh $+ " " $+
			(S.$.dalsi_sluzba)
		{endif}
	{endif}

	(L.L.ds_ok) 1 =
	{if}
		0 (S.L.ds_visible)
		(T.L.ev_IBIS_entwerter)
		(L.L.IBIS_busstop_entwerter_soll) (S.L.IBIS_busstop_entwerter_ist)

		(L.L.IBIS_Route) s5
		2 % 0.5 >
		{if}
			l5 1 + s6
		{else}
			l5 1 - s6
		{endif}

'Suche den Routeindex:

		(L.L.IBIS_LinieKurs) 100 * l6 + (M.V.GetRouteIndex) s1
		0 >=
		{if}
			
'Wenn gültig, dann wechsele:
			(M.L.IBIS_SetRoute)
			l6 (S.L.IBIS_Route)

		{endif}
'	{else}
'		0 (S.L.IBIS_mode)
	0 (S.L.ds_ok)
	{endif}

'Setzen der String-Variable "act_busstop" für die OMSI-interne Berechnung und daraus Ableitung des "globalen" Haltestellenindexes:

	(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop) (M.V.GetRouteBusstopIdent) (S.$.act_busstop)
	(M.V.GetBusstopIndex) (S.L.IBIS_busstop_index)


'Sonst zeige die Bushaltestelle
	(L.L.IBIS_busstop_index) 3 (M.V.GetBusstopString)
	(S.$.IBIS_busstop_name)

'Ausrechnen der neuen Entwerterposition:
	(L.L.IBIS_busstop_offset) (L.L.IBIS_busstop) + (S.L.IBIS_busstop_entwerter_soll)


{end}

{macro:IBIS_PlayAnnouncement}

	(L.L.IBIS_busstop) 0 >
	{if}

		"..\..\Announcements\" 0 (M.V.GetDepotStringGlobal) "\" $+ $+ (L.$.act_busstop) $+
		".wav" $+
		$msg
		(T.F.ev_IBIS_Ansagen)
	{endif}
{end}

{macro:IBIS_LCD-refresh}

	(L.L.IBIS_Route) 0 =
	{if}
		"" (S.$.IBIS_lcd_line) (S.$.IBIS_lcd_dest1)   
		"MANIPULAčNí JíZDA           " (S.$.IBIS_lcd_dest)
		"MANIPULAčNí JíZDA" (S.$.IBIS_lcd_nextstop) (S.$.IBIS_lcd_stop1) (S.$.IBIS_lcd_stop1b) (S.$.IBIS_lcd_stop2) (S.$.IBIS_lcd_stop3)
	{else}
		(L.$.Matrix_NewNr) (S.$.IBIS_lcd_line) 
		(L.$.IBIS_terminus_name) 20 $SetLengthL (S.$.IBIS_lcd_dest) 
		(L.$.IBIS_terminus_name) 20 $SetLengthL (S.$.IBIS_lcd_dest1) 
		(L.$.IBIS_busstop_name) (S.$.IBIS_lcd_nextstop) 
		(L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - (L.L.IBIS_busstop) 1 + >=
		{if}
			(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop) 1 + (M.V.GetRouteBusstopIdent)
			(M.V.GetBusstopIndex) 3 (M.V.GetBusstopString)
			(S.$.IBIS_lcd_stop1)
			(S.$.IBIS_lcd_stop1b)
		{else}
			"" (S.$.IBIS_lcd_stop1)
			""
			"KONEčNá              " (S.$.IBIS_lcd_stop1b)
		{endif}
		
		(L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - (L.L.IBIS_busstop) 2 + >=
		{if}
			(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop) 2 + (M.V.GetRouteBusstopIdent)
			(M.V.GetBusstopIndex) 3 (M.V.GetBusstopString)
			(S.$.IBIS_lcd_stop2)
		{else}
			"" (S.$.IBIS_lcd_stop2)
		{endif}
		(L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - (L.L.IBIS_busstop) 3 + >=
		{if}
			(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop) 3 + (M.V.GetRouteBusstopIdent)
			(M.V.GetBusstopIndex) 3 (M.V.GetBusstopString)
			(S.$.IBIS_lcd_stop3)
		{else}
			"" (S.$.IBIS_lcd_stop3)
		{endif}
		(L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - (L.L.IBIS_busstop) 4 + >=
		{if}
			(L.L.IBIS_RouteIndex) (L.L.IBIS_busstop)  4 + (M.V.GetRouteBusstopIdent)
			(M.V.GetBusstopIndex) 3 (M.V.GetBusstopString)
			(S.$.IBIS_lcd_stop4)
		{else}
			"" (S.$.IBIS_lcd_stop4)
		{endif}
	{endif}
	
	(L.L.ds_visible) 1 =
	{if}
		"KONEčNá" (S.$.IBIS_lcd_stop1b)
		" " (S.$.IBIS_lcd_nextstop)	
	{endif}
		
{end}

{macro:pres_zastavky}

	(L.L.IBIS_Route) 1 >=
	{if}


		"Přes : " (L.$.IBIS_lcd_nextstop) $+ " - " $+ (L.$.IBIS_lcd_stop1) $+ " - " $+ (L.$.IBIS_lcd_stop2) $+ " - " $+ (L.$.IBIS_lcd_stop3) $+ (S.$.pres_zastavky)

		(L.L.pz_ok) 0 =
		{if}
		(L.L.pz_animace) (L.S.Timegap) + (S.L.pz_animace)
	
		(L.L.pz_animace) 9 >
		{if}
		1 (S.L.pz_animace_radek)
		0 (S.L.pz_vid)
		0 (S.L.pz_animace)
		1 (S.L.pz_ok)
		{endif}	
		{endif}

		(L.L.pz_ok) 1 =
		{if}
		(L.L.pz_animace) (L.S.Timegap) + (S.L.pz_animace)
	
		(L.L.pz_animace) 9 >
		{if}
		0 (S.L.pz_animace_radek)
		1 (S.L.pz_vid)
		0 (S.L.pz_animace)
		0 (S.L.pz_ok)
		{endif}	
		{endif}
		
	{else}
	
	"" (S.$.pres_zastavky)
	{endif}
	

	
	(L.L.IBIS_Route) 1 >=
	{if}
		(L.L.pz_zmena_ok) 0 =
		{if}
		(L.L.pz_zmena) (L.S.Timegap) + (S.L.pz_zmena)
		
			(L.L.pz_zmena) 3 >
			{if}
			"" (L.$.IBIS_lcd_nextstop) (S.$.pres_zastavky_p_panel)
			0 (S.L.pz_zmena)
				(L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - (L.L.IBIS_busstop) 1 + >=
				{if}
					1 (S.L.pz_zmena_ok)
					(T.L.ev_BUSE_BOK_CHR)
				{else}
					0 (S.L.pz_zmena_ok)
				{endif}
			{endif}
		{endif}
		
		(L.L.pz_zmena_ok) 1 =
		{if}
		(L.L.pz_zmena) (L.S.Timegap) + (S.L.pz_zmena)
		
			(L.L.pz_zmena) 3 >
			{if}
			"" (L.$.IBIS_lcd_stop1) (S.$.pres_zastavky_p_panel)
			0 (S.L.pz_zmena)
				(L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - (L.L.IBIS_busstop) 2 + >=
				{if}
					2 (S.L.pz_zmena_ok)
					(T.L.ev_BUSE_BOK_CHR)
				{else}
					0 (S.L.pz_zmena_ok)
				{endif}
			{endif}
		{endif}
		
		(L.L.pz_zmena_ok) 2 =
		{if}
		(L.L.pz_zmena) (L.S.Timegap) + (S.L.pz_zmena)
		
			(L.L.pz_zmena) 3 >
			{if}
			"" (L.$.IBIS_lcd_stop2) (S.$.pres_zastavky_p_panel)
			0 (S.L.pz_zmena)			
				(L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - (L.L.IBIS_busstop) 3 + >=
				{if}
					3 (S.L.pz_zmena_ok)
					(T.L.ev_BUSE_BOK_CHR)
				{else}
					0 (S.L.pz_zmena_ok)
				{endif}
			{endif}
		{endif}
		
		(L.L.pz_zmena_ok) 3 = 
		{if}
		(L.L.pz_zmena) (L.S.Timegap) + (S.L.pz_zmena)
		
			(L.L.pz_zmena) 3 >
			{if}
			"" (L.$.IBIS_lcd_stop3) (S.$.pres_zastavky_p_panel)
			0 (S.L.pz_zmena)
				(L.L.IBIS_RouteIndex) (M.V.GetBusstopCount) 1 - (L.L.IBIS_busstop) 4 + >=
				{if}
					4 (S.L.pz_zmena_ok)
					(T.L.ev_BUSE_BOK_CHR)
				{else}
					0 (S.L.pz_zmena_ok)
				{endif}
			{endif}
		{endif}
		
		(L.L.pz_zmena_ok) 4 =
		{if}
		(L.L.pz_zmena) (L.S.Timegap) + (S.L.pz_zmena)
		
			(L.L.pz_zmena) 3 >
			{if}
			"" (L.$.IBIS_lcd_stop4) (S.$.pres_zastavky_p_panel)
			0 (S.L.pz_zmena)
			0 (S.L.pz_zmena_ok)
			{endif}
		{endif}
		
	{else}
	
	"" (S.$.pres_zastavky_p_panel)
	{endif}
	{endif}
	
	(L.L.IBIS_Route) 0 =
		{if}
			"" (S.$.C_dozastavky) (S.$.C_zezastavky)
			{else}
				(L.$.IBIS_terminus_name) 20 $SetLengthL (S.$.C_dozastavky) $+
		
				(L.L.IBIS_busstop) 0 =
				{if}
				(L.$.IBIS_busstop_name) (S.$.C_zezastavky) 
				{endif}
		{endif}

	
	
{end}

{macro:IBIS_Zahlentasten}
	s0
	(L.L.elec_busbar_main)
	{if}
		(L.L.IBIS_mode) 1 = (L.L.IBIS_input_count) 5 < &&
		(L.L.IBIS_mode) 2 = (L.L.IBIS_input_count) 2 < && ||
		(L.L.IBIS_mode) 3 = (L.L.IBIS_input_count) 3 < && ||
		{if}
			(L.L.IBIS_input) 10 * l0 + (S.L.IBIS_input)
			(L.L.IBIS_input_count) 1 + (S.L.IBIS_input_count)
			(T.L.ev_IBIS_piep)
			(L.L.IBIS_mode) 1 =
			{if}
				(L.L.IBIS_input) "05" $IntToStrEnh (S.$.kasa_turnus)
			{endif}
			(L.L.IBIS_mode) 2 =
			{if}
				(L.L.IBIS_input) "02" $IntToStrEnh (S.$.kasa_linka)
			{endif}
			(L.L.IBIS_mode) 3 =
			{if}
				(L.L.IBIS_input) "03" $IntToStrEnh (S.$.kasa_cil)
			{endif}
		{else}
			l0 0 =
			{if}
				9 (S.L.IBIS_mode)
				(T.L.ev_IBIS_piep)
			{endif}
		{endif}
	{endif}
{end}

{macro:IBIS_SetRoute}

' Macro setzt den Routeindex auf den Wert von l1 und führt die nötigen Schritte aus

' Wenn gültig, dann übernehmen:
	l1 (S.L.IBIS_RouteIndex)
' Finden des zugehörigen Ziel-Index':
	(M.V.GetRouteTerminusIndex) (S.L.IBIS_TerminusIndex)
' Finden des zugehörigen Ziel-Codes:
	(M.V.GetTerminusCode) (S.L.IBIS_TerminusCode)
' Aktualisieren des Zielschild-Textes:
	(M.L.IBIS_RefreshTerminusText)
' Ziel anzeigen:
	8 (S.L.IBIS_mode)

' Falls es entweder ein 500, ein 800 oder 900-Code ist, dann bitte beim Complex-Code eine 28 (M), eine 36 (X) bzw. 04 (N) verwenden:
	(L.L.IBIS_LinieKurs) s2 100 / trunc s3
	l3 5 =
	{if}
		l2 100 * 28 (S.L.IBIS_Linie_Suffix) + (S.L.IBIS_Linie_Complex)
	{endif}
	l3 8 =
	{if}
		l2 100 * 36 (S.L.IBIS_Linie_Suffix) + (S.L.IBIS_Linie_Complex)
	{endif}
	l3 9 =
	{if}
		l2 100 * 04 (S.L.IBIS_Linie_Suffix) + (S.L.IBIS_Linie_Complex)
	{endif}
	(M.L.IBIS_SetComplexLineString)

' Entwerter-Busstop-Offset festlegen (pseudo-Zufall aus Linien-Code und Route-Index):

	(L.L.IBIS_LinieKurs) 100 * (L.L.IBIS_RouteIndex) + 10000 * sin 10 * 15 + trunc (S.L.IBIS_busstop_offset)

{end}

{macro:IBIS_RefreshTerminusText}
	(L.L.IBIS_TerminusIndex) 5 (M.V.GetTerminusString) (S.$.IBIS_terminus_name)
{end}

{macro:IBIS_SetComplexLineString}
'Linie/Kurs:
	(L.L.IBIS_LinieKurs) s0 0 = !
	{if}
		l0 "03" $IntToStrEnh
	{else}
		"   "
	{endif}
'Linien-Suffix:
	(L.L.IBIS_Linie_Suffix) s0 0 = !
	{if}
		l0 "02" $IntToStrEnh $+
	{else}
		"  " $+
	{endif}
	(S.$.IBIS_Complex_Line)


{macro:diagnostika_frame}
	(L.L.diagnostika_sw)
	{if}
		(L.L.diagnostika) (L.S.Timegap) + (S.L.diagnostika)
		1  (S.L.cp_diag_01)

		(L.L.diagnostika) (C.L.diagnostika_zap) >
		{if}
		0  (S.L.cp_diag_01)


		0 (S.L.diagnostika)
		0 (S.L.diagnostika_sw)
		{endif}
	{endif}

	(L.L.diagnostika_sw2)
	{if}
		(L.L.diagnostika2) (L.S.Timegap) + (S.L.diagnostika2)
		1 (S.L.cp_diag_02)
		
		
		(L.L.diagnostika2) (C.L.diagnostika_zap2) >
		{if}
		0 (S.L.cp_diag_02)
	
		
		0 (S.L.diagnostika2)
		0 (S.L.diagnostika_sw2)
		{endif}
	{endif}
	
	
	


	(L.L.diagnostika_sw3)
	{if}
		(L.L.diagnostika3) (L.S.Timegap) + (S.L.diagnostika3)
		1 (S.L.cp_diag_03)
		
		(L.L.diagnostika3) (C.L.diagnostika_zap3) >
		{if}
		0 (S.L.cp_diag_03)
		
		0 (S.L.diagnostika3)
		0 (S.L.diagnostika_sw3)
		{endif}
	{endif}
	
	

	
	(L.L.diagnostika_sw4)
	{if}
		(L.L.diagnostika4) (L.S.Timegap) + (S.L.diagnostika4)
		1 (S.L.cp_diag_04)
		1 (S.L.budik_osvetelni_light)
		

		
		(L.L.diagnostika4) (C.L.diagnostika_zap4) >
		{if}
		0 (S.L.cp_diag_04)
		0 (S.L.budik_osvetelni_light)

		
		0 (S.L.diagnostika4)
		0 (S.L.diagnostika_sw4)
		{endif}
	{endif}
	
	
	(L.L.ABS_SEL_TEST) 1 = 
	(L.L.Brake) 0.3 > &&	
	{if}
	0 (S.L.ABS_SEL_TEST)
	{endif}
	
{end}

{macro:MM_odchylka}

(L.L.elec_busbar_main)
	{if}
		""
		
		(M.V.GetTTBusstopCount) 0 >
	{if}

		(L.S.Time) trunc s0

		(L.L.IBIS_busstop) (M.V.GetTTBusstopDep) trunc s1	
		
		l0 l1 - 60 / trunc sqr sqrt s2

		l2 0 =
		{if}
			"  "
		{else}
			l0 l1 <
			{if}
				l2 10 <
				{if}
					"  "
				{else}
				" "
				{endif}
			{else}
				l2 abs 10 <
				{if}
					"  "
				{else}
					" "
				{endif}
			{endif}
		{endif}
		
		l2 60 >
		{if}
		""
			(L.L.IBIS_busstop) (M.V.GetTTBusstopDep) trunc
			
			3600 / s0 trunc s1 "02" $IntToStrEnh $+ ":" $+
'			Minuten:
			l0 l1 - 60 * s2 trunc s3 "02" $IntToStrEnh $+
			
			(S.$.Kasa_od)
			
			
			""
			" Čas odjezdu" $+  (S.$.Kasa_od_text)
			
		{else}
		
		
		 
		l2 -99 < 
		{if}
		99
		{else}
			l2
		{endif}

		$IntToStr $+ " min" $+ (S.$.Kasa_od)
		
			""
		 (L.$.IBIS_Delay_state) $+  (S.$.Kasa_od_text)
		{endif}
	{else}
		" " (S.$.Kasa_od)
		"" (S.$.Kasa_od_text)
	{endif}
			
	


	{else}
		"" (S.$.Kasa_od)
		"" (S.$.Kasa_od_text)

		
	{endif}


	
{end}

'Pokud bude ziel více než 899 tak se zobrazi new plocha:

{macro:BUSE_BOK}

(L.L.IBIS_TerminusCode) 899 >
 {if}
  1 (S.L.pbuse_visible)
 {else}
  0 (S.L.pbuse_visible)
 {endif}
{end}

'Pořadí vozu na lince 1-99

{macro:poradicis}


	(L.$.kasa_turnus) 1 <
	{if}
		(L.$.kasa_turnus) 3 $cutBegin (S.$.poradi_cislo)
	{endif}

	
{end}

{macro:Mikroelektronika_001}


	
{end}





