ViewPoint Manual

Sample Custom Status Server
ViewPoint Manual426801-001
D-3
Custom Server Code
LITERAL False = 0;
LITERAL Fname^Wsz = 12;
LITERAL Recv^User^Msg = 0; ! A user message was read on $RECEIVE.
LITERAL Recv^System^Msg^From^User = 1; ! A system message related to an
! opener was read from $RECEIVE.
! Typically an OPEN, CLOSE, SETMODE
! or CONTROL message.
LITERAL Recv^End^Of^File = 2; ! The server should terminate. No
! message is returned.
DEFINE
To^Bsz( x ) = ((x) * 2)#, ! Compute str len from word len
To^Wsz( x ) = (((x) + 1) / 2)#, ! Compute word len from str len
Len^Bsz( x ) = ($LEN(x))#, ! Get string length of object
Len^Wsz( x ) = (TO^WSZ($LEN(x)))#; ! Get word length of object
DEFINE
Blankb(obj) = obj ':=' [" "] & obj FOR Len^Bsz(obj) - 1#, ! BYTE-objects only
Blankw(obj) = obj ':=' " " & obj FOR Len^Wsz(obj) - 1#, ! WORD-objects only
Zerob(obj) = obj ':=' [0] & obj FOR Len^Bsz(obj) - 1#, ! BYTE-objects only
Zerow(obj) = obj ':=' 0 & obj FOR Len^Wsz(obj) - 1#; ! WORD-objects only
?PAGE"STATUS COLLECTION SERVER LITERAL AND DEFINES"
-------------------------------------------------------------------------------
--
-- This section will first load all the ViewPoint Structure definitions
-- include in the file GTAL distributed with the ViewPoint Subvolume.
--
-- The first set of literals present the request codes that this server
-- has to support.
--
-- The second set of literals present the possible errors that can be
-- returned to the requesters.
--
-- The DEFINE Allocate^Item, will be use in procedure Server^Initialize
-- to initialize the Item^Array structure who contains the definitions and
-- initial parameters of all supported status items.
--
-------------------------------------------------------------------------------
?NOLIST, SOURCE GTAL
?LIST
-- Request-Code Values
LITERAL Z^Get^Version^Code = 1;
LITERAL Z^Scan^Item^Code = 2;
LITERAL Z^Next^Item^Code = 3;
LITERAL Z^Check^Item^Code = 4;
LITERAL Z^Sample^Item^Code = 5;
-- Error-Code Values
LITERAL Z^All^Ok^Code = 0;
LITERAL Zerr^Stat^Collect^Request = 0206;
LITERAL Zerr^Stat^No^Such^Type = 0207;
LITERAL Zerr^Stat^No^Such^Object = 0208;
LITERAL Zerr^Stat^End^Of^Types = 0209;
LITERAL Zerr^Stat^Cnfg^Incompatible = 0210;
LITERAL Zerr^Stat^Object^Unavailable = 0211;
DEFINE Allocate^Item ( Index, Description, Type^, Object^,
Value^For^100^, Use^Maximum^,
Reverse^Signify^, Scale^,
Low^Threshold^, High^Threshold^,
Low^Enabled^, High^Enabled^,
Value^Type^ ) =
@Item := @Item^Array[Index];
BLANKB( Item.Z^Item^Description );
Item.Z^Item^Description ':=' Description;
BLANKB( Item.Z^Item^Name );
Item.Z^Item^Name.Z^Item^Type ':=' Type^;
Item.Z^Item^Name.Z^Object^Name ':=' Object^;
Item.Z^Value^For^100 := Value^For^100^;
Item.Z^Use^Maximum := Use^Maximum^;
Item.Z^Reverse^Signify := Reverse^Signify^;
Item.Z^Scale := Scale^;
Item.Z^Low^Threshold := Low^Threshold^;
Item.Z^High^Threshold := High^Threshold^;
Item.Z^Low^Enabled := Low^Enabled^;
Item.Z^High^Enabled := High^Enabled^;
Item.Z^Value^Type ':=' Value^Type^
#;