Applies To: |
|
Summary: |
When filtering alarms by category(ies)
during runtime, my alarm filtering Cicode function does not work as
expected. The following errors occur: 1. All the alarms on the page disappear when I apply the filtering function. 2. The filtering function works fine only on the alarms page but not on the alarm summary page. |
Solution: |
These errors can be avoided by adhering to
the following practice when writing your Cicode function: 1. If you are passing the handle of a group in the AlarmSetInfo() function to filter the alarms by categories, ensure that you do not use GrpClose at the bottom of your Cicode function. You should not close the group until you close the display page. If you do, the group will be destroyed and the group handle will become invalid. The page would then be unable to continue displaying the desired group. You would normally close the group by entering the GrpClose() function as the Page exit command. 2. Use AlarmSetQuery(-1,"',"") to remove filtering from an alarm list before calling AlarmSetInfo to filter the alarms. AlarmSetQuery( -1, "", "" ) stops any existing query function filtering the display of alarms. The following is an example of a Cicode function that illustrates how the above two steps can be used. //In the following cicode FUNCTION, alarms are filtered by categories depending //on the values of two digital tags, bCat1 AND bCat2: //IF bCat1=1 only Alarms of Category 1 are displayed. //IF bCat2=1 only Alarms of Category 2 are displayed. //IF bCat1=1 AND bCat2=1 only Alarms of Category 1 AND 2 are displayed FUNCTION AlarmFilterCat(INT hAlarmAN) INT hAlarmCatGrp; hAlarmCatGrp=GrpOpen("catgrp",2); GrpDelete(hAlarmCatGrp,-1) !Clear the alarm category group IF bCat1=0 AND bCat2=0 THEN !If there is no filter then display all AlarmSetQuery(hAlarmAN, "", "");!Clear Any pre-existing query function AlarmSetInfo(hAlarmAN, 2, 0); ELSE ! Add in any categories that are necessary in the group for filtering IF bCat1=1 THEN GrpInsert(hAlarmCatGrp,1); END IF bCat2=1 THEN GrpInsert(hAlarmCatGrp,2); END AlarmSetQuery(hAlarmAN, "", ""); !Clear Any pre-existing query function AlarmSetInfo(hAlarmAN,2,hAlarmCatGrp);!Apply the filter END END |
Keywords: |
Alarm Filtering Category |
Related Links
Attachments