04-03-2013 06:53 AM - edited 04-03-2013 06:53 AM
Hello,
When developing applications I want to make it possible for the user to save the current configuration.
The configuration being the values of the control- and the display elements of the frontpanel, aswell as
internal variables.
If the user loads the configuration file all frontpanel elements and internal variables should be updated.
("Nice to have" would be if the configuration files are ASCII based, so they can be edited with an text editor
like notepad. The file would have a legend/header so people can easily see what every value represents.)
The problem I have is programming this in a nice, clean and scalable fashion.
Methods I tried:
- Using "Format Into String" function
This is tedious and dirty. Making local variables off all elements on the frontpanel, reading all data from FGV.
Taking clusters apart to every single value to convert them into strings. Sometimes not knowing how long
arrays will be. And after loading the file making sure every value is wired to the right frontpanel element.
Then a software revision comes up and you need to remove and change some elements.
"Old" configuration files are not compatible with the new revision anymore, users are not happy.
- Using "Flatten To String" function
Still tedious, but this has the possibility of using a loop with case structure. Less clutter on the blockpanel.
Clusters can be saved as a whole. But the configuration files are not editable with an text editor and reading
the text from the file is difficult (sometimes impossible) because you do not always know where each value
starts and stops, especially with clusters and arrays.
I hope you don't think I'm whining
So, how do you guys go about making configuration files for your VI's?
Kudos will be given!
04-03-2013 07:04 AM
There are many examples available online. This is one which is useful for UIs - https://decibel.ni.com/content/docs/DOC-15349
You will note that the comments there also mention OpenG VIs. Those are the variant configuration VIs which allow you to save and load an arbitrary cluster to an ASCII file (and they load correctly if you modify the cluster). MGI also has a set of similar VIs.
04-03-2013 11:36 AM
There was a presentation at a LabVIEW Users Group here in Oregon in February about how XML files may be used for this purpose. Take a look:
https://decibel.ni.com/content/docs/DOC-26776
Jeff