07-22-2015 02:53 PM
Are you tired of recreating the configuration dialog for every application? This user group presentation shows how to automate that process
I gave the settings dialog the same look-and feel as LabVIEW's own Options (Tools>Options) dialog.
Figure 1: The Edit Settings Dialog
Figure 2: Simplified Application architecture. Each code module supplies its own simple settings user interface VI.
If your application use plug-in modules loaded dynamically at run time, they can supply their own configuration settings (settings.vi) to the dialog. We implement our code modules as LabVIEW classes. Each class includes a very simple "settings.vi". See the figure below. As you can see, the settings.vi is extremely simple.
Figure 3: The settings.vi
When embed the VI in the dialog's sub-panel, we run the VI once with init set TRUE to populate the controls.
When the user is done updating the settings we run the VI again with init set false – it now writes the updated values to the object and passes the object out.
This simple approach works fine as long as there are no need for a programmatic interaction between controls in the settings.vi – it does not work well if a selection in one control is used to update the content in another. But, this simple approach covers the vast majority of our applications, we therefore chose to keep it this simple – we can always add more complexity if needed.
All we need to do is to pass in an array of objects. The Settings Handler VIs locates the settings VIs for all classes, the class names (e.g.: "Data Logging", "Data Acquisition") becomes the name of the categories listed. When you click a category the corresponding settings.vi from the class is embedded in the sub-panel.
Figure 4. Inserting settings VIs into the dialog.
Let's look at the diagram for the demo code:
Figure 5. Screenshot of demo code.
To insert settings.vis from your classes, simply pass in an array of objects. The supplied Settings Handler VIs (yellow banner) handles the rest. Each class must include their own "settings.vi". The Settings Handler VIs assume that your code modules are designed as LabVIEW classes, that each class includes its own "settings.vi", and that your application only need to edit settings for one instance of each code module. Configuration files are XML - one file per object. It will be fairly easy to modify the design to handle more than one instance of an object.
I hope you find this useful. Suggestions to improvements are welcome.
- Tore Johnsen, Saint Bernard Engineering, Inc.
There are more details in the presentation (check out the presentation notes too). The download contains presentation and code. LabVIEW version: 2014.
08-05-2015 09:40 AM
In case anyone else is interested in downgrading this to LV2012, I created a VI to replace the Get LV Class Name.vi (which was new in LV2013)