By default, newly generated CIMPLICITY alarms are assigned a timestamp indicating the alarm generation time and duration. The Alarm Management API lets you provide your own timestamp, so that external alarms can be synchronized to a more accurate clock. The following example shows how to generate an alarm with an external timestamp:
COR_STAMP stamp;
int yyyy, mm, dd, hh, min, sec, tt;
;
get parameters (load msg_fields)
/* Setup time for the alarm */
yyyy = 1995;
mm = 01; /* month = January */
dd = 10; /* day of the month */
hh = 13; /* hours - 24 hour clock */
min = 30; /* minutes after 1pm */
sec = 12; /* seconds after 1:30 */
tt = 50; /* ticks - 100 per second */
int ret; /* return code */
/* Convert time into a CIMPLICITY timestamp */
cor_stamp_calc( &stamp, yyyy, mm, dd, yy, min,sec, tt);
/* set up to generate the alarm */
/* the alarm is fixed as shown */
amaru_add_gen_stamp(
alarm_write_body, /* data pointer of write buffer */
alarm_write_len - IPC_HEAD_LEN, /* data length avail */
TRUE, /* TRUE if first message in buffer */
/* FALSE if not first message */
"$RTR_LINK_DOWN", /* ID of alarm */
"$SYSTEM", /* ID of resource */
object_name, /* identifier of who sent the alarm */
NULL, /* reference ID or NULL goes here */
AM_CAPTURED_RESP, /* AMRP sends response immediately */
0, /* key */
msg_field, /* the message struct array */
i, /* the number of fields in message */
FALSE, /* no reset follows */
stamp,
&ret_stat );
if (ret_stat.status != COR_SUCCESS)
{
printf("%s\n",ret_stat.err_msg);
goto end_of_program_am;
}
/* send message to AMRP as before */
There is also a corresponding function amaru_add_update_stamp() in the API which can be used to specify an external reset time for an outstanding alarm.
Alarm Management API getting started. |