To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example shows how to keep queue references in an FGV, which can then be used in a Producer and Consumer design pattern.
Description
FGVs make use of uninitialized shift registers to hold data between each call. The FGV is implemented to receive 3 commands, namely initialize, get and release. "Initialize" is used at the start of the program to obtain the desired queue reference, "get" is used to obtain the queue reference at any part of the code after it has been initialized, and "release" is used at the end of the program to release the queue reference.
The FGV is also implemented in a Producer and Consumer design pattern to clearly show how this can be utilized.
Requirements
Steps to Implement or Execute Code
Additional Information or References
Main vi block diagram
Queue Access FGV block diagram
**This document has been updated to meet the current required format for the NI Code Exchange."
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
I would recommend adding a Send Message case. That way those who are sending the commands done have to get the reference and then enqueue the element. They just call this VI to send the command.
Hey crossrulz,
I left the send message case off the FGV in case of a fixed queue size. Because this VI is non-reentrant, if you attempt to enqueue a message to a full queue, you could run into a deadlock if you have a non-zero timeout. If you abstract the send message case one level higher to individual message APIs, you can avoid this issue.
If you get deadlock, then you have more issues. Only one place should be reading from the queue. so what you do is Create the queue and then pass the reference into your reading loop. That loop then doesn't care about this VI. Only those sending will need it. So you shouldn't have any deadlock.
Call the Close case after the reading loop is complete.
hello there
i am a new one. i want to ask that: how to creat the queue model.i try million times already! thank you if you can answer~
i mean the queue out model with green color. by the way, i`d like to know how i can improve my skil in labVIEW.
What do you mean by "queue model"?
the green one indicator. data type
Right-click on the queue output of the Obtain Queue and create an indicator.
There are tutorials availabe online. I also highly recommend looking into LabVIEW training courses.
with the label"queue out"
thank you very much. and i am a graduate, it is really hard for me to learn labVIEW
it did work. but i have to do so everytime when i need this type of indicator?
The problem is that the queue reference also has to contain the type of data in the queue. You can copy the queue reference and paste is where ever you need it.