LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I update cluster items from inside a while loop that does not contain the cluster?

I have a VI that contains front panel clusters and two while loops. The main cluster contains items such as a doubles "distance" and "stepsize" and boolean "step" (a whole buch of this type stuff). The first loop contains an event structure to detect front panel changes and the second contains code and sub VIs to perform operations based on detected events.

 

The operator can enter data into either double or click the boolean. If distance is changed the second loop does what is required to process the change. The same happens with stepsize. If step is clicked the ±stepsize value is added to distance and the result is processed. In each case the front panel should track the result of the input and subsequent processing.

 

Because the clusters are outside the while loop, they are not updated unless I click 'highlight execution' which seems to allow updating each time the execution highlight is updated. There are other issues if I move the clusters into one of the loops.

 

I've tried referencing the clusters and using local variables and nothing works. It looks like overkill to use shared variables for this.

 

Any ideas would be greatly appreciated.

 

Thanks,

 

Frank    

0 Kudos
Message 1 of 6
(4,366 Views)

The solution is simple once you see it.

 

move the cluster into a sub-VI that acts on the cluster in your behalf.

 

Its Called an Action Engine and you can read about in this thread.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 6
(4,364 Views)

Hi Ben,

 

Thank you for the response. I followed the link and tried reading everything you posted on AEs but I'm afraid that I didn't understand it all. It seems that each AE example had a single input and a single output (e.g. a double). Is this the case? 

 

What I have is a couple of front panel clusters containing (approximately) 18 control doubles, 8 indicator doubles, 5 boolean radio button constructs and 26 boolean control discretes. I clusterized it to make it readable. In addition I'll eventually have a cluster of task references for hardware handles.

 

All I want to do is update the front panel values like I would do in a C, VB or any other language. I've tried referencing the cluster and using the reference from inside the loops. I've tied using local variables. Neither works. I'm experimenting with globals but it seems that I have to construct the front panel in the gloabal and then I wouldn't know how to repoduce that on the front panel of the main VI.  Sometimes it seems that more time is spent getting around Labview constructs than benefitting from them.

 

I hope the 'Add Attachment' function actuals puts a copy of the VI here and not a link to it.

 

Thanks again for the suggestion,

 

Frank 

 

 

0 Kudos
Message 3 of 6
(4,337 Views)

You have a race condition. In the bottom loop the node that reads the cluster value gets executed first and then the loop sits and waits at the Dequeue Element function. If you change the value on the front panel you'll get the event, but the bottom loop is going to use the value it read previously. You need to make sure you read the cluster value after you dequeue your event so you get the new values. You can accomplish this by simply wiring the error out from the Dequeue Element into the node that reads the cluster value.

 

 

I would also suggest that you sub-clusterize your cluster. It will make it easier to select elements, and each "band" is a natural sub-cluster. You should also consider making it a typedef.

0 Kudos
Message 4 of 6
(4,320 Views)

Agree on the type def suggestion ( see nugget here ).

 

I do really love that new option in our image gallery to find the thread where we posted images.

 

In this thread I outlined my approach to using a GUI controller that allows acess to FP objects from sub-VIs and as a bonus we get easier to read code and more modular implementations.

 

And here again I show the same technique in action.

 

Next to posting my code, letting you "look over my sholder" is the best ican do for now.

 

I hope that helps,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 6
(4,303 Views)

Thanks smercurio_fc,

 

As you said - it was a race condition. Seems to work OK now with the error cluster wired.

 

As for sub-clusters, I looked at that and decided against it because of the extra level of unbundling.

 

I make everything a typedef or strict typedef. This hadn't been done yet because I was just playing to get something that worked.

 

Thanks again for the help.

 

Frank   

 

 

0 Kudos
Message 6 of 6
(4,299 Views)