From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

vi generic cluster

Hello,

 

I'm trying to write a generic subVI that is reusable that can adapt to the input type (a cluster but with contents unknown) and an output type (again a cluster). I would have thought that this is easy as my VI can iterate through the controls property of the clusters and update contents appropriately, but LabVIEW checks the types of the main VI with that of the subVI and reports an error because they are different.

 

I thought maybe i could change the input type to the subvi is a variant and I somehow map it to a cluster, but I can't get something like that to work.

 

Ultimately, I'm reading data from a configuration file, the user provides a cluster that defines the datatype they want and an array that maps from the configuration file to the cluster (all in text form).

I've seen a few posts, but nothing concrete with examples, or with XML (which is a file format I can't use).

 

Thanks,

Jason.

0 Kudos
Message 1 of 8
(4,763 Views)

Jason,

 

if the clusters are known (but may have different content at different instances), you'd go for polymorphic vis.

Please refer to "Building Polymorphic VIs" in the LabVIEW Help for further information.

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 8
(4,755 Views)

Take look at the code I posted in this nugget that does something similar by using control references. I believe one of the methods I mentioned in that should help.

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 8
(4,751 Views)

Hello Norbert,

 

I thought about polymorphic and reviewed some examples. It seems like a similar concept to C++'s overloaded functions. If this is the case, then it's just as easy to copy the VI and replace the clusters for each project as each project will have it's own unique cluster.

 

Taking a Class like approach, I would have hoped there is a mechanism where a cluster could be "type casted" to and tell labview to accept a generic cluster (if such a beast exists).

 

For the other post about references, this is so far the best solution, except that it adds extra complexity to the application (need to get the reference, then dereference). I still need to try it if it will actually work.

 

Thanks,

Jason. 

0 Kudos
Message 4 of 8
(4,729 Views)

Hello Ben,

 

Article is pretty good. From what I understand you need to supply a reference to the control to the SubVI, is it possible somehow to wire a generic cluster directly to the subVI and have it calculate the reference? It saves one step in the main application.

 

I thought about a variant, but getting the generic reference and typecasting it to a cluster results in a type mismatch. So I'd have to use "variant to data" and I'm back to the original problem.

 

Thanks for your help,

Jason.
0 Kudos
Message 5 of 8
(4,717 Views)

Hello Jason,

 

maybe you want to have a look at MGIs 'Write Anything' and 'Read Anything' VIs (http://www.mooregoodideas.com/File/index.html).

They use a variant data type to save data in configuration files.

 

Hope this helps.

Uli

0 Kudos
Message 6 of 8
(4,710 Views)

I built a probe for any type of Variant that parses anything out returns it in a tree structure.

See the LAVA Code Repository for inspiration

 

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!
Message 7 of 8
(4,702 Views)
0 Kudos
Message 8 of 8
(3,628 Views)