LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to clean up code after pressing

Solved!
Go to solution
Solution
Accepted by topic author remotecntrl

You queue up a Run in the event structure, you never really use the value as it comes out of the dequeue function.  Basically just using it as a trigger to execute that lower loop.  After 1 iteration, the lower loop waits for another item to be queued up for it.

 

I would send the Run command as an enum from the upper structure, when it gets dequeue, the value that comes out is what triggers the Run case in the lower loop.  In the lower loop what you can do at the end of the Run case, is queue up another run.  It will fire the dequeue on the next iteration and go again.  Basically it will constantly reseed itself.

 

If you want to stop.  Then the event structure up top can feed a Stop Command.  When it gets dequeued, it will run a Stop case.  Further runs won't get queued up.

 

I scattered some comments around in the attached screenshot.  By using the queue, you can set the the producer/consumer loops up as a "queued state machine".  Then either the GUI producer loop, or the consumer loop handling the communications can determine what is the next state to execute.

Message 11 of 14
(1,153 Views)
It is still fuzzy to me, but for anyone viewing this I highly recommend checking out http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/
0 Kudos
Message 12 of 14
(1,142 Views)

Thank you sooo much.  Very helpful.

 

Katie

0 Kudos
Message 13 of 14
(1,120 Views)

Kudos to Ravens for the simple explanation.

I am implementing my first producer consumer loop (after it was suggested by you guys in my question's reply) and reading forums to understand the queuing process. I still have to figure out which is a better way - producer/consumer queued loops, or standard state machine, with single loop. and I was wondering if the "queue" has only one element or all the elements of the enum. Logically it seemed to be just one element, but still needed to read some kind of description.

I think standard state machine is more simple to see, but could be more difficult to implement, and producer/consumer loops look a bit complicated, but may simplify.

I need to design the whole process to see the possible problems.

And Kudos again for sharing Ben's Action Engine. 😉

Vaibhav
0 Kudos
Message 14 of 14
(1,009 Views)