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.
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.
10-22-2019 02:17 AM
Hello everyone,
I have two classes "Datahandler.lvclass" and "Input.lvclass" and I am trying to understand the inheritance of the methods and variables.
I can access data of the Parent class and add it to the 'Child' using the methods of the 'Parent' (syncdata.png)
Is there a way to add all the data (and references) from the 'Parent' (merge classes, sync)? I have some notifiers in the 'Parent' and I would like to activate them in the child (since they have the same data but not the correct references)
Also some methods from the 'Parent' are not allowed to pass the datalines from the 'Child' (datatransfer_broken.png).
Is there a special classification to pass them to the child? The method from the picture above seems to have no problem passing the datalines and are created using the same template (create using dynamic dispatch vi
Solved! Go to Solution.
10-22-2019 02:33 AM
I'm not exactly sure what you're asking for so I'll describe some aspects of inheritance, hopefully it will help or at least lead you to describe what you want that I missed.
Does this help at all?
10-22-2019 02:55 AM
That helped a lot.
Now my only problem is the initial synchronization. I write some data in the 'Parent' (defined in Parent.ctl). Is there a way to get whole Cluster and not all the indiviudal elements.
When I unbundle the Parentdataline (in a dynamic dispatch method) I only get the individual elements and not the Cluster with all elements. I would like to transfer all the Parent data to the Child and not make individual lines for every entry
10-22-2019 03:00 AM
@s.h._tech wrote:
When I unbundle the Parentdataline (in a dynamic dispatch method) I only get the individual elements and not the Cluster with all elements. I would like to transfer all the Parent data to the Child and not make individual lines for every entry
Then don't unbundle it. 😜
You can make accessor on cluster level or even make custom ones.
/Y
10-22-2019 03:01 AM - edited 10-22-2019 03:06 AM
You could create a typedef containing a cluster that contains all of the elements, and then either directly place that cluster inside the class data of the parent (adding an extra unbundle all the time) or alternatively add a static dispatch method that unbundles the elements individually, then bundles them into this typedef'd cluster, and returns that.
The second option (not necessarily better):
10-22-2019 03:13 AM
That means I have to add every value from the Parent manually to the child?
10-22-2019 03:21 AM
@s.h._tech wrote:
That means I have to add every value from the Parent manually to the child?
Hmm, no. Probably not, anyway. What do you want to do with the values, once you have them in the child?
You initially mentioned notifiers, so there are possibly alternatives (like using a parent VI that can be called by the child, and passing appropriate data or state from child to parent).
10-22-2019 04:34 AM
@s.h._tech wrote:
That means I have to add every value from the Parent manually to the child?
What? no.
Every Child is also a parent. If you add everything from the parent to the child you now have it twice. Once in the parent and once in the child.
Think of it in terms of clusters. You have a cluster which contains data. This is your parent. Now you make a child. The cluster for the child contains also data (different to the parent) but also a data field which represents the parent. The trick is that you don't have DIRECT access to this data field as a child, but your Parent implements accessory to grant you access. If you need tha data from the parent, use parent accessors. Don't double-up your data fields.
10-22-2019 04:58 AM
They are just there for initialization.
I think I figured it out:
10-22-2019 05:09 AM
@s.h._tech wrote:
They are just there for initialization.
I think I figured it out:
- Initial values are copied manually from parent to child
- All parentmethods that do not allow the childclass wire are newly generated (dynamic dispatch vi again) and for some reason they now allow the childwire (maybe a bug, or because it was generated before the subclass methods)
It doesn't really sound like you're figured it out to be honest.
If you have initialisation for a parent which is only setting internal values then use the parent method for the child.
If your child needs a different initialisation, make a separate method for the child. Then call one after the other.
Can you post some example code of what you're trying to do?