LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delegate method calls to members of a class

Solved!
Go to solution

Hello,

 

I'm new to LabView and using version 2013.

I'm familiar with the concepts of object oriented programming.

 

situation/goal

I have a controller that controlls two axes. The communication to said controller happens via raw text messages.

 

I want to control both axis with abstract commands (move, stop, change speed, etc.) from LabView.

Therefore I created an axis class with several parameters. (so far so good)

 

The controller communication is established via an ActiveX reference.

I created a controller class that holds said reference in addition to both axes.

My goal here is to create one controller object, that passes its ActiveX reference to both its axis.

 

In order to add the axes to the controller I dragged the axis class from the project window into the cluster of the controller class twice.

I created accessors to all the members of the axis class, including its ActiveX reference.

 

problem

In the setter method for the ActiveX reference of the controller class, I want to call the setter methods of the ActiveX reference of both axes objects the controller contains.

I can unbundle the controller to see both axes, but I can neither unbundle either one of the axes nor can I can I add a method node to them.

It makes sense that unbundling is not possible in order to ensure encapsulation, but why can't I call a method?

 

Am I even adding references to objects when dragging the axis class?

Or does that add the class itself?

If this adds the class, how do I add a reference to an object of a certain class as a member to another class?

 

I've attached a screenshot of the controller class.

 

Thank you for your help.

0 Kudos
Message 1 of 3
(3,034 Views)
Solution
Accepted by topic author max_

Hi,

The object Oriented Design is rater strong. The encapsulation forbids, as you have said, that the data of your classes are set outside their class.

 

In your case that means, you have You have to create a data member access VI inside the Axes class. You use these access VIs (methods) to set the values for these two objects type axes inside the class controller. Make sure these two classes are at least community.

 

You can reference to a class using Data Value Reference, yes, BUT in these  reference the datatype ie the class is included. At the time this seemed more practical: LabVIEW ObjectOriented Programming: The Decisions Behind the Design http://www.ni.com/white-paper/3574/en/

 

Se an Example here:

Examples for New Data Value Reference with LVOOP  Discussion Forums   https://forums.ni.com/t5/LabVIEW/Examples-for-New-Data-Value-Reference-with-LVOOP/td-p/1317493

 

If you want to use data references strongly, I would recommend the GOOP package, which has different design matters build in like singleton etc. (Which are not possible by default in LabVIEW)

 

0 Kudos
Message 2 of 3
(2,981 Views)

I dropped the idea of having a Controller class operating as a factory.

I now only have an Axis. It's constructor has a in and out for all the things that have to shared between axis objects.

 

Not a good solution, but it works.

0 Kudos
Message 3 of 3
(2,855 Views)