*DECK NVFTCCT USETEXT TEXTNVF USETEXT TEXTSS PROC NVFTCCT((PT),(CTYP),CNTIME,CNTYP); # TITLE NVFTCCT - CALCULATE APPLICATION CONNECT TIME # BEGIN # NVFTCCT # # ** NVFTCCT - CALCULATE APPLICATION CONNECT TIME. * * E. THAVIKULWAT 81/10/27 * C. BRION 83/02/15 * * THIS PROCEDURE CALCULATES THE APPLICATION CONNECT TIME. IT IS * CALLED INTO EXECUTION BY THE FOLLOWING PROCEDURES: * *NVFTIAM* *NVFTRVD* * * PROC NVFTCCT((PT),(CTYPE),CNTIME) * * ENTRY: * PT = POINTER TO PTAC OR PAAC ENTRY * CTYP = 0 IF NO CONNECT TIME MESSAGE FORMATTING (I.E., XXXXXX) * 1 IF CONNECT TIME MESSAGE FORMATTING (I.E., HH.MM.SS) * CNTYP = TYPE INDICATOR FOR EITHER T-A OR A-A SERVICE. * * EXIT: * CNTIME = APPLICATION CONNECT TIME IN DISPLAY CODE, LEFT * JUSTIFIED WITH BLANK FILLED. * * NOTES: * 1) IF THE APPLICATION CONNECT TIME SPANS FEBRUARY 28 TO MARCH 1 * IN A LEAP YEAR, THE TIME CALCULATED IS 1 DAY SHORT. * 2) MINIMUM CONNECT TIME IS 1 SECOND AND MAXIMUM CONNECT TIME IS * 999999 SECONDS (APPROXIMATELY 12 DAYS) IF NO FORMATTING (AEAP * ACCOUNT MESSAGE) OR 99.59.59 IF FORMATTING. * * METHOD: * CALCULATE NUMBER OF MONTH(S) AND DAY(S) CONNECTED. IF MORE THAN * ONE MONTH, SET NUMBER OF DAYS CONNECTED TO THE MAXIMUM (12). IF * CONNECT TIME IS MORE THAN ONE DAY, ADD NUMBER OF SECONDS PER DAY * MULTIPLIED BY NUMBER OF DAYS TO THE CURRENT TIME TO ARRIVE AT * THE REAL CURRENT TIME. DETERMINE TOTAL CONNECT TIME BY TAKING * THE DIFFERENCE BETWEEN CURRENT TIME AND SWITCH TIME. CALL MACRE * ROUTINE *XCDD* TO CONVERT THE TIME IN SECONDS TO DISPLAY CODE. # # **** PROC NVFTCCT - XREF LIST. # XREF BEGIN FUNC XCDD C(10); # CONVERT INTEGER TO DECIMAL DISPLAY CODE # END # **** # DEF MXDAYS$ #12#; # MAXIMUM NUMBER OF CONNECT DAYS # ITEM CNTIME C(10); # APPLICATION CONNECT TIME # ITEM CTEMP C(10); # TEMPORARY VARIABLE FOR CHARACTERS # ITEM CTYP I; # CONNECT TIME TYPE - FORMAT/UNFORMAT # ITEM CURDAY I; # CURRENT DAY # ITEM CURMONTH I; # CURRENT MONTH # ITEM CURTIME I; # CURRENT TIME IN SECONDS # ITEM DAYDIFF I; # NUMBER OF DAYS CONNECTED # ITEM ENDSRCH B; # EXIT LOOP VARIABLE # ITEM I I; # LOOP VARIABLE # ITEM MNBITMAP I = O"2532 4000 0000 0000 0000"; # 0=28/30,1=31 # ITEM MONDIFF I; # NUMBER OF MONTHS CONNECTED # ITEM PT I; # SUBSCRIPT FOR ARRAY PTAC # ITEM SWTDAY I; # APPLICATION SWITCH DAY # ITEM SWTMONTH I; # APPLICATION SWITCH MONTH # ITEM SWTTIME I; # APPLICATION SWITCH TIME IN SECONDS # ITEM TEMPTIM I; # TEMPORARY VARIABLE FOR TIME # ITEM TIMDIFF I; # NUMBER OF SECONDS CONNECTED # ITEM CNTYP I; # TYPE OF CONNECTION # # * FOLLOWING ARRAY DEFINES THE MAXIMUM APPLICATION CONNECT TIMES. * 999999 SECS = MAXIMUM UNFORMATTED CONNECT TIME. * 359999 SECS = 99.59.59 HH.MM.SS MAXIMUM FORMATTED CONNECT TIME. # ARRAY MAXTIME[00:01] S(1); BEGIN ITEM MXT$TIME I(00,00,60) = [999999,359999]; END # * FOLLOWING ARRAY DEFINES NUMBER OF SECONDS PER HOUR, MINUTE, AND * SECONDS. # ARRAY NUMSECS[00:02] S(1); BEGIN ITEM NSC$SECS I(00,00,60) = [3600,60,1]; END # * FETCH CURRENT MONTH, CURRENT DAY, SWITCH MONTH, AND SWITCH DAY. * CONVERT CURRENT TIME AND SWITCH TIME TO SECONDS. # CURMONTH = B<6,6>CTM$PDATE[0]; CURDAY = B<12,6>CTM$PDATE[0]; CURTIME = B<0,6>CTM$PCLK[0] * 60; # CONVERT HOURS TO MINUTES # CURTIME = (CURTIME + B<6,6>CTM$PCLK[0]) * 60; # MINS TO SECNDS # CURTIME = CURTIME + B<12,6>CTM$PCLK[0]; # TOTAL NUM OF SECONDS # # * SET THE SWITCH VARIABLES FROM EITHER THE PAAC OR PTAC DEPENDING * ON THE PASSED CONNECTION TYPE. # IF CNTYP EQ TATIME$ THEN BEGIN SWTMONTH = B<0,6>PTA$SWTIME[PT]; SWTDAY = B<6,6>PTA$SWTIME[PT]; SWTTIME = B<12,6>PTA$SWTIME[PT] * 60; # HOURS TO MINUTES # SWTTIME = (SWTTIME + B<18,6>PTA$SWTIME[PT]) * 60; # MNS TO SEC # SWTTIME = SWTTIME + B<24,6>PTA$SWTIME[PT]; # TOTAL NUM OF SECS # END ELSE IF (CNTYP EQ AATIME$) THEN BEGIN # A-A CONNECTION TYPE # SWTMONTH = B<0,6>PA$SWTIME[PT]; SWTDAY = B<6,6>PA$SWTIME[PT]; SWTTIME = B<12,6>PA$SWTIME[PT] * 60; # HRS TO MIN # SWTTIME = (SWTTIME + B<18,6>PA$SWTIME[PT]); SWTTIME = SWTTIME + B<24,6>PA$SWTIME[PT]; END ELSE BEGIN # TERMINAL SESSION CONNECTION TYPE # SWTMONTH = B<0,6>PTA$CNTIME[PT]; SWTDAY = B<6,6>PTA$CNTIME[PT]; SWTTIME = B<12,6>PTA$CNTIME[PT]*60; # HRS TO MINS # SWTTIME = (SWTTIME+B<18,6>PTA$CNTIME[PT])*60; # MINS TO SECS # SWTTIME = SWTTIME+B<24,6>PTA$CNTIME[PT]; END # * CALCULATE NUMBER OF MONTH(S) CONNECTED. IF CURRENT MONTH LESS * THAN SWITCH MONTH, THEN YEAR BOUNDARY WAS CROSSED AND ACTUAL * NUMBER OF MONTHS IS ARRIVED AT BY ADDING 12 TO THE DIFFERENCE. # MONDIFF = CURMONTH - SWTMONTH; IF (MONDIFF LS 0) THEN # CROSSED YEAR BOUNDARY # BEGIN MONDIFF = MONDIFF + 12; END # * CALCULATE NUMBER OF DAY(S) CONNECTED. IF CURRENT DAY IS LESS * THAN SWITCH DAY, THAN MONTH BOUNDARY WAS CROSSED AND MONTH * DIFFERENCE IS 1 LESS. IF MONTH BOUNDARY WAS CROSSED AND MONTH * CONNECTED IS LESS THAN 1, ACTUAL NUMBER OF DAYS IS ARRIVED AT BY * ADDING 28/30/31 (DEPENDING ON SWITCH MONTH) TO THE DIFFERENCE. # DAYDIFF = CURDAY - SWTDAY; IF (DAYDIFF LS 0) THEN # CROSSED MONTH BOUNDARY"# BEGIN MONDIFF = MONDIFF - 1; IF (MONDIFF EQ 0) THEN # LESS THAN 1 MONTH # BEGIN DAYDIFF = DAYDIFF + BMNBITMAP + 30; # ADD 30/31 # IF (SWTMONTH EQ 2) THEN # SWITCH MONTH IS FEBRUARY # BEGIN DAYDIFF = DAYDIFF - 2; # 28 DAYS FOR FEBRUARY # END END END # * IF CONNECTED FOR ONE OR MORE MONTHS, SET NUMBER OF DAYS CONNECTED * TO THE MAXIMUM (12 DAYS). # IF (MONDIFF NQ 0) THEN # MORE THAN 1 MONTH # BEGIN DAYDIFF = MXDAYS$; # MAXIMUM NUMBER OF DAYS # END # * CALCULATE TOTAL CONNECT TIME. # IF (DAYDIFF NQ 0) THEN # CONNECTED FOR MORE THAN 1 DAY # BEGIN CURTIME = CURTIME + (DAYDIFF * (24 * 3600)); # ACTUAL CURTIME # END TIMDIFF = CURTIME - SWTTIME; IF (TIMDIFF LQ 0) THEN # LESS THAN ONE SECOND # BEGIN TIMDIFF = 1; # SET TO MINIMUM CONNECT TIME # END ELSE # ONE SECOND OR MORE # BEGIN IF (TIMDIFF GR MXT$TIME[CTYP]) THEN # GREATER THAN MAXIMUM ALLOWED # BEGIN TIMDIFF = MXT$TIME[CTYP]; # SET TO MAXIMUM TIME ALLOWED # END END # * CONVERT TOTAL CONNECT TIME TO THE REQUESTED FORMAT IN DISPLAY * CODE. # IF (CTYP EQ 0) THEN # NO MESSAGE FORMATTING # BEGIN CTEMP = XCDD(TIMDIFF); # CONVERT TO DISPLAY CODE # ENDSRCH = FALSE; FOR I = 0 STEP 1 WHILE (NOT ENDSRCH AND I LS 10) DO BEGIN IF (CCTEMP NQ " ") THEN # FOUND NON-BLANK CHARACTER # BEGIN CNTIME = CCTEMP; # LEFT JUSTIFIED, BLANK FILLED # ENDSRCH = TRUE; # EXIT LOOP # END END END ELSE # MESSAGE FORMATTING REQUIRED # BEGIN CNTIME = " "; # BLANK FILL # FOR I = 0 STEP 1 UNTIL 2 DO BEGIN # CONVERT SECS TO HH.MM.SS # TEMPTIM = TIMDIFF / NSC$SECS[I]; TIMDIFF = TIMDIFF - (TEMPTIM * NSC$SECS[I]); TEMPTIM = TEMPTIM + 100; # ENSURE LEADING ZERO # CTEMP = XCDD(TEMPTIM); CCNTIME = C<8,2>CTEMP; END C<2,1>CNTIME = "."; C<5,1>CNTIME = "."; END END # END NVFTCCT # TERM