From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array of clusters change one element in multiple loops

Solved!
Go to solution

Hello, sorry for my bad english.

 

I have an array of clusters, the clusters has others arrays and controls.

Imagen1.png

 I want to access to each control individually  in the array, in multiple loops to avoid data loosing. i know i can make a reference for each control in the cluster and change his values, but it changes the values in the array too.

Imagen2.png

Or i can access to the cluster i want in the array, but i cant access each control individually.

Imagen3.png

If i do something like this im going to loose data.

Imagen4.png

So what i can do?. what is the most efficient way to do it?

 

Thanks in advance.

0 Kudos
Message 1 of 8
(4,848 Views)
Solution
Accepted by Cordova_Mr

Sounds like what you really need is a Data Value Reference on the array.  Then you use the In Place Element Structure to access the array, index the element you want, then unbundle by name to get the actual control you want.  Do the reverse to clean it up and save the data.


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 8
(4,842 Views)

Hi Cordova,

 

encapsulate access to your data: use a FGV or OOP.

 

If i do something like this im going to loose data.

Yes, due to race conditions because of local variable overuse…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 8
(4,837 Views)

Thank you for the fast reply, im going to check those option and i will come back later to tell you how it works.

 

Thanks again

0 Kudos
Message 4 of 8
(4,827 Views)

Hi GerdW, im not very familiar to FGV or OOP,
I was reading about FGV, but in my case i dont think is a solution because i want one of my loops run as fastest it can, it will be handling comunications
and i dont want it be slowed with FGV. so i think i need an reentrant control. Well that is if i understand right FGV.
With OOP could be an option, what i understand, i have to change my control to "typedef" and im going to be able to use it in subvi like an a global variable,
but how i can avoid race conditions if im not able to change every control in my array individually?

 

Hi crossrulz, i investigated in place etructures and data value reference, i did some test with this

 Imagen5.png


it seems to work, the only thing is that the control is not updated in front panel, but for my aplication i dont need that, im going to start
testing this option, it seems very good and efficient

 

Again im not familiar with this, if im wrong in something please correct me.

Thank you

0 Kudos
Message 5 of 8
(4,816 Views)

If you want data updated in a front panel, you need to put an indicator in there to show the data.

 

Functional Global Variables aren't going to slow down your code if you use them properly.  (And they certainly can't be reentrant.)  A functional global variable is going to execute quickly and return.  When dealing with multiple items in a cluster, your command enum might constant of actions like Set Number, Set String, Set boolean,  Set Number 2.  And of course Get to just return the existing data.  Inside you grab the data from the shift register, execute a case structure that just updates the one particular element of the cluster based on what command was sent in.  Then update the shift register and send out the current value of the cluster.   The read, set value, update, return data is all encapsulated in a single non-reentrant VI which will return quickly and not keep any faster loops from executing even if that particular instance of the FGV is in a slow running loop.

 

Look at Ben's Action Engine Nugget

Message 6 of 8
(4,811 Views)

what option you recomend? in Place structure or FGV, what is the most efficient way?

 

Thank you

0 Kudos
Message 7 of 8
(4,791 Views)

@Cordova_Mr wrote:

what option you recomend? in Place structure or FGV, what is the most efficient way?


That depends on what you have in your cluster.  If you have a lot of different "actions" with many different inputs, I would go with the DVR (Data Value Reference).  If the number of actual inputs and actions are small, I would go with the Action Engine.


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 8 of 8
(4,785 Views)