WAIT in DEFINE_PROGRAM section
pushtoplay
Posts: 12
Does a WAIT in the define_program section get executed once until wait time expires, or do the WAIT's stack up and ultimately hose the processor. More specifically, is the following code snippet example a problem?
DEFINE_PROGRAM
WAIT 5 // .5 seconds
{
UpdateTouchPanelFeedback()
}
P.S. I added something like this "in a hurry" on Friday. The processor needed to be rebooted over the weekend. I'm guessing this is the cause. I have rewritten using TIMELINE and am planning on updating the system tomorrow.
DEFINE_PROGRAM
WAIT 5 // .5 seconds
{
UpdateTouchPanelFeedback()
}
P.S. I added something like this "in a hurry" on Friday. The processor needed to be rebooted over the weekend. I'm guessing this is the cause. I have rewritten using TIMELINE and am planning on updating the system tomorrow.
0
Comments
No the waits don't stack up. Otherwise you couldn't use them in define_program as you have mentioned. Your wait will get executed every half second, but that is still far too often to update a touch panel, and this is what is hosing your master. I don't know what UpdateTouchPanelFeedback does, but if it sends text to the touch panel or does anything other than turn on/off channels, you are seriously compromising the reliability and responsiveness of the system. Is there some reason you need to update the panel every half second? Is it controlling a nuclear launch site or a particle accelerator?
If you are sending text then you should change how you send or how you track what you send. You can either send as you receive data and parse it or create a variable, variable array or structure to store your sent strings and then compare those strings to the received data to verify the text on the TP's indeed needs to be updated. Something like this:
If your just sending strings straight from the DATA_EVENT after parsing data you should still store the strings being sent somewhere so you can updates TPs when they come online or when another TP flips to that page, that is unless you're sending to the entire TP array like the example above. Now the example above is old code which hasn't yet been re-written to send updates only to TPs on this particular device page which is the direction we all should be moving towards.
You may not be sending any data to a TP for on/off channels and levels that haven't changed, but the processor has to check each one of those variables 200 times a second to see if they have. I tend to see this in code a lot and I think its responsible for a laggy system once they start to get big.
99.99% of the time this code will run and nothing will change, so why bother, especially when it can usually be put in a channel event with no overhead? As sloppy as this code is, it would still be better than the above:
Paul
Unforetunately most code presently being used isn't written this way, especially the AMX modules and a lot of coders aren't into that level of feedback and processor management yet so for them they need simple ways to modify their existing code so that their output light isn't solid red all the time.
Also a lot of text being sent to the TPs like like surround modes or audio inputs can be done easier with less effort but sending levels and have TP button made as multi-state bargraphs with each state holding its own text. Then sending levels (fixed or constant VT) is manage by the master.
I don't know that I'd agree entirely. I think there are a lot of places, especially with wireless panels that may or may not be online all the time, that doing feedback in the [dvTP,1]=nProjectorPower method works fine, and might even be preferable. Also, I prefer tracking thing like Proj status in variables, instead of just sending the state directly to the panel, so you can more easily follow things in debug.
I like having a system designed such that I don't have to manually update panels when they come back online, and short of combining panels to a virtual device, I think the best way to do it is through assigning button channels to variables.
I'd agree that sending text to panels over and over is poor, and I only do that in events, but I do my TP feedback in a timeline that runs every half second or so, and in several decently large systems I've never once experienced a slowdown that commenting out my TP timeline fixed.
I like my timeline for feedback instead of a wait in define program, but its certainly a valid way to code.
J
A wait in the program simply adds the statement or stetements that follows to the system timeline which repeats at 100ms to see if it time to execute the code. The problem with putting waits in the system timeline (wait queue) is that every 100ms it has to check every item in the queue to see if it's time is up and if not subtract 100ms from its time to execute. So depending on how much stuff through out the entire code is running waits at any given time the system could have a substantial list to run through and subtract time from every 100ms.
That way you just set nMuted to on, and the button blinks every half second.
The only reason I stopped doing it was that it made stepping through code frustrating beyond all belief. Lately I've been having non blinking mute buttons, but I admit I'd rather have it blink again.
J
Why would you even need to make the processor handle this? Unless you are dealing with keypads, you can just set the button feedback to Blink. It will only blink when the channel is on. This way, all you have to do is: [dvTP,MuteButton] = nMuteState; .
This solves all of the processor overhead and extra coding problems
Jeff
Why even have that in mainline when you could do this?