- XUTMDEVQ ;ISCSF/RWF - Device call and Queue in one place ;01/18/2006
- ;;8.0;KERNEL;**20,120,275,389**;Jul 10, 1995;Build 1
- ; this routine has four entry points: EN, DEV, NODEV, QQ
- ; usage:
- ;D EN^XUTMDEVQ(ZTRTN,ZTDESC,.ZTSAVE,[.]%ZIS,[FLAG])
- ;S X=$$DEV^XUTMQUE(ZTRTN,ZTDESC,[.]%VAR,.%VOTH,[.]%ZIS,IOP,%WR)
- ;S X=$$NODEV^XUTMQUE(ZTRTN,ZTDESC,[.]%VAR,.%VOTH,%WR)
- ;S X=$$QQ(%RTN,%DESC,[.]%VAR1,.%VOTH1,.%ZIS,IOP,%WR,%RTN2,%DESC2,[.]%VAR2,.%VOTH2)
- ;EN
- ;Call with %ZTLOAD parameters and it will call $ZIS and
- ;run or queue the output.
- ;
- EN(ZTRTN,ZTDESC,ZTSAVE,%ZIS,%) ;ZTSAVE AND %ZIS pass by reference.
- Q:$G(ZTRTN)=""
- N %RET,ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI N:'$G(%) ZTSK K IO("Q")
- D ZIS I POP G KILL
- I '$D(IO("Q")) D RUN G KILL
- D ZTLOAD
- KILL K ZTDTH,ZTSAVE
- Q
- ZIS ;
- S:$G(%ZIS)'["Q" %ZIS=$G(%ZIS)_"Q"
- D ^%ZIS
- Q
- ZTLOAD ;
- K IO("Q"),ZTSK
- D ^%ZTLOAD,HOME^%ZIS
- S:$D(ZTSK) %RET=ZTSK
- Q
- RUN ;
- U IO
- D @ZTRTN
- D ^%ZISC
- Q
- ;
- DEV(ZTRTN,ZTDESC,%VAR,%VOTH,%ZIS,IOP,%WR) ; single que ask for device
- ; ZTRTN - required - [tag]^routine that taskman will run
- ; ZTDESC - optional - default to name of [tag]~routine
- ; %VAR - optional - single value or passed by reference
- ; this will be used to S ZTSAVE()
- ; can be a string of variable names separated by ';'
- ; each ;-piece will be used as a subscript in ztsave
- ; %VOTH - optional - passed by reference
- ; %voth(sub)="" or explicit value
- ; sub - this is any other %ZTLOAD variable besides
- ; ZTRTN,ZTDESC,ZTIO,ZTSAVE
- ; example: %VOTH("ZTDTH")=$H
- ; %ZIS - optional - default value "MQ" - passed by reference
- ; standard %ZIS variable array for calling device handler
- ; IOP - optional - IOP variable as defined in Kernel device handler
- ; %WR - optional - if %WR>0 then write text to the screen as to
- ; whether or not the queueing was successful
- ;
- ; return: ZTSK value if successfully queued
- ; 0 if run ztrtn without queuing
- ; -1 if unsuccessful device call or failed %ztload call
- ;
- N ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTSK,ZTPRI,ZTKIL,%RET,POP
- S %RET=-1 I $G(ZTRTN)="" G OUT
- D SETUP,ZIS I POP G OUT
- I '$D(IO("Q")) D RUN S %RET=0
- D ZTLOAD
- OUT I $G(%WR),%RET'=0,'$D(ZTQUEUED) D
- .W !! I %RET<0 W "Request Aborted",!
- .E W "Task queued ["_(+%RET)_"]",!
- .I $P(%RET,U,2) W !,"Second task queued ["_$P(%RET,U,2)_"]",!
- .Q
- Q %RET
- ;
- NODEV(ZTRTN,ZTDESC,%VAR,%VOTH,%WR) ; single que no device needed
- ; see DEV for parameter descriptions and return values
- N ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTSK,ZTKIL,ZTPRI,%RET,POP
- S %RET=-1 I $G(ZTRTN)]"" S ZTIO="" D SETUP,ZTLOAD
- G OUT
- ;
- QQ(%RTN,%DESC,%VAR1,%VOTH1,%ZIS,IOP,%WR,%RTN2,%DESC2,%VAR2,%VOTH2) ;
- ; double queuing - queue up the second routine to device, but do not
- ; schedule the task in Taskman
- ; queue up the first job to ZTIO="" and schedule it
- ; %RTN - required - [tag]^routine for the 1st job to be run (usually a
- ; search and build sorted data type process)
- ; %DESC - optional - ZTDESC value for 1st job (default [tag]~routine)
- ; %VAR1 - optional - ZTSAVE values for 1st job - see %VAR descript above
- ;%VOTH1 - optional - 1st job - see %VOTH description above
- ; %ZIS - optional - see %ZIS description above, except for one diff
- ; the 2nd job will be tasked to this device call
- ; exception: IF $D(%ZIS)=0 then default value is "MQ" and call
- ; device handler
- ; IF $D(%ZIS)=1,%ZIS="" then queue 2nd job also with
- ; ZTIO="" i.e., do not do device handler call
- ; IOP - optional - see above - default value "Q" - if IOP is passed
- ; and IOP does not start with "Q;" then "Q;" will
- ; be added
- ; %WR - optional - see above
- ; %RTN2 - required - [tag]^routine for the 2nd job to be run (usually a
- ; print job)
- ;%DESC2 - optional - ZTDESC value for 2nd job (default [tag]~routine)
- ; %VAR2 - optional - ZTSAVE values for 2nd job - see %VAR descript above
- ; if %VAR1 is not passed and $D(%VAR) then also send %VAR
- ; data to 2nd tasked job. If $D(%VAR1) then do not send %VAR
- ; data to 2nd tasked job.
- ;%VOTH2 - optional - 2nd job - see %VOTH description above - usually not
- ; needed - note: if %VOTH1("ZTDTH") is passed it will be ignored
- ; as it is necessary to S ZTDTH="@" for the 2nd job - this will
- ; create the task but not schedule it
- ;
- ; return: if successfully queued, return ztsk1^ztsk2 where
- ; ztsk1 = ZTSK value of 1st job, ztsk2 = ZTSK value of 2nd job
- ; -1 if unsuccessful device call or failed %ztload call
- ;
- N ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTSK,ZTPRI,ZTKIL,ZTDESC,%RET,POP
- N %VAR,%VOTH,%TMP S %RET=-1
- I $G(%RTN)=""!($G(%RTN2)="") G OUT
- ; setup 2nd job to %ZIS
- S ZTRTN=%RTN2
- I $D(%VAR2) M %VAR=%VAR2
- I '$D(%VAR),$D(%VAR1) M %VAR=%VAR1
- I $D(%VOTH2) M %VOTH=%VOTH2
- I $G(%DESC2)]"" S ZTDESC=%DESC2
- I $D(%ZIS)=1,%ZIS="" S ZTIO=""
- E D
- .I $D(IOP),IOP'?1"Q;".E S IOP="Q;"_IOP
- .I '$D(IOP) S IOP="Q"
- .Q
- D SETUP,ZIS:'$D(ZTIO) I $G(POP) G OUT
- S ZTDTH="@" D ZTLOAD
- K %VAR,%VOTH,%ZIS,IOP S %TMP=%RET
- S ZTRTN=%RTN
- I $D(%VAR1) M %VAR=%VAR1
- I $D(%VOTH1) M %VOTH=%VOTH1
- I $G(%DESC)]"" S ZTDESC=%DESC
- D SETUP S ZTIO="",%RET=-1,ZTSAVE("XUTMQQ")=%TMP D ZTLOAD I %RET>0 S %RET=%RET_U_%TMP
- G OUT
- ;
- REQQ(ZTSK,ZTDTH,%VAR) ;Reschedule the second part of a QQ task.
- ;The task to work on should be in XUTMQQ.
- N ZTIO,ZTDESC,ZTRTN,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTPRI,ZTKIL,ZTREQ
- I $G(ZTSK)=""!($G(ZTDTH)="") Q 0
- D VAR
- D REQ^%ZTLOAD
- Q $G(ZTSK(0),0) ;Return 1 for rescheduled, 0 for fail.
- ;
- SETUP ; setup %ztload variables
- K ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTPRI,ZTKIL,ZTSK,IO("Q") N I,X,Y
- D VAR
- I $D(%VOTH) F S X=$O(%VOTH(X)) Q:X="" S:'$D(@X) @X=%VOTH(X)
- I '$D(ZTDESC) S ZTDESC=$TR($P(ZTRTN,"("),U,"~")
- Q
- ;
- VAR ;Setup ZTSAVE
- I $D(%VAR)#2 F I=1:1:$L(%VAR,";") S X=$P(%VAR,";",I),ZTSAVE(X)=""
- S X="" F S X=$O(%VAR(X)) Q:X="" S ZTSAVE(X)=%VAR(X)
- Q
- 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
- +2 ; this routine has four entry points: EN, DEV, NODEV, QQ
- +3 ; usage:
- +4 ;D EN^XUTMDEVQ(ZTRTN,ZTDESC,.ZTSAVE,[.]%ZIS,[FLAG])
- +5 ;S X=$$DEV^XUTMQUE(ZTRTN,ZTDESC,[.]%VAR,.%VOTH,[.]%ZIS,IOP,%WR)
- +6 ;S X=$$NODEV^XUTMQUE(ZTRTN,ZTDESC,[.]%VAR,.%VOTH,%WR)
- +7 ;S X=$$QQ(%RTN,%DESC,[.]%VAR1,.%VOTH1,.%ZIS,IOP,%WR,%RTN2,%DESC2,[.]%VAR2,.%VOTH2)
- +8 ;EN
- +9 ;Call with %ZTLOAD parameters and it will call $ZIS and
- +10 ;run or queue the output.
- +11 ;
- EN(ZTRTN,ZTDESC,ZTSAVE,%ZIS,%) ;ZTSAVE AND %ZIS pass by reference.
- +1 IF $GET(ZTRTN)=""
- QUIT
- +2 NEW %RET,ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI
- IF '$GET(%)
- NEW ZTSK
- KILL IO("Q")
- +3 DO ZIS
- IF POP
- GOTO KILL
- +4 IF '$DATA(IO("Q"))
- DO RUN
- GOTO KILL
- +5 DO ZTLOAD
- KILL KILL ZTDTH,ZTSAVE
- +1 QUIT
- ZIS ;
- +1 IF $GET(%ZIS)'["Q"
- SET %ZIS=$GET(%ZIS)_"Q"
- +2 DO ^%ZIS
- +3 QUIT
- ZTLOAD ;
- +1 KILL IO("Q"),ZTSK
- +2 DO ^%ZTLOAD
- DO HOME^%ZIS
- +3 IF $DATA(ZTSK)
- SET %RET=ZTSK
- +4 QUIT
- RUN ;
- +1 USE IO
- +2 DO @ZTRTN
- +3 DO ^%ZISC
- +4 QUIT
- +5 ;
- DEV(ZTRTN,ZTDESC,%VAR,%VOTH,%ZIS,IOP,%WR) ; single que ask for device
- +1 ; ZTRTN - required - [tag]^routine that taskman will run
- +2 ; ZTDESC - optional - default to name of [tag]~routine
- +3 ; %VAR - optional - single value or passed by reference
- +4 ; this will be used to S ZTSAVE()
- +5 ; can be a string of variable names separated by ';'
- +6 ; each ;-piece will be used as a subscript in ztsave
- +7 ; %VOTH - optional - passed by reference
- +8 ; %voth(sub)="" or explicit value
- +9 ; sub - this is any other %ZTLOAD variable besides
- +10 ; ZTRTN,ZTDESC,ZTIO,ZTSAVE
- +11 ; example: %VOTH("ZTDTH")=$H
- +12 ; %ZIS - optional - default value "MQ" - passed by reference
- +13 ; standard %ZIS variable array for calling device handler
- +14 ; IOP - optional - IOP variable as defined in Kernel device handler
- +15 ; %WR - optional - if %WR>0 then write text to the screen as to
- +16 ; whether or not the queueing was successful
- +17 ;
- +18 ; return: ZTSK value if successfully queued
- +19 ; 0 if run ztrtn without queuing
- +20 ; -1 if unsuccessful device call or failed %ztload call
- +21 ;
- +22 NEW ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTSK,ZTPRI,ZTKIL,%RET,POP
- +23 SET %RET=-1
- IF $GET(ZTRTN)=""
- GOTO OUT
- +24 DO SETUP
- DO ZIS
- IF POP
- GOTO OUT
- +25 IF '$DATA(IO("Q"))
- DO RUN
- SET %RET=0
- +26 DO ZTLOAD
- OUT IF $GET(%WR)
- IF %RET'=0
- IF '$DATA(ZTQUEUED)
- Begin DoDot:1
- +1 WRITE !!
- IF %RET<0
- WRITE "Request Aborted",!
- +2 IF '$TEST
- WRITE "Task queued ["_(+%RET)_"]",!
- +3 IF $PIECE(%RET,U,2)
- WRITE !,"Second task queued ["_$PIECE(%RET,U,2)_"]",!
- +4 QUIT
- End DoDot:1
- +5 QUIT %RET
- +6 ;
- NODEV(ZTRTN,ZTDESC,%VAR,%VOTH,%WR) ; single que no device needed
- +1 ; see DEV for parameter descriptions and return values
- +2 NEW ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTSK,ZTKIL,ZTPRI,%RET,POP
- +3 SET %RET=-1
- IF $GET(ZTRTN)]""
- SET ZTIO=""
- DO SETUP
- DO ZTLOAD
- +4 GOTO OUT
- +5 ;
- 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
- +2 ; schedule the task in Taskman
- +3 ; queue up the first job to ZTIO="" and schedule it
- +4 ; %RTN - required - [tag]^routine for the 1st job to be run (usually a
- +5 ; search and build sorted data type process)
- +6 ; %DESC - optional - ZTDESC value for 1st job (default [tag]~routine)
- +7 ; %VAR1 - optional - ZTSAVE values for 1st job - see %VAR descript above
- +8 ;%VOTH1 - optional - 1st job - see %VOTH description above
- +9 ; %ZIS - optional - see %ZIS description above, except for one diff
- +10 ; the 2nd job will be tasked to this device call
- +11 ; exception: IF $D(%ZIS)=0 then default value is "MQ" and call
- +12 ; device handler
- +13 ; IF $D(%ZIS)=1,%ZIS="" then queue 2nd job also with
- +14 ; ZTIO="" i.e., do not do device handler call
- +15 ; IOP - optional - see above - default value "Q" - if IOP is passed
- +16 ; and IOP does not start with "Q;" then "Q;" will
- +17 ; be added
- +18 ; %WR - optional - see above
- +19 ; %RTN2 - required - [tag]^routine for the 2nd job to be run (usually a
- +20 ; print job)
- +21 ;%DESC2 - optional - ZTDESC value for 2nd job (default [tag]~routine)
- +22 ; %VAR2 - optional - ZTSAVE values for 2nd job - see %VAR descript above
- +23 ; if %VAR1 is not passed and $D(%VAR) then also send %VAR
- +24 ; data to 2nd tasked job. If $D(%VAR1) then do not send %VAR
- +25 ; data to 2nd tasked job.
- +26 ;%VOTH2 - optional - 2nd job - see %VOTH description above - usually not
- +27 ; needed - note: if %VOTH1("ZTDTH") is passed it will be ignored
- +28 ; as it is necessary to S ZTDTH="@" for the 2nd job - this will
- +29 ; create the task but not schedule it
- +30 ;
- +31 ; return: if successfully queued, return ztsk1^ztsk2 where
- +32 ; ztsk1 = ZTSK value of 1st job, ztsk2 = ZTSK value of 2nd job
- +33 ; -1 if unsuccessful device call or failed %ztload call
- +34 ;
- +35 NEW ZTIO,ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTSK,ZTPRI,ZTKIL,ZTDESC,%RET,POP
- +36 NEW %VAR,%VOTH,%TMP
- SET %RET=-1
- +37 IF $GET(%RTN)=""!($GET(%RTN2)="")
- GOTO OUT
- +38 ; setup 2nd job to %ZIS
- +39 SET ZTRTN=%RTN2
- +40 IF $DATA(%VAR2)
- MERGE %VAR=%VAR2
- +41 IF '$DATA(%VAR)
- IF $DATA(%VAR1)
- MERGE %VAR=%VAR1
- +42 IF $DATA(%VOTH2)
- MERGE %VOTH=%VOTH2
- +43 IF $GET(%DESC2)]""
- SET ZTDESC=%DESC2
- +44 IF $DATA(%ZIS)=1
- IF %ZIS=""
- SET ZTIO=""
- +45 IF '$TEST
- Begin DoDot:1
- +46 IF $DATA(IOP)
- IF IOP'?1"Q;".E
- SET IOP="Q;"_IOP
- +47 IF '$DATA(IOP)
- SET IOP="Q"
- +48 QUIT
- End DoDot:1
- +49 DO SETUP
- IF '$DATA(ZTIO)
- DO ZIS
- IF $GET(POP)
- GOTO OUT
- +50 SET ZTDTH="@"
- DO ZTLOAD
- +51 KILL %VAR,%VOTH,%ZIS,IOP
- SET %TMP=%RET
- +52 SET ZTRTN=%RTN
- +53 IF $DATA(%VAR1)
- MERGE %VAR=%VAR1
- +54 IF $DATA(%VOTH1)
- MERGE %VOTH=%VOTH1
- +55 IF $GET(%DESC)]""
- SET ZTDESC=%DESC
- +56 DO SETUP
- SET ZTIO=""
- SET %RET=-1
- SET ZTSAVE("XUTMQQ")=%TMP
- DO ZTLOAD
- IF %RET>0
- SET %RET=%RET_U_%TMP
- +57 GOTO OUT
- +58 ;
- REQQ(ZTSK,ZTDTH,%VAR) ;Reschedule the second part of a QQ task.
- +1 ;The task to work on should be in XUTMQQ.
- +2 NEW ZTIO,ZTDESC,ZTRTN,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTPRI,ZTKIL,ZTREQ
- +3 IF $GET(ZTSK)=""!($GET(ZTDTH)="")
- QUIT 0
- +4 DO VAR
- +5 DO REQ^%ZTLOAD
- +6 ;Return 1 for rescheduled, 0 for fail.
- QUIT $GET(ZTSK(0),0)
- +7 ;
- SETUP ; setup %ztload variables
- +1 KILL ZTDTH,ZTSYNC,ZTCPU,ZTUCI,ZTSAVE,ZTPRI,ZTKIL,ZTSK,IO("Q")
- NEW I,X,Y
- +2 DO VAR
- +3 IF $DATA(%VOTH)
- FOR
- SET X=$ORDER(%VOTH(X))
- IF X=""
- QUIT
- IF '$DATA(@X)
- SET @X=%VOTH(X)
- +4 IF '$DATA(ZTDESC)
- SET ZTDESC=$TRANSLATE($PIECE(ZTRTN,"("),U,"~")
- +5 QUIT
- +6 ;
- VAR ;Setup ZTSAVE
- +1 IF $DATA(%VAR)#2
- FOR I=1:1:$LENGTH(%VAR,";")
- SET X=$PIECE(%VAR,";",I)
- SET ZTSAVE(X)=""
- +2 SET X=""
- FOR
- SET X=$ORDER(%VAR(X))
- IF X=""
- QUIT
- SET ZTSAVE(X)=%VAR(X)
- +3 QUIT