EMS Manual

EMS Procedures
EMS Manual426909-005
15-6
Examples
Example 5: Sending an SPI Command
To create an SPI command buffer and use the WRITEREAD procedure to send it to a
collector:
INT ALT^SPI^FNUM; !From OPEN
INT .CMD^BUF[0:ZEMS^VAL^BUFSIZE - 1];
INT CMD^LEN;
IF NOT (ERROR := SSINIT(CMD^BUF, .....)) THEN
BEGIN !Buffer Initialized OK
IF NOT (ERROR := SSPUT(CMD^BUF, .....)) THEN
BEGIN !Token added OK
.
.
.
CALL SSGETTKN(CMD^BUF
, ZSPI^TKN^USEDLEN
, CMD^LEN);
CALL WRITEREAD(ALT^SPI^FNUM
, CMD^BUF
, CMD^LEN
, ZEMS^VAL^BUFLEN);
IF = THEN
BEGIN !SPI command sent OK
Example 6: Determining Whether a Process Is an EMS
Collector
To determine whether a named process is an EMS collector, use DEVICEINFO2:
INT RECLEN;
CALL DEVICEINFO2 (PROCESSNAME,DEVTYPE,RECLEN,,ERROR,2,1000D);
IF NOT ERROR THEN
IF DEVTYPE.<4:9> = 1 THEN
BEGIN ! Process is an EMS collector
IF RECLEN = 102 THEN
BEGIN ! Process is a primary collector
END
ELSE
BEGIN ! Process is an alternate collector
END;
END
ELSE
BEGIN ! Process is not an EMS collector
END;