Show Events/Alarms and the Use of SNMP
Show Events/Alarms and the Use of SNMP
This example demonstrates the use of EventList widget to display alarms/events and how to use the SNMP protocol to get values from an ethernet switch.
How to Run the Example
To run the example from CDP Studio, open Welcome mode and find it under Examples. Next, in Configure mode right click on the system project and select Run & Connect. See the Running the Example Project tutorial for more information.
This example includes
- A simple system (project) consisting of one control application, and one GUI application
- The control application includes a SNMPManagerIO component configured to communicate with a Lynx ethernet switch using SNMP protocol
- The GUI application has a meter showing the temperature inside the switch, and two EventLists
- The first EventList shows active alarms in the system, while the other shows all events happening in the system.
This example is made using a Lynx ethernet switch. Most user will not have this device available and the system is therefore configured to use the Loopback interface to run without a physical device. The EventLists will then show alarms and events happening in the system.
If you have an other managed ethernet switch or another unit with a SNMP Agent available (e.g. printer), you must select the interface where you are connected to the SNMP Agent, see Deployments Manual. Add another SNMPAgent into your SNMPManagerIO, set the agent's remote address, choose SNMP version and configure the different ReceiveEventTraps, ReceiveAlarmTraps, GetRequests and SetRequests. There is an indepth tutorial on how to use and configure a SNMPManagerIO in the Tutorial section in the Welcome mode, called SNMP Configuration Example, see also documentation SNMP I/O Configuration Example.
The control application (called SNMPControlApp) includes a SNMPManagerIO component (added from SNMPIO resources). The SNMPManagerIO component is configured to poll a Lynx ethernet switch by sending Get-Requests (configured with name 'GetTemp') regularly. The response received from the switch contains the measured temperature inside the switch. The 'GetTemp' request is configured to update a CDPChannel (Signal) called 'Temperature' with this received value. The SNMPManagerIO component also has configuration for how to respond when receiving Traps from the switch. For some Traps, events are generated, and for others, Alarms may be Set or Cleared. These configurations can be found if you look into SNMPControlApp.SNMPManagerIO in Configure mode. Click on the in front of LynxSwitch in the SNMPAgents section. The interesting sections are ReceiveEventTraps, ReceiveAlarmTraps and GetRequests.
An Event is generated when there is a change in the system, typically when a property changes value or an alarm changes state (e.g. from set to clear). The event includes a timestamp, text describing the change and some additional information.
For this control application, the debug level is set to 2 for SNMPManagerIO to have additional information printed in the Application Output tab at the bottom of the screen. Here useful output from the application is found during run time, typical info is error messages, versions, libraries, build dates and more.
See CDP Messagelog for information about application console output.
The GUI contains 3 widgets (GUI elements).
In the top, there is a Meter showing the inside temperature of the Lynx switch. It is continuously updated with new values since the cdpRouting property is set to SNMPControlApp.SNMPManagerIO.LynxSwitch.GetTemp.Temperature.
The Event List widget is used to show both Events and Alarms. Here we have 2 Event List widgets, one showing events (bottom) and one showing alarms (middle). They both subscribe to events (alarm is a type of event) from the GUI application's GUI.CDP.CDPEventSubscriber. There is 1 CDPEventSubsriber per application and here you set up which events the application shall subscribe to.
Each application has 1 CDPEventNode. The CDPEventNode collects all events that are generated in the application and send the events to all registered subscribers. In this example, the GUI applications CDPEventSubscriber subscribe to events generated in the control application (SNMPControlApp.CDP.CDPEventNode) and the events generated in the GUI application itself (GUI.CDP.CDPEventNode).
For more information about how to display the hidden CDP object and configure the event subscriptions, see Subscribing to events.
Event List widgets may be configured in many different ways, but the most important property is called listType. The Event List in the middle has listType active, which means that it will only show active Alarms. This type of Event List is also often referred to as an AlarmList. Active alarms means that the Status is either 'UNACK-SET', 'SET' or 'UNACK'.
|UNACK-SET||The object is in a fault state, and the user/operator has not Acknowledged the alarm yet.|
|SET||The object is still in a fault state, but the user/operator has Acknowledged the alarm.|
|UNACK||The object is no longer in a fault state (but it has been), and the user/operator has not Acknowledged the alarm yet.|
To Acknowledge an active alarm, you may double-click on the line containing the alarm, or you may right-click and choose 'Ack' or 'Ack All'. When an alarm is acknowledged, a message is sent to the alarm object. The alarm object will then generate an event which is received by the AlarmList, and the AlarmList will update the status. If an alarm with (only) Status UNACK is acknowledged, it will go to OK status and be removed from the list of active alarms.
The Event List at the bottom has listType history, which means that it will show all received events (except events sent regularly for active alarms). These events are only stored in memory, up to a configurable maximum size. If you need to store events to disk, you must choose listType database.
If you click on one of the Event Lists in Design mode, and then push F1, you will get a more detailed description about the CDPEventList class. If you right-click on the header of an EventList, you will get a list of different menus to do configuration (both offline view (Design mode) and when running the GUI), see Menus by right-clicking in header to get a description.