LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

methods of class contained in an other class

Solved!
Go to solution

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

 

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 1 of 5
(3,282 Views)

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,

 

Thomas B. | CLAD
National Instruments France

Message 2 of 5
(3,210 Views)
Solution
Accepted by tinnitus

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

Message 3 of 5
(3,202 Views)

thank you both,

 

Schubert ,thank for the by ref tip, but what do you mean with "by the error wire alone"

 

 

regards

 

Tinnitus

 

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 4 of 5
(3,172 Views)

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

0 Kudos
Message 5 of 5
(3,169 Views)