LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Initializing & Updating Indicator-Laden Front Panels

Hello! I'm on my 4th re-code of a program (re-doing the code as I learn better methods) and I have two questions. First...here is my setup.
 
IThe front panel of my main VI contains several boolean indicators as well as several text indicators. The program runs 5 looping state machines, each of which updates corresponding boolean and text indicators on the front panel.  I originally passed one reference for each indicator to each of the subvi/state machines and used that to update the front panel. The state machines run continuously and I'm worried that I'm eating up memory (how much I'm not sure) by not closing these individual references. Not to mention my state machines look like porcupines with all the references being passed to the subVIs.
 
So what is the best way for this application? In my search on here I discovered some people were passing an array of references. My question is since my state machines keep running in cycles, I'll never close these array references. Do they use up more memory everytime a reference is used to change a value? What happens when I use a reference to change a value in a few different states of the machine?
 
Lastly the other question I have is what is a good method to set initial values for controls and indicators on the front panels? I have been just using a stacked sequence where the first sequence is all the default values being passes to all the indicator/control via references.  This seems clunky to me. Does anyone really trust "Set as Default Values"?
 
Thanks for the help! I'm also aware that I'm dancing on a line of "these questions have already been answered" but the fact that my state machines never stop unless the entire program stops running has put a bit of a twist of it (at least it is my belief that it did).
 
 
0 Kudos
Message 1 of 2
(2,540 Views)
Arrays of references should reduce the number of connector pane terminals. Another approach is to pass a reference to the main front panel and the extract the Controls[] array of references in the subVIs. This will get references to all controls and indicators on the panel (except those inside clusters and other compound controls), so you need to identify the ones you want to update by some means such as name (label.text property). If you close references when you are done with them and only open new ones when needed, you should be OK. The exact rules for which references are closed automatically and which need to be closed explicitly are complicated. Search for several threads which discuss this.

One method I use is to have a parallel loop for the front panel. It contains an event structure to capture user inputs. These are passed to the state machines via queues. The data from the state machines is returned to the GUI loop via queues or Action Engines. In the timeout case of the event structure the front panel is updated if new data has been received from the state machines. This has the advantage over using references and property nodes that the state machine subVIs do not have to switch to the UI thread and can thus see performance improvements. And no references to close.

Lynn
0 Kudos
Message 2 of 2
(2,522 Views)