Instructions: This entries shows you how to use the standard function "AXC_SetFilter()" in order to set the following message filter on a WinCC Alarm Control at Runtime. Using the message filter, only those messages are to be displayed which:
- Are assigned to the messages classes "Alarm", "Warning" or "PLC process control messages".
- Contain the character string "TI4711" in the user text block tb1 ("source").
- Contain the character string "area1" in the user text block tb2 ("area").
- Are not hidden by "Alarm Hiding" (the Alarm Hiding is available from WinCC V6.2).
The following figure shows the associated script.
  Fig 01
The script is ready for you to download as a text file and exported action.
WinCC_AXC_SetFilter.zip ( 3 KB )
The following table explains the important program lines.
| No. |
Description |
| 1 |
"memset(&scSelect , 0, sizeof(scSelect));" The internal C function "memset()" resets the filter structure. The memory occupied by the filter structure is preset with 0.
"memset(&scError , 0, sizeof(scError));" The internal C function "memset()" resets the error structure. The memory occupied by the error structure is preset with 0. |
| 2 |
"strcpy (scSelect.szFilterName, "MySelection");" The "strcmp()" function assigns the name "MySelection" to the structure element "szFilterName" of the filter structure. This name is arbitrary and has no influence on the actual effect of the filter. |
| 3 |
"scSelect.dwFilter = MSG_FILTER_CLASS | MSG_FILTER_TEXT | MSG_FILTER_VISIBLEONLY ;" The constants "MSG_FILTER_CLASS", "MSG_FILTER_TEXT" and "MSG_FILTER_VISIBLEONLY" are linked bit by bit with "ODER" and assigned to the structure element "dwFilter". The structure element "dwFilter" now contains the information that is to be filtered with regard to message classes and user text blocks. The constant "MSG_FILTER_VISIBLEONLY" ensures that only those messages are displayed that are not hidden by the "Alarm Hiding".
Notes:
- "MSG_FILTER_HIDDENONLY" and "MSG_FILTER_VISIBLEONLY"
- The constant "MSG_FILTER_HIDDENONLY" ensures that only those messages are displayed that are hidden by the "Alarm Hiding".
- The constants "MSG_FILTER_HIDDENONLY" and "MSG_FILTER_VISIBLEONLY" are available from WinCC V6.2.
- If you use neither the constant "MSG_FILTER_HIDDENONLY" nor the constant "MSG_FILTER_VISIBLEONLY", then the hidden and the visible messages are displayed.
- "MSG_FILTER_TEXT_EQUAL"
You can also use the constant "MSG_FILTER_TEXT_EQUAL" to check that the user text blocks used are exactly equal. |
| 4 |
"scSelect.dwMsgClass = 0x0001 | 0x0002 | 0x0008 ;" The values of the message classes are linked bit by bit with "OR" and assigned to the structure element "dwMsgClass". The structure element "dwMsgClass" now contains the information that is to be filtered with regard to the message classes "Class 1" ("Alarm"), "Class 2" ("Warning") and "Class 4" ("PLC process control messages").
Notes:
- The message classes are bit coded. This means that exactly one bit in the structure element "dwMsgClass" is assigned to each message class. If the bit is set, this means that the messages of that message class are displayed in the WinCC Alarm Control. Here the number of the message class corresponds to the number of the bit in the structure element "dwMsgClass". Please note that the numbers of the message classes start at 1 and the numbers of the bits start at 0.
- You can proceed as follows to determine the number of the bit for a message class:
- Open the Alarm Logging editor.
- Right-click the pop-up menu for a message class whose number you wish to determine. Select the "Properties" option.
The "Configure message classes" dialog opens.
  Fig 02
