External Alarm State Management API Sample Program

About this task

The External Alarm State Management API contains a sample program that demonstrates the use of this API. You can find the source file and make file for this program in the %BSM_ROOT%\api\amxasmgr directory. It contains:

amxassample.cpp The sample application source code.
Amxassample_exe.vcxproj Visual Studio project that creates the sample executable.
makefile Makefile that creates the sample executable.

This sample program generates up to ten alarms and processes Acknowledge, Clear, and Delete requests passed to it by the Alarm Manager.

Note: The program generates each of the alarms you create, then repeats the first three alarms every thirty seconds.

You can use the project provided with the sample as a basis for constructing projects for your own applications.

Note: Depending on how you installed Visual C++, the INCLUDE, LIB, and PATH environment variables may not be automatically set when you install MSDEV. If they are not set, you will have to set them manually or run the following to set them before building any user programs.
for /F "tokens=* USEBACKQ" %F in (`"%PROGRAMFILES(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath`) do set VSPATH=%F call "%VSPATH%\Common7\Tools\VsDevCmd.bat"
  • You can use any project to create and run the executable for the sample program.
  • Create a sample program.
  • Run a sample program.

Create a Sample Program

Procedure

  1. From the Start menu, select the CIMPLCIITY menu.
  2. Select a project.
  3. In the CIMPLICITY Workbench, select Tools>Command Prompt.

    This ensures that your environment variables (in particular %BSM_ROOT% and %SITE_ROOT%) are set correctly.

  4. In the Command Prompt window, issue the following commands:

    <drive>:

    cd %BSM_ROOT%\api

    where <drive> is the disk where your CIMPLICITY software is installed

  5. If the environment variables are not set automatically, issue the following command to set them:
     for /F "tokens=* USEBACKQ" %F in (`"%PROGRAMFILES(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath`) do set VSPATH=%F call "%VSPATH%\Common7\Tools\VsDevCmd.bat" 
  6. Start Visual Studio:

    devenv CimplicityAPI.sln

  7. Open the Solution Explorer.
  8. Right-click amxassample_exe.
  9. Select Build on the Popup menu.

    The sample program in the project is amxassample.exe.

  10. Create the R1 resource and assign it to all available users.
  11. Create 10 alarms. When you create each alarm, enter/select the following values.
    Property Value
    Alarm IDs Name the alarms as follows. LONG_NAME_POINT_123456789123456789123456789_TEST1 LONG_NAME_POINT_123456789123456789123456789_TEST2 LONG_NAME_POINT_123456789123456789123456789_TEST3 LONG_NAME_POINT_123456789123456789123456789_TEST4 LONG_NAME_POINT_123456789123456789123456789_TEST5 TEST6 TEST7 TEST8 TEST9 TEST10
    Alarm Definitions Alarm Class Select High.
    Alarm Type Leave blank.
    Maximum Stacked Set to 20.
    Alarm Message Enter text (e.g. for Test 1 enter TEST1 Alarm).
    Alarm Routing Route to all users. Note: Add the USER role to the Configured Roles For Alarm list.
    Alarm Options Deletion Requirements Check both check boxes.
    Automatic Actions Select None.
    Manual Reset Allowed Check the check box.
  12. Update the project's configuration.
  13. Start the project.
  14. When project startup is complete, select Command prompt... from the Tools menu.
  15. To run the sample program. type:

    AMXASSAMPLE

  16. The sample program starts generating alarms.
    Note: The program generates all ten alarms, and then repeats the first three alarms at thirty second intervals.
  17. You can acknowledge, reset and delete these alarms through an Alarm Viewer.
    The Alarm Manager sends the action you request to the sample program. The sample program then asks you if you want to perform the action you requested. If you confirm the action, the sample program sends a message to the Alarm Manager to execute the action. If you do not confirm the action, it is not performed.