'###########################################
'           Conduent Script 2021
'          Adam Mathieson For GPM
'-------------------------------------------
'          Redistributable version
'         Usable in Halyon Products
'###########################################

' Change Log
'--------------------
'    Date    |     Author     | Changes
' 17/12/2021 | Adam Mathieson | Initial Release
' 00/00/0000 |       -        | - 



' Triggers

{trigger:Conduent_Sleep}
    (T.L.as114_touch)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_Page) 1000 >
    {if}
        (L.L.Conduent_Page) 1000 - (S.L.Conduent_Page)
        1 (S.L.Conduent_Refresh)
    {endif}
{end}

{trigger:Conduent_StartService}
    (T.L.as114_touch)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    300 (S.L.Conduent_Page)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    0 (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad0}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 * 0 + (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad1}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 * 1 + (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad2}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 * 2 + (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad3}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 * 3 + (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad4}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 * 4 + (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad5}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 * 5 + (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad6}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 * 6 + (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad7}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 * 7 + (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad8}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 * 8 + (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad9}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 * 9 + (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad_Bksp}
    (T.L.as114_touch)
    -1 (S.L.Conduent_UnsuccsessfulLogin)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_input) 10 / trunc (S.L.Conduent_input)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad_Cancel}
    (T.L.as114_touch)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_Page) 300 =
    {if}
        200 (S.L.Conduent_Page)
        0 (S.L.Conduent_input)
    {else}
        (L.L.Conduent_Page) 301 =
        {if}
            300 (S.L.Conduent_Page)
            0 (S.L.Conduent_input)
        {else}

        {endif}
    {endif}
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Keypad_OK}
    (T.L.as114_touch)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_Page) 300 =
    {if}
        (C.L.Conduent_disable_GPM_Online)
        {if}
            (L.L.Conduent_input) trunc 21310 =
            {if}
                (L.L.Conduent_input) (S.L.Conduent_Driver)
                301 (S.L.Conduent_Page)
                0 (S.L.Conduent_input)
            {else}
                300 (S.L.Conduent_Page)
                (L.L.Conduent_input) (S.L.Conduent_UnsuccsessfulLogin)
            {endif}
        {endif}
    {else}
        (L.L.Conduent_Page) 301 =
        {if}
            (L.L.Conduent_input) (S.L.Conduent_Service)
            302 (S.L.Conduent_Page)
            0 (S.L.Conduent_input)
        {else}

        {endif}
    {endif}
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Service_NextStop}
    (T.L.as114_touch)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_Stop_Offset) 1 + (M.V.GetTTBusstopCount) (M.V.GetTTBusstopIndex)  - 1 - min (S.L.Conduent_Stop_Offset)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Service_PrevStop}
    (T.L.as114_touch)
    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
    (L.L.Conduent_Stop_Offset) 1 - (M.V.GetTTBusstopIndex) -1 * max (S.L.Conduent_Stop_Offset)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Service_Ticket0}
    (T.L.as114_touch)
    -1 (S.L.Conduent_Ticket_Position)
    0 (S.L.Conduent_Selected_Ticket)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Service_Ticket1}
    (T.L.as114_touch)
    -1 (S.L.Conduent_Ticket_Position)
    1 (S.L.Conduent_Selected_Ticket)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Service_Ticket2}
    (T.L.as114_touch)
    -1 (S.L.Conduent_Ticket_Position)
    2 (S.L.Conduent_Selected_Ticket)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Service_Ticket3}
    (T.L.as114_touch)
    -1 (S.L.Conduent_Ticket_Position)
    3 (S.L.Conduent_Selected_Ticket)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Service_Ticket4}
    (T.L.as114_touch)
    -1 (S.L.Conduent_Ticket_Position)
    4 (S.L.Conduent_Selected_Ticket)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Service_Sell}
    (T.L.as114_touch)
    (T.L.conduent_print)
    0 (S.L.Conduent_Ticket_Position)
    (L.L.Conduent_Selected_Ticket) (S.L.GivenTicket)
    -1 (S.L.Conduent_Selected_Ticket)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Service_Close}
    (T.L.as114_touch)
'TODO: CLOSE SERVICE
    200 (S.L.Conduent_Page)
    1 (S.L.Conduent_Refresh)
{end}

