LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to read flushed cluster array from input queue?

Hi! I'm new to LabView. Can someone please help me?

I want to use a subvi to read a queue which I created in another vi. The created queue holds an array of clusters that I want to unbundle in a for loop in the reading vi. But the output of the flush queue function is a string array (since the subvi has no info on what sort of queue is being input).

I can't connect the unbundle function to a string input; can I use the type cast function to force the flush output to be a cluster? Or is there a better way to do this?

And if so, what is the string constant I need to attach to the "type" input in the type cast function?

And also, I'm told that the cluster is kind of like a "struct"; so is there a way to n
ame it so that other vi's know what it is(i.e. type cast)?

🙂 jen
0 Kudos
Message 1 of 7
(3,930 Views)
Hi Jen,

in the client vi you just have to wire the element data type to the relative input in Obtain Queue function; this has to be of the same type of the data contained in the queue.In your case it has to be an array of clusters (it can be a constant); and the cluster should also be of the same type. Just an hint: from the diagram of the server vi right-click on the control terminal you input in the queue and select create constant, move it on the client vi and connect it to the element data type terminal; the Flush Queue will return data of the same type (array of your clusters).
Let me know if that was not clear enough; good luck,

Alberto
Message 2 of 7
(3,930 Views)
Hello JenMc,

you should really use the Help-function of LabView (Ctrl-H)!

For reading queue elements use "Dequeue Elements". With "Flush Queue" you empty the queue and get all remaining elements in an array. Both functions give you the same element type that you told the "Obtain Queue" function.
If you give "Obtain..." a cluster than both "Dequeue..." and "Flush..." give you clusters, as single element or as array of cluster respectively. You dont need to type cast.

Hope this helps
Best regards,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 7
(3,930 Views)
Hello JenMc,

a simple example explaining my message above...

Best regards,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(3,930 Views)
Hi Alberto! Thank you! That was very helpful. I wasn't using the obtain queue function. I had just told the flush queue function to create a control, and it, of course, gave me whatever was the generic type. I only went through a one-week crash course in LabView, and the instruction was "controls are input" and "indicators are output", so I was searching for a queue control, but couldn't find one and didn't even think of using the function to grab it. So silly! I should have figured that out. Darn.. Well now it works perfectly!

Thanks for your help!!
🙂 jen
0 Kudos
Message 5 of 7
(3,930 Views)
I did look at the help examples, but I couldn't find one that was sending the queue from one vi to another(well, not any that I could understand), and that was really my problem.

I did get the thing to work when it was all in one vi.

You bring up an interesting point about "dequeue" and "flush". Perhaps I am mistaken, but my reasoning for using flush rather than dequeue was the following:

I am using the queue as a data buffer. I need the queue to hold a few minutes of data. This data is dumped to file upon fault event, i.e. it tells me what was going on right before the fault occurred. I need that queue to dump the data and then immediately turn around and start filling up again. I felt that holding on to the queue reference in the save-to-file routi
ne (which involves lots of potentially slow hard disk access) might cause the object to lock and hence not be able to save right away. I don't know how LabView does threading, but if I was writing the threading routine, I would lock any object which was being executed upon in a routine to prevent data collision.

Of course, this begs the question: does LabView lock all objects in a subroutine that is executing? Or just in the part which is unresolved? or does it lock objects at all? Perhaps I should flush the queue outside of the subroutine anyway, so that the subroutine can happily munch on the flushed array while my queue goes back to the business of collecting data?

Am I way off base in how the threading works?

Thanks!
🙂 jen
0 Kudos
Message 6 of 7
(3,930 Views)
I haven't installed the update (7.1) yet. I couldn't read this. (I only installed 7.0 about 1 week ago!)
0 Kudos
Message 7 of 7
(3,930 Views)