LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically get the label of a connector

Solved!
Go to solution

Hi,

 

I want to compare the output of a VI to a value read from a file. The file is written in with multiple key-value pairs. I want to programmatically make sure that the key matches the Label of the VI so if my VI has "Channel" and "Status" as outputs, I want to compare the output of "Status" from the VI with the value paired with the "Status" key. Is there a way for me to get the label of a VI's connector as a string so I can do a string compare to make sure the VI's connector label is the same as the key? 

 

Thanks 

 

EDIT: I'm using Labiew 2010.

0 Kudos
Message 1 of 11
(3,140 Views)

I don't think you can do that outside of some VI Scripting stuff that wouldn't work outside of the dev environment.

 

That said- it sounds like you're trying to enforce that your VI is wired right. If that's the case, what you're doing isn't a good idea as it will only fail at run-time, not edit time. I'd suggest using a typedef'd output, then you won't be able to connect it wrong.

0 Kudos
Message 2 of 11
(3,134 Views)

Okay, thanks!

 

My goal is to have one VI that can take in an arbitrary input and then go through an array and choose the correct value.

 

If I have a file with key-value pairs:

Key1, Value1

Key2, Value2

Key3, Value3

...

I would read that into an array in Labview.

Now I want to take a connection from another VI with a label, such as Key2, and then match that label with the key read in from the file so my VI would match "Key2" from the input file with "Key2" from the label of the input and then output "Value2". I thought that would be an easy way for arbitrary VIs with potentially different label names. Perhaps I need to approach this with a different strategy.

0 Kudos
Message 3 of 11
(3,128 Views)

I think you can use the "Name" output of the "Get type information" on the Variant -> Data type parsing palette to do this.

 

It extracts whatever the name of the data on the wire was, which is by default the label output indicator it comes from.

0 Kudos
Message 4 of 11
(3,098 Views)

One method would be to use a typedef'd output and make your multi-use VI polymorphic so it picks the correct version automatically.

0 Kudos
Message 5 of 11
(3,093 Views)

Try this.

"If you weren't supposed to push it, it wouldn't be a button."
Message 6 of 11
(3,092 Views)

@Kyle97330 wrote:

I think you can use the "Name" output of the "Get type information" on the Variant -> Data type parsing palette to do this.

 

It extracts whatever the name of the data on the wire was, which is by default the label output indicator it comes from.


It doesn't look like there are any default attributes. Based on your comment I would of expected "MyNumber" to be available as an attribute named "Name".

variantattributes.PNG

 

 

 

0 Kudos
Message 7 of 11
(3,074 Views)
Solution
Accepted by topic author JosephLi89

None of those are "Get type information".  This is:

 

Get type information to Name.PNG

0 Kudos
Message 8 of 11
(3,065 Views)

Hi

 

If I understand the requirement correctly, you would like to run some VIs dynamically and check if the outputs match your expected values.

 

Could you try as in the attached picture and see if it works?

 

 

Regards
Freelance_LV
TestAutomation Consultant
Message 9 of 11
(3,033 Views)

@Kyle97330 wrote:

None of those are "Get type information".  This is:

 

Get type information to Name.PNG


Yes, Thanks! That's exactly what we're looking for! 

 

Unfortunately, I don't think this VI exists in Labview 2010 which is what we're using. We're going to still check for the key and values but we're going to hardcode the key name in the VI where we would have used the Get Type Information VI 

0 Kudos
Message 10 of 11
(2,972 Views)