Home AMX Forum NetLinx Studio
Options

AutoShutdown Timeline

Yes i'm new to this and no i have not done the programmer 2 course. I'm just bored and are trying to improve what i'm giving the customers. Doing this i'm trying to make a countdown that will turn of the system 20 seconds after pushing exit.

I wont be able to test this before monday and was hoping anybody here could tell if i'm on to something or totaly off on making this work.


PROGRAM_NAME='cShutdown'


DEFINE_CONSTANT

TL1 = 1

DEFINE_VARIABLE


LONG Timearray[20]=
{
1000,
2000,
3000,
4000,
5000,
6000,
7000,
8000,
9000,
10000,
11000,
12000,
13000,
14000,
15000,
16000,
17000,
18000,
19000,
20000
}




DEFINE_EVENT



BUTTON_EVENT[dvTP,39] //IF dvTP,39 EXIT IS PUSHED, EXIT PAGE IS SHOWN AND THE COUNTDOWN TIMELINE BEGINS.
{
PUSH:
{
TIMELINE_CREATE(TL1,Timearray,20,TIMELINE_ABSOLUTE,TIMELINE_ONCE)
}
}




BUTTON_EVENT[dvTP,40] //CANCEL THE TIMELINE AND RETURN TO MAIN PAGE
{
PUSH:
{
PanelPage ('Main')
TIMELINE_KILL(TL1)
}
}




BUTTON_EVENT[dvTP,210] //OFF BUTTON IS PUSHED BEFORE THE TIMELINE IS DONE. THE SYSTEM IS SHUT DOWN AND THE TIMELINE IS CANCLED.
{
PUSH:
{
TIMELINE_KILL(TL1)
}
}





TIMELINE_EVENT[TL1]
{
SEND_COMMAND dvTP,"'TEXT1-30,0',ITOA(20 - TIMELINE.SEQUENCE)" // AT THE END OF THE TIMELINE OFF BUTTON IS PUSHED

IF(TIMELINE.SEQUENCE = 20)
{
DO_PUSH (dvTP,210)
}
}





DEFINE_PROGRAM

IF (TIME = '18:00:00') // TIDSBASERT AUTOSHUTDOWN
{
DO_PUSH(dvTP,39)
send_command dvTP, "'PAGE-Exit 2'"
SEND_COMMAND dvTP,"'WAKE'"
}

Comments

  • My 2 cents... (partially, must be completed to get a compiler run)
    DEFINE_VARIABLE
    LONG lOneSecondTick[] = { 1000 } // second tick
    INTEGER nMySecondCount // manually count passes
    ...
    // start timer
    TIMELINE_CREATE(TL1,lOneSecondTick,1,TIMELINE_RELATIVE,TIMELINE_REPEAT)
    nMySecondCount = 0
    
    ...
    TIMELINE_EVENT[TL1]
    {
    IF(TIMELINE.REPETITION = 20) // 20x repeated
    {
    TIMELINE_KILL(TL1)
    nMySecondCount = 0
    }
    ELSE
    {
    SEND_COMMAND dvTP,"'TEXT1-30,0',ITOA(20 - TIMELINE.REPETITION)" 
    nMySecondCount++
    }
    }
    
    Contains a variations - based on TIMELINE.REPETITION (how much repeats done, so 1st run thru Timeline it is 0 (zero)), or on a manually counted variable nMySecondCount.
  • espen.sandorfespen.sandorf Registered User
    Thank you, this made it work. my last problem now is the counter, it wont show the counting digits in the touchpanel.

    Anyone know whats wrong?

    Forget it, found a missing comma.
    > ,
  • espen.sandorfespen.sandorf Registered User
    New error, something in this code is making my controller go bananas after i shut down the system. anyone that see whats causing it???


    PROGRAM_NAME='cShutdown'


    DEFINE_CONSTANT

    TL1 = 1

    DEFINE_VARIABLE


    LONG lOneSecondTick[] = { 1000 } // second tick
    INTEGER nMySecondCount // manually count passes


    DEFINE_EVENT



    BUTTON_EVENT[dvTP,39] //IF dvTP,39 EXIT IS PUSHED, EXIT PAGE IS SHOWN AND THE COUNTDOWN TIMELINE BEGINS.
    {
    PUSH:
    {
    TIMELINE_CREATE(TL1,lOneSecondTick,1,TIMELINE_RELATIVE,TIMELINE_REPEAT)
    nMySecondCount = 0
    }
    }



    BUTTON_EVENT[dvTP,40] //CANCEL THE TIMELINE AND RETURN TO MAIN PAGE
    {
    PUSH:
    {
    TIMELINE_KILL(TL1)
    nMySecondCount = 0
    }
    }

    BUTTON_EVENT[dvTP,210] //OFF BUTTON IS PUSHED BEFORE THE TIMELINE IS DONE. THE SYSTEM IS SHUT DOWN AND THE TIMELINE IS CANCLED.
    {
    PUSH:
    {
    TIMELINE_KILL(TL1)
    nMySecondCount = 0
    PanelPage ('Main2')
    }
    }




    TIMELINE_EVENT[TL1]
    {
    IF(TIMELINE.REPETITION = 20) // 20x repeated
    {
    TIMELINE_KILL(TL1)
    nMySecondCount = 0
    DO_PUSH(dvTP,210)
    PanelPage ('Main2')
    }
    ELSE
    {
    SEND_COMMAND dvTP,"'^TXT-300,0,',ITOA(20 - TIMELINE.REPETITION)"
    nMySecondCount++
    }
    }

    (****************************************************TIDSBESTEMT AUTOSHUTDOWN*********************************************************************************************************************)
    (*************************************************************************************************************************************************************************************************)
    DEFINE_PROGRAM

    IF (TIME = '18:00:00') // TIDSBASERT AUTOSHUTDOWN
    {
    DO_PUSH(dvTP,39)
    PanelPage ('Exit2')
    SEND_COMMAND dvTP,"'WAKE'"
    }
Sign In or Register to comment.