Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: XUTMDEVQ

XUTMDEVQ.m

Go to the documentation of this file.
  1. XUTMDEVQ ;ISCSF/RWF - Device call and Queue in one place ;01/18/2006
  1. ;;8.0;KERNEL;**20,120,275,389**;Jul 10, 1995;Build 1
  1. ; this routine has four entry points: EN, DEV, NODEV, QQ
  1. ; usage:
  1. ;D EN^XUTMDEVQ(ZTRTN,ZTDESC,.ZTSAVE,[.]%ZIS,[FLAG])
  1. ;S X=$$DEV^XUTMQUE(ZTRTN,ZTDESC,[.]%VAR,.%VOTH,[.]%ZIS,IOP,%WR)
  1. ;S X=$$NODEV^XUTMQUE(ZTRTN,ZTDESC,[.]%VAR,.%VOTH,%WR)
  1. ;S X=$$QQ(%RTN,%DESC,[.]%VAR1,.%VOTH1,.%ZIS,IOP,%WR,%RTN2,%DESC2,[.]%VAR2,.%VOTH2)
  1. ;EN
  1. ;Call with %ZTLOAD parameters and it will call $ZIS and
  1. ;run or queue the output.
  1. ;
  1. EN(ZTRTN,ZTDESC,ZTSAVE,%ZIS,%) ;ZTSAVE AND %ZIS pass by reference.
  1. Q:$G(ZTRTN)=""
  1. N %RET,ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI N:'$G(%) ZTSK K IO("Q")
  1. D ZIS I POP G KILL
  1. I '$D(IO("Q")) D RUN G KILL
  1. D ZTLOAD
  1. KILL K ZTDTH,ZTSAVE
  1. Q
  1. ZIS ;
  1. S:$G(%ZIS)'["Q" %ZIS=$G(%ZIS)_"Q"
  1. D ^%ZIS
  1. Q
  1. ZTLOAD ;
  1. K IO("Q"),ZTSK
  1. D ^%ZTLOAD,HOME^%ZIS
  1. S:$D(ZTSK) %RET=ZTSK
  1. Q
  1. RUN ;
  1. U IO
  1. D @ZTRTN
  1. D ^%ZISC
  1. Q
  1. ;
  1. DEV(ZTRTN,ZTDESC,%VAR,%VOTH,%ZIS,IOP,%WR) ; single que ask for device
  1. ; ZTRTN - required - [tag]^routine that taskman will run
  1. ; ZTDESC - optional - default to name of [tag]~routine
  1. ; %VAR - optional - single value or passed by reference
  1. ; this will be used to S ZTSAVE()
  1. ; can be a string of variable names separated by ';'
  1. ; each ;-piece will be used as a subscript in ztsave
  1. ; %VOTH - optional - passed by reference
  1. ; %voth(sub)="" or explicit value
  1. ; sub - this is any other %ZTLOAD variable besides
  1. ; ZTRTN,ZTDESC,ZTIO,ZTSAVE
  1. ; example: %VOTH("ZTDTH")=$H
  1. ; %ZIS - optional - default value "MQ" - passed by reference
  1. ; standard %ZIS variable array for calling device handler
  1. ; IOP - optional - IOP variable as defined in Kernel device handler
  1. ; %WR - optional - if %WR>0 then write text to the screen as to
  1. ; whether or not the queueing was successful
  1. ;
  1. ; return: ZTSK value if successfully queued
  1. ; 0 if run ztrtn without queuing
  1. ; -1 if unsuccessful device call or failed %ztload call
  1. ;
  1. N ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTSK,ZTPRI,ZTKIL,%RET,POP
  1. S %RET=-1 I $G(ZTRTN)="" G OUT
  1. D SETUP,ZIS I POP G OUT
  1. I '$D(IO("Q")) D RUN S %RET=0
  1. D ZTLOAD
  1. OUT I $G(%WR),%RET'=0,'$D(ZTQUEUED) D
  1. .W !! I %RET<0 W "Request Aborted",!
  1. .E W "Task queued ["_(+%RET)_"]",!
  1. .I $P(%RET,U,2) W !,"Second task queued ["_$P(%RET,U,2)_"]",!
  1. .Q
  1. Q %RET
  1. ;
  1. NODEV(ZTRTN,ZTDESC,%VAR,%VOTH,%WR) ; single que no device needed
  1. ; see DEV for parameter descriptions and return values
  1. N ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTSK,ZTKIL,ZTPRI,%RET,POP
  1. S %RET=-1 I $G(ZTRTN)]"" S ZTIO="" D SETUP,ZTLOAD
  1. G OUT
  1. ;
  1. QQ(%RTN,%DESC,%VAR1,%VOTH1,%ZIS,IOP,%WR,%RTN2,%DESC2,%VAR2,%VOTH2) ;
  1. ; double queuing - queue up the second routine to device, but do not
  1. ; schedule the task in Taskman
  1. ; queue up the first job to ZTIO="" and schedule it
  1. ; %RTN - required - [tag]^routine for the 1st job to be run (usually a
  1. ; search and build sorted data type process)
  1. ; %DESC - optional - ZTDESC value for 1st job (default [tag]~routine)
  1. ; %VAR1 - optional - ZTSAVE values for 1st job - see %VAR descript above
  1. ;%VOTH1 - optional - 1st job - see %VOTH description above
  1. ; %ZIS - optional - see %ZIS description above, except for one diff
  1. ; the 2nd job will be tasked to this device call
  1. ; exception: IF $D(%ZIS)=0 then default value is "MQ" and call
  1. ; device handler
  1. ; IF $D(%ZIS)=1,%ZIS="" then queue 2nd job also with
  1. ; ZTIO="" i.e., do not do device handler call
  1. ; IOP - optional - see above - default value "Q" - if IOP is passed
  1. ; and IOP does not start with "Q;" then "Q;" will
  1. ; be added
  1. ; %WR - optional - see above
  1. ; %RTN2 - required - [tag]^routine for the 2nd job to be run (usually a
  1. ; print job)
  1. ;%DESC2 - optional - ZTDESC value for 2nd job (default [tag]~routine)
  1. ; %VAR2 - optional - ZTSAVE values for 2nd job - see %VAR descript above
  1. ; if %VAR1 is not passed and $D(%VAR) then also send %VAR
  1. ; data to 2nd tasked job. If $D(%VAR1) then do not send %VAR
  1. ; data to 2nd tasked job.
  1. ;%VOTH2 - optional - 2nd job - see %VOTH description above - usually not
  1. ; needed - note: if %VOTH1("ZTDTH") is passed it will be ignored
  1. ; as it is necessary to S ZTDTH="@" for the 2nd job - this will
  1. ; create the task but not schedule it
  1. ;
  1. ; return: if successfully queued, return ztsk1^ztsk2 where
  1. ; ztsk1 = ZTSK value of 1st job, ztsk2 = ZTSK value of 2nd job
  1. ; -1 if unsuccessful device call or failed %ztload call
  1. ;
  1. N ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTSK,ZTPRI,ZTKIL,ZTDESC,%RET,POP
  1. N %VAR,%VOTH,%TMP S %RET=-1
  1. I $G(%RTN)=""!($G(%RTN2)="") G OUT
  1. ; setup 2nd job to %ZIS
  1. S ZTRTN=%RTN2
  1. I $D(%VAR2) M %VAR=%VAR2
  1. I '$D(%VAR),$D(%VAR1) M %VAR=%VAR1
  1. I $D(%VOTH2) M %VOTH=%VOTH2
  1. I $G(%DESC2)]"" S ZTDESC=%DESC2
  1. I $D(%ZIS)=1,%ZIS="" S ZTIO=""
  1. E D
  1. .I $D(IOP),IOP'?1"Q;".E S IOP="Q;"_IOP
  1. .I '$D(IOP) S IOP="Q"
  1. .Q
  1. D SETUP,ZIS:'$D(ZTIO) I $G(POP) G OUT
  1. S ZTDTH="@" D ZTLOAD
  1. K %VAR,%VOTH,%ZIS,IOP S %TMP=%RET
  1. S ZTRTN=%RTN
  1. I $D(%VAR1) M %VAR=%VAR1
  1. I $D(%VOTH1) M %VOTH=%VOTH1
  1. I $G(%DESC)]"" S ZTDESC=%DESC
  1. D SETUP S ZTIO="",%RET=-1,ZTSAVE("XUTMQQ")=%TMP D ZTLOAD I %RET>0 S %RET=%RET_U_%TMP
  1. G OUT
  1. ;
  1. REQQ(ZTSK,ZTDTH,%VAR) ;Reschedule the second part of a QQ task.
  1. ;The task to work on should be in XUTMQQ.
  1. N ZTIO,ZTDESC,ZTRTN,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTPRI,ZTKIL,ZTREQ
  1. I $G(ZTSK)=""!($G(ZTDTH)="") Q 0
  1. D VAR
  1. D REQ^%ZTLOAD
  1. Q $G(ZTSK(0),0) ;Return 1 for rescheduled, 0 for fail.
  1. ;
  1. SETUP ; setup %ztload variables
  1. K ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTPRI,ZTKIL,ZTSK,IO("Q") N I,X,Y
  1. D VAR
  1. I $D(%VOTH) F S X=$O(%VOTH(X)) Q:X="" S:'$D(@X) @X=%VOTH(X)
  1. I '$D(ZTDESC) S ZTDESC=$TR($P(ZTRTN,"("),U,"~")
  1. Q
  1. ;
  1. VAR ;Setup ZTSAVE
  1. I $D(%VAR)#2 F I=1:1:$L(%VAR,";") S X=$P(%VAR,";",I),ZTSAVE(X)=""
  1. S X="" F S X=$O(%VAR(X)) Q:X="" S ZTSAVE(X)=%VAR(X)
  1. Q