XUTMTR1 ;SEA/RDS - TaskMan: ToolKit, Report 1 (Status) ;05/26/98 16:41 [ 04/02/2003 8:29 AM ]
;;8.0;KERNEL;**1002,1003,1004,1005,1007**;APR 1, 2003
;;8.0;KERNEL;**86**;Jul 10, 1995
;
TASK ;Lookup Task File Data
L +^%ZTSK(XUTMT) I $D(^%ZTSCH("TASK",XUTMT)),$D(^(XUTMT,0))[0 W !,"Task # ",XUTMT," is currently running, but its record has been deleted." G T4
I '$D(^%ZTSK(XUTMT)) W !,"Task # ",XUTMT," does not exist." G NOPE
I $D(^%ZTSK(XUTMT,0))[0 W !,"Task # ",XUTMT," does exist, but is missing critical data." G NOPE
T4 S ZTSK=XUTMT,XUTSK(0)=$S($D(^%ZTSK(ZTSK,0))#2:^(0),1:""),XUTSK(.1)=$S($D(^(.1))#2:^(.1),1:""),XUTSK(.2)=$S($D(^(.2))#2:^(.2),1:""),XUTSK(.26)=$S($D(^(.26))#2:^(.26),1:"")
N %,%D,%H,%M,%Y,%ZTT,X,Y,ZT,ZT1,ZT2,ZT3,ZTC
;
SCHED ;Lookup Task In Schedule File
S ZT1="" F ZT=0:0 S ZT1=$O(^%ZTSCH(ZT1)) Q:'ZT1 I $D(^%ZTSCH(ZT1,ZTSK))#2 S XUTSK("A",ZT1,ZTSK)="",ZT2=^(ZTSK) I ZT2]"" S $P(XUTSK(.2),U)=ZT2
S ZT1="" F ZT=0:0 S ZT1=$O(^%ZTSCH("IO",ZT1)),ZT2="" Q:ZT1="" F ZT=0:0 S ZT2=$O(^%ZTSCH("IO",ZT1,ZT2)) Q:ZT2="" S:$D(^(ZT2,ZTSK))#2 XUTSK("IO",ZT1,ZT2,ZTSK)=""
S ZT1="" F ZT=0:0 S ZT1=$O(^%ZTSCH("JOB",ZT1)) Q:ZT1="" S:$D(^(ZT1,ZTSK))#2 XUTSK("JOB",ZT1,ZTSK)=""
S ZT1="" F ZT=0:0 S ZT1=$O(^%ZTSCH("LINK",ZT1)),ZT2="" Q:ZT1="" F ZT=0:0 S ZT2=$O(^%ZTSCH("LINK",ZT1,ZT2)) Q:ZT2="" S:$D(^(ZT2,ZTSK))#2 XUTSK("LINK",ZT1,ZT2,ZTSK)=""
S:$D(^%ZTSCH("TASK",ZTSK))#2 XUTSK("TASK",ZTSK)=^(ZTSK)
L -^%ZTSK(XUTMT)
;
STATUS ;Determine Status According To Lookup Data
S ZTC=0
I $D(XUTSK("A")) S ZT1="" F ZT=0:0 S ZT1=$O(XUTSK("A",ZT1)) Q:ZT1="" S XUTSK(.15,ZTC)="Scheduled to start "_$$TIME^XUTMTP(ZT1),ZTC=ZTC+1
I XUTSK(.26)]"" S XUTSK(.15,ZTC)="Waiting for hunt group"_$S(XUTSK(.26)[",":"s ",1:" ")_XUTSK(.26)_".",ZTC=ZTC+1
I XUTSK(.26)="",$D(XUTSK("IO")) S ZT1="" F ZT=0:0 S ZT1=$O(XUTSK("IO",ZT1)) Q:ZT1="" S XUTSK(.15,ZTC)="Waiting for device "_ZT1_".",ZTC=ZTC+1 D IOQ
I $D(XUTSK("JOB")) S XUTSK(.15,ZTC)="Waiting for a submanager.",ZTC=ZTC+1 D JL
I $D(XUTSK("LINK")) S ZT1="" F ZT=0:0 S ZT1=$O(XUTSK("LINK",ZT1)) Q:ZT1="" S XUTSK(.15,ZTC)="Waiting for the link to "_ZT1_" to be restored.",ZTC=ZTC+1 D LL
I $D(XUTSK("TASK")) S XUTSK(.15,ZTC)="Currently running.",ZTC=ZTC+1
I $O(XUTSK(.3))="",$D(XUTSK(.1))#2,$P(XUTSK(.1),U)]"" X "S X=""TRAP^XUTMTP0"",@^%ZOSF(""TRAP"") D @($P(XUTSK(.1),U)_""^XUTMTP0"")" S X="",@^%ZOSF("TRAP"),ZTC=ZTC+1
;
REPORT ;Report Status And Quit
F ZT=0:1:ZTC-1 W !,XUTSK(.15,ZT)
K XUTMT Q
;
A ;STATUS--determine position of late task in Schedule List
N ZTP
Q
;
IOQ ;STATUS--determine position in Device Waiting List
N ZTP
S ZTP=0,ZT2="" F ZT=0:0 S ZT2=$O(^%ZTSCH("IO",ZT1,ZT2)),ZT3="" Q:ZT2="" F ZT=0:0 S ZT3=$O(^%ZTSCH("IO",ZT1,ZT2,ZT3)) Q:ZT3="" S ZTP=ZTP+1 I ZT3=ZTSK G I1
I1 S XUTSK(.15,ZTC)=" "_(ZTP-1)_" task"_$S(ZTP=2:"",1:"s")_" ahead of this one.",ZTC=ZTC+1
Q
;
JL ;STATUS--determine position in Job List
N ZTP
S ZTP=0,ZT1="" F ZT=0:0 S ZT1=$O(^%ZTSCH("JOB",ZT1)),ZT2="" Q:ZT1="" F ZT=0:0 S ZT2=$O(^%ZTSCH("JOB",ZT1,ZT2)) Q:ZT2="" S ZTP=ZTP+1 I ZT2=ZTSK G J1
J1 S XUTSK(.15,ZTC)=" "_(ZTP-1)_" task"_$S(ZTP=2:"",1:"s")_" ahead of this one.",ZTC=ZTC+1
Q
;
LL ;STATUS--determine position in Link Waiting List
N ZTP
S ZTP=0,ZT2="" F ZT=0:0 S ZT2=$O(^%ZTSCH("LINK",ZT1,ZT2)),ZT3="" Q:ZT2="" F ZT=0:0 S ZT3=$O(^%ZTSCH("LINK",ZT1,ZT2,ZT3)) Q:ZT3="" S ZTP=ZTP+1 I ZT3=ZTSK G L1
L1 S XUTSK(.15,ZTC)=" "_(ZTP-1)_" task"_$S(ZTP=2:"",1:"s")_" ahead of this one.",ZTC=ZTC+1
Q
;
NOPE L -^%ZTSK(XUTMT) K XUTMT
Q
XUTMTR1 ;SEA/RDS - TaskMan: ToolKit, Report 1 (Status) ;05/26/98 16:41 [ 04/02/2003 8:29 AM ]
+1 ;;8.0;KERNEL;**1002,1003,1004,1005,1007**;APR 1, 2003
+2 ;;8.0;KERNEL;**86**;Jul 10, 1995
+3 ;
TASK ;Lookup Task File Data
+1 LOCK +^%ZTSK(XUTMT)
IF $DATA(^%ZTSCH("TASK",XUTMT))
IF $DATA(^(XUTMT,0))[0
WRITE !,"Task # ",XUTMT," is currently running, but its record has been deleted."
GOTO T4
+2 IF '$DATA(^%ZTSK(XUTMT))
WRITE !,"Task # ",XUTMT," does not exist."
GOTO NOPE
+3 IF $DATA(^%ZTSK(XUTMT,0))[0
WRITE !,"Task # ",XUTMT," does exist, but is missing critical data."
GOTO NOPE
T4 SET ZTSK=XUTMT
SET XUTSK(0)=$SELECT($DATA(^%ZTSK(ZTSK,0))#2:^(0),1:"")
SET XUTSK(.1)=$SELECT($DATA(^(.1))#2:^(.1),1:"")
SET XUTSK(.2)=$SELECT($DATA(^(.2))#2:^(.2),1:"")
SET XUTSK(.26)=$SELECT($DATA(^(.26))#2:^(.26),1:"")
+1 NEW %,%D,%H,%M,%Y,%ZTT,X,Y,ZT,ZT1,ZT2,ZT3,ZTC
+2 ;
SCHED ;Lookup Task In Schedule File
+1 SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(^%ZTSCH(ZT1))
IF 'ZT1
QUIT
IF $DATA(^%ZTSCH(ZT1,ZTSK))#2
SET XUTSK("A",ZT1,ZTSK)=""
SET ZT2=^(ZTSK)
IF ZT2]""
SET $PIECE(XUTSK(.2),U)=ZT2
+2 SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(^%ZTSCH("IO",ZT1))
SET ZT2=""
IF ZT1=""
QUIT
FOR ZT=0:0
SET ZT2=$ORDER(^%ZTSCH("IO",ZT1,ZT2))
IF ZT2=""
QUIT
IF $DATA(^(ZT2,ZTSK))#2
SET XUTSK("IO",ZT1,ZT2,ZTSK)=""
+3 SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(^%ZTSCH("JOB",ZT1))
IF ZT1=""
QUIT
IF $DATA(^(ZT1,ZTSK))#2
SET XUTSK("JOB",ZT1,ZTSK)=""
+4 SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(^%ZTSCH("LINK",ZT1))
SET ZT2=""
IF ZT1=""
QUIT
FOR ZT=0:0
SET ZT2=$ORDER(^%ZTSCH("LINK",ZT1,ZT2))
IF ZT2=""
QUIT
IF $DATA(^(ZT2,ZTSK))#2
SET XUTSK("LINK",ZT1,ZT2,ZTSK)=""
+5 IF $DATA(^%ZTSCH("TASK",ZTSK))#2
SET XUTSK("TASK",ZTSK)=^(ZTSK)
+6 LOCK -^%ZTSK(XUTMT)
+7 ;
STATUS ;Determine Status According To Lookup Data
+1 SET ZTC=0
+2 IF $DATA(XUTSK("A"))
SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(XUTSK("A",ZT1))
IF ZT1=""
QUIT
SET XUTSK(.15,ZTC)="Scheduled to start "_$$TIME^XUTMTP(ZT1)
SET ZTC=ZTC+1
+3 IF XUTSK(.26)]""
SET XUTSK(.15,ZTC)="Waiting for hunt group"_$SELECT(XUTSK(.26)[",":"s ",1:" ")_XUTSK(.26)_"."
SET ZTC=ZTC+1
+4 IF XUTSK(.26)=""
IF $DATA(XUTSK("IO"))
SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(XUTSK("IO",ZT1))
IF ZT1=""
QUIT
SET XUTSK(.15,ZTC)="Waiting for device "_ZT1_"."
SET ZTC=ZTC+1
DO IOQ
+5 IF $DATA(XUTSK("JOB"))
SET XUTSK(.15,ZTC)="Waiting for a submanager."
SET ZTC=ZTC+1
DO JL
+6 IF $DATA(XUTSK("LINK"))
SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(XUTSK("LINK",ZT1))
IF ZT1=""
QUIT
SET XUTSK(.15,ZTC)="Waiting for the link to "_ZT1_" to be restored."
SET ZTC=ZTC+1
DO LL
+7 IF $DATA(XUTSK("TASK"))
SET XUTSK(.15,ZTC)="Currently running."
SET ZTC=ZTC+1
+8 IF $ORDER(XUTSK(.3))=""
IF $DATA(XUTSK(.1))#2
IF $PIECE(XUTSK(.1),U)]""
XECUTE "S X=""TRAP^XUTMTP0"",@^%ZOSF(""TRAP"") D @($P(XUTSK(.1),U)_""^XUTMTP0"")"
SET X=""
SET @^%ZOSF("TRAP")
SET ZTC=ZTC+1
+9 ;
REPORT ;Report Status And Quit
+1 FOR ZT=0:1:ZTC-1
WRITE !,XUTSK(.15,ZT)
+2 KILL XUTMT
QUIT
+3 ;
A ;STATUS--determine position of late task in Schedule List
+1 NEW ZTP
+2 QUIT
+3 ;
IOQ ;STATUS--determine position in Device Waiting List
+1 NEW ZTP
+2 SET ZTP=0
SET ZT2=""
FOR ZT=0:0
SET ZT2=$ORDER(^%ZTSCH("IO",ZT1,ZT2))
SET ZT3=""
IF ZT2=""
QUIT
FOR ZT=0:0
SET ZT3=$ORDER(^%ZTSCH("IO",ZT1,ZT2,ZT3))
IF ZT3=""
QUIT
SET ZTP=ZTP+1
IF ZT3=ZTSK
GOTO I1
I1 SET XUTSK(.15,ZTC)=" "_(ZTP-1)_" task"_$SELECT(ZTP=2:"",1:"s")_" ahead of this one."
SET ZTC=ZTC+1
+1 QUIT
+2 ;
JL ;STATUS--determine position in Job List
+1 NEW ZTP
+2 SET ZTP=0
SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(^%ZTSCH("JOB",ZT1))
SET ZT2=""
IF ZT1=""
QUIT
FOR ZT=0:0
SET ZT2=$ORDER(^%ZTSCH("JOB",ZT1,ZT2))
IF ZT2=""
QUIT
SET ZTP=ZTP+1
IF ZT2=ZTSK
GOTO J1
J1 SET XUTSK(.15,ZTC)=" "_(ZTP-1)_" task"_$SELECT(ZTP=2:"",1:"s")_" ahead of this one."
SET ZTC=ZTC+1
+1 QUIT
+2 ;
LL ;STATUS--determine position in Link Waiting List
+1 NEW ZTP
+2 SET ZTP=0
SET ZT2=""
FOR ZT=0:0
SET ZT2=$ORDER(^%ZTSCH("LINK",ZT1,ZT2))
SET ZT3=""
IF ZT2=""
QUIT
FOR ZT=0:0
SET ZT3=$ORDER(^%ZTSCH("LINK",ZT1,ZT2,ZT3))
IF ZT3=""
QUIT
SET ZTP=ZTP+1
IF ZT3=ZTSK
GOTO L1
L1 SET XUTSK(.15,ZTC)=" "_(ZTP-1)_" task"_$SELECT(ZTP=2:"",1:"s")_" ahead of this one."
SET ZTC=ZTC+1
+1 QUIT
+2 ;
NOPE LOCK -^%ZTSK(XUTMT)
KILL XUTMT
+1 QUIT