source: FOIAVistA/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/_ZTMS.m@ 785

Last change on this file since 785 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.5 KB
Line 
1%ZTMS ;SEA/RDS-TaskMan: Submanager, (Entry & Trap) ;11/3/03 13:46
2 ;;8.0;KERNEL;**2,18,24,36,67,94,118,127,136,162,275**;Jul 10, 1995
3 ;
4START ;Bottom level of submanager
5 S $ETRAP="D ERROR^%ZTMS HALT"
6 D NOW^%DTC S ZTQUEUED=0,U="^",DT=X
7 D KMPR("$STRT ZTMS$")
8 D PARAMS G:$D(ZTOUT) QUIT
9 I ZTPFLG("XUSCNT") D COUNT^XUSCNT(1)
10 D SETNM^%ZOSV("Sub "_$J)
11 S ^%ZTSCH("SUB",ZTPFLG("HOME"),0)=0
12 I $D(^%ZTSCH("STOP","SUB",ZTPAIR)) G QUIT
13 I ZTPFLG("XUSCNT") D SETLOCK^XUSCNT($NA(^%ZTSCH("SUBLK",ZTPFLG("HOME"),$J)))
14 G SUBMGR^%ZTMS1
15 ;
16KMPR(TAG) ;Call KMPR to log data
17 N Y
18 I +$G(^%ZTSCH("LOGRSRC")) S Y="" X $G(^%ZOSF("UCI")) I Y[^%ZOSF("PROD") D LOGRSRC^%ZOSV(TAG)
19 Q
20QUIT D KMPR("$STOP ZTMS$")
21 I ZTPFLG("XUSCNT") D COUNT^XUSCNT(-1)
22 Q
23PARAMS ;
24 ;START--lookup parameters
25 X ^%ZOSF("PRIINQ") S %ZTMS("PRIO")=Y ;Get starting priority
26 D GETENV^%ZOSV
27 S ZTCPU=$P(Y,U,2),ZTNODE=$P(Y,U,3),ZTPAIR=$P(Y,U,4),ZTUCI=$P(Y,U)_$S(ZTCPU]"":","_ZTCPU,1:"") S:ZTPAIR[":" ZTNODE=$P(ZTPAIR,":",2)
28 S ZTPFLG("RT")=0,ZTPFLG("MIN")=1,ZTYPE="",ZTPFLG("ZTREQ")=0
29 S ZTPN=$O(^%ZIS(14.7,"B",ZTPAIR,0)),ZTPFLG("ZTPN")=ZTPN
30 I ZTPN>0 S %=$G(^%ZIS(14.7,ZTPN,0)) D
31 . S ZTPFLG("RT")=+$P(%,U,6),ZTYPE=$P(%,U,9) S:$P(%,U,12)>1 ZTPFLG("MIN")=$P(%,U,12)
32 . S ZTPFLG("HOME")=$S($P(%,U,13):$P(^%ZIS(14.7,+$P(%,U,13),0),U),1:ZTPAIR)
33 . S ZTPFLG("ZTREQ")=+$G(^%ZIS(14.7,ZTPN,3))
34 . Q
35 S ZTPFLG("XUSCNT")=0 I ^%ZOSF("OS")["GT.M" S ZTPFLG("XUSCNT")=$L($T(^XUSCNT))
36 K ZTMLOG ;Set to log msg about locks
37 I "FO"[ZTYPE S ZTOUT=1 Q ;SM only run on C,P,G types
38 Q
39ERROR ;START--trap
40 I $S(^%ZOSF("OS")["GT.M":$ZS["STACKO",1:$ZE["STKOVR"!($ZE["STACK")) S $ET="Q:$ST>"_($ST-8)_" D ERR2^%ZTMS" Q
41 ;set backup trap, prepare to handle error.
42ERR2 S $ETRAP="D ERROR2^%ZTMS0 HALT"
43 S %ZTERLGR=$$LGR^%ZOSV
44 S %ZTME=$$EC^%ZOSV,ZTERROH=$H
45 S %ZTMETSK=$S($D(%ZTTV)#2:$P(%ZTTV,"^",4),$G(ZTSK)>0:ZTSK,1:0)
46 I %ZTMETSK L ^%ZTSK(%ZTMETSK) ;Unlock all other locks
47 I $G(IO)]"" L +^%ZTSCH("DEV",IO) ;Keep other tasks from IO device.
48 ;Check if to record error
49 I '$$SCREEN^%ZTER(%ZTME) D
50 . D ^%ZTER ;Kernel error file
51 . ;log error and context in TaskMan Error file
52 . L +^%ZTSCH("ER") H 1 S ZTERROH=$H
53 . S ^%ZTSCH("ER",+ZTERROH,$P(ZTERROH,",",2))=%ZTME
54 . D XREF^%ZTMS0
55 . S ^%ZTSCH("ER",+ZTERROH,$P(ZTERROH,",",2),1)=ZTERROX1
56 . L -^%ZTSCH("ER")
57 . Q
58 ;
59 I $D(ZTDEVOK) S $P(^%ZTSCH("IO"),U,2)=ZTDEVOK ;Have others skip dev.
60 ;Update Task file entry
61 I $G(ZTQUEUED),%ZTMETSK,$D(^%ZTSK(%ZTMETSK)) D STATUS^%ZTMS0
62 ;
63 ;D KMPR("$ETRP ZTMS$")
64 I ZTPFLG("XUSCNT") D COUNT^XUSCNT(-1)
65 I ZTQUEUED>.9,%ZTMETSK>0,$G(DUZ)>.9,$D(^DD(8992,.01,0)) D
66 . S XQA(DUZ)="",XQAMSG="Your task #"_%ZTMETSK_" stopped because of an error",XQADATA=%ZTMETSK,XQAROU="XQA^XUTMUTL"
67 . D SETUP^XQALERT Q
68 ;
69CLEAN ;clean up global data related to this process
70 I $G(ZTQUEUED)>.9,'$D(^%ZTSCH("TASK",ZTQUEUED,"P")) K ^%ZTSCH("TASK",ZTQUEUED)
71 K ^TMP($J),^UTILITY($J),^XUTL("XQ",$J)
72 I '$G(ZTQUEUED) D SUB^%ZTMS1(-1)
73 I $D(ZTDEVN)#2,$D(%ZTIO)#2,%ZTIO]"" D DEVLK^%ZTMS1(-1,%ZTIO)
74 I $D(ZTDEVOK)#2 D DEVBAD^%ZTMS0
75 I $G(ZTSYNCFL)]"" S X=$$SYNCFLG^%ZTMS2("S",ZTSYNCFL,"","Stopped because of an error")
76 ;
77CLOSE ;close i/o device after error
78 D ERCLOZ^%ZTMS0
79 I $G(IO)]"" C IO H 5 ;In case of a port problem give it time to reset.
80 ;
81 D KMPR("$STOP ZTMS$")
82 I ZTQUEUED=.5,%ZTMETSK>0,$P($G(^%ZTSK(%ZTMETSK,.12)),"^")<5 D ;Only try 5 times
83 . S $P(^(.12),"^")=^%ZTSK(%ZTMETSK,.12)+1
84 . S ^%ZTSCH($$NEWH^%ZTMS2($H,600),%ZTMETSK)=""
85 HALT ;Start a new process to continue
86 ;
87GTM ;Special entry point for GT.M
88 S $ZINTERRUPT="I $$JOBEXAM^ZU($ZPOSITION)"
89 G START
Note: See TracBrowser for help on using the repository browser.