04-04-2010 06:12 AM
Hello
I am using a Queued State Machine that is controlled by an Event Structure. In this example, the State Machine has 3 cases: Idle, State 1 and State 2.
I need to trigger State 2 execution, from inside State 1.
Thanks
Dan07
Solved! Go to Solution.
04-04-2010 06:35 AM
Define State 2 as a User Event. Use the Generate User Event VI to trigger the event from within State 1.
04-04-2010 07:03 AM
But in my real VI this will happen several times because my State Machine has a lot of cases (not only 3, as the example) and I would have to define almost all the States as User Events. I would like to keep using the Queue function that I used within the Event Structure, but within the State 1 to trigger State 2.
Thanks
04-04-2010 07:27 AM
maybe you can use a property node (value/signaling)
04-04-2010 07:27 AM
You should have a look at this Dr. Damien's Developement post. It shows two ways of creating a queued state machine with Event handler.
Basically you will nedd to do the following:
a) check for the queue timout, if so go to the idle state
b) place the event structure inside the Idle state
Then you can enqueue State 2 inside the State 1.
Felix
04-04-2010 07:37 AM - edited 04-04-2010 07:38 AM
04-04-2010 07:58 AM
Then you need to have two parallel while loops, one for the Event handling and one for the state machine. But in this case, triggering state 2 out of state 1 isn't good. You should instead always send 2 commands to the consumer 'State 1', 'State 2'.
Felix
04-04-2010 01:39 PM
you can put an enqueue element function inside the case structure and let the state machine feed new states into the queue. the problem is that your while loop will wait for an event before it starts another execution.
your architecture will work better as two separate loops: one for the event structure, and one for the case structure (producer consumer).
04-04-2010 04:38 PM - edited 04-04-2010 04:39 PM
Hello guys
Now I have two while loops running (Producer and Consumer). Is there anything else that I can improve in my code?
Thanks
04-04-2010 08:20 PM
looks good!
-why trigger events on mouseup? What I think is most common is to use value change, which handles the different ways the control can be changed (ie keyboard), and also if you absolutely have to, you can use a value(signaling) property to trigger that case.
-handle the panel close? event to perform the same function as your stop button.