Adaptive Save Restore
Adaptive Save Restore
A Case Study of Exploiting Control References to Reduce Development Time By Ben Rayner, Data Science Automation And Ray Robichaud, Drawbridge Technologies, Inc. A frequently requested operation in applications is the ability to save and restore configurations when an application is shutdown and later restarted. If you are working in the LabVIEW development environment, this can easily be accomplished using the "Edit >>> Make Current Values Default" operation, see Figure 1.
Figure 1: Useful to save defaults in simple programs.
While this operation is useful, it is limited in a number of ways. This functionality does not allow various sets or "versions" to be saved. When the current values are set as default, the previous default settings are lost. Attempts to perform this same operation fail if the VI is running (see Figure 2) furthermore, it is not available in any form if the VI is intended for deployment as an executable. Because the default values are saved with the VI itself so this would require rebuilding of the application with the newly revised default values
Figure 2: Can not save defaults at run time.
The generally suggested solution to these restrictions has been to use or develop code that saves the control and system information to file such that it can be restored at a later time. If the file storing the data does not have to be in an easily readable format, then the OpenG solutions are worth considering.
If the information has to be saved in an easily human readable form, then consider the code from Moore Good Ideas.
Both of these approaches use variant data to one extent or another. While the use of variants is acceptable, we must carefully observe that the format of the variant data is within the National Instruments domain and they can (and will) change its format or representation in future releases of the development platform. In this Nugget we attempt to present a novel approach that is independent of the variant data format. It illustrates another method of saving and restoring data that relies on control references. This method exploits the characteristics of control references. It automatically adapts to changes to data structures (as is often the case with Type Definitions).
The ability to work with any data structure allows all of the sub-VIs to be re-usable. The sub-VIs will not have to change if the data type changes. It also allows support for multiple data structures with a single VI devoted to each data type and sharing all other sub-VIs.