TIMELINE_KILL inside TIMELINE_EVENT, Is this a legal operation?
pushtoplay
Posts: 12
Here is a code fragment. I don't have access to a processor at the moment to test this. Is it legal to kill a timeline while the event is being processed? Also, is timeline_reload allowed in the event handler? Dumb question, how does one maintain the program formatting in a post?
DEFINE_FUNCTION AVR_Send_Cmd(INTEGER nInChar)
{
nRingBuffer[nEndPtr] = nInChar // put the character in the ring buffer
if (nEndPtr != BUFFER_SIZE) // at the end of the buffer
nEndPtr = nEndPtr + 1; // nope
else
nEndPtr = 1; // yup, back to the beginning
if (TIMELINE_ACTIVE(TL1) = 0) // timeline is NOT active (or created)
{
if (nAVR_OnState = 0) // device was off, wait for it to power up
TimeArray[2] = POWERUP_DELAY
TIMELINE_CREATE(TL1, TimeArray, 3, TIMELINE_RELATIVE, TIMELINE_REPEAT) // create the timeline
}
}
(***********************************************************)
(* THE EVENTS GO BELOW *)
(***********************************************************)
DEFINE_EVENT
TIMELINE_EVENT[TL1]
{
SWITCH(Timeline.Sequence) // which time was it?
{
CASE 1: // execute command
{
if (nEndPtr != nStartPtr) // when nEndPtr = StartPtr, then buffer is empty
{
nOutChar = nRingBuffer[nStartPtr] //extract the character
send_string 0, "'Out_char=',itoa(nOutChar),' Start Ptr=',itoa(nStartPtr),' End Ptr=',itoa(nEndPtr)" //debug
if (nStartPtr < BUFFER_SIZE) // at the end of ring?
nStartPtr = nStartPtr + 1; // nope
else
nStartPtr = 1; // yup, back to the begining
}
else
{
timeline_kill(TL1) // finished sending commands, terminate timeline
}
break
}
CASE 2: // do nothing delay time, waiting for device to receive and process command.
{
break
}
CASE 3:
{
if (nAVR_OnState = 0) // device was OFF
{
TimeArray[2] = COMMAND_PACING // normal command pacing
nAVR_OnState = 1 // after 1 pass, the device is on
timeline_reload(TL1,TimeArray,3) // use new times
}
break
}
}
}
DEFINE_FUNCTION AVR_Send_Cmd(INTEGER nInChar)
{
nRingBuffer[nEndPtr] = nInChar // put the character in the ring buffer
if (nEndPtr != BUFFER_SIZE) // at the end of the buffer
nEndPtr = nEndPtr + 1; // nope
else
nEndPtr = 1; // yup, back to the beginning
if (TIMELINE_ACTIVE(TL1) = 0) // timeline is NOT active (or created)
{
if (nAVR_OnState = 0) // device was off, wait for it to power up
TimeArray[2] = POWERUP_DELAY
TIMELINE_CREATE(TL1, TimeArray, 3, TIMELINE_RELATIVE, TIMELINE_REPEAT) // create the timeline
}
}
(***********************************************************)
(* THE EVENTS GO BELOW *)
(***********************************************************)
DEFINE_EVENT
TIMELINE_EVENT[TL1]
{
SWITCH(Timeline.Sequence) // which time was it?
{
CASE 1: // execute command
{
if (nEndPtr != nStartPtr) // when nEndPtr = StartPtr, then buffer is empty
{
nOutChar = nRingBuffer[nStartPtr] //extract the character
send_string 0, "'Out_char=',itoa(nOutChar),' Start Ptr=',itoa(nStartPtr),' End Ptr=',itoa(nEndPtr)" //debug
if (nStartPtr < BUFFER_SIZE) // at the end of ring?
nStartPtr = nStartPtr + 1; // nope
else
nStartPtr = 1; // yup, back to the begining
}
else
{
timeline_kill(TL1) // finished sending commands, terminate timeline
}
break
}
CASE 2: // do nothing delay time, waiting for device to receive and process command.
{
break
}
CASE 3:
{
if (nAVR_OnState = 0) // device was OFF
{
TimeArray[2] = COMMAND_PACING // normal command pacing
nAVR_OnState = 1 // after 1 pass, the device is on
timeline_reload(TL1,TimeArray,3) // use new times
}
break
}
}
}
0
Comments
Especially if you have a repeating timeline that needs to end once the condition is met.
Don't know abou tthe timeline_reload - never tried it from nside - why wouldn't it work?
Click on the "BB code" at the bottom left. You will see a "code" item in the list.
keith
Yeah I started checking each time for timeline_active before killing just to avoid the run time errors. I think that is still an issue