amaru_add_update

Call this subroutine to add alarm update information to the current IPC buffer. It is the responsibility of the application program to allocate space for the message buffer. The routine may be called repeatedly to load multiple alarm update segments into the message buffer.

The purpose of the update function is to change the state of an outstanding alarm. The states can be changed as follows:

AM_ACKNOWLEDGED

The alarm has been acknowledged by an operator.

AM_CLEARED

The condition that generated the alarm is now gone.

AM_DELETED

The alarm should be deleted

These constants can be found in the inc_path:am_defs.h include file .

Note: The contents of the alarm message field of an alarm cannot be updated. If an application needs to display a different alarm message when a particular alarm has been cleared, the application program must generate a new alarm occurrence with the new message and then update the new alarm occurrence to the desired state.

Syntax

int amaru_add_update (bodyptr, bodylen, first_seg,

                      alarm_id, fr_id, user_or_serv_id,

                      ref_id, action, seq_num, resp_type,

                      key, ret_stat);

char *bodyptr;

int bodylen;

COR_BOOLEAN first_seg;

char alarm_id[ALARM_ID_LEN+1];

char fr_id[FR_ID_LEN+1];

char user_or_serv_id[COR_MAX(USER_ID_LEN, SERVICE_ID_LEN)+1];

char ref_id[AM_REF_ID_LEN+1];

AM_STATE_TYPE action;

int seq_num;

AM_RESP_TYPE resp_type;

AM_RESP_KEY key;

COR_STATUS *ret_stat;

Input Arguments

bodyptr

Pointer to the beginning of the message body of the IPC buffer.

Bodylen

Maximum length of the message body.

first_seg

Boolean value specifying whether the current generation request should be the first request in the message. TRUE implies first segment.

alarm_id

Identifier of the alarm to be generated.

fr_id

Identifier of the factory resource for which the alarm is being generated.

user_or_serv_id

Used for labeling logged alarms. Usually this is the service_id of the sending process. The AMAP sends the user_id of the connected terminal.

ref_id

Used to specify unique alarms when multiple alarm definitions are generated for the same Factory Resources. Alarm uniqueness is defined by the combination of alarm_id, fr_id, and ref_id.

 

Note: The ref_id is not displayed directly on the Alarm Manager User Interface. The ref_id, when used, can be duplicated in a message field for display.

action

Specifies the update action to take.

seq_num

Only used by AMAP. Application programs should pass zero (0).

resp_type

Used to select the type of response desired from the AMRP. The application program has three choices:

 

AM_CAPTURED_RESP - AMRP responds once the message has been captured (sent to a slave process or journalled).

 

AM_FULL_RESP - AMRP responds once the message has been fully processed. A status segment is returned for each request in the original message.

 

AM_NO_RESP - No response from AMRP to indicate that an alarm message has been received.

 

Note: Only the resp_type in the first generation message of each segment is used. Therefore, it is not possible to intermix the type of responses desired within a single IPC message.

key

The key is useful when the resp_type is set to AM_FULL_RESP. The key allows the application program to match the status segments returned with the alarm generation/update requests. The key is specified by the application program and is returned "as is" by the AMRP.

Output Arguments

ret_stat

Pointer to status structure.

Return Value

Either COR_SUCCESS, or COR_FAILURE. If the function returns anything other than COR_SUCCESS, additional error information can be found in ret_stat.err_msg and ret_stat.err_code.

amaru_add_update does not directly generate error codes. It passes the status set by the MF-routines back to the calling program. The error codes are defined in the inc_path:mf_defs.h include file and are shown in Chapter 7.

When an error occurs, the value of ret_stat.status is COR_FAILURE. ret_stat.err_source and ret_stat.err_code can be used to determine the type of error.

If the source is COR_MF_ERR and the code is MF_INSUF_SPACE, the alarm generation information is not added as the message if full. The application program should call amaru_send_msg, reset first_seg to TRUE, and then add the information to the now empty buffer.

More information

Application subroutines for field definitions: Alarm Management API.