EMS Manual

Retrieving Event Messages Programmatically
EMS Manual426909-005
4-8
Event-Message Sources
This example illustrates some of these restrictions by showing how to start with the
previous two-collector example and end up with the distributor connected to a saved
log file called $OPS.LOG.SV930315:
! Build CONTROL command message to delete both collectors
IF (error := SSINIT(spibuffer,
ZEMS^VAL^BUFLEN,
ZEMS^VAL^SSID,
ZSPI^VAL^CMDHDR,
ZEMS^CMD^CONTROL)) THEN ...
! Place token to delete first collector in spibuffer
spi^error := SSPUTTKN(spibuffer,
ZEMS^TKN^DISCONNECT^SRC^COLL,
coll^name1);
! Handle any error from SPI procedure
IF spi^error <> ZSPI^ERR^OK THEN ...
! Place token to delete second collector in spibuffer
spi^error := SSPUTTKN(spibuffer,
ZEMS^TKN^DISCONNECT^SRC^COLL,
coll^name2);
! Handle any error from SPI procedure
IF spi^error <> ZSPI^ERR^OK THEN ...
! Determine how many bytes of spibuffer have been used
spi^error := SSGETTKN(spibuffer,
ZSPI^TKN^USEDLEN,
buffer^length);
! Handle any error from SPI procedure
IF spi^error <> ZSPI^ERR^OK THEN ...
! And send the command message
CALL WRITEREAD(fnum,
spibuffer,
buffer^length,
ZEMS^VAL^BUFLEN,
count^read);
IF <> THEN ...
! The SPI response is now in spibuffer.
! Reset buffer length to what you declared for spibuffer
spi^error := SSPUTTKN(spibuffer,
ZSPI^TKN^RESET^BUFFER,
ZEMS^VAL^BUFLEN);
! Check if anything wrong with response buffer
IF spi^error <> ZSPI^ERR^OK THEN ...
! Buffer ok, was distributor CONTROL command ok?
spi^error := SSGETTKN(spibuffer,