LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can Dynamic Dispatched Connector Change Auto Updated to Child Class?

Solved!
Go to solution

Dear all,

 

I am using Object Oriented programming recently, and have a question regards to the Dynamic Dispatch VI here.

 

I created a Root Class, called Class-1, and created a Dynamic Dispatched VI called Initialize.vi;

I then created a child Class, called Class-2, and I then added an override VI from its parent, Initialize.vi;

Then, I realized that I forgot to add a string input for Class-1>Initialize.vi, and this connector pin is also required for all the child override Vis;

My question is after the Initialize.vi has already been added into child class, if I change its connector pin(s) in the parent class, what should I do to the child override VI? 

 

Should I manually add the forgetten string input to Class-2 as I did to Class-1?

Is there way for the dynamic dispatched VI auto update its change to its all child classes?

 

For example, what if I have 100 child classed inherited from Class-1,  it is not possible to manually change every override child vi.

 

Thank you so much,

 

Jing

0 Kudos
Message 1 of 14
(3,120 Views)

It sounds like you're doing something wrong...

 

Can you explain why each child of the parent needs a different implementation which works without the connector you're mentioning? That sounds kind of weird.

 

You know that the children only need to implement a VI at all if it has a different block diagram than the parent, right?

0 Kudos
Message 2 of 14
(3,106 Views)

Hello Jinghag,

As far as I know, there is no way to automatically update the connector pane of the child classes. 

0 Kudos
Message 3 of 14
(3,098 Views)

Hi 

 

Thank you for your reply, I will use the example from Tom McQuillan as a instance.

 

Project also attached, the situation is:

1. Parent Class is Image Acquisition.lvclass

2. Child Class is Camera-1.lvclass (inherited from Image Acquisition.lvclass), and this has been tested in fully working order.

3. another Child Class is Camera-2. lvclass (inherited from Camera-1).

 

Both Camera-1 and Camera-2 will override the dynamic dispatched vi called Initialize.vi.

 

Because Camera-1.lvclass>Initialize.vi has been tested in fully working order, so that I do not want to copy and paste its codes in its child Camera-2. lvclass>Initialize.vi, so that I just want to leave the Initialize.vi (inherited from Cemera-1.lvclass) as it is (I do NOT need to delete this vi, and then add another identical codes in Camera-2. lvclass>Initialize.vi, because the codes in Camera-1.lvclass>Initialize.vi will also applicable for Camera-2. lvclass>Initialize.vi). 

 

Then, I realized in order to do so, I should have had a input connetor in the parent Initialize.vi, e.g., Camera Com, I then added this Camera Com to parent Initialize.vi, but I then had to manually add the connector to both Camera-1.lvclass>Initialize.vi, and Camera-2. lvclass>Initialize.vi.

 

Is there anything wrong behind the ideas?

 

For example, if I have another camere needs to be used in future, I can call is Camera-3, and make it inherited from Camera-1. 

 

 

Jinghang_0-1661774302456.png

Jinghang_1-1661774750268.png

 

 

0 Kudos
Message 4 of 14
(3,096 Views)

I don't quite get what you're trying to say:

 

If your Parent:Initialise method is working, and you have a child which should use the SAME CODE, then just do NOT implement an "initialise" method for the child. When you wire up the method, it will automatically revert to the parent method (In this case, the child "initialise" is kind of implied). So you don't need to copy anything to Child 2, just do not create the Child2:Initialise at all.

0 Kudos
Message 5 of 14
(3,090 Views)

The OP's question is that he started with a connector pane pattern with some inputs for the parent, then created a bunch of children.

 

Later, there is a new requirement to add another input to the Initialize method, what is the best way to do this across both the parent and the children?

 

Since he is using dynamic dispatch, LV will require both the parent and all children implementation of the method to have the same connector pattern and inputs, but now it is tedious to go to each child and add a new control and wire it to the connector pane. So, now the question becomes, can one just update the parent with the new input and select some option that can propagate his new connector pattern and inputs to all the overridden children methods?

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 6 of 14
(3,075 Views)

Thanks @santo_13 for the explains. 

 

You are correct that, that is my question: "can user just update the parent with the new input and select some option that can propagate the updated new connector pattern and inputs to all the overridden children methods?" and I assume the answer is No? 

 

There is no way to automatically update the child class connector pin if the parent connector pin changed, user will have to manually update all the child classes.

0 Kudos
Message 7 of 14
(3,070 Views)

My counter question is still:

Do all the child classes actually need this input, have they worked fine until now?

0 Kudos
Message 8 of 14
(3,066 Views)

your reply make sense and very inspiring, thanks for your replies!

0 Kudos
Message 9 of 14
(3,063 Views)
Solution
Accepted by Jinghang

Since most initialisation is where connector pane differences occur most, I tend to keep my "init" VIs pretts sparse on the connector pane. I add "pre-init" VIs (basically accessory for the parent), which are able to change between children. Typically, the "init" occurs at the same point of time where you actually know the type of the child, so it still works there. By keeping the connector pane of "Init" minimal, issues like this can be avoided to a large extent.

0 Kudos
Message 10 of 14
(3,052 Views)