02-06-2014 09:53 AM
The event structure subscribes to the registered events, if any of those happens it'll run. This includes the timeout event which'll auto generate after the wait time. I'd set 10 or 100 as fixed timeout to have a responsive program which still will be calm and wait for the events.
/Y
02-06-2014 10:40 AM
@rcote1 wrote:
Yes, that's what I did, but its the Timeout event that decides if its goig to be a 0 or -1 that the Timeout terminal takes. My question is, how does the timeout event gets notified of any event that need to be handled?
Why would the timeout case determine its own timeout? That makes no sense to me. The timeout should be determined based on what actions you are performing. So it should be the button presses that determine the timeout.
Can you post some code so we can see where you are at?
02-06-2014 02:23 PM
Is there a way to prioritize the other events if they happen instead of the Timeout event. I use a Timeout of 0 and if there are other events I would like them to be handled first. That would truly simplify.
02-06-2014 02:28 PM
Producer/Consumer. This thread is going down a path that is not following best practices. Handling the events in the same loop as the state machine makes no sense to me. Separate the two.
02-06-2014 02:50 PM
Here is my program.
Richard
02-06-2014 02:52 PM
@rcote1 wrote:
Is there a way to prioritize the other events if they happen instead of the Timeout event. I use a Timeout of 0 and if there are other events I would like them to be handled first. That would truly simplify.
If there is an event in the queue, the Timeout will not be selected. The event that was queued up will run instead. The given timeout is just how long the structure will wait for an event starting when the event structure was reached. Events could be queued up before the event structure was reached. If so, they will run, not the timeout.
02-06-2014 04:55 PM
@kbbersch wrote:
Producer/Consumer. This thread is going down a path that is not following best practices. Handling the events in the same loop as the state machine makes no sense to me. Separate the two.
You mean like the State Machine fundamental example?
It sounds like a valid design.
/Y
02-06-2014 05:13 PM
Using a Producer/Consumer design pattern with a queued state machine would make a lot more sense in this application. There would be no chance of blocking the state machine. Easier to extend. Lots of pluses.