LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extract label from a cluster in a global variable

Solved!
Go to solution

Hi guys !

 

In my application I was using in my subVI a cluster of booleans for the different types of errors I could have.

It wasn't really convenient to manage all these clusters so I decided to create a global one.

 

Now the problem is that I'm not able anymore to extract the labels and values of this cluster. Before I was passing as a reference theses values but I think there is no way to create a reference directly from my global variable (cluster).

So as you can see in this printscreen I created a new array indicator in my VI. But if I am adding a new boolean value in my global cluster I need to create again the cluster and it is not really convenient. 

 

The goal is to list the errors in a string only if the value is true.

 

I don't know if I am clear, if not I can explain more. 

 

Global_cluster.JPG 

 

Download All
0 Kudos
Message 1 of 11
(5,113 Views)

Make your control a typedef and save it.  Then drop the typedef into your global variable.  If your indicator is also made from that typedef, then all you need to do is update the typedef contro and both the global and the indicator should update automatically.  I never use global variables, however, so you'll need to verify this.

Message 2 of 11
(5,097 Views)

Hello,

Thanks for your reply, but I'm not sure I undestand it right...

 

I created a Error.ctl but I cannot drop it to the ErrorList.vi (which is my global variable)...

Can you tell me more.

 

Or is it another way (trick) to do what I want ?

 

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

Hi remvu,

 

you can right-click the control and select "Replace"...

 

One way to access the global variable should be to open a reference to the owning vi and get all controls via the front panel reference (never tried for a global, but should work too). But anyway: use FGVs instead...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 11
(5,060 Views)

I'm sorry but I didn't succeeded to program neither of them...

 

What control should I transform to typedef and where should I store it ?

I'm completely lost... 

 

Maybe I will be better with a little screenshot or a exemple VI...

Thanks again 

0 Kudos
Message 5 of 11
(5,052 Views)

Hi remvu,

 

read the article "Creating Custom Controls, Indicators, and Type Definitions" in the LabView help...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 11
(5,041 Views)

I am not sure if this works (I never did something the like with globals), but you can give it a try: 

Use the VI Server to open a reference to your global. Use the FP.Controls[] property and index the error cluster control (so 0 if it is the only control). Wire this reference to your property node.

 

Felix 

Message 7 of 11
(5,037 Views)

I tried this way :

cluster_ctrl.JPG 

 

But as you can see when I wire the "Clust (strict)" to my reference (which is the control in my global variable), I don't know why but I could have access to this class...I did something wrong ?

Because the reference is for sure the cluster.

 

 

Oh my god, I think I would give up to find an automatic way, I can still delete and create again my control each time I do a modification to my global...Because I already lost so much time.

It just sound weird for me to have so much difficulty with LV just to extract the names and values of my booleans in my global variable 

 

0 Kudos
Message 8 of 11
(5,021 Views)
Solution
Accepted by topic author remvu

Hi remvu,

 

have you tried to insert a "to more specific class" before the ctl-property node?

 

As you still want to know the names of the booleans you should really give a shot at typedefinitions...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 11
(5,018 Views)

My Nugget on Expoiting Control References should give you all of the hints you need to accomplish what you are trying.

 

The code included demonstrates how to navigate into a un-known data structure starting with only a reference.

 

please note that I encouraged using a Type Definition in that Nugget as many of the prvious posters have suggested. I wrote about the power of Type definitions in this Nugget.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 11
(5,010 Views)