LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LVOOP Accessor vs. Property Node

Solved!
Go to solution

@xubuli wrote:

A class usually has private data fields and properties, and methods to operate on data. To access data in the class method, one can unbundle private data from class wire or use property node to access properties. I believe the later one is more expensive, but see it a lot in example code. Any comments?


The property node access is just calling the access methods you used.  This is for VIs outside of the class, or children classes, to access the data.  If inside of the class, you use the Unbundle By Name.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 11 of 18
(1,388 Views)

@xubuli wrote:

A class usually has private data fields and properties, and methods to operate on data. To access data in the class method, one can unbundle private data from class wire or use property node to access properties. I believe the later one is more expensive, but see it a lot in example code. Any comments?


I feel like you're not hearing what we're saying; you do NOT use a property node to get class data, you're using an accessor VI. The property node  just changes the appearance of the VI. It does NOT change what the VI is doing.

 

The ONLY way to get class data is via an unbundle on the class ref. That's it. If you wrap that in a VI, voila, you now have an accessor that can be called externally to the class. If  you put that VI in a Property Definition folder, bam, now you got a property node.

 

I will say it again. You do not use property nodes to access class data. Property nodes are visual representations of VI's, not an accessing methodology. Only unbundle nodes can access class data.

 

As far as speed goes, when you create an accessor via the scripting tool (right click the class -> create VI for data member access), the resulting accessor is automatically configured to be inlined, which is basically the same as having the unbundle node directly on the block diagram.

 

I believe there is a small difference if you give the accessor error handling terminals and leave the case structure in place, but that won't matter unless you're REALLY trimming every microsecond off your execution times. I haven't done any benchmarking but I would wager it's not important until 10's of thousands of property node calls per second. I'd be happy to be proven wrong, of course.

Message 12 of 18
(1,371 Views)

I don't' agree with you about "I will say it again. You do not use property nodes to access class data. Property nodes are visual representations of VI's, not an accessing methodology. Only unbundle nodes can access class data."

 

I see it everywhere in Fabiola's new book (LabVIEW Graphical Programming, 5th edition). If someone knows her ID here, please let me know. 

 

Thank you for your post. I appreciate your time very much.

 

 

 

 

0 Kudos
Message 13 of 18
(1,361 Views)

Agree. That's how I understand. But both ways should work. I am just curious about experts comments. 

0 Kudos
Message 14 of 18
(1,360 Views)

@xubuli wrote:

I see it everywhere in Fabiola's new book (LabVIEW Graphical Programming, 5th edition). If someone knows her ID here, please let me know.


FabiolaDelaCueva 

 


@xubuli wrote:

I don't' agree with you about "I will say it again. You do not use property nodes to access class data. Property nodes are visual representations of VI's, not an accessing methodology. Only unbundle nodes can access class data."

 

I see it everywhere in Fabiola's new book (LabVIEW Graphical Programming, 5th edition).


I haven't gotten a copy of her book yet, but I am willing to bet that the property node is being used outside of the class.  Inside of the class, you use the Unbundle By Name and the Bundle By Name.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 15 of 18
(1,351 Views)

@xubuli wrote:

I don't' agree with you about "I will say it again. You do not use property nodes to access class data. Property nodes are visual representations of VI's, not an accessing methodology. Only unbundle nodes can access class data."

 

I see it everywhere in Fabiola's new book (LabVIEW Graphical Programming, 5th edition). If someone knows her ID here, please let me know. 

 

Thank you for your post. I appreciate your time very much.

 


We're not communicating somehow. I apologize if this comes across as being blunt; I'm just not sure how to describe this in another way but I will try. I think we're colliding on my choice of the word "use".

 

A property node is NOT used to retrieve class private data; it is used to wrap a VI that contains an unbundle node. The property node does return private data, but it does not retrieve the private data.

 

A crappy analogy is a bluetooth headset on a cell phone. You can either make a call on the phone itself or use the bluetooth speaker. The bluetooth speaker isn't what's doing the calling- it's still the cell phone.

 

The bluetooth headset is the property node here, and the VI is the cell phone. Though the sound comes out of the headset, you're not "using" the headset to make the call. I believe you think that you can just plop down a property node to access data- you cannot do this. You must create a Property Definition Folder in your LV Project that contains accessor VI's. Internally to them, they will contain an Unbundle node.

 

Here is an example project that might hopefully illustrate my point:

BertMcMahan_0-1592935647513.png

 

Open the project and follow the instructions in Accessor demo.vi. I think it will be informative for you.

Message 16 of 18
(1,348 Views)

Actually, I got it well. It's not about defend your pride when there are different opinions. You guys are well recognized experts on the forum and are very helpful.

I've used the concept of property in C# for years till I read the example in the book.

 

But there is nothing stopping developers from calling property in a class, in which property is originally defined. If so, what will be the penalty? That's question I was asking. Maybe I did not get to the point at the very beginning.

 

For Fabiola's book source code, please see the official github link below:

https://github.com/LGP5/Resources

 

Example Serial Device Class (Base class) -> Initialize Method

SerialPort.PNG

 

 

 

 

 

 

0 Kudos
Message 17 of 18
(1,297 Views)

@xubuli wrote:

But there is nothing stopping developers from calling property in a class, in which property is originally defined. If so, what will be the penalty? That's question I was asking. Maybe I did not get to the point at the very beginning.


True, there is nothing stopping you.  The penalty will be based on what is done inside of your accessor method that the property node is calling.  First you have the VI call, which is negligible.  After that, it depends on what functions, case structures, etc. you have in your method.

 

I, personally, do not like the property node syntax.  But that is just my opinion.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 18 of 18
(1,291 Views)