LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for Queued state machine template

I can't remember where I found this image, but it looks like a really good state machine template.  I think I remember that it was from an issue of LTR.  Does anyone happen to have the VI that goes with this diagram?
 
Thanks,
Brad
0 Kudos
Message 1 of 9
(5,853 Views)
Hello Brad,

I often use that template attached... There are certainly functions you may want to remove, I use it to test some "image analysis VI".

Hope this help you... feel free to ask for comments 😉



We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 9
(5,823 Views)


TiTou,

Thanks, that is pretty close to the picture I sent out.  In the case structure you have a frame named "IHM".  I'm just curious what that stands for.  Also one other little difference having to do with the queue that I would like to understand.  On your "Dequeue Element" function you have no timeout, so I understand that it is the default of never timeout.  In the image I sent, they put a timeout of 10 ms on it.  LabVIEW help for that function does not say what gets put on the "element" output if the function times out, therefore I'm not sure which state would be executed.  I'm guessing that the default value for the data type of the queue gets put on that output?  If it's an enum, the default would be the 0 element?  That's one of the reasons I wanted to see the original code that went with that particular diagram.  I want to understand how to implement state machines very well since they are so important.

Thanks,

Brad

Message 3 of 9
(5,801 Views)
Hi Brad,

IHM stands for "Interface Homme-Machine", understand "Graphical User Interface"... Sorry I try to use only english when I develop but sometimes my french part is just too strong Smiley Tongue

About the timeout to dequeue elements... well, it is certainly beter to put a 10ms constant not to get locked. I have no idea of what happens if you try to dequeue an element from an empty queue. My code is certainly not perfect and that is a part I could improve, thanks for that comment !

I will try to dequeue an empty queue with and without timeout to see what happens, I assume there will be an error and a default element.
BTW, it is possible to define the default value of a enum so it can be diferent from 0 😉

Also, a nice way to avoid that would be to make a custom dequeue that first perform a "preview queue" to make sure the queue is not empty and then either reads the queue if not empty or return "whatever you want it to return" if the queue is empty.

I assume you'll be able to do that yourself Smiley Tongue

Thanks again for pointing out "room for improvment" in my code 😉


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 4 of 9
(5,789 Views)

I confirm that the timeout should always be connected !

And weirdly, the default value returned after the time out for an enum IS NOT the default value but the value 0... this, for me is not a normal behaviour so I would advise to develop a "custom dequeue" VI that preview the Q and returns a default element if time out happend.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 5 of 9
(5,779 Views)
The picture you sent out is from an article from Bloomy Solutions
Newsletter, from spring 2003.

http://www.bloomy.com/newsletters/Simple%20State%20Machine%20Template.pdf

If you contact them. They may give you the source code for the
template.

Hope this helps.

Message 6 of 9
(5,759 Views)

Oh, yes - Bloomy.  I remember downloading several free VIs from them a while back.  They're worth checking out if anyone hasn't done so yet.  Thanks for the info...

- Brad

0 Kudos
Message 7 of 9
(5,756 Views)

I've put a version of our simple state machine template on our web site for you all to download.

http://www.bloomy.com/resources/index.php#vis

Hope this helps!

Keith Brainard, Bloomy Controls

Message 8 of 9
(5,592 Views)

Mr. Brainard,

Thanks for sending my that QSM template back when I contacted you about it.  I ended up using it to completely restructure one of our nightmarish app's that had a dizzying number of deeply-nested structures.  It is now MUCH easier to understand and modify (which I did after I converted the structure).  I attached a screen capture of the final working code.  It works very well.

Thanks again,

- Brad

 

0 Kudos
Message 9 of 9
(5,547 Views)