Using CitectSCADA > Configuring and Processing Alarms > Using custom alarm filters > Implementing queries that use custom alarm filters

Implementing queries that use custom alarm filters

Implementing a query based on the custom alarm filters you have defined requires two steps:

  1. Create a Cicode function that performs the query you want to implement. The format of the query function you need to create is:
  2. INT FUNCTION Query (INT nRecordID, INT nVersion, STRING sInfo)



    The value to be used in calls to AlarmGetFieldRec;

    for example AlarmGetFieldRec(nRID, "CUSTOM1", nVer).

    (See the help for AlarmGetFieldRec for details on the fields available.)


    The version of the record; this will increase each time a record is changed.


    A user defined string to be used to control the logic in the Query function.

    A 0 or 1 is expected as a return value, with 1 determining that the record will be displayed.

  3. Set this query by calling it via the function AlarmSetQuery. Verify that you've defined the custom filters appropriately for your alarm tags before proceeding.


You want to create a query that calls current alarms for the conveyors in your plant. This could be drawn from the alarm tags you have identified as being associated with a conveyor, by applying the keyword "conveyor" to the field Custom Filter 1.

The query function you would create would be as follows:

FUNCTION CheckCustom1(INT nRid, INT nVer, STRING sValue)
STRING sCustom;
// Get the information in CUSTOM1
sCustom = AlarmGetFieldRec(nRid, "CUSTOM1", nVer);
IF sCustom = sValue THEN
// Lets display this
// Skip over this

Say you then want to create a button on a graphics page that lists current conveyor alarms. You would implement this by applying the AlarmSetQuery function to the button.

AlarmSetQuery(0, "CheckCustom1", "conveyor");

You could also create a reset button that clears the current displayed list by cancelling the query:

AlarmSetQuery(-1, "", "")


You have the choice of calling a specific Cicode function, for example, "Customfeld1", with the argument "pumpcontrol", or using a more generic approach with the function "Checkfield" with argument "CUSTOM1= pumpcontrol". In this case, the Cicode function parses the passed string and checks the field specified.