{trigger:Conduent_Ticket}
    (T.L.conduent_tear)
    -1 (S.L.Conduent_Ticket_Position)
{end}

{trigger:Conduent_Move_drag}
	1 (S.L.Conduent_Move_dragged)
	(L.L.Conduent_Move_pos) (S.L.Conduent_Move_lastpos)

	(L.S.mouse_x) 500 / (L.L.Conduent_Move_pos) + (S.L.Conduent_Move_pos) s0
	l0 0 <
	{if}
		0 (S.L.Conduent_Move_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.Conduent_Move_pos)
	{endif}

	(L.L.Conduent_Move_pos) (L.L.Conduent_Move_lastpos) - (L.S.Timegap) / (S.L.Conduent_Move_speed)
{end}

{trigger:Conduent_Move_off}
	1 (S.L.Conduent_Move_dragged)
{end}


' Main Methods

{macro:Conduent_init}
    0 (S.L.Conduent_Page) (S.L.Conduent_Keypad)
{end}

{macro:Conduent_frame}
    (L.L.Conduent_Ticket_Position) -1 >
    (L.L.Conduent_Ticket_Position) 1 < &&
    {if}
        (L.L.Conduent_Ticket_Position) 0.08 + (S.L.Conduent_Ticket_Position)
    {endif}

'    (L.L.Conduent_Selected_Ticket) (L.L.GivenTicket) = !
'    {if}
'        -1 (S.L.Conduent_Ticket_Position)
'    {endif}
    
' Conduent Frame Updates
    (M.L.Conduent_Screen)
    (M.L.Conduent_ClockStr)
    (M.L.Conduent_DateStr)
(M.L.Conduent_Move_frame)




' Push Render Updates 

    (L.L.elec_busbar_main) (C.L.elec_busbar_minV) > (L.L.Conduent_elec_state_last) = ! (L.L.Ticketprinter) 1 = &&
    {if}
        (L.L.elec_busbar_main) (C.L.elec_busbar_minV) > d (S.L.Conduent_elec_state_last)
        {if}
            100 (S.L.Conduent_Page)
        {else}
            0 (S.L.Conduent_Page) (S.L.Conduent_Keypad)
        {endif}
        1 (S.L.Conduent_Refresh)
    {endif}

    (L.$.Conduent_ClockStr_LAST) (L.$.Conduent_ClockStr) $= !
    {if}
        (L.$.Conduent_ClockStr) (S.$.Conduent_ClockStr_LAST)
        1 (S.L.Conduent_Refresh)
    {endif}

    (L.L.Conduent_Stop_Last) (M.V.GetTTBusstopIndex) = !
    {if}
        (M.V.GetTTBusstopIndex) (S.L.Conduent_Stop_Last)
        0 (S.L.Conduent_Stop_Offset)
        1 (S.L.Conduent_Refresh)
    {endif}



    (L.L.Conduent_Refresh)
    {if}
        0 (S.L.Conduent_Refresh)
        (M.L.Conduent_Set_Background)
        (M.L.Conduent_Render_Screen)
    {endif}

{end}

' Helper Methods

