02-23-2018 08:40 AM
I have a vi that monitors temperatures graphically using thermistors as sensors. I will be compiling this as an .exe application to use on multiple computers. I want to have a "settings tab" on the front panel that will have a number of numeric controls. The number entered into these numeric controls will be parameters of each thermistor and used to calculate the temperature. I am looking for a way to to save these values as default after they have been entered. The purpose of this is so that if a thermistor is replaced, the application can be configured with new parameters to match the thermistor.
Solved! Go to Solution.
02-23-2018 09:21 AM
I have a roll-my-own set of VIs that store and read from XML. Basically just write a control cluster using the standard LabVIEW Write XML and then at program initialization do a Read from XML.
I'm pretty sure the MGI Library has the functions you want in the Application Control section if you want something pre-packaged.
02-23-2018 09:31 AM - edited 02-23-2018 09:33 AM
You will need to save these values to a file before your program exits and read them back from the file when your program starts.
It does not have to be anything fancy like an XML file, a simple text file will work as you will save and read them back in the same order every time.
02-23-2018 10:09 AM
OpenG also has a function in the Variant Config File menu called Read Panel from INI and Write Panel to INI.
02-23-2018 10:17 AM
Makes sense. What is the best way to have it read a file only one time when the program starts up and then assign the values to the correct spot? I cant think of a way to do it without reading continuously.
02-23-2018 10:41 AM
Does your program have a defined structure, for instance a state machine, where you initialize your app and then transition to the main while loop and wait for some action to occur? Is so, put the read in the initialize state.
Loops are designed to do just that, they loop over and over until you tell them to stop. If you don't want to read from the file continuously, move the read function outside the loop.
What I suspect you are doing in this case is using the Run Continuously button to start your app. This is a big no no. You really should go look at the free resources that are offered by NI to learn Labview.
02-23-2018 10:42 AM - edited 02-23-2018 10:48 AM
Here's a simple example
When my program exits the last thing it does is save the front panel the settings by reading the local variables and saving it to a text file
When my program starts the first thing it does is read the file (If it exists) and write the values to locals restoring the last settings
02-26-2018 02:44 PM
Ok this is good. But is there a way to have a numeric control on the front panel that displays the current value when the application starts without using a numeric indicator? basically I want a numeric control and indicator all in one that will display the current value and when a new value is entered and the app closed, will write values to a file.
02-26-2018 02:53 PM - edited 02-26-2018 03:01 PM
I am not sure I understand your question, but a local variable will read or write to an indicator or control.
02-26-2018 02:54 PM
I recommend that you save your settings file whenever the user changes a parameter.
Only saving the file on program exit works fine if you always have an orderly shutdown of your program.
Does your IT department ever reboot your machines remotely (ie: after updates)?
Do you ever lose power in your building?
I'm sure you can think of other scenarios where your program is just stopped arbitrarily.
Save your settings file on every change, minimize the chance of lost data.