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/XUSCNT.m@ 677

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

initial load of FOIAVistA 6/30/08 version

File size: 2.8 KB
Line 
1XUSCNT ;ISF/RWF - Job counting for GTM ;6/24/04 15:22
2 ;;8.0;KERNEL;**275**;July 10, 1995;
3 ;0 return CNT
4 ;1 inc CNT
5 ;-1 dec CNT
6COUNT(INC,JOB) ;Keep count of jobs
7 N XUCNT,X
8 S JOB=$G(JOB,$J)
9 ;Return Current Count
10 I INC=0 D TOUCH Q +$G(^XUTL("XUSYS","CNT"))
11 ;Increment Count
12 I INC>0 D Q
13 . S X=$G(^XUTL("XUSYS",JOB,"NM")) K ^XUTL("XUSYS",JOB) S ^XUTL("XUSYS",JOB,"NM")=X
14 . D TOUCH
15 . L +^XUTL("XUSYS","CNT"):5
16 . S XUCNT=$G(^XUTL("XUSYS","CNT"))+1,^XUTL("XUSYS","CNT")=XUCNT
17 . L -^XUTL("XUSYS","CNT")
18 . Q
19 ;Decrement Count
20 I INC<0 D Q
21 . L +^XUTL("XUSYS","CNT"):5
22 . S XUCNT=$G(^XUTL("XUSYS","CNT"))-1,^XUTL("XUSYS","CNT")=$S(XUCNT>0:XUCNT,1:0)
23 . L -^XUTL("XUSYS","CNT")
24 . K ^XUTL("XUSYS",JOB)
25 Q
26 ;
27CHECK(JOB) ;Check if job number active
28 ; 0 = Job doesn't seem to be running
29 ; 1 = Job maybe running
30 ; 2 = Job still has Lock out.
31 Q:$G(JOB)'>0 0
32 I '$D(^XUTL("XUSYS",JOB)) Q 0
33 N LK,%T
34 S %T=0,LK=$$GETLOCK()
35 I $L(LK) L +@LK:0 S %T=$T L:%T -@LK
36 Q $S(%T:2,1:1)
37 ;
38SETLOCK(NLK) ;Set the Lock we will keep
39 I $L($G(NLK)) S ^XUTL("XUSYS",$J,"LOCK")=NLK
40 E K ^XUTL("XUSYS",$J,"LOCK")
41 D TOUCH ;Update the time
42 Q
43 ;
44TOUCH ;Update the time
45 S ^XUTL("XUSYS",$J,0)=$H
46 Q
47 ;
48GETLOCK() ;Get the node to Lock
49 Q $G(^XUTL("XUSYS",$J,"LOCK"))
50 ;
51CLEAR(DB) ;Check for locks and time clear old ones.
52 N %J,%T,CNT,CT,LK,IM,IMAGE,H K ^TMP($J)
53 D TOUCH ;See that we are current
54 ;S %J=0 F S %J=$ZPID(%J) Q:%J'>0 S ^TMP($J,%J)="",^TMP($J,%J,1)=$ZGETJPI(%J,"IMAGNAME")
55 S DB=+$G(DB),IMAGE="mumps" ;$ZGETJPI($J,"IMAGNAME") ; ours
56 S %J=0,CNT=0,H=$H,CT=$$H3($H)
57 I DB W !,"Current Job Count: ",$$COUNT(0)
58 F S %J=$O(^XUTL("XUSYS",%J)) Q:%J'>0 D
59 . S CNT=CNT+1
60 . I DB W !,CNT," Job: ",%J
61 . S LK=$G(^XUTL("XUSYS",%J,"LOCK")) ;Get lock name
62 . I '$L(LK) W:DB " No Lock node"
63 . I $L(LK) L +@LK:0 S %T=$T D Q:'%T L -@LK ;Quit if lock still held
64 . . I '%T,DB W " Lock Held"
65 . . I %T,DB W " Lock Fail"
66 . S IM=$G(^TMP($J,%J,1))
67 . I IM=IMAGE W:DB " Image Match: ",IM Q
68 . I IM["ZFOO.EXE" W:DB " ZFOO Image" Q ;Quit if in same image
69 . S H=$G(^XUTL("XUSYS",%J,0)) I H>0 S H=$$H3(H)
70 . I H+60>CT D Q ;Updated in last 30 seconds.
71 . . I DB W " Current TimeStamp"
72 . S NM=$G(^XUTL("XUSYS",%J,"NM"))
73 . I NM["Task " S TM=+$P(NM,"Task ",2) I TM>0 D Q:%
74 . . S TM(1)=$G(^%ZTSK(TM,.1)),%=(TM(1)=5)
75 . . I DB,% W " Running Task"
76 . . Q
77 . ;More checks
78 . D COUNT(-1,%J) I DB W " Not Active: Removed" ;Not Active
79 . Q
80 L +^XUTL("XUSYS","CNT"):3
81 S CNT=0,%J=0 F S %J=$O(^XUTL("XUSYS",%J)) Q:%J'>0 S CNT=CNT+1
82 S ^XUTL("XUSYS","CNT")=CNT
83 L -^XUTL("XUSYS","CNT")
84 I DB W !,"New JOB count: ",CNT
85 Q
86 ;
87H3(%H) ;Just seconds
88 Q %H*86400+$P(%H,",",2)
89 ;
90 ;Called from the X-REF both the volume and Max signon from file 8989.3
91XREF(X1,V) ;V="S" or "K"
92 N %,N
93 S %=$G(^XTV(8989.3,1,4,X1,0)),N=$P(%,"^") Q:%=""
94 I V="K" K ^XTV(8989.3,"AMAX",N) Q
95 S ^XTV(8989.3,"AMAX",N)=$P(%,"^",3)
96 Q
Note: See TracBrowser for help on using the repository browser.