LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Polymorphic Object??

I have implemented some classes where the children can expose themselves using a configuration screen as shown below.

 

Figure_5_Complex_Surface_Mapping.PNG 

 

Since new shape may be required in the future I implemented my classes such that they have methods to;

 

Insert in sub-panel

Apply setting

Save

 

Anything that does not fall into the methods I have in parents can only be accessed through the config panel.

 

I'll post the NI Week paper if NI balks at it.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 31 of 45
(707 Views)

 

(ignore the error wires...just copied and old image.)

I might have missed it during this thread...but, how do I load the parent object (used above as the specific termainal on the To Specific above) knowing only the name of it's file on disk?

 

For example, I'd like it to be specified externally, not baked in the code.

 

 

0 Kudos
Message 32 of 45
(689 Views)

@MacDroid wrote:

 

(ignore the error wires...just copied and old image.)

I might have missed it during this thread...but, how do I load the parent object (used above as the specific termainal on the To Specific above) knowing only the name of it's file on disk?

 

For example, I'd like it to be specified externally, not baked in the code.


It's not possible to dynamically change the constant class wired to the To More Specific node.  I think your best bet is to create one of these load class VIs for each of your parent classes.  

 

Again though, your code isn't going to be able to predict the future and your code will have to be edited as you add more parent classes.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 33 of 45
(686 Views)

So, bottom line: you have to bake at least the parent into the code?

0 Kudos
Message 34 of 45
(681 Views)

@MacDroid wrote:

So, bottom line: you have to bake at least the parent into the code?


As far as I know.  There may be some more sophisticated methods or hacks I'm not aware of.

 

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 35 of 45
(679 Views)

@MacDroid wrote:

So, bottom line: you have to bake at least the parent into the code?


 

Only if you want it do something useful. Smiley Tongue

 

The generic LV Class from which all other descend has no methods.

 

I have some plug-ins that only have Create, Run Close so my home baked version of the Actor Frame work just has those methods. What happens inside is determined by the falvor I selected.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 36 of 45
(675 Views)

Ok, so the parent class TOP has methods X, Y, Z.

 

Child A has X, Y, Z

 

Child B has X, Y, Z, W

 

A & B are loaded into an array and X, Y, Z can be accessed with To Specific with the target input wired to a TOP object.

 

How do I access W? Like so:

 

 

 

0 Kudos
Message 37 of 45
(665 Views)

@MacDroid wrote:

Ok, so the parent class TOP has methods X, Y, Z.

 

Child A has X, Y, Z

 

Child B has X, Y, Z, W

 

A & B are loaded into an array and X, Y, Z can be accessed with To Specific with the target input wired to a TOP object.

 

How do I access W? Like so:

 

 

 


 

You would have to invoke W from with X, Y, or Z.

 

Other wise you will need a wire of type B to invoke W.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 38 of 45
(662 Views)

So in the image, I can call (blue 1) from within (yellow1)?

0 Kudos
Message 39 of 45
(659 Views)

@MacDroid wrote:

So in the image, I can call (blue 1) from within (yellow1)?


 

I don't know what your color scheme is so I will ignore that part.

 

You have the parent TOP.

 

In your code you invoke X then Y then Z using the methods from TOP.

 

If you code B's version of X such that it calls X from TOP then (still inside of B's X) invokes W when the type flowing on the wire is of type B, then the over-ride VI of B will be invoked.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 40 of 45
(655 Views)