Step 2: Adding Setting A-variables
This step corresponds to test_agg_lib_2 .
In this step we are going to add necessary setting A-variables. These will be used to store the few configuration and status parameters our application requires.
A-variables we are going to have are:
• The BR setting to store the baudrate of the serial port. This will allow us to select a standard baudrate from a list of baudrates (like 9600, 19200, etc.)
• The EG setting to enable/disable access control event generation.
• The UT setting to store the unlock time for the door. This is the number of half-second intervals that the door lock will stay unlocked for (once it is unlocked).
• The DS setting for reading the current door state (closed or opened).
Looking now at the test_agg_lib_2 project, notice that...
The STG library is now in the project (and all related steps were taken, including calling stg_start() in on_sys_init() , etc.).
A way to initialize settings is provided. After each boot, the device will start blinking its red and green status LEDs . This will continue for 5 seconds. If you press the MD button within this time, stg_restore_multiple() will be called. Reboot the device after the green status LED is turned on. If you do not press the button within the 5-second time window, the application will continue running. All related code is in the on_sys_init() event handler.
Settings.xtxtdefines required settings . Notice that the Timestamp option is enabled in the setting configurator . This is because the AGG library requires settings to carry timestamps.
AggreGate.xtxtlists required A-variables .
There is an additional callback procedure in device.tbs — for callback_agg_convert_setting() . Examine the code — it "converts" between the UT setting (measuring time in half-second intervals) and the UT A-variable (measuring time in seconds). You can now see this procedure's usefulness — it allows you to store values differently compared to how they are perceived in AggreGate.
You will now be able to see newly created A-variables in the AggreGate Client (as shown on the screenshot below). Notice how all four A-variables appear on the Access Control tab? This is defined in the AggreGate configurator.
Notice also that each A-variable is displayed/edited differently:
• The Baudrate ( BR ) setting has a drop-down which shows all available values;
• The Generate Event ( GE ) setting as a checkbox because it is of the boolean type;
• The Unlock Time ( UT ) setting is just a plain value that is expressed in seconds (although the UT setting is in half-seconds).
• The Door State ( DS ) setting displays custom values "closed" and "opened" and is read-only.
Setting A-variables as we have them now are not doing anything useful on the device just yet. They simply exist as values. We will glue it all together later.