Home AMX User Forum NetLinx Studio
Options

Parse Timeline value

How would one parse the value of an active timeline?

Say I create a TL for system shutdown, for example. I want my system to shutdown 4 hours after x button is pushed. I know it will shutdown 4 hours from when I pushed it, but how can I send the value of the active timeline counting down to a text box?

Sample code appreciated!

Comments

  • Options
    the8thstthe8thst Posts: 470
    Not complete or tested code because I don't have the time, but this should help. I am assuming you just want to count down by minutes and the idea can easily be modified to work based on seconds.
    	// create timeline that repeats every 1 minute
    	timeline_event[tl4hourTimer]
    	{
    		stack_var integer minutesRemaining
    		stack_var integer nHour
    		stack_var integer nMin
    		
    		minutesRemaining = 240 - timeline.repetition
    		nMin = minutesRemaining % 60
    		nHour = type_cast(minutesRemaining / 60)
    		
    		send_command dvTouchPanelArray,"'!T',nTimerDisplayAdr,itoa(nHour),':',itoa(nMin)"
    		
    		if(!minutesRemaining) {
    			timeline_kill(tl4hourTimer)
    			fnExecuteSystemShutdown();
    		}
    	}
    

    Something like that was the first thing that came to my mind.

    edit: I just realized you wanted it to count down from 4 hours, so I modified the code to count down instead of up
  • Options
    ericmedleyericmedley Posts: 4,177
    Another method might be to create a shorter repeating timeline (60000 ms for one min repeats) and use a global counter decrementing down from 4 hours. In the TL_Event check for counter=0 and kill the TL then. Then you can easily convert the counter to text time. Additionally you'll be able to manipulate the counter to adjust the time on the fly if needed. Just another thought...
  • Options
    DHawthorneDHawthorne Posts: 4,584
    I prefer Eric's method. On a long timeline like that, it ensures that if the master gets interrupted or restarted, it will pick up where it left off and not lose the event altogether. It also ensures any of your variables don't fall out of scope because they aren't stacks in the timeline itself.
Sign In or Register to comment.