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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the reference or the property node of a member in OOP ?

Solved!
Go to solution

Hi,everyone

Is there any way to get the reference of a member in OOP ?

After creating a class and insert a member control into the cluster, I find that, when right click on it, there is no item of "creat -> reference" or "create -> property node" ?

So,  How to get the reference or the property node of a member in OOP ?

 

0 Kudos
Message 1 of 4
(2,878 Views)

Are you asking about LVOOP?

 

If so take a look at the shipping example for "Singlton" to see how you can work in a manner similar to 'by reference".

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 4
(2,867 Views)
Solution
Accepted by topic author chenyin

Hi

 

There are a few reasons you cant do what you want to do:

1. In regular LVOOP (as opposed to DVRs in LabVIEW 2009, or some other framework / design pattern) LabVIEW Objects are by-value, just like a cluster and therefore you cannot create a reference to a class.

 

2. A object control (ie what you get when you drop an object on a front panel) is a "black box" in that you cannot look inside. This is to support the notion that a class's data is private. This means that you cannot get a reference to any internal controls when its on a front panel

 

3. Control references are only valid for front panel controls, and therefore any class (or other LabVIEW data item) on a wire / shift register / constant / anywhere other than the front panel, will only have the data part of the control available.

 

To gain access to the elements inside a class, you need to create accessor VIs (you can easily create them by right clicking a the class  (or folder within the class) in the Project Browser and choosing New->VI for Data Member Access. This VI would at least have an unbundle / bundle node (depending on whether its read/write) and could, if you want, have much more functionality such as range checking. You would then use this VI whenever you want to read the member your intersted in.

 

I hope this helps,

Shaun

Message 3 of 4
(2,853 Views)

Thanks Ben and shew82.

It's very helpful for me. 

0 Kudos
Message 4 of 4
(2,823 Views)