At several points it is possible for a user to define own extensions to the SATAN system. He/she may define additional commands or provide function plug-ins for certain standard tasks.
The command 'OVERLAY' is declared with the two optional positional parameters 'analyzer identifier' and 'event type identifier', both character strings of 18 bytes maximum length. Replaceable default for the event type is 'LIST'.
$INITPROC; DCL AOVER ENTRY(CHAR(18) VAR, CHAR(18) VAR); CALL $CMDDEF('OVERLAY | ANLID(T(18)) EVTID(T(18) R(LIST))',AOVER); END;
AOVER: PROCEDURE(CANLID,CEVTID); /* command to add the first half of an analyzer to the second half */ %INCLUDE $MACRO($ANLFET), /* declarations of entries */ $MACRO($PROENT); DECLARE CEVTID CHAR(18) VAR, /* event name */ CANLID CHAR(18) VAR, /* analyzer name */ IEVTID BIN FIXED, /* event number */ IANLID BIN FIXED, /* analyzer number */ ICND BIN FIXED, /* number of conditions */ IDIM BIN FIXED, /* number of dimensions */ ILIM(4,4) BIN FIXED, /* analyzer limits */ ITYPE BIN FIXED, /* analyzer type */ IL BIN FIXED, /* upper limit (temporary) */ IRC BIN FIXED, /* return code */ (I,J) BIN FIXED; /* loop variables */ ; IEVTID,IANLID = 0; /* force use of names */ $LFETCH($ACHECK);; /* get analyzer limits */ CALL $ACHECK(CEVTID,IEVTID,CANLID,IANLID,ITYPE,ICND,IDIM,ILIM,IRC); IF IRC^=0 THEN DO; /* errors? */ CALL $PRTCL('ERROR CHECKING '||CANLID||' '||CEVTID|| ', RETURNCODE IS'||CHAR(IRC),1); RETURN; END; IF IDIM^=1 THEN DO; /* more than 1 dimension? */ CALL $PRTCL('ANALYZER IS NOT ONE-DIMENSIONAL',1); RETURN; END; IL = ILIM(1,4); /* upper bound of work array */ ; ABEGIN: BEGIN; DECLARE SPEC(IL) BIN FIXED(31); /* allocate spectrum work array */ ; $LFETCH($AGTSPC);; /* fetch the spectrum */ CALL $AGTSPC(IEVTID,IANLID,ILIM,SPEC,0,IRC); IF IRC^=0 THEN DO; CALL $PRTCL('ERROR FETCHING SPECTRUM. RETURNCODE ='||CHAR(IRC),1); RETURN; END; J = 0; DO I=IL/2+1 TO IL; /* loop over channels */ J = J + 1; SPEC(I) = SPEC(I) + SPEC(J); END; $LFETCH($ASTSPC);; /* store processed spectrum */ CALL $ASTSPC(IEVTID,IANLID,ILIM,SPEC,0,IRC); IF IRC^=0 THEN CALL $PRTCL('ERROR STORING SPECTRUM, RETURNCODE ='||CHAR(IRC),1); END ABEGIN; RETURN; END AOVER;
Fetchable program: Assume, the fetchable module shall access the external pointer P, the external structure S, the file F and the resident procedures MYENTRY and $PRTCL. The following declarations have to be coded:
DECLARE MYFETCH VARIABLE ENTRY(...) INIT($LTDMY); ... $LFETCH(MYFETCH); CALL MYFETCH(...); ...
Resident root definition: Resident elements and root groups used by the fetchable module must be declared in a resident program, too. However, in this case the macro @LBASE instead of @LFETCH is required to resolve the code.
MYFETCH: PROC(...); %INCLUDE $MACRO(@LFETCH); DCL $LEXT(P,USER) POINTER, 1 $LEXT(S,USER), 2 C_ID CHAR(20) VAR INIT('MY_COUNTER'), 2 L BIN FIXED(31) INIT(0), $LENTRY(MYENTRY,USER) (CHAR(*) VAR,BIN FIXED), $LENTRY($PRTCL,USER) (CHAR(*) VAR,BIN FIXED), $LFILE(F,USER); $LROOT(USER) EXT(P,S) ENTRY(MYENTRY,$PRTCL) FILE(F);; ... CALL $PRTCL(C_ID ||' = '||L,1); ... END MYFETCH;
%INCLUDE $MACRO(@LBASE); DCL $LEXT(P,USER) POINTER, 1 $LEXT(S,USER), 2 C_ID CHAR(20) VAR INIT('MY_COUNTER'), 2 L BIN FIXED(31) INIT(0), $LENTRY(MYENTRY,USER) (CHAR(*) VAR,BIN FIXED), $LENTRY($PRTCL,USER) (CHAR(*) VAR,BIN FIXED), $LFILE(F,USER); ... $LROOT(USER) EXT(P,S) ENTRY(MYENTRY,$PRTCL) FILE(F);;
Command Function Purpose $INIT command definitions (no analysis) GO $MYGO start data input HALT $MYHALT stop data input EXIT $MYEXIT leave SATAN INPUT $MYINP allocate and start input MFO28 $MYFORM convert external raw data format