- The name of the first tab contains the number of the message class. In Fig. 02 you can see that the message class "PLC process control messages" represents message class "Class 4". Bit 3 is assigned to message class 4. Bit 3 is represented by the hexadecimal value 0x0008.
|
| 5 |
"scSelect.dwMsgType[0] = 0x00000001 | 0x00000002 ;" The values of the message types are linked bit by bit with "OR" and assigned to the first field element of the structure element "dwMsgType". The first field element now contains the information that the message types "Type 1" and "Type 2" of message class "Class 1" are to be displayed.
Note:
- The structure element "dwMsgType" is a Field as data type. In each field are defined the message types of exactly one message class that are to be displayed. The order of the field elements corresponds to the consecutive numbering of the message classes. Please note in the syntax of the programming language "C" that field elements are counted starting at "0". So message class 1 is addressed by field element "[0]".
- The message types are bit coded, which means that exactly one bit in the structure element "dwMsgType" is assigned to each message type of a message class. If the relevant bit is set, the messages of that message class and message type are displayed in the WinCC Alarm Control. The bits of the structure element "dwMsgType" represent a maximum of 16 different message types for each field element (each message class). Here, Bit 0 is always assigned to the first message type that is available for the message class concerned. Here, Bit 15 is always assigned to the sixteenth (last) message type that is available for the message class concerned.
Warning:
Note that the numbering of the message types in the WinCC Alarm Logging runs continuously across all message classes. This demands extra work to specify the associated bit position for the structure element "dwMsgType" from the consecutive number of a message type. The table available below in this entry gives the exact bit position in the structure element "dwMsgType" of any message type.
- In the structure element "dwMsgType" the relevant bit positions must be set for those message types that are to be displayed by the message filter. As soon as at least one message type of a message class is defined as filter, the message type for the rest of the message classes must also be specified explicitly. Only in the case when the message types are not used at all as a filter criterion can you drop populating the structure element "dwMsgType" completely to achieve the same effect. Please note, however, that the current active message filter can then only be displayed with the selection dialog if the message types are also specified as filters.
- You can proceed as follows to determine the number of the bit for a message type:
- Open the Alarm Logging editor.
- Right-click the pop-up menu for a message type whose number you wish to determine. Select the menu command "Properties" to open the "Type" dialog.
  Fig 03
- The name of the first tab contains the consecutive number of the message type. In Fig. 03 you can see that the message type "Alarm High" represents the message type "Type 1". Bit 0 is assigned to message type 1. Bit 0 is represented by the hexadecimal value 0x0001. Since the message type "Type 1" is assigned to the first message class "Class 1" there is no need for any special conversion.
|
| 6 |
"scSelect.dwMsgType[1] = 0x04 | 0x08 ;" The values of the message types are linked bit by bit with "OR" and assigned to the second field element of the structure element "dwMsgType". The second field element now contains the information that the message types "Type 19" and "Type 20" of message class "Class 2" are to be displayed.
Note:
You can find the relevant bit positions of the message types in the table given below. |
| 7 |
"scSelect.dwMsgType[3] = 0x40 |0x80 ;" The values of the message types are linked bit by bit with "OR" and assigned to the fourth field element of the structure element "dwMsgType". The fourth field element now contains the information that the message types "Type 55" and "Type 56" of message class "Class 4" are to be displayed.
Note:
You can find the relevant bit positions of the message types in the table given below. |
| 8 |
"scSelect.dwTB = 0x0001 | 0x0002 ;" The values of the user text blocks are linked bit by bit with "OR" and assigned to the structure element "dwTB". With this statement the structure element contains the information that the user text blocks "tb1" and "tb2" are used for selection. |
| 9 |
"strcpy (scSelect.szTB[0], "TI4711");" The character string "TI4711" is assigned to the first field element of the structure element "szTB". This means that only those messages are displayed in the Alarm Control that contain this character string in the user block "tb1". |
| 10 |
"strcpy (scSelect.szTB[1], "area1");" The character string "area1" is assigned to the second field element of the structure element "szTB". This means that only those messages are displayed in the Alarm Control that contain this character string in the user block "tb2". |
| 11 |
"bOK = AXC_SetFilter(lpszPictureName,"Control1",&scSelect,&scError);" This function "AXC_SetFilter()" executes the filter criterion defined in the structure "scSelect". |
The following table gives the relationship between consecutive numbering of the message types and the bit positions in the structure element "dwMsgType".
WinCC_AXC_SetFilter_dwMsgType_e.pdf ( 13 KB )
Notes: Please also refer to the information given in Entry ID 25288354. This will give you a general idea of the various options for filtering messages in the WinCC Alarm Control.
Path specifications of the WinCC Information System are also available there.
|