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/ZTMKU.m@ 1742

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

initial load of FOIAVistA 6/30/08 version

File size: 3.8 KB
Line 
1ZTMKU ;SEA/RDS-Taskman: Option, ZTMWAIT/RUN/STOP ;11/04/99 15:05
2 ;;8.0;KERNEL;**118,127,275,355**;Jul 10, 1995;Build 9
3 ;
4 Q
5SSUB(NODE) ;Stop sub-managers
6 D SS(1,"SUB",NODE) Q
7SMAN(NODE) ;stop managers
8 D SS(1,"MGR",NODE) Q
9 ;
10SS(MD,GR,NODE) ;Set/clear STOP nodes.
11 S GR=$G(GR,"MGR") S:"MGR_SUB_"'[GR GR="MGR"
12 I MD=1 S ^%ZTSCH("STOP",GR,NODE)=$H D WS(0,GR)
13 I MD=0 K ^%ZTSCH("STOP",GR,NODE)
14 Q
15 ;
16WS(MD,GR) ;Set/Clear Wait state
17 S GR=$G(GR,"MGR") S:"MGR_SUB_"'[GR GR="MGR"
18 I MD=1 S ^%ZTSCH("WAIT",GR)=$H ;set wait state
19 I MD=0 K ^%ZTSCH("WAIT",GR) ;Clear wait
20 Q
21 ;
22GROUP(CALL) ;Do CALL for each node, use NODE as the parameter
23 N J,ND,NODE
24 ;Get the Managers
25 F J=0:0 S J=$O(^%ZTSCH("STATUS",J)) Q:J="" S ND=$G(^(J)),NODE=$P(ND,"^",3) D @CALL
26 ;Get any remote Sub-Managers
27 S NODE="" F S NODE=$O(^%ZTSCH("SUB",NODE)) Q:NODE="" D @CALL
28 Q
29 ;
30OPT(MD) ;Disable/Enable option prosessing
31 I MD=1 S ^%ZTSCH("NO-OPTION")=""
32 I MD=0 K ^%ZTSCH("NO-OPTION")
33 Q
34 ;
35RUN ;Remove Task Managers From WAIT State
36 D WS(0,"MGR"),WS(0,"SUB") K ^%ZTSCH("STOP") W !,"Done!",!
37 Q
38 ;
39UPDATE ;Have Managers Do an parameter Update
40 K ^%ZTSCH("UPDATE") W !,"Done!",!
41 Q
42 ;
43WAIT ;Put Task Managers In WAIT State
44 D WS(1,"MGR") W !,"TaskMan now in 'WAIT STATE'",$C(7)
45 D QSUB
46 Q
47 ;
48STOP ;Shut Down Task Managers
49 N ZTX,ND,J
50 F R !!,"Are you sure you want to stop TaskMan? NO// ",ZTX:$S($D(DTIME)#2:DTIME,1:60) Q:'$T!("^YESyesNOno"[ZTX) W:ZTX'["?" $C(7) W !,"Answer YES to shut down all Task Managers on current the volume set."
51 I "^NOno"[ZTX W !,"TaskMan NOT shut down." Q
52 W !,"Shutting down TaskMan." D GROUP("SMAN(NODE)")
53 ;. F J=0:0 S J=$O(^%ZTSCH("STATUS",J)) Q:J="" S ND=$G(^(J)) D SMAN($P(ND,U,3))
54 ;. Q
55 D QSUB
56 Q
57 ;
58QSUB N ZTX,ND
59 F R !!,"Should active submanagers shut down after finishing their current tasks? NO// ",ZTX:$S($D(DTIME)#2:DTIME,1:60) Q:'$T!("^"[ZTX)!("YESyesNOno"[ZTX) W:ZTX'["?" $C(7) W !,"Please answer YES or NO."
60 D:"YESyes"[ZTX&(ZTX]"") GROUP("SSUB(NODE)") W !,"Okay!",!
61 Q
62 ;
63QUERY ;Query Status Of A Task Manager
64 Q:$D(%ZTX)[0 Q:%ZTX="" S %ZTY=0
65 I $D(^%ZTSCH("STATUS",%ZTX))#2 S %ZTY=^%ZTSCH("STATUS",%ZTX)
66 K %ZTX Q
67 ;
68NODES ;Return Task Manager Status Nodes
69 S %ZTX="" F %ZTY=0:0 S %ZTX=$O(^%ZTSCH("STATUS",%ZTX)) Q:%ZTX="" S %ZTY=%ZTY+1,%ZTY(%ZTY)=%ZTX
70 K %ZTX Q
71 ;
72LIVE ;Return Whether A Task Manager Is Live
73 Q:$D(%ZTX)[0 Q:%ZTX="" S %ZTY=0,U="^",%ZTX1=$H,%ZTX2=$P(%ZTX,U)
74 S %ZTX3=%ZTX1-%ZTX2*86400+$P(%ZTX1,",",2)-$P(%ZTX2,",",2)
75 I %ZTX3'<0 S %ZTY=$S($D(^%ZTSCH("RUN"))[0&(%ZTX'["WAIT"):0,%ZTX3<30:1,%ZTX3<120&(%ZTX["PAUSE"):1,1:0)
76 K %ZTX,%ZTX1,%ZTX2,%ZTX3 Q
77 ;
78TABLE ;Display Task Manager Table
79 W !,"NUMBER",?15,"STATUS",?25,"DESCRIPTION",?55,"LAST UPDATED",?75,"LIVE"
80 W !,"------",?15,"------",?25,"-----------",?55,"------------",?75,"----"
81 D NODES S %ZTZ=%ZTY,%ZTZ1=0,U="^",%H=$H D YMD^%DTC S DT=X
82 F %ZTI=1:1:%ZTZ S %ZTX=%ZTY(%ZTI) D QUERY I %ZTY'=0 W !,%ZTY(%ZTI),?15,$P(%ZTY,U,2),?25,$P(%ZTY,U,3),?55 S %ZTT=$P(%ZTY,U) D T S %ZTX=%ZTY D LIVE W ?75,$S(%ZTY:"YES",1:"NO") I %ZTY S %ZTZ1=%ZTZ1+1
83 W !?6,"Total:",$J(%ZTZ,3),!?6,"Live :",$J(%ZTZ1,3)
84 K %ZTI,%ZTT,%ZTY,%ZTZ Q
85 ;
86CLEAN ;Cleanup Status Node
87 K ^%ZTSCH("STATUS") W !,"Done!",! Q
88PURGE ;Purge the TASK list of running tasks.
89 N TSK S TSK=0
90 F S TSK=$O(^%ZTSCH("TASK",TSK)) Q:TSK'>0 I '$D(^%ZTSCH("TASK",TSK,"P")) K ^%ZTSCH("TASK",TSK)
91 W !,"Done!",! Q
92 ;
93ZTM ;Return Number Of Live Task Managers
94 D NODES S %ZTZ=%ZTY,%ZTZ1=0 F %ZTI=1:1:%ZTZ S %ZTX=%ZTY(%ZTI) D QUERY I %ZTY'=0 S %ZTX=%ZTY D LIVE I %ZTY S %ZTZ1=%ZTZ1+1
95 S %ZTY=%ZTZ1 K %ZTI,%ZTZ,%ZTZ1 Q
96 ;
97T ;Print Informal-format Conversion Of $H-format Date ; Input: %ZTT, DT.
98 S %H=%ZTT D 7^%DTC W $S(DT=X:"TODAY",DT+1=X:"TOMORROW",1:$E(X,4,5)_"/"_$E(X,6,7)_"/"_$E(X,2,3))_" AT " S X=$P(%ZTT,",",2)\60,%H=X\60 W $E(%H+100,2,3)_":"_$E(X#60+100,2,3)
99 K %,%D,%H,%M,%Y,X Q ; Output: %ZTT, DT.
100 ;
Note: See TracBrowser for help on using the repository browser.