Sleep Timers and Timelines...
vegastech
Posts: 369
I have been reviewing the Netlinx language reference guide as well as the Programmer 1 &2 manual, and they both show a section on Timelines. I still don't get it. The example refers to sending a command to a touchpanel, like so:
case 1: { SEND_COMMAND dvPanel,"'TEXT1-1 1'" }
isn't this just sending a text string to the panel? how would it know what button or field to send it to?
I added the TimeArray variable into the watch bar under debug mode, but when I press the button I assigned it to, the values don't change. I believe I entered this verbatim from the PDF file, as I wanted to see what it did.
<code>
DEFINE_CONSTANT
TL1=1 //timeline item #1
TL2=2 //timeline item #2
DEFINE_VARIABLE
LONG TimeArray[100] //Timeline item #3
DEFINE_EVENT
TIMELINE_EVENT[TL1] //timeline item #4, captures all events
{
switch(TIMELINE.SEQUENCE) //which time was it?
{
case 1: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT1-1 1'"}
case 2: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT1-1 2'"}
case 3: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT1-1 3'"}
case 4: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT1-1 4'"}
case 5: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT1-1 5'"}
}
}
TIMELINE_EVENT[TL2] //timeline item #5, captures all events
{
switch(TIMELINE.SEQUENCE) //which time was it?
{
case 1: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT2-2 1'"}
case 2: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT2-2 2'"}
case 3: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT2-2 3'"}
case 4: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT2-2 4'"}
case 5: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT2-2 5'"}
}
}
DEFINE_PROGRAM
PUSH[dvJVCLT37X898Tp,502]
{
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[dvJVCLT37X898Tp,503]
{
TimeArray[1] = 1000
TimeArray[2] = 1000
TimeArray[3] = 1000
TimeArray[4] = 1000
TimeArray[5] = 1000
TIMELINE_CREATE(TL2, TimeArray, 5, TIMELINE_RELATIVE, TIMELINE_ONCE)
}
</code>
case 1: { SEND_COMMAND dvPanel,"'TEXT1-1 1'" }
isn't this just sending a text string to the panel? how would it know what button or field to send it to?
I added the TimeArray variable into the watch bar under debug mode, but when I press the button I assigned it to, the values don't change. I believe I entered this verbatim from the PDF file, as I wanted to see what it did.
<code>
DEFINE_CONSTANT
TL1=1 //timeline item #1
TL2=2 //timeline item #2
DEFINE_VARIABLE
LONG TimeArray[100] //Timeline item #3
DEFINE_EVENT
TIMELINE_EVENT[TL1] //timeline item #4, captures all events
{
switch(TIMELINE.SEQUENCE) //which time was it?
{
case 1: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT1-1 1'"}
case 2: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT1-1 2'"}
case 3: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT1-1 3'"}
case 4: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT1-1 4'"}
case 5: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT1-1 5'"}
}
}
TIMELINE_EVENT[TL2] //timeline item #5, captures all events
{
switch(TIMELINE.SEQUENCE) //which time was it?
{
case 1: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT2-2 1'"}
case 2: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT2-2 2'"}
case 3: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT2-2 3'"}
case 4: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT2-2 4'"}
case 5: {SEND_COMMAND dvJVCLT37X898Tp,"'TEXT2-2 5'"}
}
}
DEFINE_PROGRAM
PUSH[dvJVCLT37X898Tp,502]
{
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[dvJVCLT37X898Tp,503]
{
TimeArray[1] = 1000
TimeArray[2] = 1000
TimeArray[3] = 1000
TimeArray[4] = 1000
TimeArray[5] = 1000
TIMELINE_CREATE(TL2, TimeArray, 5, TIMELINE_RELATIVE, TIMELINE_ONCE)
}
</code>
0
Comments
From the example you pasted in :
When the timeline starts it starts at an arbitrary zero moment in 'time' and the elements of the array (in this case 5) correspond to the times at which it will fire an event. In the above example, at 1second every second through to 5 seconds.
At each of these 'times' a timeline event is triggered in which you can do specific things dependant on which timeline.sequence number it was (ie which position in the array), or indeed do anything you want in this array at which ever time you want.
A timeline can be repeating, in the above set of times, if the timeline was created as a repeating timeline then it would continue to fire a sequence of events 1 through to 5 once a second for ever.
The following set of times:
Gives us a good example of the difference between an ABSOLUTE timeline, as in the previsous example where the times in the array triggered events at abosulte moments in time, and a RELATIVE timeline.
A Relative timeline (TIMELINE_RELATIVE) fires events (in this case 5 of them again) relative to the previous time, so from our zero moment in time, the first event TimeArray[1] = 1000 will fire 1000msec after that zero moment, so an absolute 1 second from the start point of our timeline. The second event will fire 1000msec later relative to our 1st event, so an absolute 2sec after our zero moment.
I hope that helps with timelines, as to the send command. AMX-PI provides you with a list of all commands and their syntax that you can send to a touchpanel.
That specific command is a legacy command and its structure is as follows:
"'TEXT<variable text address 1-255>-<new text to be put in button>'"
I hope this helps!
From AMX-PI:
Here's what I mean about naming the Variable Text addresses as constants:
LOL on your <\Code> craziness. How many variations are there
--John
Anyways, my whole purpose here is to determine the best way to do a sleep timer in a master bedroom. I understand that I should use a Timeline, ok. I think I want to start out by saying set the TimeArray to 1 sec. so that it will repeat every second. At the end of the Timeline, I want to execute the function for Room Off, and kill the timeline. While the timeline is running, I want to have a countdown button showing the time remaining before the system will shut down. I want to allow the user to press the actual time remaining, and auto-increment both the time remaining as well as the actual timeline.
Its not working... Tips?
First, if you look at your timeline event carefully you will see that the count down actually taxes 61 seconds. This may be okay, but if you want to be more precise you could move your decrement un top of your test to see if the timer has expired. This may have odd consequences if you allow your timeline to run indefinitely Then, after the time has expired, you can kill the timeline to prevent it from running the tv turnoff function every second.
might look like this
you could also use timeline_pause and timeline_restart instead of timeline_kill and a subsequent timeline_create. I don't know enough to say what advantage in resources one method may have over another. Personally, sort of like pausing and restarting rather than killing and creating, but that may be just a fetish.
The Timeline works on an array of times because these times can differ. For example, you can have an array { 1000, 2000, 5000, 5500, 6000, 7000 } that will fire an event after one second, two seconds, then five seconds, then five and a half etc etc, depending on whether its absolute or relative. Much fun can be had!
I don't think it really matters, as long as they are unique. My understanding is that they are a handle to a pointer.