取消
显示结果 
搜索替代 
您的意思是: 

Need a generic control reference

Hi All,

 

Please see attached.

 

I'm trying to simplify a VI here that has a bunch of controls and wires by making lookup dictionaries for a specific data type. Example: Create a variant lookup table from an array of string references and their names, call it "system info".

 

The problem is that I can only group references of a particular type together for a lookup table - I end up making a polymorphic "ref array to dictionary" VI and this isn't flexible.

 

Is it possible to have a more generic VI that doesnt care what type of references I'm taking in?

 

Oh, P.S. I hate clusters.

 

 

 

0 项奖励
1 条消息(共 11 条)
5,302 次查看

You can use the "to more generic".

 

ToMoreGeneric.png

0 项奖励
2 条消息(共 11 条)
5,288 次查看

Hey! Thanks a lot for the input.

 

After going down the path you sent me down, I believe I may have found an even easier way.

 

By right clicking on my ref in, apparently (havent ever played with this) I can select VI server class and just make it a generic control. Then I can wire anything I please right in to this subvi and my "ref array to dictionary" is no longer polymorphic!

 

WOOHOO

 

Thanks brah.

0 项奖励
3 条消息(共 11 条)
5,269 次查看

Glad you got it working.  Mark it as accepted solution.

 

Michel

0 项奖励
4 条消息(共 11 条)
5,264 次查看

 

In the example shown, the 'To More Generic Class' function is completely unnecessary.  The references will be coerced to a common class at the input of 'Build Array'

"If you weren't supposed to push it, it wouldn't be a button."
0 项奖励
5 条消息(共 11 条)
5,244 次查看
Well yes and no. They will be coerced to a common type, which in this case is a control reference. However, the readability stinks as it is easy to miss those little dots. Better to do the explicit cast so there is no question what the result is.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 项奖励
6 条消息(共 11 条)
5,203 次查看

 

I disagree.  I my opinion, the code is more readable without the 'To More Generic Class' functions.  Even if you don't notice those coercion dots, there's nothing confusing about it.

There are cases where a latent bug may be caused by undesirable coercion, but this isn't one of them.

 

"If you weren't supposed to push it, it wouldn't be a button."
0 项奖励
7 条消息(共 11 条)
5,177 次查看

Here's a forum discussion link to coercion dot, so anyone can make their mind and you may add your though there.

 

http://forums.ni.com/t5/LabVIEW/Dealing-with-Coercion-Dots/m-p/926925/highlight/true#M416411

 

The simple example was to show that classes exist in LabVIEW, simple as that.

 

Michel

0 项奖励
8 条消息(共 11 条)
5,171 次查看
The big point to be made here is that going to a lot of trouble just to avoid using clusters because you "hate" them (an absurd proposition on its face) is a hack. Putting them into an array is misusing the array datatype. A array holds a collection of the same thing, like a collection of voltage readings or a collection of identifier strings. What you are doing is forcing into an array a collection of fundamentally different things.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 项奖励
9 条消息(共 11 条)
5,125 次查看

Not really. References are not "different things".

I get to decide what is the "same" (bundling is also putting different things together). The inability to programmatically cluster things is a huge disadvantage to clusters in addition to their slow lookup speed.

0 项奖励
10 条消息(共 11 条)
5,097 次查看