| 1 | %ZTLOAD ;ISF/RDS,RWF - TaskMan: Programmer Interface: Entry Points ;07/26/2006
|
---|
| 2 | ;;8.0;KERNEL;**67,118,127,339,381**;JUL 10, 1995;Build 2
|
---|
| 3 | ;
|
---|
| 4 | QUEUE ;queue a task (create, schedule) (Entry Point = ^%ZTLOAD)
|
---|
| 5 | G ^%ZTLOAD1
|
---|
| 6 | ;
|
---|
| 7 | S(MSG) ;Entry Point: extrinsic variable returns boolean: should task stop?
|
---|
| 8 | I $G(ZTQUEUED)>.5,$D(^%ZTSCH("TASK",ZTQUEUED)) S ^%ZTSCH("TASK",ZTQUEUED,1)=$H
|
---|
| 9 | I $D(MSG),$G(ZTQUEUED)>.5 S ^%ZTSK(ZTQUEUED,.11)=MSG
|
---|
| 10 | N ZTSTOP S ZTSTOP=0
|
---|
| 11 | I $G(ZTQUEUED)>.5,$L($P($G(^%ZTSK(ZTQUEUED,.1)),"^",10)) S ZTSTOP=1
|
---|
| 12 | Q ZTSTOP
|
---|
| 13 | ;
|
---|
| 14 | TM() ;Entry Point: extrinsic variable returns boolean: is TM running?
|
---|
| 15 | N ZTH,ZTR S ZTH=$H,ZTR=$G(^%ZTSCH("RUN"))
|
---|
| 16 | Q ZTH-ZTR*86400+$P(ZTH,",",2)-$P(ZTR,",",2)<500
|
---|
| 17 | ;
|
---|
| 18 | REQ ;Entry Point: requeue a task (edit, reschedule)
|
---|
| 19 | G ^%ZTLOAD3
|
---|
| 20 | ;
|
---|
| 21 | KILL ;Entry Point: delete a task
|
---|
| 22 | S ZTSK=$G(ZTSK)
|
---|
| 23 | K ZTSK(0) S ZTSK(0)=0
|
---|
| 24 | I ZTSK>1,$D(^%ZTSK(ZTSK)) D L -^%ZTSK(ZTSK) ;could be done!
|
---|
| 25 | . L +^%ZTSK(ZTSK):20 Q:'$T
|
---|
| 26 | . ;Don't kill running persistent tasks.
|
---|
| 27 | . I $D(^%ZTSCH("ZTSK",ZTSK,"P")) Q
|
---|
| 28 | . K ^%ZTSK(ZTSK) S ZTSK(0)=1
|
---|
| 29 | Q
|
---|
| 30 | ;
|
---|
| 31 | ISQED ;Entry Point: return whether task is pending (scheduled or waiting)
|
---|
| 32 | G ^%ZTLOAD4
|
---|
| 33 | ;
|
---|
| 34 | STAT ;Entry Point: return status of a task
|
---|
| 35 | G ^%ZTLOAD5
|
---|
| 36 | ;
|
---|
| 37 | DQ ;Entry Point: dequeue a task (unschedule)
|
---|
| 38 | G ^%ZTLOAD6
|
---|
| 39 | ;
|
---|
| 40 | DESC(DESC,LST) ;Find tasks with description
|
---|
| 41 | G DESC^%ZTLOAD5
|
---|
| 42 | ;
|
---|
| 43 | RTN(RTN,LST) ;Find tasks that call this routine
|
---|
| 44 | G RTN^%ZTLOAD5
|
---|
| 45 | ;
|
---|
| 46 | OPTION(OPNM,LST) ;Find tasks for this OPTION.
|
---|
| 47 | G OPTION^%ZTLOAD5
|
---|
| 48 | ;
|
---|
| 49 | JOB(ZTM) ;Return the job # for a running task
|
---|
| 50 | G JOB^%ZTLOAD5
|
---|
| 51 | ;
|
---|
| 52 | ZTSAVE(%,%1) ;input variables in string delimited by ; to build ZTSAVE array
|
---|
| 53 | N %2 K:$G(%1) ZTSAVE
|
---|
| 54 | F %1=1:1 S %2=$P(%,";",%1) Q:%2="" S ZTSAVE(%2)=""
|
---|
| 55 | Q
|
---|
| 56 | ;
|
---|
| 57 | PSET(ZTM) ;e.f. Set the persistents node
|
---|
| 58 | D TN Q:'$D(^%ZTSCH("TASK",ZTM)) 0
|
---|
| 59 | S ^%ZTSCH("TASK",ZTM,"P")=""
|
---|
| 60 | Q 1
|
---|
| 61 | ;
|
---|
| 62 | PCLEAR(ZTM) ;Clear the persistents node
|
---|
| 63 | D TN Q:'$D(^%ZTSCH("TASK",ZTM))
|
---|
| 64 | K ^%ZTSCH("TASK",ZTM,"P")
|
---|
| 65 | Q
|
---|
| 66 | ;
|
---|
| 67 | ASKSTOP(ZTSK) ;E.F. Ask a task to stop.
|
---|
| 68 | G ASKSTOP^%ZTLOAD2
|
---|
| 69 | Q
|
---|
| 70 | ;
|
---|
| 71 | TN S ZTM=$S($G(ZTM)>0:ZTM,$G(ZTQUEUED)>.9:ZTQUEUED,$G(ZTSK)>0:ZTSK,1:0)
|
---|
| 72 | Q
|
---|