Oscar Software Framework Manual Configuration Module
scs edited this page Jul 16, 2012
·
3 revisions
Go to Table of Contents.
The configuration module provides support to read/write configuration files of the following type:
<TAG>: <VALUE>
CAMERA_NAME: ProductionTest ALGO_FEATURE_A: TRUE EXPOSURE_TIME: 380
- log: For error logging.
Following code segment demonstrates the usage of the cam module. It is a simple example of a typical program sequence, and does not cover all the functionality of the module. For the sake of simplicity, error checking as well as framework creation and destruction are neglected.
OscCfgRegisterFile(&hCfgFile, "/mnt/app/config", 1024); /* (1) */ configKey.strSection = NULL; /* (2) */ configKey.strTag = "EXPOSURE"; OscCfgGetUInt32Range( hCfgFile, /* (3) */ &configKey, &exposureTime, /* Variable to store result in */ 1, /* Min value */ 100000, /* Max value */ 10000); /* Default value. */ configKey.strSection = NULL; /* (4) */ configKey.strTag = "PASSWORD" OscCfgSetStr(hCfgFile, /* (5) */ &configKey, strPassword); OscCfgFlushContentAll(hCfgFile); /* (6) */
- Create a handle to a config file for subsequent use by specifying the file name and its maximum size.
- Initializes a config key entry with the tag "EXPOSURE" in the config file. The corresponding entry could look like this: ExposureTime: 15000
- Read the value associated with above config key into the variable exposureTime. If the read value is lower than 1 or higher than 100'000, the default value of 10'000 will be taken instead.
- Initialize a config key entry with the tag "PASSWORD" for saving a password to the config file.
- Save the local password variable as a string to the configuration file. For performance, this will only write it to the cached contents of the config file and not to the file system.
- Flush all cached changes of the config file back to the file system.