Example 6-1, Starting and stopping the subsystem – HP NonStop G-Series User Manual
Page 120
![background image](/manuals/397027/120/background.png)
Creating a Custom Measurement Application
Measure User’s Guide — 520560-003
6 -8
Starting and Stopping the Measure Subsystem
Example 6-1. Starting and Stopping the Subsystem
DEFINE WLEN(S) = $LEN(S)>>1#;
LITERAL STOP^SUBSYS = 0,
START^SUBSYS = -1,
MAX^NUM^MEASUREMENTS = 64;
! Structures for the Measure control block and for the
! array of measurement names returned by MEASMONSTATUS.
STRUCT .MEASCB(MEASCB^DEF);
STRUCT .MEASNAMES[0:MAX^NUM^MEASUREMENTS-1];
BEGIN
INT FNAME[0:11];
END;
INT MEASUREMENTS,
ERROR;
.
.
.
! Start the subsystem. The call to MEASMONSTATUS is the
! first Measure procedure call, so initialize the control
! block first. Then check the subsystem status by calling
! MEASMONSTATUS. If no error is returned, the subsystem is
! running. If error ERR^MEASMON is returned, the subsystem
! hasn't been started, so start it.
MEASCB.FIRSTWORD ':=' -1 & MEASCB.FIRSTWORD FOR
(WLEN(MEASCB) - 1);
IF ERROR := MEASMONSTATUS(MEASCB, MEASUREMENTS, MEASNAMES)
THEN
BEGIN
IF ERROR = ERR^NOMEASMON
THEN
IF ERROR := MEASMONCONTROL(MEASCB,TRUE) !start it
THEN ... ! Handle error on start attempt
ELSE ... ! Handle error on status attempt
! Stop the subsystem. Call MEASMONSTATUS to see if any
! measurements are active (nonzero measurements parameter
! returned). If some are, resolve appropriately (for
! example, notify operator), and do not stop the subsystem.
! If no measurements are active (zero in returned
! measurements parameter), stop the subsystem.
IF ERROR := MEASMONSTATUS(MEASCB,MEASUREMENTS,MEASNAMES)
THEN ... ! handle error
IF MEASUREMENTS
THEN ... ! handle case of active measurements
ELSE ! shut down the subsystem
IF ERROR := MEASMONCONTROL(MEASCB,FALSE)
THEN ... ! handle error