LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array of references of different types, performance question

Solved!
Go to solution

Hi All, 

 

See the attached code. I'm using a callback VI and need to pass some references via user parameters. I use an array.

 

The question is, to avoid coercion (should I care?), I type cast to more a generic class, then in the callback function, go to a more specific class. (Is this the best way to do it?)

 

As you can see, though, for some reason almost all the property nodes are reading as variants, forcing me to use Variant To Data, which seems inefficient. Why is this the case? If I type cast to bool, Value should be a bool... why force me to use Variant To Data? 

 

Is there a better way of doing all of this? Thanks for the feedback. 

Download All
0 Kudos
Message 1 of 3
(2,107 Views)

I would just use a cluster.  All of the references can stay their own type that way (instead of converting back and forth).


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 2 of 3
(2,101 Views)
Solution
Accepted by topic author pobrepablo1

if you use a cluster istead of an array you can maintain the strictness of the reference.

 

THe reason you are getting variants is you are not casting the ref back to the same type. Try...

 

In main create a constant from the strict ref wire. Drag that constant into the call back VI and use it when you cast as more specific. You property nodes should adapt to the specific data type they were in main.

 

Note:

You can also create refs of the proper type by dragging the appropriate type of control into the ref control and it will adapt.

 

I hope that made sense.

 

Ben 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 3
(2,098 Views)