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/ZISC.m@ 794

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

initial load of FOIAVistA 6/30/08 version

File size: 4.9 KB
Line 
1%ZISC ;SFISC/GFT,AC,MUS - CLOSE LOGIC FOR DEVICES ;1/24/08 16:09
2 ;;8.0;KERNEL;**24,36,49,69,199,216,275,409,440**;JUL 10, 1995;Build 13
3 ;Per VHA Directive 2004-038, this routine should not be modified
4C0 ;
5 N %,%E,%H,%ZISI,%ZISOS,%ZISX,%ZISV
6 ;Clear IO var we will use for reporting
7 K IO("ERROR"),IO("LASTERR"),IO("CLOSE")
8 ;Protect ourself from calls with incomplete setup.
9 S:$D(IO)[0 IO=$I S:'$D(IO(0)) IO(0)=$P
10 S U="^",%ZISOS=$G(^%ZOSF("OS")),%ZISV=$G(^("VOL"))
11 ;S %=$S(+$G(IOS):IOS,$L($G(ION)):ION,1:IO)
12 S %=$S($L($G(ION)):ION,1:IO) ;p409
13 I (%="")!(IO="") G SETIO:IO(0)]"",END
14 I $G(IOT)="RES" D RES G SETIO ;Handle a resource device
15 ;
16 ;Define subtype info if not already defined.
17 D SUBTYPE
18 ;
19 ;perform close execute
20 I $G(IOST(0))>0 D
21 . I $G(^%ZIS(2,+IOST(0),3))]"",$D(IO(1,IO)) D
22 . . U IO S:$X $X=1 D X3^ZISX:'$D(IO("T"))
23 ;
24 ;Incase the Close execute changed IO, Open IO("HOME") or NULL.
25 I '$L($G(IO)) D Q
26 . S IOP=$S($L($G(IO("HOME"))):"`"_(+IO("HOME")),1:"NULL") D ^%ZIS
27 . Q
28 ;
29 ;Perform the following if the device is open.
30 I $D(IO(1,IO)) D
31 . I $G(IO("P"))["B" D ;Return to normal intensity
32 . . S %=$P($G(^%ZIS(2,+IOST(0),7)),"^",3) I %]"" W @%
33 . I $G(IO("P"))["P" D ;Return to default pitch
34 . . S %=$G(^%ZIS(2,+IOST(0),12.11)) I %]"" W @%
35 . ;
36 . W:$$FF @IOF ;Issue form feed at close
37 . I $$CLOSPP D X11^ZISX:'$D(IO("T")) K IO("S") ;Close printer port
38 . Q
39 ;
40 ;Don't use IOCPU as we now use IO(1,IO)
41 I (IO'=IO(0)!$D(IO("C"))),$D(IO(1,IO)) D
42 . U:$S($D(ZTQUEUED):0,'$L($G(IO(0))):0,$D(IO(1,IO(0)))#2:1,1:0) IO(0)
43 . C IO K IO(1,IO) S IO("CLOSE")=IO ;close device
44 ;Unlock global used to control access.
45 S %=$G(^XUTL("XQ",$J,"lock",+$G(IOS))) I $L(%) L -@% K ^XUTL("XQ",$J,"lock",IOS)
46 ;
47 I $D(IO("SPOOL")) D CLOSE^%ZIS4 ;Special close for spool device
48 ;
49SETIO ;
50 ;See if old device has PCX code
51 I $G(IOS),$G(^%ZIS(1,+IOS,"PCX"))]"" S %ZISPCX=^("PCX")
52 ;Setup the IO(0) device, should be the home device
53 S IO=IO(0),(IOPAR,IOUPAR)="" K IO("T") D CIOS(IO(0))
54 I 'IOS S IOT="TRM" G END
55 S ION=$P(^%ZIS(1,IOS,0),"^",1),IOT=$G(^("TYPE")),IOST(0)=$S(IOT["TRM"&($D(^XUTL("XQ",$J,"IOST(0)"))):^("IOST(0)"),1:$G(^%ZIS(1,IOS,"SUBTYPE")))
56 I IOT["TRM",$D(^XUTL("XQ",$J,"IO")) D HOME^%ZIS G END
57 S %="Y"
58 I IOST(0),$D(^%ZIS(2,IOST(0),1)) S %=^(1),IOM=+%,IOF=$P(%,"^",2),IOSL=$P(%,"^",3),IOBS=$P(%,"^",4)
59 I $D(^%ZIS(1,IOS,91)) S %=^%ZIS(1,IOS,91) S:+% IOM=+% S:$P(%,"^",3) IOSL=$P(%,"^",3)
60 ;Don't know the subtype so set some defaults
61 I %="Y" S IOM=80,IOSL=24,IOF="#",IOST="C-OTHER",IOBS="$C(8)"
62S1 S:IOST(0) IOST=$P($G(^%ZIS(2,+IOST(0),0)),"^"),IOXY=$G(^("XY"))
63 I '$D(ZTQUEUED),'$D(IO("C")),IOT["TRM" D RM:$D(IO(1,IO))
64 ;With home device set, Do Post-close execute code of Device closed.
65END I '$D(IO("T")),$G(%ZISPCX)]"" S %Y=%ZISPCX D %Y^ZISX
66 ;See that any extra IO variables are cleaned up
67 K IO("P"),IO("DOC"),IO("HFSIO"),IO("SPOOL"),IOC,IONOFF
68 ;IOCPU should not be changed.
69 Q
70 ;
71SUBTYPE ;Find a subtype
72 N %S
73 S IOST=$G(IOST),IOST(0)=+$G(IOST(0))
74 I $L(IOST)&$L(IOST(0)) Q ;Have a subtype
75 S %S=$G(^%ZIS(2,+IOST(0),0)) I $L(%S) S IOST=$P(%S,U) Q
76 I $L(IOST) S %S=$O(^%ZIS(2,"B",$G(IOST,"X"),0)) I %S>0 S IOST(0)=+%S Q
77 S IOST="",IOST(0)=0 D CIOS($I) Q:IOS'>0
78 S IOST(0)=$G(^%ZIS(1,+IOS,"SUBTYPE")),IOST=$P($G(^%ZIS(2,+IOST(0),0)),"^")
79 Q
80 ;
81CIOS(%I) ;Find a value for IOS (IEN into device file)
82 N %ZISVT
83 I $D(^XUTL("XQ",$J,"IOS")) S IOS=+^("IOS") Q
84 I $D(%ZISV) S %ZISVT=%I D VTLKUP^%ZIS S IOS=+%E
85 E S IOS=+$O(^%ZIS(1,"C",%I,0))
86 Q:$G(IOS)>0
87 S %ZISVT=%I D VIRTUAL^%ZIS
88 I $D(%ZISVT) S %H=%E I %ZISVT]"",%H>0,$D(^%ZIS(1,%H,0)),$D(^("TYPE")),^("TYPE")="VTRM" S IOS=%H
89 Q
90 ;
91RM N X S X=+IOM X ^%ZOSF("RM")
92 Q
93 ;
94RES ;Close resource device.
95 Q:'$D(IO(1,IO))&'$D(^%ZISL(3.54,"AJ",$J))
96 N %ZISJOB,%X,%Y,%ZISD0,%ZISD1,%ZISRES,%ZISRL,%ZISY0,%ZTRTN,ZTSAVE,ZTIO
97 S %ZISJOB=$J
98 ;
99RES1 G RQ:'$D(IOS),RQ:'$D(^%ZIS(1,+IOS,1)) S %ZISRL=+$P(^(1),"^",10),%ZISRL=$S(%ZISRL:%ZISRL,1:1)
100 S %X=$O(^%ZISL(3.54,"B",IO,0)) G RQ:'%X
101 G RQ:'$D(^%ZISL(3.54,+%X,0)) S %ZISD0=+%X,%ZISY0=^(0)
102 S %X=$O(^%ZISL(3.54,"AJ",%ZISJOB,%ZISD0,0)) S %ZISD1=%X G RQ:'%X
103 S %Y=$G(^%ZISL(3.54,%ZISD0,1,+%ZISD1,0)) G RQ:$P(%Y,"^",3)'=%ZISJOB
104 D KILLRES(+%ZISD0,+%ZISD1)
105RQ K IO(1,IO)
106 Q
107 ;
108KILLRES(D0,D1) ;Kill one resource use
109 Q:(D0'>0)!(D1'>0)
110 N %X,%Y,%J,%ZISRL
111 L +^%ZISL(3.54,D0,0)
112 S %Y=$G(^%ZISL(3.54,D0,0)) G KRX:%Y=""
113 S %X=$G(^%ZISL(3.54,D0,1,D1,0)),%J=$P(%X,"^",3) S:%J="" %J=" "
114 K ^%ZISL(3.54,D0,1,D1,0),^%ZISL(3.54,D0,1,"B",D1,D1),^%ZISL(3.54,"AJ",%J,D0,D1)
115 S %X=$P(%Y,"^",2)+1,$P(^%ZISL(3.54,D0,0),"^",2)=%X
116 ;I '$D(^%ZISL(3.54,%ZISD0,1,0)) S ^(0)="^3.542A^^" G RQ
117 S %Y=$G(^%ZISL(3.54,D0,1,0)),%X=$P(%Y,"^",4),$P(^%ZISL(3.54,D0,1,0),"^",3,4)="^"_$S(%X>0:(%X-1),1:0)
118KRX L -^%ZISL(3.54,D0,0)
119 Q
120 ;
121DQCRES ;Tasked entry point to close resource device.
122 S IO=%ZISRES G RES1
123 ;
124FF() ;Issue form feed
125 I $E(IOST,1,2)'["C-",$D(IO(1,IO)),$G(IOT)="TRM"!($G(IOT)="SPL"),'$D(IO("T"))&$Y&'$D(IONOFF)&'$D(IO(1,IO,"NOFF")) Q 1
126 Q 0
127 ;
128CLOSPP() ;Close printer port
129 I $D(IO("S")),$D(^%ZIS(2,+IO("S"),11))&$D(IO(1,IO)) Q 1
130 Q 0
Note: See TracBrowser for help on using the repository browser.