Applies To:
  • CitectSCADA 5.xx

I am using the ctFindFirst function in C to get a list of all configured alarms:

    hSearch = ctFindFirst(hCTAPI, "CTAPIAlarm(0, 4, -1)", NULL, &hObject, 0);

This function returns all alarms in the current area but I would like to get a list of alarms in all areas. How do you do do this?


In order to search multiple area you will need to create a Group. You can then open this group and use the group handle with CTAPIAlarm in ctFindFirst() in order to search the grouped areas.

eg. To use Group "MyGrp"

    ctCicode(hCTAPI, "GrpOpen(MyGrp, 1)", 0, 0, sGrp, sizeof(sGrp), NULL);
    sprintf(sCmd, "CTAPIAlarm(0, 4, %s)", sGrp);
    hSearch = ctFindFirst(hCTAPI, sCmd, NULL, &hObject, 0);

You also must close the group when you are finished with it or you will leak memory in Citect. So must call

    sprintf(sCmd, "GrpClose(%s)", sGrp);
    ctCicode(hCTAPI, sCmd, 0, 0, NULL, 0, NULL);

You can also use StrToGrp() to create groups dynamically. For example to group all areas:

    StrToGrp("MyGrp", "0..255")

See Citect Help for more information on CTAPI and Group Functions.