1 | LABTEST ;SLC/RWF - AUTOMATED INSTRUMENT INTERFACE TESTING ;7/20/90 07:37 ;
|
---|
2 | ;;5.2;AUTOMATED LAB INSTRUMENTS;;Sep 27, 1994
|
---|
3 | A S DIC="^LAB(62.4,",DIC(0)="AEMQZ",DIC("S")="I Y<99,Y#10=1" D ^DIC G END:Y<1 S LANM=$P(Y(0),"^",3)
|
---|
4 | S HOME=$O(^LAB(62.4,"C",LANM,0)),BASE=HOME-1 I HOME<1 W !,$C(7),"Can't find '",LANM,"' as a program name in auto instrument file." Q
|
---|
5 | S U="^",IOP=$P(^LAB(62.4,HOME,0),U,2),%ZIS="" I IOP="" W !,$C(7),"No IO device to open in auto instrument file." Q
|
---|
6 | D ^%ZIS W !,"I ",$S(POP:"Can't open",1:"Will use")," the data IO device: ",ION,"." Q:POP
|
---|
7 | D INIT^LABINIT K IOP,%ZIS S LANM="LABTEST"
|
---|
8 | X ^%ZOSF("NBRK") U IO(0) W $C(7),!,"Now please turn-OFF then ON the interface."
|
---|
9 | F I=1:1:30 U IO R X:60 U IO(0) W !,X Q:X["START"
|
---|
10 | X ^%ZOSF("BRK")
|
---|
11 | U IO(0) I X'["START" W !,"Did not find starting point. Please check cables." G TRAP
|
---|
12 | U IO W *13,*13 R X:2 ;
|
---|
13 | IO S T=T-BASE,HDR="T"_$E(100+T,2,3)_"L"_$E(1000+$L(OUT),2,4)
|
---|
14 | U IO(0) W !,"==>",HDR," ",OUT," " F I=1:1:100 U IO W HDR,!,OUT,! R *X:5 U IO(0) W $C(X) Q:$C(X)=ACK Q:(X=-1)&(T=0)
|
---|
15 | S TRY=0
|
---|
16 | RD U IO R HRD:TOUT G TOUT:'$T R IN:2 U IO(0) W !,"<==",HRD," ",IN," " S T=+$E(HRD,2,3)+BASE,L=+$E(HRD,5,7),M=+$E(HRD,9,11)
|
---|
17 | I HRD'?1"T"2N1"L"3N1"M"3N!(L'=$L(IN)),TRY<50 S TRY=TRY+1 U IO(0) W NAK U IO W NAK G RD
|
---|
18 | U IO(0) W ACK U IO W ACK G W:TRY>49
|
---|
19 | IO1 S TOUT=2 IF $D(^LA("TP",0)) S ^LA("TP",0)=1+^(0),^(^(0))=IN
|
---|
20 | IF T=HOME S RT=$H,ASK=-2
|
---|
21 | IO2 IF '$D(^LA(T)),$D(^LAB(62.4,T,1)) X ^(1)
|
---|
22 | IF '$D(^LA(T)) S T=HOME
|
---|
23 | LOCK ^LA(T) G IO2:'$D(^LA(T,"I"))#2 S CNT=^LA(T,"I")+1,^("I")=CNT,^("I",CNT)=IN L
|
---|
24 | I $D(^LAB(62.4,T,.5)) S OUT="" X ^(.5) I OUT'="" S T=T+BASE G IO
|
---|
25 | W IF $D(^LA("STOP")) K ^LA("LOCK",HOME),^LA("STOP",HOME),^LA(HOME),^TMP($J),^TMP("LA",$J) G H^XUS
|
---|
26 | S OTN=-1,OUT=$S(TOUT<10:"",1:"1"),T=$S(OUT:HOME,1:BASE) G IO:^LA("Q")=^LA(HOME,"Q")
|
---|
27 | LOCK ^LA("Q") S Q=^LA(HOME,"Q")+1,^("Q")=Q,T=$S($D(^LA("Q",Q)):^(Q),1:0) G W:T<HOME,W:HOME+9<T
|
---|
28 | K ^LA("Q",Q) L G IO:T<1,W:'$D(^LA(T))
|
---|
29 | S CNT=^LA(T,"O",0)+1 IF $D(^(CNT)) S ^(0)=CNT,OUT=^(CNT)
|
---|
30 | S TOUT=2 G IO
|
---|
31 | ;
|
---|
32 | SET G SET^LAB
|
---|
33 | ;
|
---|
34 | TOUT S:TOUT<35 TOUT=TOUT+2 S:TOUT>35 ASK=ASK+1
|
---|
35 | IF ASK=0,TOUT>35 S OUT="1",T=HOME G IO
|
---|
36 | IF ASK>1 D ^LABALARM S ASK=-1 U IO
|
---|
37 | G W
|
---|
38 | OUT S CNT=^LA(T,"O")+1,^("O")=CNT,^("O",CNT)=OUT
|
---|
39 | LOCK ^LA("Q") S Q=^LA("Q")+1,^("Q")=Q,^("Q",Q)=T LOCK
|
---|
40 | Q
|
---|
41 | INIT ;
|
---|
42 | TRAP D ^LABERR K ^LA("LOCK",HOME) D ^%ZISC U IO(0) W !,"LABTEST STOPPED.",!
|
---|
43 | Q
|
---|
44 | END K DIC,LANM Q
|
---|