LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems saving control values using get all flat

I have a great deal of controls on the front panel of my VI (~ 800). Many of these controls are used to set values for a sequence of events that would like to occur. This sequence changes from situation to situation, so I would like to be able to save the values of these controls to a file in order to recal them for each specific situation. Unfortunately, there are control values on the front panel that I do not want to import from a file. If I use the "Invoke Method : Control Value : Get All Flattened" function to save the control values to a file and then use the "Invoke Method : Control Value : Set Flattened" function, then all of control values are loaded.

In an attempt to to selectively save my control values, I split the output array into two pieces and only saved the upper portion to a file. I used the set tabbing order funtion to order the front panel controls in an atttempt to place all of the controls that I don't want saved below the index value and all that I do want saved above the index value. Unfortunately, the tabbing order does not affect the order in which the "Get All Flattened" collects the control values from the front panel. So, does anyone know what determines the order taht this function collects the front panel values, and more importantly how can I change this order.

Alternatively, if anyone has a way to save this data into a file that can be opened into excel and edited and then resave dinto a form that labview can read the values from, that would be helpful as well. I cannot seem to alter the array that is output by this function so that I can save the data in an easily readable format.

Any other suggestions for alternative solutions would be appreciated as well.


Thanks,


Justin
0 Kudos
Message 1 of 6
(3,403 Views)
Justin,

The configuration files can be used to do what you want.

Create an array with the names (Labels) of the controls with values to be saved. From a reference to the VI get the reference to the panel and then the array of references to controls[]. In a loop match an element in the array of labels with the Label.text property for an element of the controls[] array. When the label match, read or write the value from or to the configuration file using the label as the key.

For this to work each control on the panel must have a unique name. If you want more than one control to display identical text to the user, use the caption.

Lynn
Message 2 of 6
(3,394 Views)
I'll set aside the comment about you having 800 controls on a front panel. Smiley Surprised

As you noted, the tab order does not affect the order in which that method returns the list of controls. This makes complete sense. The order, I'm pretty sure, is established by the creation order. I.e., the order in which you actually created the controls.

You cannot control the "amount" of controls that gets returned by that function so you have to do something similar to what Lynn suggested and filter out the ones you actually want to save. A similar operation would need to be done for the reverse operation.

As for saving the values, this comes up a lot. There's a variety of ways to do this. Ben discussed this in this Community Nugget.
Message 3 of 6
(3,388 Views)
Hi guys,

Thanks for the help so far.

I have 800+ controls on the front panel because I have a process with 40 steps and each step has 20 items that can be controlled (flow rates, valves, sample loops, etc.). Each step can have a unique combination of values, thus the need for all of the controls, the controls are essentially a configuration file  fir the series of events that will occur.  These are the cotrols taht I would like to be able to save and load.

The other controls on the front panel I want to be unaffected by loading a set of saved values. I contemplated using a loop style approach to filter out saved and unsaved values, its just that there are so many controls that it would be very unweildy.

I will check out the thread on saving values and see if there  is anything taht I can use.

What would be helpful in leiu of sorting the order in which values are saved is the ability to save the values to a spreadsheet file so that the unwanted entries can be removed, then the edited file can be loaded into labview.

Any ideas?

Thanks!

Justin
0 Kudos
Message 4 of 6
(3,377 Views)

Hi Justin,

As the primary author on the previously mentioned Nugget, I'd like to step in and offer some advise.

0) 20 X 40 screams an array of clusters. this would be a single control instead of 800. That single change would make the code I provided in the Nugget workable for you.

1) Using the Save-restore function (of the Nugget) without changing the structure of your data (array of clusters) would takes DAYS to implement for 800 controls.

2) Using the flatten-unflatten technique (you have said you are using) wil break when you load old files when anything is added to or removed from your front panel (see Nugget).

3) OpenG has a solution that will work but the files are saved as XML (see Nugget).

4) (Was it Lynn?) the previous suggestion to start with a ref to the FP and find all of the controls is probably your best solution but unfortunately you have to write this functionality yourself. If you are using LV8 or better keep in mind that there are panes on the FP now.


Warning: Shameless plug follows

5) (least desirable) If you are using LV 7.1 or earlier, I could sell you some code (AS-IS) that will save and restore all of the controls to an "ini" file and includes an optional "exclude" file that lets you control which controls and indicators will be skipped durring the save-restore.

I am not recomending you buy it from me!

I would rather you wrote this yourself!

If interested e-mail me at

bar@DSAutomation.com

End of shameless plug.


Just trying to help,

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
(3,370 Views)
Hi Lynne,

I need to do the same thing, but I'm struggling to follow what you are saying. Could you post a more explicit (newbie) version and/or a picture?

Thanks,  Phil
0 Kudos
Message 6 of 6
(3,367 Views)