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: 

Possible to add an existing class as a child to another class?

Solved!
Go to solution

Hello,

 

I need to test some code for functionality (a PMBus over I2C functionality on a Sub-20 board). Eventually this will be an instrumentation subclass in the higher program, but I haven't done much of the overall program yet. Is it possible to create my Sub-20 driver class first, and later tie it into the program's instrumentation class?

 

Thanks,

Simon

0 Kudos
Message 1 of 4
(2,577 Views)
Solution
Accepted by topic author SimonGoodson

Theoretically, yes, but if the parent class has any data elements, you obviously won't be able to use them during your development. Also, any VIs that you would create in the parent class that are dynamic dispatch would have to be already implemented in the child class.

 

In other words, you kind of have to already know what the parent class needs to be like. Why not go ahead and create it? At least a stub, with all of the data and VIs that your child classes will use?

Wes Pierce
Principal Engineer
Pierce Controls
0 Kudos
Message 2 of 4
(2,571 Views)

Well, I suppose that I could, but I'm pretty new at this and trying to write a program with a HAL, so there are probably two or three "parent" classes that need to go above the code I want to write now. Since I don't have those very well defined right now, if I create them I will have to refactor that code anyway.

 

Thanks for the answer though!

 

Simon

0 Kudos
Message 3 of 4
(2,563 Views)

This is where UML comes in handy.  Define what your class hierarchy will will look like.  Define what functions you will need to override.  Define what functions will be common to everything and put those in the parent.  A good UML diagram is pretty much essencial to a good HAL.  You cannot go into it blindly.  You need very detailed plan of attack before you even start to code.


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