LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Looking to simplify SubVI so that it's reusable.. Is this possible?

Solved!
Go to solution

I'm looking at the possibility of making a VI more generic so that I can reuse it for multiple applications. The VI is used to write to a Config File (.ini) the settings of an instrument. The subVI's are from VIPM under the OpenG Variant Configuration FIle Library. The VIs take in a clustor of clustors, and turns their settings into a configuration file. I'm wanting to make it more generic for reuse so that I can use any instruments clustor of clustors for settings (each insturment will be different) between projects.

 

Is it possible to pass A clustor refnum and within the subVI re-create the clustor to pass it to this VI?  Or should I just shut up and create a new VI for each project instead of trying to make something that is reusable between insturment projects?

 

Write Cfg.png

 

 

 

 

 

Download All
0 Kudos
Message 1 of 3
(2,593 Views)
Solution
Accepted by topic author rkmadse

If you think about it, this very easy. Write INI Cluster itself is of course able to take any cluster as input. That is why the input is not actually a cluster, but a variant. (notice the red dot)

Change the "Settings ini" control to variant instead of cluster and your vi will be more reusable.

Message 2 of 3
(2,581 Views)

The one "gotcha" to implementing perhult's suggestion (which is really the "right" answer) is that you cannot "pass through" the Cluster to such a general VI (as you have done in yours), except as a Variant (you might be able to reconstruct it using LabVIEW Scripting, but that's quite a bit of work, won't work in an executable, and really is not necessary -- simply have the Variant input "swallow" the cluster and use it.  Note that you might want to use some of the OpenG Variant functions to be sure that what is being passed in to the Cluster is, indeed, a Variant.

 

Which brings up the following point -- this might be one of those VIs that you might want to consider not "generalizing".  I applaud the fact that the Cluster you brought in that will become your Configuration is stored in a TypeDef.  Each Instrument will, of course, have its own Cluster and its own TypeDef, and it might not be a "bad thing" to have a separate VI for each Instrument's Configuration File.

 

If you really want to generalize, probably the way to do it is with Objects, but that's a topic for another time ...

 

Bob Schor

Message 3 of 3
(2,576 Views)