LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parent Child Inheritance

Ive read a few forums and googled around with what seems to be an answer, but with newer versions of LabVIEW out since their posrtings I figure I would ask. I have a Parent class called Measure with private data being an AI Channel, AI Task, AO Channel and AO Task. I have created 4 more classes that inherit from Measure and no private data of their own. Is there currently a way where I can set values in Measure using a write accessor, and when I go to use the values in the child classes methods, have them be initialized with the same value as the ones in Measure? Thanks.

 

 

Brad

0 Kudos
Message 1 of 2
(1,912 Views)

If your parent class provides accessor methods to the private data your child classes will be able to set/get them. The child classes cannot access the private data directly.

 

LabVIEW classes are by-value and by default if you branch the wire each branch gets its own copy of the data. If the value is changed on one branch of the wire the other branch will not see the change. However, there are a few ways you can create establish data which is shared among all branches. The two most basic are to use a single element queue or a data value reference. Your accessor methods will access either the SEQ or DVR and update/get the data.

 

If you want the data to be shared among multiple instances of the class you will need to put some logic in to initialize the data on the first call/instantiation of the class and then use that reference for all subsequent instances.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 2
(1,910 Views)