LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

general state machine question

What is the best way to configure a state machine in order to prevent polling - is this even possible?
 
I currently have a state machine running through 13 states (13 different tests). However, some of the states require input from the user before proceeding and therefore the loop polls until it the user presses a button to continue. Is there a more efficient way to do this? I can't use an event structure because I already have one in another while loop in the same frame (the state machine is in a different while loop than the event structure).
 
Thanks for the help!
 
-Erik
 
 
0 Kudos
Message 1 of 7
(3,569 Views)
There are two options, you could use something like a queue with a timeout of -1 to execute states. Or you could build the state machine into the timeout case of your existing event loop. I've done both and both can work well - the selection depends on the details of what you're doing.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 7
(3,567 Views)
Use a dialog style subVI that gets called as a first thing in the state of interest.
 
Once all parameters are entered in the dialog box, continue the state with the parameters from the dialog box. Dataflow will stall the main code until the dialog has completed. No polling loops and sequences needed. 🙂
0 Kudos
Message 3 of 7
(3,562 Views)
So essentially I should just reconfigure my current state machine to use queues and then set the timeout to -1?

Message Edited by Erik_1 on 07-02-2007 08:31 PM

0 Kudos
Message 4 of 7
(3,558 Views)
In general yes, the only thing is that you are going to need to make provisions for shutting the loop down since a -1 timeout will wait forever. The way I have done it in the past is to define a special queue value that the loop interprets as a shutdown command.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 7
(3,555 Views)
Another option is to register for a value change and have a local event case.

Or wrap this in a subvi


Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 6 of 7
(3,530 Views)
You can also use Release Queue with force destroy? set to True. The consumer (state machine) will block until an element is available to deque or an error occurs (Release Queue will throw an error). Wire the error out of Dequeue Element
 to the conditional terminal of the loop to exit.


0 Kudos
Message 7 of 7
(3,511 Views)