While settings are the values you like to be able to change during the run-time of your program, the configuration is often a quite stable collection of values. The configuration cluster contains often values you like to have personalised, but for a certain setup should be constant, e.g. the communication port number of the RS232 port or the path of the data storage directory.
In this tutorial we will show how to add the configuration of your component. Important is that you have already read and done the steps in the tutorial 2: Configuration and settings cluster.
Setting up the configuration
- Add to the project a virtual folder named “configuration”.
- Right mouse click on this folder and select New >> VI for override.
- Select the methods “Read configuration”, “Write configuration” and “Check if configuration files exist”.
- Imitate the concept of Check if configuration files exist from the parent, but replace the class by your own.
- Imitate the concept of Write configuration file from the parent, but replace the class by your own.
- Imitate the concept of Read configuration file from the parent, but replace the class by your own.
- Add to the project a virtual folder “action methods”, add to this folder the method “Configure” by New >> VI for override. Make this configure method like a normal event handler.
- Add the integer with the value “0” and use with shift registers as the timeout value. Wire through all the event cases.
- In the timeout case, wire a “-1” to the time out. Add the method “Read configuration”, set “force loading” to FALSE. Unbundle by the name the parameters. Write the values to the controls by using local variables.
- Add the boolean control “Configure Murmex”. Call in this method the parent. Don’t wire out the “cancelled?” status.
- Add the boolean control “Cancel”. Stop the program, but wire a TRUE to “cancelled?”. Use shift registers for adjusting the data, make a copy or original data for as output when the “Cancel” button is pressed to give out.
- Add the boolean control “Ok”. Write all the parameters by using the Bundle by name to the cluster. Save the data by calling the method Write configuration. Stop the program.
- The configuration files are automatically stored in the My Documents directory under %user%\Documents\Distrio\configuration\%Component name%. These XML files are human-readable and editable. When controls are added to or removed from the configuration cluster, the reading of the configuration will fail. Remove the configuration file and configure newly or remove / add the XML-tags manually.