EMS Manual

Procedure Calls for Standard Events
EMS Manual426909-005
11-49
Program Example
#include <CEXTDECS(EMSADDTOKENS, FILE_OPEN_)> nolist
#include <CEXTDECS(SSGETTKN, WRITEREAD)> nolist
#include "$dsv.Zspidef.ZSPIC" nolist
#include "$dsv.Zspidef.ZEMSC" nolist
#include "$dsv.Zspidef.ZCOMC" nolist
#include "MYAPC" /* generate from myapddl */
#include "myerror" /* handling error messages */
#pragma PAGE "Globals and defines"
/*
* Define values
*/
#define NULL 0
#define SYMPTOM_LEN 20
#define SUBJECT_LEN 15
#define TOKEN_LENGTH 15
#pragma PAGE "main program code"
int main(void)
{
/*
* Declare the ssid's using the typedefs from the DDL output
*/
zems_val_ssid_def zems_val_ssid;
myap_val_ssid_def myap_ssid;
/*
* Global declarations and variables -- just an example --
*/
short event_buf[ZEMS_VAL_EVT_BUFLEN];
short buf_len = 0;
short current_state = ZEMS_VAL_MIN_USER_VALUE + 1;
short previous_state = current_state;
char coll_name[] = "$mycol";
char symptom[SYMPTOM_LEN] = "object unvailable ";
char subject_value[SUBJECT_LEN] = "line name ";
short coll_num = 0;
char token_value[TOKEN_LENGTH] = "token value ";
short status;
short myap_evt_obj_unavail = 109;
short coll_name_len = sizeof(coll_name) - 1;
strncpy(myap_ssid.u_z_filler.z_filler, MYAP_VAL_OWNER, 8);
myap_ssid.z_number = MYAP_SSN_MYAP;
myap_ssid.z_version = MYAP_VAL_VERSION;
/*
* Open the EMS collector
*/
FILE_OPEN_ (coll_name, coll_name_len, &coll_num);
printf(" sizeof coll_name = %d\n", coll_name_len);
/*
* Display error message and exit if collector is unsuccessfully opened.
* Otherwise build an event and send to the collector
*/
if (coll_num == -1) /* return value coll_num from OPEN */
{
printf (" Unsuccessfully open %s collector\n", coll_name);
printf (" coll_num = %d \n", coll_num);
}
else