LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i implement inheritance or interfaces in LabVIEW?

Solved!
Go to solution

Hi all,

 

I'm trying to implement OOP into my LabVIEW code and have a need for either inheritance or just an interface (as one might need in java).  I do have a good understanding of OOP its just how i get it done in LabVIEW that I'm curious.

 

I'll try to stick with my own example for the time being so that someone might be able to tell me how exactly to implement this.

 

anyways, i have two different DMMs and each come with their own GPIB commands to get the measurements and set the measurement configurations.  This seems like a perfect example for learning how to use inheritance.  I have figured out how to make a class for each DMM but was curious how i might be able to create a parent class for both of them since they both need the same fields in their configuration (AC/DC, Measurment Type, Range, VISA address).  I would think i could create a parent class with these fields and then methods for using these fields and then have the child classes inherit the fields and override the methods of the parent classes so that depending on what DMM the user selected it would be able to use the correct class to issue the right GPIB commands.

 

If anyone can point me to a great example or explain how this might be implemented into labview that would be super.  I'm also perusing the LVOOP forums at LavaG trying to figure this out, thanks!

 

Brent 

Message 1 of 5
(3,822 Views)

Hey Brent,

 

Could you post what you have so far?

 

Thanks.

 

 

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 2 of 5
(3,796 Views)

Hi Matt,

 

I have the class for the Agilent 34405A zipped and will attach it.  I would similarly implement the same .ctl and methods with different GPIB commands for an HP3478A DMM as well.  I'm sure you understand that I'm trying to create a parent class so that each of these would inherit the control from the parent but with a different "read measurement.vi" for the GPIB commands.

0 Kudos
Message 3 of 5
(3,791 Views)
Solution
Accepted by topic author BrentSchenk

Brent,

 

The LabVIEW Help contains a lot of detailed information about how to work with classes.  I recommend reading through it before you get started with OOP in LabVIEW.  In the Contents tab of the Help window, browse to "Fundamentals >> LabVIEW Object-Oriented Programming >> How-To".  There is an article titled "Changing the Inheritance of a LabVIEW Class" that should be what you're looking for.

 

Chris M 

Message 4 of 5
(3,773 Views)

yessir, sometimes all it takes is going to the help file which i do forget to do quite often.  My usual steps for figuring out problems are to search the NI website for any articles on the issue, search the forums, and if that doesnt take care of it then i goto google, before posting here.  For some reason i totally skip the included help file which did answer all my questions.  I have inheritance working now, although i found it very confusing that when you create a VI for override it puts the call parent method vi in there by default, which made me think i needed it in there when it was quite the opposite.  anyways, for others who might run into this problem i will attach the project i just created along with one parent class with 2 child classes that demonstrates how the environment will automatically call the correct overriding VI (take measurement in this case) depending on which class is selected on the front panel.

 

disclaimer: you will need to get rid of all VISA calls (diagram disable?) to make sure this runs on your system, it was mostly done so that i could see it for myself.  Depending on which class it calls it outputs a 5 or a 10.  hopefully this helps someone else in the future

Message 5 of 5
(3,767 Views)