Home AMX User Forum NetLinx Studio

Timelines

I want to make a timeline that will call a Function every 60 minutes. I'm not sure where to put the data. Can anyone help me?

Comments

  • Did you check out the example given in the Netxlinx Keword Help for Timeline?
    Define_Device 
    dvPanel = 128:1:0 
    DEFINE_VARIABLE 
    LONG TimeArray[100] 
    
    DEFINE_CONSTANT 
    TL1 = 1 
    TL2 = 2 
    
    DEFINE_EVENT 
    
    TIMELINE_EVENT[TL1] // capture all events for Timeline 1 
    { 
    switch(Timeline.Sequence) // which time was it? 
    { 
    case 1: { SEND_COMMAND dvPanel,"'TEXT1-1 1'" } 
    case 2: { SEND_COMMAND dvPanel,"'TEXT1-1 2'" } 
    case 3: { SEND_COMMAND dvPanel,"'TEXT1-1 3'" } 
    case 4: { SEND_COMMAND dvPanel,"'TEXT1-1 4'" } 
    case 5: { SEND_COMMAND dvPanel,"'TEXT1-1 5'" } 
    } 
    } 
    
    TIMELINE_EVENT[TL2] 
    { 
    switch(Timeline.Sequence) 
    { 
    case 1: { SEND_COMMAND dvPanel,"'TEXT2-2 1'" } 
    case 2: { SEND_COMMAND dvPanel,"'TEXT2-2 2'" } 
    case 3: { SEND_COMMAND dvPanel,"'TEXT2-2 3'" } 
    case 4: { SEND_COMMAND dvPanel,"'TEXT2-2 4'" } 
    case 5: { SEND_COMMAND dvPanel,"'TEXT2-2 5'" } 
    } 
    } 
    
    DEFINE_PROGRAM 
    
    PUSH[dvPanel,1] 
    { 
    TimeArray[1] = 1000 
    TimeArray[2] = 2000 
    TimeArray[3] = 3000 
    TimeArray[4] = 4000 
    TimeArray[5] = 5000 
    
    TIMELINE_CREATE(TL1, TimeArray, 5, TIMELINE_ABSOLUTE,TIMELINE_REPEAT) 
    
    } 
    
    PUSH[dvPanel,2] 
    { 
    TimeArray[1] = 1000 
    TimeArray[2] = 1000 
    TimeArray[3] = 1000 
    TimeArray[4] = 1000 
    TimeArray[5] = 1000 
    
    TIMELINE_CREATE(TL2, TimeArray, 5, TIMELINE_RELATIVE, TIMELINE_ONCE) 
    
    }
    
    IF(TIMELINE_ACTIVE(TL1)) // if timeline 1 is running
    
    {
    
    // do something 
    
    }
    

    Once you've got your Timeline running it fires the Timeline_Event[TimelineName] event - which is where you'd want your function to go.

    Hope this helps. :)
  • davidvdavidv Posts: 90
    Timeline

    Yes I did.

    However this will not be acutated by a button push.

    I want this timeline running at startup and every 60minutes I want to perform my Define_Function.

    Then I want my timeline to start over again and repeat.
  • davidvdavidv Posts: 90
    This is what I have

    This is what I have so far.


    DEFINE_VARIABLE
    LONG TimeArray[100]

    DEFINE_CONSTANT
    TL1 = 1

    DEFINE_EVENT

    TIMELINE_EVENT[TL1] // capture all events for Timeline 1
    {
    fnGetRSS
    }

    DEFINE_PROGRAM
    {
    TimeArray[1] = 6000
    TIMELINE_CREATE(TL1, TimeArray, 1, TIMELINE_ABSOLUTE,TIMELINE_REPEAT)
    }

    IF(TIMELINE_ACTIVE(TL1))
    {

    Do some stuff

    }
  • Spire_JeffSpire_Jeff Posts: 1,917
    Just put the timeline_create() call in the define start. Use a time of 3600000 (60 mins * 60 secs/min * 1000 secs/msec). use the TIMELINE_RELATIVE and TIMELINE_REPEAT constant in the timeline_create().

    Then create a timeline_event[timeline_id]{ doMyFunction()};

    That should do it.

    Jeff
  • Spire_JeffSpire_Jeff Posts: 1,917
    Move the TimeArray = 3600000 and the timeline_create statements to the DEFINE_START section so they only run once.

    I'm not sure why you are using the If(timeline_active(tl1)) section. It sounds like you want the timeline constantly running, so the code in this section will always run. You could save some processor time by just putting the chunk of code directly in the mainline (DEFINE_PROGRAM section). If you want to make sure the timeline is constantly running, you could add a if(!timeline_active(TL1)){ timeline_create(); } chunk of code, but unless you stop the timeline, I don't see that being an issue (altho I am not quite sure what happens when the number of iterations exceeds the capacity of the variable holding the number, but I think it would just wrap back to 0 or 1).

    Jeff
    davidv wrote: »
    This is what I have so far.


    DEFINE_VARIABLE
    LONG TimeArray[100]

    DEFINE_CONSTANT
    TL1 = 1

    DEFINE_EVENT

    TIMELINE_EVENT[TL1] // capture all events for Timeline 1
    {
    fnGetRSS
    }

    DEFINE_PROGRAM
    {
    TimeArray[1] = 6000
    TIMELINE_CREATE(TL1, TimeArray, 1, TIMELINE_ABSOLUTE,TIMELINE_REPEAT)
    }

    IF(TIMELINE_ACTIVE(TL1))
    {

    Do some stuff

    }
  • davidvdavidv Posts: 90
    Define_Variable
    LONG TimeArray[3600000]

    Define_Constant
    TL1 = 1

    DEFINE_EVENT
    TIMELINE_EVENT[TL1]
    {
    fnGetRSS() // This is my define_function call //
    }

    Define_Start
    TIMELINE_CREATE(TL1, TimeArray, 1, TIMELINE_RELATIVE,TIMELINE_REPEAT)
  • Spire_JeffSpire_Jeff Posts: 1,917
    Close, but try this:
    Define_Variable
    LONG TimeArray[2]
    
    Define_Constant
    TL1 = 1
    
    DEFINE_EVENT
    TIMELINE_EVENT[TL1]
    {
    fnGetRSS() // This is my define_function call //
    }
    
    Define_Start
    TimeArray[1] = 3600000;
    TIMELINE_CREATE(TL1, TimeArray, 1, TIMELINE_RELATIVE,TIMELINE_REPEAT) 
    

    The number inside the [ ] tells netlinx how many elements are in the array. The way you had it written, I think the compiler would have yelled at you... if not, you would have chewed up a bunch of memory that won't be used :) (you are only using the first value in the array).

    Even tho you are only using 1 slot in the array, the variable still needs to be declared as an array or the compiler will complain.

    Jeff
Sign In or Register to comment.