*DECK CSTSCD
USETEXT TEXTCS
USETEXT TXTCTCS
USETEXT TXTSMCS
PROC CSTSCD (LASTERM);
# TITLE CSTSCD - SELECT CORRECT DEVICE. #
BEGIN # CSTSCD #
#
** CSTSCD - SELECT CORRECT DEVICE.
*
* D. G. DEPEW. 81/10/16.
*
* CSTSCD SELECTS APPROPRIATE DEVICE ENTRIES FOR A GIVEN TERMINAL
* ENTRY WITHIN THE LINE RECORD OF A GIVEN NCF DATA QUEUE ENTRY, AND
* FOR EACH DEVICE SELECTED CALLS PROC CSTITR TO ISSUE (PLACE IN THE
* OUTGOING TRAFFIC QUEUE) THE CNF/TE/N RESPONSE SM.
*
* PROC CSTSCD (LASTERM)
*
* ENTRY BASED ARRAYS *LINEREC* AND *TRMINFO* POINT TO THE CORRECT
* LINE RECORD AND TERMINAL ENTRY, RESPECTIVELY.
* LASTERM = TRUE, IF THIS IS THE LAST TERMINAL ON THE LINE
* FOR WHICH DEVICES ARE TO BE CONFIGURED.
* LASTERM = FALSE, IF THERE ARE MORE TERMINALS ON THE LINE
* FOR WHICH DEVICES ARE TO BE CONFIGURED.
*
* EXIT BASED ARRAYS *LINEREC* AND *TRMINFO* POINT TO THE SAME
* RELATIVE POSITION WITHIN THE NCF DATA QUEUE ENTRY AS
* UPON ENTRY.
* ALL CONFIGURE TERMINAL NORMAL RESPONSE SMS APPROPRIATE TO
* THE GIVEN TERMINAL ENTRY HAVE BEEN PLACED IN THE
* OUTGOING TRAFFIC QUEUE.
* ITEM *NRDEV* (IN TXTCTCS) IS INCREMENTED BY THE NUMBER OF
* CNF/TE/N SMS ISSUED.
*
* METHOD THE LOGIC OF THIS ROUTINE IS BASED ON THE FACT THAT FOR
* AUTORECOGNITION THERE IS NO WAY OF KNOWING IN ADVANCE HOW
* MANY DEVICES WILL BE CONFIGURED AND THENCE NO WAY OF
* KNOWING WHEN TO SET THE LAST RESPONSE FLAG IN THE CNF/TE/N
* RESPONSE. THUS, WHEN A MATCHING DEVICE ENTRY IS FOUND,
* ITS ORDINAL IS SAVED UNTIL A SUBSEQUENT MATCHING ENTRY IS
* FOUND. AT THAT POINT THE DEVICE DEFINED BY THE PREVIOUS
* ENTRY IS CONFIGURED AND THE SUBSEQUENT DEVICE ENTRY
* ORDINAL IS SAVED UNTIL ANOTHER MATCHING DEVICE IS FOUND,
* AND SO ON. AT THE END OF THIS PROCESS A SPECIAL CASE IS
* MADE TO CONFIGURE THE LAST DEVICE. FOR REASONS OF
* CONSISTENCY AND SIMPLICITY, SIMILIAR LOGIC IS USED FOR
* FIXED CONFIGURATION LINES.
#
ITEM LASTERM B; #LAST TERMINAL ON A LINE FLAG #
#
**** PROC CSTSCD - XREF LIST.
#
XREF
BEGIN
PROC CSTITR; #ISSUE CONFIGURE TERMINAL NORMAL RESPONSE #
PROC SSBEBF; #EXTRACT BITFIELD #
END
#
****
#
ITEM I, J; #LOOP INDUCTION VARIABLES #
ITEM MATCH B; #INDICATES A DEVICE MATCH HAS BEEN FOUND #
ITEM LASTDEV B; #LAST DEVICE ON A LINE FLAG #
ITEM PREVDEV; #NDQ WORD ORDINAL OF PREVIOUS DEVICE ENTRY#
ITEM A2DTORD; #WORD ORDINAL OF A2/DT PAIR IN CNF/TE/R SM#
ITEM A2DTBIT; #START BIT POS OF A2/DT PAIR IN WORD #
ITEM LDES; #LEN ALL DEV NTRYS IN A TERM NTRY (CM WDS)#
ARRAY A2DTPAIR [00:00] S(1); #STORAGE FOR EXTRACTED A2/DT PAIR #
BEGIN
ITEM PR$A2DT U(00,00,60); #A2/DT COMBINED #
ITEM PR$A2 U(00,44,08); #ADDRESS TWO #
ITEM PR$DT U(00,52,08); #DEVICE TYPE #
END
PROC CALLITR;
BEGIN # CALLITR #
#
* CALLITR - CALL PROC CSTITR.
*
* THIS EMBEDDED PROC SAVES THE POINTERS FOR THE TERMINAL AND DEVICE
* ENTRY (WITHIN A LINE RECORD) BASED ARRAYS, CALLS PROC CSTITR TO
* CONFIGURE THE PREVIOUSLY SELECTED DEVICE, AND RESTORES ALL THREE
* BASED ARRAYS (LINE, TERMINAL AND DEVICE) IN A MANNER THAT ALLOWS
* FOR STORAGE MOVEMENT OF THE NCF DATA QUEUE.
*
* PROC CALLITR
*
* ENTRY PREVDEV = NCF DATA QUEUE ORDINAL OF THE DEVICE TO BE
* CONFIGURED.
* P<LINEREC> = ABSOLUTE ADDRESS OF THE CURRENT LINE RECORD.
* P<TRMINFO> = ABSOLUTE ADDRESS OF THE CURRENT TERMINAL
* ENTRY.
* P<DEVNTRY> = ABSOLUTE ADDRESS OF THE ENTRY FOR THE NEXT
* DEVICE TO BE CONFIGURED, OR IF *PREVDEV* IS
* POINTING TO THE LAST DEVICE TO BE CONFIGURED
* ON THE CURRENT TERMINAL, THE ABSOLUTE ADDRESS
* OF THE WORD FOLLOWING THE TERMINAL ENTRY.
*
* EXIT A CNF/TE/N SM HAS BEEN PLACED IN THE OUTGOING TRAFFIC
* QUEUE FOR THE DEVICE INDICATED BY *PREVDEV* UPON ENTRY.
* PREVDEV = NCF DATA QUEUE ORDINAL OF THE NEXT DEVICE TO BE
* CONFIGURED, OR IF THE LAST DEVICE ON THE CURRENT
* TERMINAL WAS CONFIGURED (I.E., CNF/TE/N QUEUED
* IN OTQ) THIS TIME, THE NCF DATA QUEUE ORDINAL OF
* THE WORD FOLLOWING THE TERMINAL ENTRY.
* P<LINEREC> = SAME AS ENTRY BUT REVISED FOR STORAGE MOVE.
* P<TRMINFO> = SAME AS ENTRY BUT REVISED FOR STORAGE MOVE.
* P<DEVNTRY> = SAME AS ENTRY BUT REVISED FOR STORAGE MOVE.
*
* NOTE PROC CSTITR CALLS PROC SSTAQE (TO QUEUE CNF/TE/N IN OTQ),
* WHICH IN TURN CALLS PROC SSTATS (TO ALLOCATE CORE IN OTQ),
* WHICH CAN CAUSE STORAGE TO MOVE.
*
* METHOD TO PROVIDE FOR STORAGE MOVING, WE SIMPLY CONVERT THE
* VARIOUS BASED ARRAY POINTERS (WHICH CONTAIN ABSOLUTE
* ADDRESSES) INTO THEIR RESPECTIVE NCF DATA QUEUE ORDINALS.
#
ITEM CRNTERM; #NDQ WORD ORDINAL OF CURRENT TERMINAL NTRY#
ITEM CRNTDEV; #NDQ WORD ORDINAL OF CURRENT DEVICE ENTRY #
CRNTERM = P<TRMINFO> - P<NDQ>; # SAVE POINTERS #
CRNTDEV = P<DEVNTRY> - P<NDQ>;
P<DEVNTRY> = P<NDQ> + PREVDEV; # DEVICE TO CONFIGURE #
CSTITR (LASTDEV);
PREVDEV = CRNTDEV; # NEXT DEVICE TO CONFIGURE #
P<LINEREC> = P<NDQ> + NDQ$TCSIZE[0]; # RESTORE POINTERS #
P<TRMINFO> = P<NDQ> + CRNTERM;
P<DEVNTRY> = P<NDQ> + CRNTDEV;
NDQ$WORD[NDQL] = 1; # INSURE CORRECT LOOP TERMINATION #
END # CALLITR #
# MAIN ROUTINE BEGINS HERE. #
LASTDEV = FALSE;
LDES = TE$WC[0] - TEHDRL$; # WORD COUNT OF DEV NTRYS #
IF CNFTTA[0] NQ 0
THEN # AUTORECOGNITION LINE #
BEGIN
PREVDEV = 0;
A2DTORD = 1; # SET UP FOR A2/DT PAIR EXTRACTION #
A2DTBIT = 20;
FOR I=1 STEP 1 UNTIL CNFNT[0]
DO # ATTEMPT TO CONFIG ALL REPORTED DEVICES #
BEGIN
MATCH = FALSE;
SSBEBF (CSSM[0], A2DTORD, A2DTBIT, 16, A2DTPAIR);
P<DEVNTRY> = P<TRMINFO> + TEHDRL$; # 1ST DEV IN TERM NTRY#
FOR J=DE$WC[0] STEP DE$WC[0]
WHILE J LQ LDES AND NOT MATCH
DO # LOOP TIL END OF TRM NTRY OR DEVICE MATCH#
IF NOT DE$CONFIG[0]
AND (DE$A2[0] EQ PR$A2[0] OR DE$A2[0] EQ 0)
AND (DE$DT[0] EQ PR$DT[0])
THEN # THIS DEVICE OK #
BEGIN
MATCH = TRUE;
DE$CONFIG[0] = TRUE; # DONT MATCH ON THIS DEV NTRY AGAIN#
# INSURE VALUES REQUIRED FOR CNF/TE/N ARE IN LINE RECORD FIELDS. #
DE$A2DT[0] = PR$A2DT[0];
IF PREVDEV EQ 0
THEN # THIS IS THE FIRST MATCHING DEVICE ENTRY #
PREVDEV = P<DEVNTRY> - P<NDQ>;
ELSE # THERE IS A PREVIOUS DEVICE MATCH #
CALLITR; # JUGGLE POINTERS AND ISSUE CNF/TE/N #
END
ELSE # THIS DEVICE NO GOOD #
P<DEVNTRY> = P<DEVNTRY> + DE$WC[0]; # NXT DEV NTRY #
END
END
ELSE # FIXED CONFIGURATION LINE #
BEGIN
PREVDEV = P<TRMINFO> - P<NDQ> + TEHDRL$; # NDL INSURES ONE DEV#
P<DEVNTRY> = P<TRMINFO> + TEHDRL$ + TE$WC[TEHDRL$]; # 2ND DEV #
LDES = LDES - TE$WC[TEHDRL$]; # ADJUST, LOOP STARTS AT 2ND DEV#
FOR J=DE$WC[0] STEP DE$WC[0]
WHILE J LQ LDES
DO # LOOP UNTIL END OF TERMINAL ENTRY #
BEGIN
CALLITR; # JUGGLE POINTERS AND ISSUE CNF/TE/N #
P<DEVNTRY> = P<DEVNTRY> + DE$WC[0]; # NXT DEV NTRY #
END
END
IF PREVDEV NQ 0
THEN
# THERE IS AT LEAST ONE DEVICE TO CONFIGURE ON THE TERMINAL, AND #
# THIS IS THE LAST DEVICE TO CONFIGURE ON THE TERMINAL. #
BEGIN
LASTDEV = LASTERM; # MAYBE LAST DEVICE ON LINE, MAYBE NOT #
CALLITR; # JUGGLE POINTERS AND ISSUE CNF/TE/N #
END
END # CSTSCD #
TERM