INHOQR1 ; FRW/JMB ; 24 Aug 95 14:18; Show GIS queue status - cont.
;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
;COPYRIGHT 1991-2000 SAIC
;
EN ;Main entry point
G EN^INHOQR
Q
;
ENZTSK ;Taskman entry point
;New Statements
N BP,BPC,BP0,COUNT,CUR,D,DATA,DATE,DTOUT,DTSAR,DTSOP,EXIT,FMT,GL,H,HDR
N INDEST,INEXIT,INITER,INQ,INQUEUE,INRUN,INRUNASC
N IN0,INDAT,INRUNAVG,INTOTAL,LOOP,M,NAME,NODE,OC,P,PAGE,S,X
N SAR,SEC,SEOV,SESAR,SESARTOT,SESOP,SESOPTOT,SOP,STAT,T,TAB,TOT
;
;Initialize report variables
S INEXIT=0,INPAR("START")=$H,INITER=0 H 1
S INPAR("MSGSTART")=$P(^INTHU(0),U,3),INPAR("TSKSTART")=$P(^INLHFTSK(0),U,3)
;Initialize TABs
S TAB(0)=34,TAB(1)=44,TAB(2)=52,TAB(3)=60,TAB(4)=68
;Intialize data array
D INIARR^INHOQR
;Display message
W:'INTASKED !!,"Compiling ..."
;
ENRPT ;Repeat entry point
;
;Init scan variables
S INTOTAL=0,INQUEUE=0,INITER=INITER+1
S (INPAR("REPSTART"),INPAR("QSTART"))=$H
;Init queue count by priority for next scan
D IND^INHOQR2
;Format controller
G:'$$QUEUE("^INLHFTSK(""AH"")",$P(^INTHPC(2,0),U),1) EXIT
;Output Controller
G:'$$QUEUE("^INLHSCH",$P(^INTHPC(1,0),U),2) EXIT
;Destination queues
S BPC=0
F S BPC=$O(INDEST(BPC)) Q:'BPC!INEXIT Q:'$$QUEUE(U_$P(INDEST(BPC),U,2),$P(INDEST(BPC),U),BPC)
G:INEXIT EXIT
;
;Provide support for totals
D ST1(400,INTOTAL,"Queue Total")
;
;Provide support for message creation rates
Q:'$$ENTRIES("^INTHU","Messages created per hour",700,"MSGSTART")
;
;Provide support for transaction identification rates
Q:'$$ENTRIES("^INLHFTSK","Transactions identified per hour",750,"TSKSTART")
;
;Repeat display for terminals, one time for printers
D:'INTASKED DISP^INHOQR2
;Check for end of tasked report
I INTASKED,INITER'<INPAR("ITER") D DISP^INHOQR2 G EXIT
;
;hang until next recalc
G:$$QUIT EXIT
F X=1:1:INPAR("REPAINT") Q:$$QUIT!INEXIT H 1
G:INEXIT EXIT
G ENRPT
Q
;
QUEUE(GL,Q,INQUEUE) ;Determine entries in queue
;INPUT:
; GL - location (global) of queue
; queue in format -> @GL@( priority , time to process , ien )
; Q - name of queue
; INQUEUE - subscript (usually ien) of queue in INDAT array
;OUTPUT:
; function - complete processing ( 0 - no ; 1 - yes )
; updated INDAT array with latest queue size data
; updated INTOTAL with total number of entries in all queues
;
;Intialize variables
S INPAR("QSTART")=$H,OC=0,P=999,STAT=1
F S P=$O(@GL@(P),-1) Q:+P'=P!INEXIT S H="~" F S H=$O(@GL@(P,H),-1) Q:'$L(H)!INEXIT D
. ;Check wether to report tasks in the future
. I +H>+$H,'INPAR("FUTURE") Q
. ;Check wether to report tasks in the future
. I $P(H,",",2)>$P($H,",",2),+H=+$H,'INPAR("FUTURE") Q
. S M=" " F S M=$O(@GL@(P,H,M),-1) Q:'M D I '(OC#1000),$$QUIT S STAT=0
.. S OC=OC+1
.. Q:'INPAR("DETAIL")
.. ;count entries by priority (P) and Time (NST=Non stat or ST=Stat)
.. I H S INDAT(INQUEUE,P,"STN","COUNT")=$G(INDAT(INQUEUE,P,"STN","COUNT"))+1 Q
.. S:'H INDAT(INQUEUE,P,"ST","COUNT")=$G(INDAT(INQUEUE,P,"ST","COUNT"))+1
;Stats with priorities
D:INPAR("DETAIL") ST0(INQUEUE)
;Stats totals
D ST1(INQUEUE,OC,Q)
;Update total queue entries
S INTOTAL=INTOTAL+INDAT(INQUEUE,"COUNT")
Q STAT
;
ENTRIES(GL,NAME,INQ,NODE) ;Get entries created in file / hour
;INPUT:
; GL - location (global) of file
; file in format -> @GL@( ien )
; NAME - name of queue
; INQ - subscript of queue in INDAT array
; NODE - node in INPAR that contains the last entry in the file
; when the report was started
;OUTPUT:
; function - complete processing ( 0 - no ; 1 - yes )
; updated INDAT array with latest queue size data
;
S CUR=$P(@GL@(0),U,3) S:'INPAR(NODE) INPAR(NODE)=CUR
S OC=CUR-INPAR(NODE)/($$TDIF^INHUTS(INPAR("START"))+.00001)*3600\1
D ST1(INQ,OC,NAME)
Q 1
;
ST0(INQ) ;Build Stats - Priority levels
;INPUT:
; INQ = Process Id#
;OUTPUT:
; updated INDAT array with latest queue size sorted by priority
;
N P,T,COUNT
S P=""
F S P=$O(INDAT(INQ,P)) Q:+P'=P S T="" F S T=$O(INDAT(INQ,P,T)) Q:'$L(T) D
.S COUNT=INDAT(INQ,P,T,"COUNT")
.;Minimum
.S:COUNT<$G(INDAT(INQ,P,T,"MIN"))!($G(INDAT(INQ,P,T,"MIN"))="") INDAT(INQ,P,T,"MIN")=COUNT
.;Maximum
.S:COUNT>$G(INDAT(INQ,P,T,"MAX"))!($G(INDAT(INQ,P,T,"MAX"))="") INDAT(INQ,P,T,"MAX")=COUNT
.;Total entries sorted by priority-time (T is either "ST"
.; for STAT or"STN" for Non Stat entries)
.S INDAT(INQ,P,T,"TOTC")=$G(INDAT(INQ,P,T,"TOTC"))+COUNT
.;Current average number of entries by priority-time
.S INDAT(INQ,P,T,"AVG")=INDAT(INQ,P,T,"TOTC")\INITER
Q
;
ST1(INQ,COUNT,NAME) ;Stats - Queue Totals
;INPUT
; INQ
; COUNT
; NAME
;OUTPUT
; INDAT array with total stats
;
;Negative numbers not allowed
S:+$G(COUNT)<0 COUNT=0
;Current count
S INDAT(INQ,"COUNT")=COUNT
;Queue name
S:$L($G(NAME)) INDAT(INQ,"NAME")=NAME
;Minimum
S:INDAT(INQ,"MIN")="" INDAT(INQ,"MIN")=COUNT
S:COUNT<INDAT(INQ,"MIN") INDAT(INQ,"MIN")=COUNT
;Maximum
S:INDAT(INQ,"MAX")="" INDAT(INQ,"MAX")=COUNT
S:COUNT>INDAT(INQ,"MAX") INDAT(INQ,"MAX")=COUNT
;Total entries found in all scans
S INDAT(INQ,"TOTC")=INDAT(INQ,"TOTC")+COUNT
;Current average number of entries of all scans
S INDAT(INQ,"AVG")=INDAT(INQ,"TOTC")\INITER
;
;PROVIDE Support for data array to be used in graphing
Q
;
QUIT() ;Determine if program should quit
;INPUT:
; INEXIT - quit flag
;OUTPUT:
; INEXIT - quit flag
; function - 1 - time to exit ; 0 - continue
;
;Quit If:
;report time calculation takes too long
I 'INPAR("RUNTOEND"),$$TDIF^INHUTS(INPAR("REPSTART"))>INPAR("MAXREPTIME") S INEXIT=1 Q INEXIT
;queue time calculation takes too long
I 'INPAR("RUNTOEND"),$$TDIF^INHUTS(INPAR("QSTART"))>INPAR("MAXQTIME") S INEXIT=1 Q INEXIT
;user presses <any key>
I 'INTASKED S INEXIT=$$QUIT^INHUTS
Q INEXIT
;
EXIT ;Primary exit point
;Close device
D ^%ZISC
Q
INHOQR1 ; FRW/JMB ; 24 Aug 95 14:18; Show GIS queue status - cont.
+1 ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
+2 ;COPYRIGHT 1991-2000 SAIC
+3 ;
EN ;Main entry point
+1 GOTO EN^INHOQR
+2 QUIT
+3 ;
ENZTSK ;Taskman entry point
+1 ;New Statements
+2 NEW BP,BPC,BP0,COUNT,CUR,D,DATA,DATE,DTOUT,DTSAR,DTSOP,EXIT,FMT,GL,H,HDR
+3 NEW INDEST,INEXIT,INITER,INQ,INQUEUE,INRUN,INRUNASC
+4 NEW IN0,INDAT,INRUNAVG,INTOTAL,LOOP,M,NAME,NODE,OC,P,PAGE,S,X
+5 NEW SAR,SEC,SEOV,SESAR,SESARTOT,SESOP,SESOPTOT,SOP,STAT,T,TAB,TOT
+6 ;
+7 ;Initialize report variables
+8 SET INEXIT=0
SET INPAR("START")=$HOROLOG
SET INITER=0
HANG 1
+9 SET INPAR("MSGSTART")=$PIECE(^INTHU(0),U,3)
SET INPAR("TSKSTART")=$PIECE(^INLHFTSK(0),U,3)
+10 ;Initialize TABs
+11 SET TAB(0)=34
SET TAB(1)=44
SET TAB(2)=52
SET TAB(3)=60
SET TAB(4)=68
+12 ;Intialize data array
+13 DO INIARR^INHOQR
+14 ;Display message
+15 IF 'INTASKED
WRITE !!,"Compiling ..."
+16 ;
ENRPT ;Repeat entry point
+1 ;
+2 ;Init scan variables
+3 SET INTOTAL=0
SET INQUEUE=0
SET INITER=INITER+1
+4 SET (INPAR("REPSTART"),INPAR("QSTART"))=$HOROLOG
+5 ;Init queue count by priority for next scan
+6 DO IND^INHOQR2
+7 ;Format controller
+8 IF '$$QUEUE("^INLHFTSK(""AH"")",$PIECE(^INTHPC(2,0),U),1)
GOTO EXIT
+9 ;Output Controller
+10 IF '$$QUEUE("^INLHSCH",$PIECE(^INTHPC(1,0),U),2)
GOTO EXIT
+11 ;Destination queues
+12 SET BPC=0
+13 FOR
SET BPC=$ORDER(INDEST(BPC))
IF 'BPC!INEXIT
QUIT
IF '$$QUEUE(U_$PIECE(INDEST(BPC),U,2),$PIECE(INDEST(BPC),U),BPC)
QUIT
+14 IF INEXIT
GOTO EXIT
+15 ;
+16 ;Provide support for totals
+17 DO ST1(400,INTOTAL,"Queue Total")
+18 ;
+19 ;Provide support for message creation rates
+20 IF '$$ENTRIES("^INTHU","Messages created per hour",700,"MSGSTART")
QUIT
+21 ;
+22 ;Provide support for transaction identification rates
+23 IF '$$ENTRIES("^INLHFTSK","Transactions identified per hour",750,"TSKSTART")
QUIT
+24 ;
+25 ;Repeat display for terminals, one time for printers
+26 IF 'INTASKED
DO DISP^INHOQR2
+27 ;Check for end of tasked report
+28 IF INTASKED
IF INITER'<INPAR("ITER")
DO DISP^INHOQR2
GOTO EXIT
+29 ;
+30 ;hang until next recalc
+31 IF $$QUIT
GOTO EXIT
+32 FOR X=1:1:INPAR("REPAINT")
IF $$QUIT!INEXIT
QUIT
HANG 1
+33 IF INEXIT
GOTO EXIT
+34 GOTO ENRPT
+35 QUIT
+36 ;
QUEUE(GL,Q,INQUEUE) ;Determine entries in queue
+1 ;INPUT:
+2 ; GL - location (global) of queue
+3 ; queue in format -> @GL@( priority , time to process , ien )
+4 ; Q - name of queue
+5 ; INQUEUE - subscript (usually ien) of queue in INDAT array
+6 ;OUTPUT:
+7 ; function - complete processing ( 0 - no ; 1 - yes )
+8 ; updated INDAT array with latest queue size data
+9 ; updated INTOTAL with total number of entries in all queues
+10 ;
+11 ;Intialize variables
+12 SET INPAR("QSTART")=$HOROLOG
SET OC=0
SET P=999
SET STAT=1
+13 FOR
SET P=$ORDER(@GL@(P),-1)
IF +P'=P!INEXIT
QUIT
SET H="~"
FOR
SET H=$ORDER(@GL@(P,H),-1)
IF '$LENGTH(H)!INEXIT
QUIT
Begin DoDot:1
+14 ;Check wether to report tasks in the future
+15 IF +H>+$HOROLOG
IF 'INPAR("FUTURE")
QUIT
+16 ;Check wether to report tasks in the future
+17 IF $PIECE(H,",",2)>$PIECE($HOROLOG,",",2)
IF +H=+$HOROLOG
IF 'INPAR("FUTURE")
QUIT
+18 SET M=" "
FOR
SET M=$ORDER(@GL@(P,H,M),-1)
IF 'M
QUIT
Begin DoDot:2
+19 SET OC=OC+1
+20 IF 'INPAR("DETAIL")
QUIT
+21 ;count entries by priority (P) and Time (NST=Non stat or ST=Stat)
+22 IF H
SET INDAT(INQUEUE,P,"STN","COUNT")=$GET(INDAT(INQUEUE,P,"STN","COUNT"))+1
QUIT
+23 IF 'H
SET INDAT(INQUEUE,P,"ST","COUNT")=$GET(INDAT(INQUEUE,P,"ST","COUNT"))+1
End DoDot:2
IF '(OC#1000)
IF $$QUIT
SET STAT=0
End DoDot:1
+24 ;Stats with priorities
+25 IF INPAR("DETAIL")
DO ST0(INQUEUE)
+26 ;Stats totals
+27 DO ST1(INQUEUE,OC,Q)
+28 ;Update total queue entries
+29 SET INTOTAL=INTOTAL+INDAT(INQUEUE,"COUNT")
+30 QUIT STAT
+31 ;
ENTRIES(GL,NAME,INQ,NODE) ;Get entries created in file / hour
+1 ;INPUT:
+2 ; GL - location (global) of file
+3 ; file in format -> @GL@( ien )
+4 ; NAME - name of queue
+5 ; INQ - subscript of queue in INDAT array
+6 ; NODE - node in INPAR that contains the last entry in the file
+7 ; when the report was started
+8 ;OUTPUT:
+9 ; function - complete processing ( 0 - no ; 1 - yes )
+10 ; updated INDAT array with latest queue size data
+11 ;
+12 SET CUR=$PIECE(@GL@(0),U,3)
IF 'INPAR(NODE)
SET INPAR(NODE)=CUR
+13 SET OC=CUR-INPAR(NODE)/($$TDIF^INHUTS(INPAR("START"))+.00001)*3600\1
+14 DO ST1(INQ,OC,NAME)
+15 QUIT 1
+16 ;
ST0(INQ) ;Build Stats - Priority levels
+1 ;INPUT:
+2 ; INQ = Process Id#
+3 ;OUTPUT:
+4 ; updated INDAT array with latest queue size sorted by priority
+5 ;
+6 NEW P,T,COUNT
+7 SET P=""
+8 FOR
SET P=$ORDER(INDAT(INQ,P))
IF +P'=P
QUIT
SET T=""
FOR
SET T=$ORDER(INDAT(INQ,P,T))
IF '$LENGTH(T)
QUIT
Begin DoDot:1
+9 SET COUNT=INDAT(INQ,P,T,"COUNT")
+10 ;Minimum
+11 IF COUNT<$GET(INDAT(INQ,P,T,"MIN"))!($GET(INDAT(INQ,P,T,"MIN"))="")
SET INDAT(INQ,P,T,"MIN")=COUNT
+12 ;Maximum
+13 IF COUNT>$GET(INDAT(INQ,P,T,"MAX"))!($GET(INDAT(INQ,P,T,"MAX"))="")
SET INDAT(INQ,P,T,"MAX")=COUNT
+14 ;Total entries sorted by priority-time (T is either "ST"
+15 ; for STAT or"STN" for Non Stat entries)
+16 SET INDAT(INQ,P,T,"TOTC")=$GET(INDAT(INQ,P,T,"TOTC"))+COUNT
+17 ;Current average number of entries by priority-time
+18 SET INDAT(INQ,P,T,"AVG")=INDAT(INQ,P,T,"TOTC")\INITER
End DoDot:1
+19 QUIT
+20 ;
ST1(INQ,COUNT,NAME) ;Stats - Queue Totals
+1 ;INPUT
+2 ; INQ
+3 ; COUNT
+4 ; NAME
+5 ;OUTPUT
+6 ; INDAT array with total stats
+7 ;
+8 ;Negative numbers not allowed
+9 IF +$GET(COUNT)<0
SET COUNT=0
+10 ;Current count
+11 SET INDAT(INQ,"COUNT")=COUNT
+12 ;Queue name
+13 IF $LENGTH($GET(NAME))
SET INDAT(INQ,"NAME")=NAME
+14 ;Minimum
+15 IF INDAT(INQ,"MIN")=""
SET INDAT(INQ,"MIN")=COUNT
+16 IF COUNT<INDAT(INQ,"MIN")
SET INDAT(INQ,"MIN")=COUNT
+17 ;Maximum
+18 IF INDAT(INQ,"MAX")=""
SET INDAT(INQ,"MAX")=COUNT
+19 IF COUNT>INDAT(INQ,"MAX")
SET INDAT(INQ,"MAX")=COUNT
+20 ;Total entries found in all scans
+21 SET INDAT(INQ,"TOTC")=INDAT(INQ,"TOTC")+COUNT
+22 ;Current average number of entries of all scans
+23 SET INDAT(INQ,"AVG")=INDAT(INQ,"TOTC")\INITER
+24 ;
+25 ;PROVIDE Support for data array to be used in graphing
+26 QUIT
+27 ;
QUIT() ;Determine if program should quit
+1 ;INPUT:
+2 ; INEXIT - quit flag
+3 ;OUTPUT:
+4 ; INEXIT - quit flag
+5 ; function - 1 - time to exit ; 0 - continue
+6 ;
+7 ;Quit If:
+8 ;report time calculation takes too long
+9 IF 'INPAR("RUNTOEND")
IF $$TDIF^INHUTS(INPAR("REPSTART"))>INPAR("MAXREPTIME")
SET INEXIT=1
QUIT INEXIT
+10 ;queue time calculation takes too long
+11 IF 'INPAR("RUNTOEND")
IF $$TDIF^INHUTS(INPAR("QSTART"))>INPAR("MAXQTIME")
SET INEXIT=1
QUIT INEXIT
+12 ;user presses <any key>
+13 IF 'INTASKED
SET INEXIT=$$QUIT^INHUTS
+14 QUIT INEXIT
+15 ;
EXIT ;Primary exit point
+1 ;Close device
+2 DO ^%ZISC
+3 QUIT