12-21-2010 08:04 AM
Hello,
i would like to know is there is another way than what i do with classes embeded in another:
ex i have a device classe that containe a class Com (rs232 ...)
what i do whan i want to setup a com of a device is get com objet of device then appliing change on COM with com methodes
is there a way to apply com methode directly to Device ? i thought about putting get instr method in Com class so unbundle is done directly
but i don't think this is a good thing ...
Is there something to do with friend class or community ?
see attached .jpg
Regards
Tinnitus
Solved! Go to Solution.
01-10-2011 04:38 AM
Hi Tinnitus,
I think you are talking about "inheritance".
Inheritance means that you have a "parent" class and a "child" class.
The "child" is a special type of "parent". Such as a "dog" is a special type of "animal".
The child class has access to all the methods and properties of the parent class.
And the child class can have additionnal methods/properties that the more generic class doesnt have.
It is also possible to overide the methods in the child class to customize them.
For more information about this concept:
LabVIEW Object-Oriented Programming: The
Decisions Behind the Design
http://zone.ni.com/devzone/cda/tut/p/id/3574
In the LabVIEW project explorer, you can go to the properties of a class, and define this class as the child of another class (modify inheritance).
Then, when you instantiate the child class, the object can access the methods/properties of it's parent class.
However, if you instantiate the parent class, the object won't be able to access the methods that are specific to the child class.
The parent class is more generic than the child class.
Hope this will help.
Best regards,
01-10-2011 04:53 AM
From the picture I guess you are talking about associations and composition design pattern.
You can just implement Accessor VIs in the Instr.class to Get/Set the Com.class. Using a by-val design, you would get the Com.class, call whatever methods on the Com.class and then put it back with the Setter: Inst.class.SetCom(Com).
Using a by-ref design, you don't need the Setter and can make the Com property of Instr.class read-only. But then you need to do the sequencing (program flow) by the error wire alone.
Felix
01-13-2011 08:31 AM
thank you both,
Schubert ,thank for the by ref tip, but what do you mean with "by the error wire alone"
regards
Tinnitus
01-13-2011 09:41 AM
After you are done with all methods on the contained by-ref class, the object wire isn't wired anywhere, while the error wire goes back to the methods of the container class, otherwise they might operate at the contained class as well and you have a race condition.
Felix