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: 

Use Non Class VIs within Class

Solved!
Go to solution

I suppose this is a theory of OOP question.

 

Say I have 2 classes, 1 is used to set the voltage on a power supply, and another is used to update a user interface.  They are not really related at all in that there is no common parent class and there is essentially no relationship between them.

 

Now, I write a subVI that is some sort of specialized random number generator.  What if I want to use that VI within a method of each of the two classes I created above.  Where does this subVI belong?

 

I can think of the following options, but I'm not sure what the best one is.  I would really love to hear your suggestions because it's been bugging me for a while:

 

1) Create a method within each class that has the random number generator functionality.  I don't like this idea because I will be duplicating code.

2) Simply choose to store the VI as part of my project and not include it within the classes.  What I don't like about this is that if I decide to reuse my code/class in another project, I will need to copy VIs that are not part of my class with it.

3) Create some sort of "utilities" class that would hold all of these miscellaneous VIs and then use methods from this class.  I could pass an object of this utilities class into each class so I would have access to the methods.  But this seems to be pretty complicated.

 

So that's the dilemma.  I'm wondering how all of you have chosen to solve this problem.  Thanks!

0 Kudos
Message 1 of 2
(2,407 Views)
Solution
Accepted by topic author Gerry_Ford

Create a reuse library.  I recommend looking at VI Package Manager.  You can create "packages" of reuse code and "install" them into each version of LabVIEW.  Then anybody can use them since they are in one nice location.


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 2 of 2
(2,390 Views)