%ZTMS7 ;SEA/RDS-TaskMan: Submanager, (GetNext) ;10 Feb 2003 3:17 pm
;;8.0;KERNEL;**1,118,127,136,275**;Jul 10, 1995;
;
GETNEXT ;PROCESS--search Device Waiting List for next task waiting for %ZTIO
;check stop node, and claim ownership of Device Waiting List
S %ZTIME=$$H3^%ZTM($H)
I $D(^%ZTSCH("STOP","SUB",ZTPAIR)) S ZTQUIT=1 G DEALOC8
I $D(^%ZTSCH("WAIT","SUB")) G DEALOC8
I $O(^%ZTSCH("IO",%ZTIO,0))<1 G DEALOC8
S %=$G(^%ZTSCH("IO",%ZTIO))
I %'["RES" S X=$$DEVLK^%ZTMS1(1,%ZTIO,3) D:$D(ZTMLOG) LOG("No Lock "_%ZTIO) I 'X G DEALOC8
I %["RES" D ^%ZISC ;If a RES close now so open will update
S ZTDTH=""
;
;look for task
G3 S ZTDTH=$O(^%ZTSCH("IO",%ZTIO,ZTDTH)),ZTSK="" I ZTDTH="" G DEALOC8
G5 S ZTSK=$O(^%ZTSCH("IO",%ZTIO,ZTDTH,ZTSK)) I ZTSK="" G G3
L +^%ZTSK(ZTSK):0 G G5:'$T
I $D(^%ZTSCH("IO",%ZTIO,ZTDTH,ZTSK))[0 L -^%ZTSK(ZTSK) G G5
D DQ^%ZTM4 ;Remove from lists
I $D(^%ZTSK(ZTSK,0))[0!'ZTSK D G G5
. I ZTSK>0,$D(^%ZTSK(ZTSK)) D TSKSTAT("I","Discarded Because Incomplete")
. L -^%ZTSK(ZTSK)
I $L($P($G(^%ZTSK(ZTSK,.1)),U,10)) D G G5
. D TSKSTAT("D","Stopped by User")
. L -^%ZTSK(ZTSK)
S ZTQUEUED=.5
D:$D(ZTMLOG) LOG("Got "_%ZTIO)
Q ;Quit w/ ^%ZTSK(ZTSK) locked
;
DEALOC8 ;GETNEXT--deallocate device, and set ZTNONEXT
D DEVLK^%ZTMS1(-1,%ZTIO)
S IO("C")="",IO("T")=1 D ^%ZISC K IO("T"),IO("C")
S ZTNONEXT=1,%ZTIO=""
L ;Quit w/ all locks clear.
Q
;
LOG(M) ;Log a msg
N % S %=$G(^%ZTSCH("L",$J))+1,^($J)=%
S ^%ZTSCH("L",$J,%)=M_" ^"_$H
Q
TSKSTAT(CODE,MSG) ; Update task's status
S $P(^%ZTSK(ZTSK,.1),U,1,3)=$G(CODE)_U_$H_U_$G(MSG)
Q
%ZTMS7 ;SEA/RDS-TaskMan: Submanager, (GetNext) ;10 Feb 2003 3:17 pm
+1 ;;8.0;KERNEL;**1,118,127,136,275**;Jul 10, 1995;
+2 ;
GETNEXT ;PROCESS--search Device Waiting List for next task waiting for %ZTIO
+1 ;check stop node, and claim ownership of Device Waiting List
+2 SET %ZTIME=$$H3^%ZTM($HOROLOG)
+3 IF $DATA(^%ZTSCH("STOP","SUB",ZTPAIR))
SET ZTQUIT=1
GOTO DEALOC8
+4 IF $DATA(^%ZTSCH("WAIT","SUB"))
GOTO DEALOC8
+5 IF $ORDER(^%ZTSCH("IO",%ZTIO,0))<1
GOTO DEALOC8
+6 SET %=$GET(^%ZTSCH("IO",%ZTIO))
+7 IF %'["RES"
SET X=$$DEVLK^%ZTMS1(1,%ZTIO,3)
IF $DATA(ZTMLOG)
DO LOG("No Lock "_%ZTIO)
IF 'X
GOTO DEALOC8
+8 ;If a RES close now so open will update
IF %["RES"
DO ^%ZISC
+9 SET ZTDTH=""
+10 ;
+11 ;look for task
G3 SET ZTDTH=$ORDER(^%ZTSCH("IO",%ZTIO,ZTDTH))
SET ZTSK=""
IF ZTDTH=""
GOTO DEALOC8
G5 SET ZTSK=$ORDER(^%ZTSCH("IO",%ZTIO,ZTDTH,ZTSK))
IF ZTSK=""
GOTO G3
+1 LOCK +^%ZTSK(ZTSK):0
IF '$TEST
GOTO G5
+2 IF $DATA(^%ZTSCH("IO",%ZTIO,ZTDTH,ZTSK))[0
LOCK -^%ZTSK(ZTSK)
GOTO G5
+3 ;Remove from lists
DO DQ^%ZTM4
+4 IF $DATA(^%ZTSK(ZTSK,0))[0!'ZTSK
Begin DoDot:1
+5 IF ZTSK>0
IF $DATA(^%ZTSK(ZTSK))
DO TSKSTAT("I","Discarded Because Incomplete")
+6 LOCK -^%ZTSK(ZTSK)
End DoDot:1
GOTO G5
+7 IF $LENGTH($PIECE($GET(^%ZTSK(ZTSK,.1)),U,10))
Begin DoDot:1
+8 DO TSKSTAT("D","Stopped by User")
+9 LOCK -^%ZTSK(ZTSK)
End DoDot:1
GOTO G5
+10 SET ZTQUEUED=.5
+11 IF $DATA(ZTMLOG)
DO LOG("Got "_%ZTIO)
+12 ;Quit w/ ^%ZTSK(ZTSK) locked
QUIT
+13 ;
DEALOC8 ;GETNEXT--deallocate device, and set ZTNONEXT
+1 DO DEVLK^%ZTMS1(-1,%ZTIO)
+2 SET IO("C")=""
SET IO("T")=1
DO ^%ZISC
KILL IO("T"),IO("C")
+3 SET ZTNONEXT=1
SET %ZTIO=""
+4 ;Quit w/ all locks clear.
LOCK
+5 QUIT
+6 ;
LOG(M) ;Log a msg
+1 NEW %
SET %=$GET(^%ZTSCH("L",$JOB))+1
SET ^($JOB)=%
+2 SET ^%ZTSCH("L",$JOB,%)=M_" ^"_$HOROLOG
+3 QUIT
TSKSTAT(CODE,MSG) ; Update task's status
+1 SET $PIECE(^%ZTSK(ZTSK,.1),U,1,3)=$GET(CODE)_U_$HOROLOG_U_$GET(MSG)
+2 QUIT