VistA-WorldVistAEHR/r/AUTOMATED_LAB_INSTRUMENTS-LA/LAEPXPXX.m

41 lines
2.0 KiB
Mathematica
Raw Normal View History

2009-11-29 13:37:14 -05:00
LAEPXPXX ;SLC/DLG - AUTOMATED SINGLE INSTRUMENT EPX DIRECT CONNECT LAB INTERFACE ;9/5/90 14:34 ;
;;5.2;AUTOMATED LAB INSTRUMENTS;;Sep 27, 1994
;THIS ROUTINE IS STARTED TO RUN AN INSTRUMENT DIRECT TO A CPU
;RATHER THAN THRU THE LSI. IT IS A CONSTANT BACKGROUND JOB
;THAT ONLY STOPS WHEN SYSTEM IS TAKEN DOWN OR THE JOB IS STOPPED BY
;SETTING THE ^LA("STOP",INST#)=""
;THE CODE HAS A DATA TRAP CAPABILITY TO TRAP ALL DATA GOING THRU
;THIS ROUTINE. S ^LA("D"_T,0)=0 WHERE T IS THE AUTOINSTRUMENT
;ENTRY NUMBER WILL TURN THE TRAP ON. K ^LA("D"_T) WILL TURN THE
;TRAP OFF AND KILL ALL THE DATA.
S:$D(ZTQUEUED) ZTREQ="@" S LANM=$T(+0),(HOME,T)=+$E(LANM,7,8) Q:+T<1 Q:$D(^LA("LOCK",T))
S DEB="D"_T,PAR=$S($D(^LAB(62.4,T,.5))#2:^(.5),1:""),OUT="",BASE=0,TOUT=5,U="^",IOP=$P(^LAB(62.4,HOME,0),"^",2) G:IOP="" H^XUS S IOP=IOP_";255",%ZIS=""
D ^%ZIS G:POP H^XUS U IO X ^%ZOSF("TYPE-AHEAD"),^%ZOSF("LABOFF")
C:IO(0)'=IO IO(0) S X="TRAP^"_LANM,@^%ZOSF("TRAP"),DUZ=.5
S ^LA("LOCK",T)=$J
R X:1,X:1 ;ALLOW BREAK AND FLUSH BUFFER
LA2 I OUT]"" D:$D(^LA(DEB,0)) DEBUGO W OUT G:OUT'["#" W W *13 S TRY=0,OUT=""
RD S IN="" F I=0:0 R *X:TOUT Q:'$T Q:X=13 S IN=IN_$C(X) Q:$L(IN)=255
G:X<0 TOUT
LA22 D SET
L ^LA(T) G LA22:'$D(^LA(T,"I"))#2 S CNT=^LA(T,"I")+1,^("I")=CNT,^("I",CNT)=IN L
D:$D(^LA(DEB,0)) DEBUGI
I IN'["#" G RD
I PAR]"" S OUT="" X PAR I OUT]"" S T=T+BASE G LA2
G RD
W IF $D(^LA("STOP",HOME)) K ^LA("LOCK",HOME),^LA("STOP",HOME) G H^XUS
S OUT="" S CNT=^LA(T,"O",0)+1 IF $D(^(CNT)) S ^(0)=CNT,OUT=^(CNT)
S TOUT=5 G LA2
;
SET S:'$D(^LA(T,"I"))#2 ^LA(T,"I")=0,^("I",0)=0
SETO S:'$D(^LA(T,"O"))#2 ^LA(T,"O")=0,^("O",0)=0 Q
;
TOUT S TOUT=$S(TOUT<8:TOUT+1,1:5) G:TOUT'=5 RD S OUT="" G RD:'$D(^LA(T))
I $D(^LA(T,"O",0)),^LA(T,"O")>^LA(T,"O",0) G W
G RD Q
DQ K ^LA("LOCK",$E($T(+0),7,8)) G LAEPXPXX
DEBUGO S (Q,^LA(DEB,0))=^LA(DEB,0)+1,^(Q)="OUT: "_$E(OUT,1,230)_"%^%"_$H Q
DEBUGI S (Q,^LA(DEB,0))=^LA(DEB,0)+1,^(Q)="IN: "_$E(IN,1,230)_"%^%"_$H Q
TRAP D ^LABERR S T=TSK D SET G @("LA2^"_LANM)
Q