LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generic Queue?

Solved!
Go to solution

Hi all,

 

My project involves testing SubVIs. I`m doing this by writing a test VI that calls SubVis. Many of these SubVis take queues as inputs. Therefore, my test VI obtains a reference to a queue, fills the queue from an array, passes this reference into the SubVi being tested, then destroys the queue.

 

I'm finding that I need to copy and paste this "obtain a queue, fill the queue, pass the queue into a SubVI, destroy the queue" logic a lot. The only difference in each copy & paste is the queue data type. Is there a way to avoid copying and pasting this VI all over the place? I'd love to have only one VI that does "obtain a queue, fill the queue, pass the queue into a SubVI, destroy the queue" and have many seperate VIs that define different queue data types. Is this possible in LabView? All this copy and pasting I'm doing will be difficult to maintain.

 

I've attached the VI that does "obtain a queue, fill the queue, pass the queue into a SubVI, destroy the queue".

 

Thank you!

0 Kudos
Message 1 of 29
(4,336 Views)

To start, you could save that function as a VI Template (File->Save As, change the file type drop down to be a VI Template).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 29
(4,305 Views)

If I do that but later I find a problem in the template I need to go back and correct all VIs that used that template though, right? 

 

Thank you.

0 Kudos
Message 3 of 29
(4,253 Views)

Yes, that would be the case. Another option you investigate would be VI scripting. You could write a VI that would create your new VI and programming select the data type for the queue.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 29
(4,239 Views)
Solution
Accepted by topic author Jared7

@Jared7 wrote:

If I do that but later I find a problem in the template I need to go back and correct all VIs that used that template though, right? 

 

Thank you.


yes, the bug will just be copied to each instance you create from the template.

 

Thinking about this more, you might want to make a polymorphic VI to hold all of the instances you have used.  That way you can just drop down the polymorphic VI and have it auto select which instance to use based on the input data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 29
(4,232 Views)

Cant you generalize the testing sub-vi with a vi ref or path in and open the vi that way, thus only using 1 VI for all tests? If all VI's uses "Queue in" you can set it through e.g. invoke ctrl.set, or if all uses the same connector pane you can use the Call by reference.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 29
(4,228 Views)

Thank you for so many quick and good suggestions! I'll give these a try and let you know how they work for me.

0 Kudos
Message 7 of 29
(4,221 Views)

This is one reason why the cluster of string,varient, QMH is so popular.  What it lacks in readability (Compared to the type def enum driven, QMH) it makes up in testability.  The major difference being that you must handle the "Typo" case since some developer somewhere will type a string wrong.  (If we could all type perfectly LabVIEW itself might not exist)


"Should be" isn't "Is" -Jay
Message 8 of 29
(4,209 Views)

Another option is to use a variant data type in the queue.  This requires, however, that each subvi reads in variant data and converts it to the data type it needs.  This method allows you to send any data you wish so long as the subvi converts variant data to the appropriate type.

 

While it may be too much work right now to modify these subvi's, you would only need one section of code in your main "test" vi.

0 Kudos
Message 9 of 29
(4,187 Views)

Hey all again. I'm looking at implementing the various solutions suggested and have come up with the following:

 

- Polymorphic VI - The problem I see with this is I will still need to copy and paste VIs to include in a single polymorphic VI. Each copied and pasted VI will have a slightly different connector pane. Again, if I find a bug in one VI I will have to go into each cloned VI and correct the problem.

 

- Use a single VI - This seems like a good idea. All VI's do have a "Queue in". I'm not sure how to populate the queue with data that has an unknown type at run-time though. I might need something like a Generic Array as input. I'm somewhat new to LabView.

 

- Using variants - Yes, this also would only require 1 test VI. Unfortunately I would need to modify a lot of VIs to convert the variant to required data types.

 

Since this VI is pretty small I may go with the copy & paste approach. Since I'm somewhat new to LabView I wanted to ensure I'm not missing something obvious before doing this. I'm more familiar with C# where this problem could be solved with a single parent class containing the "obtain a queue, fill the queue, pass the queue into a SubVI, destroy the queue" logic, and several child subclasses that call different subVIs and handle the different data types.

 

Thank you!

0 Kudos
Message 10 of 29
(4,173 Views)