Code Examples. More...
Code Examples.
This section include two function which are used to initialize and finalize the alarm client library. These are as follows:
If the component is managing a resource having alarms, the IDE generated code takes care that alarm lib initialization is done via Execution object (EO) infrastructure. But if user wants to call them saperately he/she can call them as follows.
Finalizes the alarm management library.
The alarm client library implements a function which is used both to raise and clear the alarms. One of the element of the ClAlarmInfoT structure passed to this function decides whether that alarm is going to be raised or cleared. The function call that is used to raise/clear is:
The information about the alarm being asserted or cleared is filled in the instance of ClAlarmInfoT structure. The information includes the resource identifier (MOId), probable cause, category and severity of the alarm and the state of the alarm that is whether it is being asserted or cleared. After processing the appropriate value of the alarm, the handle is filled in the "pAlarmHandle" by the alarm client based on the alarm configuration.
This example also describes about attaching payload with the alarm and retrieving it in the event receive callback.
The alarm server publishes event for every successfully reported alarm. The event is published on the global event channel, so component running on any other node can receive the event published on a node. For getting the event, the component has to subscribe for them. This can be done via calling the function:
The function takes a callback function as a parameter. The callback function takes pointer to the structure ClAlarmHandleInfoT as parameter. This structure contains information about the alarm which is being published. The callback function is called for every event published by the alarm server. The usage example is as follows:
The function is used to unsubscribe for the events published by the alarm server for which the subscription was done earlier using clAlarmEventSubscribe. After the event unsubscribe is done, the callback function registered using the alarm event subscribe function would not be called for any further event publish from the alarm server.
This example describes about attaching payload with the alarm which is used by the SNMP subagent for reporting the traps. The payload information that need to be given in the trap has to be given in the proper format as explained in the usage example. After providing the details, using clAlarmUtilPayloadFlatten() function, this can be converted into flat buffer and passed on to the alarm raise function. The alarm server will raise the event for this alarm and the payload information given with the alarm will be delivered to the alarm event-listener. For generating traps, the SNMP subagent listens for this event and extracts the payload information and sends the trap to the management station.
The usage example providing the payload information understood by the SNMP subagent and raising the alarm is as follows:
Event Delivery callback function which unpacks the payload information published with the alarm.
This function is used to verify the version of the alarm client library with the version that is supported. For that the user has to fill the version information available with the application. This will be verified against the supported version. In case of mismatch the highest version supported by the client library is updated in the version field.