{macro:Conduent_Set_Background}
    (L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
    {if}
        (L.L.Conduent_Page) 100 =
        {if}
            "Conduent\Conduent_boot01.dds" (S.$.Conduent_Screen)
        {else}
            (L.L.Conduent_Page) 101 =
            {if}
                "Conduent\Conduent_boot1.dds" (S.$.Conduent_Screen)
            {else}
                (L.L.Conduent_Page) 102 =
                {if}
                    "Conduent\Conduent_boot2.dds" (S.$.Conduent_Screen)
                {else}
                    (L.L.Conduent_Page) 103 =
                    {if}
                        "Conduent\Conduent_boot3.dds" (S.$.Conduent_Screen)
                    {else}
                        (L.L.Conduent_Page) 104 =
                        {if}
                            "Conduent\Conduent_boot4.dds" (S.$.Conduent_Screen)
                        {else}
                            (L.L.Conduent_Page) 105 =
                            {if}
                                "Conduent\Conduent_boot5.dds" (S.$.Conduent_Screen)
                            {else}
                                (L.L.Conduent_Page) 200 =
                                {if}
                                    "Conduent\conduent_StartServ.dds" (S.$.Conduent_Screen)
                                {else}                            
                                    (L.L.Conduent_Page) 1000 >
                                    {if}
                                        "Conduent\conduent_sleep2.dds" (S.$.Conduent_Screen)
                                    {else}
                                        (L.L.Conduent_Page) 300 =
                                        {if}
                                            "Conduent\conduent_nAgt.dds" (S.$.Conduent_Screen)
                                        {else}
                                            (L.L.Conduent_Page) 301 =
                                            {if}
                                                "Conduent\conduent_nSrv.dds" (S.$.Conduent_Screen)
                                            {else}
                                                (L.L.Conduent_Page) 302 =
                                                {if}
                                                    "Conduent\conduent_attserv.dds" (S.$.Conduent_Screen)
                                                {else}
                                                    (L.L.Conduent_Page) 400 =
                                                    {if}
                                                        (L.L.Conduent_Stop_Offset) (M.V.GetTTBusstopIndex) + 0 >
                                                        {if}
                                                            "Conduent\Conduent_Srv_2.dds" (S.$.Conduent_Screen)
                                                        {else}
                                                            "Conduent\Conduent_Srv.dds" (S.$.Conduent_Screen)
                                                        {endif}
                                                    {else}
                
                                                    {endif}
                                                {endif}
                                            {endif}
                                        {endif}
                                    {endif}
                                {endif}
                            {endif}
                        {endif}
                    {endif}
                {endif}
            {endif}
        {endif}
    {else}
        "Conduent\Conduent_boot_off.dds" (S.$.Conduent_Screen)
    {endif}
{end}


{macro:Conduent_Render_Screen}
    (C.L.Conduent_ST) (M.V.STNewTex)
    (C.L.Conduent_ST) (M.V.STLock)

'DEBUG String
    (C.L.Conduent_TESTString)
    {if}
        (C.L.Conduent_ST) 255 255 0 255 (M.V.STSetColor)
        100 400 random + s0
        (C.L.Conduent_ST) 64 64 "AS114_font_arialbd24" (M.V.GetFontIndex) 0 0 "TEST " l0 $IntToStr $+ (M.V.STTextOut)
    {endif}
    


    (L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
    {if}
        (L.L.Conduent_Page) 200 =
        (L.L.Conduent_Page) 302 = ||
        (L.L.Conduent_Page) 1000 > ||
        {if}
            (M.L.Conduent_Render_Clock)
            "AS114_font_arialbd12" (M.V.GetFontIndex) s3
'            334 "En attente de prise de service" $+ l3 (M.V.TextLength) 2 / - s0 l0 $IntToStr (S.$.Conduent_tmp3)
'            (C.L.Conduent_PDS_Center0) s0
'            (C.L.Conduent_ST) l0 155 l3 0 0 "En attente de prise de service" (M.V.STTextOut)
'            334 "VOIR BILLETTIQUE" (L.$.ident) $+ l3 (M.V.TextLength) 2 / - s0 l0 $IntToStr (S.$.Conduent_tmp4)
'            (C.L.Conduent_PDS_Center1) s0
'            (C.L.Conduent_ST) l0 185 l3 0 0 "VOIR BILLETTIQUE" (M.V.STTextOut)
'            334 "Vehicule: " (L.$.ident) $+ l3 (M.V.TextLength) 2 / - s0
'            (C.L.Conduent_ST) l0 215 l3 0 0 "Vehicule: " (L.$.ident) $+ (M.V.STTextOut)
        {endif}

        (L.L.Conduent_Page) 300 =
        {if}
            (M.L.Conduent_Render_Clock)
            "AS114_font_arialbd16" (M.V.GetFontIndex) s3
            (L.L.Conduent_UnsuccsessfulLogin) (L.L.Conduent_input) =
            {if}
                (C.L.Conduent_ST) 255 255 0 0 (M.V.STSetColor)
                (C.L.Conduent_ST) 128 135 l3 0 0 "No. AGENT INCONNU" (M.V.STTextOut)
            {else}
                (C.L.Conduent_ST) 255 0 0 0 (M.V.STSetColor)
                (C.L.Conduent_ST) 128 135 l3 0 0 (L.L.Conduent_input) "08" $IntToStrEnh (M.V.STTextOut)
            {endif}
        {endif}

        (L.L.Conduent_Page) 301 =
        {if}
            (M.L.Conduent_Render_Clock)
            "AS114_font_arialbd16" (M.V.GetFontIndex) s3
            (L.L.Conduent_UnsuccsessfulLogin) (L.L.Conduent_input) =
            {if}
                (C.L.Conduent_ST) 255 255 0 0 (M.V.STSetColor)
                (C.L.Conduent_ST) 170 135 l3 0 0 "No. SERVICE INCONNU" (M.V.STTextOut)
            {else}
                (C.L.Conduent_ST) 255 0 0 0 (M.V.STSetColor)
                (C.L.Conduent_ST) 170 135 l3 0 0 (L.L.Conduent_input) "08" $IntToStrEnh (M.V.STTextOut)
            {endif}
        {endif}

        (L.L.Conduent_Page) 400 =
        {if}
            (M.L.Conduent_Render_Clock)
            (M.L.Conduent_Render_Selected_Ticket)
            "AS114_font_arialbd10" (M.V.GetFontIndex) s3
            (C.L.Conduent_ST) 255 255 255 255 (M.V.STSetColor)

            0 (M.V.GetTicketName) 8 $SetLengthL (C.L.Conduent_ST) 243 273 l3 0 0 (M.V.STTextOut)
            1 (M.V.GetTicketName) 8 $SetLengthL (C.L.Conduent_ST) 347 273 l3 0 0 (M.V.STTextOut)
            2 (M.V.GetTicketName) 8 $SetLengthL (C.L.Conduent_ST) 243 373 l3 0 0 (M.V.STTextOut)
            3 (M.V.GetTicketName) 8 $SetLengthL (C.L.Conduent_ST) 347 373 l3 0 0 (M.V.STTextOut)
            4 (M.V.GetTicketName) 8 $SetLengthL (C.L.Conduent_ST) 243 473 l3 0 0 (M.V.STTextOut)
            
            "AS114_font_arial10" (M.V.GetFontIndex) s3
            0 (M.V.GetTicketName) "" $= !
            {if}
                0 (M.V.GetTicketValue) s1
                (C.L.Conduent_ST) 243 290 l3 0 0 "EUR " l1 trunc $IntToStr $+ "." $+ l1 l1 trunc - 10 * "02" $IntToStrEnh $+ (M.V.STTextOut)
            {endif}
            1 (M.V.GetTicketName) "" $= !
            {if}
                1 (M.V.GetTicketValue) s1
                (C.L.Conduent_ST) 347 290 l3 0 0 "EUR " l1 trunc $IntToStr $+ "." $+ l1 l1 trunc - 10 * "02" $IntToStrEnh $+ (M.V.STTextOut)
            {endif}
            2 (M.V.GetTicketName) "" $= !
            {if}
                2 (M.V.GetTicketValue) s1
                (C.L.Conduent_ST) 243 390 l3 0 0 "EUR " l1 trunc $IntToStr $+ "." $+ l1 l1 trunc - 10 * "02" $IntToStrEnh $+ (M.V.STTextOut)
            {endif}
            3 (M.V.GetTicketName) "" $= !
            {if}
                3 (M.V.GetTicketValue) s1
                (C.L.Conduent_ST) 347 390 l3 0 0 "EUR " l1 trunc $IntToStr $+ "." $+ l1 l1 trunc - 10 * "02" $IntToStrEnh $+ (M.V.STTextOut)
            {endif}
            4 (M.V.GetTicketName) "" $= !
            {if}
                4 (M.V.GetTicketValue) s1
                (C.L.Conduent_ST) 243 490 l3 0 0 "EUR " l1 trunc $IntToStr $+ "." $+ l1 l1 trunc - 10 * "02" $IntToStrEnh $+ (M.V.STTextOut)
            {endif}


            
            "AS114_font_arialbd16" (M.V.GetFontIndex) s3
            (C.L.Conduent_ST) 255 0 0 0 (M.V.STSetColor)
            (L.L.Conduent_Stop_Offset) (M.V.GetTTBusstopIndex) + s2
            l2 (M.V.GetTTBusstopName) 16 $SetLengthL $RemoveSpaces 225 l3 (M.V.TextLength) 2 / - s0
            l2 (M.V.GetTTBusstopName) 16 $SetLengthL $RemoveSpaces (C.L.Conduent_ST) l0 115 l3 0 0 (M.V.STTextOut)
            
            "AS114_font_arial10" (M.V.GetFontIndex) s3
            "L: " (L.$.GPM_DataBus_LineName) $+ (C.L.Conduent_ST) 75 177 l3 0 0 (M.V.STTextOut)
            "D: " (L.$.GPM_DataBus_DestinationName) 16 $SetLengthL $RemoveSpaces $+ (C.L.Conduent_ST) 200 177 l3 0 0 (M.V.STTextOut)
            "A: " (L.$.GPM_DataBus_DriverCode) $+ (C.L.Conduent_ST) 75 205 l3 0 0 (M.V.STTextOut)
            "S: " (L.$.GPM_DataBus_ServiceCode) $+ (C.L.Conduent_ST) 200 205 l3 0 0 (M.V.STTextOut)

        {endif}
    {endif}
    (C.L.Conduent_ST) (M.V.STUnlock)
    (C.L.Conduent_ST) (M.V.STFilter)

' Refresh ST twice? IDK why but render breaks if not.
    (C.L.Conduent_ST) (M.V.STLock)
    (C.L.Conduent_ST) (M.V.STUnlock)
    (C.L.Conduent_ST) (M.V.STFilter)
{end}

{macro:Conduent_Render_Clock}

    (C.L.Conduent_ST) 255 255 255 255 (M.V.STSetColor)

    "AS114_font_arial12" (M.V.GetFontIndex) s0

    302 s3
    6 s2

    (C.L.Conduent_ST) l3 l2 l0 0 0 (L.$.Conduent_DateStr) " " $+ (L.$.Conduent_ClockStr) $+ (M.V.STTextOut)
{end}

{macro:Conduent_ClockStr}
'   Time Separator    
    ":" (S.$.Conduent_tmp0)

    (L.S.Time) 3600 / trunc " 2" s0
    (L.S.Time) 60 / l0 60 * - s1
    l0 10 <
    {if}
        "0" l0 $IntToStr $+
    {else}
        l0 $IntToStr
    {endif}
    
    l1 10 <
    {if}
        (L.$.Conduent_tmp0) $+ "0" $+ l1 $IntToStr $+
    {else}
        (L.$.Conduent_tmp0) $+ l1 $IntToStr $+
    {endif} (S.$.Conduent_ClockStr)
{end}

{macro:Conduent_DateStr}
    (L.S.Day) "02" $IntToStrEnh "/" $+ (L.S.Month) "02" $IntToStrEnh $+ "/" $+ (L.S.Year) "04" $IntToStrEnh 2 $cutBegin $+
    (S.$.Conduent_DateStr)
{end}


{macro:Conduent_Screen}
    (L.L.Conduent_Page) 100 =
    {if}
        (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
        {if}
            (L.S.GetTime) (S.L.Conduent_Screen_Timer)
            (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
            1 (S.L.Conduent_Refresh)
        {endif}

        (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs 2 >
        {if}
            101 (S.L.Conduent_Page)
        {endif}
    {else}
        (L.L.Conduent_Page) 101 =
        {if}
            (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
            {if}
                (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                1 (S.L.Conduent_Refresh)
            {endif}

            (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs 2 >
            {if}
                102 (S.L.Conduent_Page)
            {endif}
        {else}
            (L.L.Conduent_Page) 102 =
            {if}
                (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
                {if}
                    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                    (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                    1 (S.L.Conduent_Refresh)
                {endif}

                (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs 1 >
                {if}
                    103 (S.L.Conduent_Page)
                {endif}
            {else}
                (L.L.Conduent_Page) 103 =
                {if}
                    (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
                    {if}
                        (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                        (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                        1 (S.L.Conduent_Refresh)
                    {endif}

                    (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs 0.5 >
                    {if}
                        104 (S.L.Conduent_Page)
                    {endif}
                {else}
                    (L.L.Conduent_Page) 104 =
                    {if}
                        (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
                        {if}
                            (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                            (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                            1 (S.L.Conduent_Refresh)
                        {endif}

                        (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs 1 >
                        {if}
                            105 (S.L.Conduent_Page)
                        {endif}
                    {else}
                        (L.L.Conduent_Page) 105 =
                        {if}
                            (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
                            {if}
                                (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                                (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                                1 (S.L.Conduent_Refresh)
                            {endif}

                            (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs 2 >
                            {if}
                                200 (S.L.Conduent_Page)
                            {endif}
                        {else}
                            (L.L.Conduent_Page) 200 =
                            {if}
                                (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
                                {if}
                                    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                                    (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                                    1 (S.L.Conduent_Refresh)
                                    0 (S.L.Conduent_Keypad)
                                {endif}

                                (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs (C.L.Conduent_SleepTime) >
                                {if}
                                    1200 (S.L.Conduent_Page)
                                {endif}
                            {else}
                                (L.L.Conduent_Page) 1000 >
                                {if}
                                    (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
                                    {if}
                                        (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                                        (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                                        1 (S.L.Conduent_Refresh)
                                        0 (S.L.Conduent_Keypad)
                                    {endif}
                                {else}
                                    (L.L.Conduent_Page) 300 =
                                    {if}
                                        (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
                                        {if}
                                            (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                                            (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                                            1 (S.L.Conduent_Refresh) (S.L.Conduent_Keypad)
                                        {endif}

                                        (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs (C.L.Conduent_SleepTime) >
                                        {if}
                                            1300 (S.L.Conduent_Page)
                                        {endif}
                                    {else}
                                        (L.L.Conduent_Page) 301 =
                                        {if}
                                            (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
                                            {if}
                                                (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                                                (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                                                1 (S.L.Conduent_Refresh) (S.L.Conduent_Keypad)
'                                                0 (S.L.INEO_PDS_Ready)
                                            {endif}
    
                                            (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs (C.L.Conduent_SleepTime) >
                                            {if}
                                                1301 (S.L.Conduent_Page)
                                            {endif}
                                        {else}
                                            (L.L.Conduent_Page) 302 =
                                            {if}
                                                (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
                                                {if}
                                                    (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                                                    (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                                                    (L.L.Conduent_Service) $IntToStr (S.$.GPM_DataBus_ServiceCode)
                                                    (L.L.Conduent_Driver) $IntToStr (S.$.GPM_DataBus_DriverCode)
                                                    "..\..\..\maps\Grand Paris-Moulon\services\" (L.$.GPM_DataBus_ServiceCode) $+ "-1.dds" $+ (S.$.GPM_ServiceSheet)
                                                    1 (S.L.Conduent_Refresh)
                                                    0 (S.L.Conduent_Keypad)

                                                {endif}
        
                                                (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs 1.5 >
                                                {if}
                                                    400 (S.L.Conduent_Page)
'                                                    1 (S.L.INEO_PDS_Ready)
                                                {endif}
                                            {else}
                                                (L.L.Conduent_Page) 400 =
                                                {if}
                                                    (L.L.Conduent_Page) (L.L.Conduent_Page_Last) = !
                                                    {if}
                                                        (L.S.GetTime) (S.L.Conduent_Screen_Timer)
                                                        (L.L.Conduent_Page) (S.L.Conduent_Page_Last)
                                                        1 (S.L.Conduent_Refresh)
                                                        -1 (S.L.Conduent_Selected_Ticket)
                                                    {endif}
            
                                                    (L.S.GetTime) (L.L.Conduent_Screen_Timer) - abs (C.L.Conduent_SleepTime) >
                                                    {if}
                                                        1400 (S.L.Conduent_Page)
                                                    {endif}
                                                {else}
                                                    
                                                {endif}
                                            {endif}
                                        {endif}
                                    {endif}
                                {endif}
                            {endif}
                        {endif}
                    {endif}
                {endif}
            {endif}
        {endif}
    {endif}
{end}

{macro:Conduent_Render_Selected_Ticket}
    (L.L.Conduent_Selected_Ticket) 0 =
    {if}
    (C.L.Conduent_ST) 255 0 0 0 (M.V.STSetColor)
    (C.L.Conduent_ST) 236 267 332 342 (M.V.STDrawRect)
    (C.L.Conduent_ST) 0 0 0 0 (M.V.STSetColor)
    (C.L.Conduent_ST) 240 271 328 338 (M.V.STDrawRect)
    {else}
        (L.L.Conduent_Selected_Ticket) 1 =
        {if}
            (C.L.Conduent_ST) 255 0 0 0 (M.V.STSetColor)
            (C.L.Conduent_ST) 340 267 436 342 (M.V.STDrawRect)
            
            (C.L.Conduent_ST) 0 0 0 0 (M.V.STSetColor)
            (C.L.Conduent_ST) 344 271 432 338 (M.V.STDrawRect)

        {else}
            (L.L.Conduent_Selected_Ticket) 2 =
            {if}
                (C.L.Conduent_ST) 255 0 0 0 (M.V.STSetColor)
                (C.L.Conduent_ST) 236 267 100 + 332 342 100 + (M.V.STDrawRect)
                
                (C.L.Conduent_ST) 0 0 0 0 (M.V.STSetColor)
                (C.L.Conduent_ST) 240 271 100 + 328 338 100 + (M.V.STDrawRect)
            {else}
                (L.L.Conduent_Selected_Ticket) 3 =
                {if}
                    (C.L.Conduent_ST) 255 0 0 0 (M.V.STSetColor)
                    (C.L.Conduent_ST) 340 267 100 + 436 342 100 + (M.V.STDrawRect)
                    
                    (C.L.Conduent_ST) 0 0 0 0 (M.V.STSetColor)
                    (C.L.Conduent_ST) 344 271 100 + 432 338 100 + (M.V.STDrawRect)
                {else}
                    (L.L.Conduent_Selected_Ticket) 4 =
                    {if}
                        (C.L.Conduent_ST) 255 0 0 0 (M.V.STSetColor)
                        (C.L.Conduent_ST) 236 267 200 + 332 342 200 + (M.V.STDrawRect)
                        
                        (C.L.Conduent_ST) 0 0 0 0 (M.V.STSetColor)
                        (C.L.Conduent_ST) 240 271 200 + 328 338 200 + (M.V.STDrawRect)
                    {endif}
                {endif}
            {endif}
        {endif}
    {endif}
{end}

{macro:Conduent_Move_frame}
	(L.L.Conduent_Move_dragged) !
	{if}
		(L.L.Conduent_Move_pos) (L.S.Timegap) (L.L.Conduent_Move_speed) * + (S.L.Conduent_Move_pos)

		(L.L.Conduent_Move_pos) 1 >
		{if}
			1 (S.L.Conduent_Move_pos)
			(L.L.Conduent_Move_speed) /-/ 0.7 * (S.L.Conduent_Move_speed)
		{endif}
		(L.L.Conduent_Move_pos) 0 <
		{if}
			0 (S.L.Conduent_Move_speed) (S.L.Conduent_Move_pos)
		{endif}

		(L.L.Conduent_Move_pos) 0 >
		{if}
			(L.L.Conduent_Move_speed) (L.S.Timegap) (L.L.A_Trans_Y) (C.L.Conduent_Move_anschlagseite) * (L.L.A_Trans_X) /-/ + 0.3 * (L.L.Conduent_Move_globalangle) * * + (S.L.Conduent_Move_speed)
		{endif}

		(L.L.Conduent_Move_speed) s0 (S.L.Conduent_Move_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.Conduent_Move_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.Conduent_Move_speed)
		{endif}

		(L.L.Conduent_Move_speed) 0 > (L.L.Conduent_Move_lastspeed) 0 < &&
		(L.L.Conduent_Move_speed) 0 < (L.L.Conduent_Move_lastspeed) 0 > && ||
		{if}
			0 (S.L.Conduent_Move_speed)
		{endif}
	{endif}

	(L.L.Conduent_Move_pos) 0 > (L.L.Conduent_Move_open) ! &&
	{if}
		(T.L.ev_Sun-Blind1-1_auf)
		1 (S.L.Conduent_Move_open)
	{endif}

	(L.L.Conduent_Move_pos) 0 = (L.L.Conduent_Move_open) &&
	{if}
		(T.L.ev_Sun-Blind1-1_zu)
		0 (S.L.Conduent_Move_open)
	{endif}

	(L.L.Conduent_Move_pos) 140 * 27 + 3.14 * 180 / sin (S.L.Conduent_Move_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)
{end}