LAMSPAN ; IHS/DIR/FJE - MICROSCAN PROTOCALL ROUTINE W/ ACK-NAK 7/20/90 09:50 ;
;;5.2;LA;;NOV 01, 1997
;;5.2;AUTOMATED LAB INSTRUMENTS;;Sep 27, 1994
A L ^LA(T) I '$D(^LA(T,"P")) S ^("P")="MICROSCAN^IN"
S MODE=$P(^LA(T,"P"),"^",2),CTRL=$S($F(IN,"~")=$L(IN):$P(IN,"~",2),1:" ") D @MODE L Q
;
IN ;C= <STX>+<LF>+<CR> or there replaced values.
Q:"BU"[CTRL G I2:"C"[CTRL I CTRL["E" S OUT=$C(6) Q
G:CTRL["D" SETOUT
S C=2+13+13 F I=1:1:$L(IN) S C=C+$A(IN,I)
S ^LA(T,"P1")=C#256 Q
I2 S C=$A(IN,1)-64*16+$A(IN,2)-64,CHK=$S($D(^LA(T,"P1")):^("P1"),1:-1),OUT=$S(C=CHK:$C(6),1:$C(21))
I C'=CHK S CNT=^LA(T,"I")-2,^("I")=$S(CNT'<0:CNT,1:0)
Q
OUT I CTRL'="F" S CNT=^LA(T,"O",0)-2,^(0)=$S(CNT'<0:CNT,1:0) ;drop into next line
Q:'$D(^LA(T,"O",0)) S CNT=^LA(T,"O",0)+1 I '$D(^LA(T,"O",CNT)) K ^LA(T) Q ;Clean up and leave
S ^(0)=CNT,OUT=^LA(T,"O",CNT)
L ^LA("Q") S Q=^LA("Q")+1,^LA("Q")=Q,^("Q",Q)=T
Q
SETOUT ;Change to output
Q:'$D(^LA(T,"O",0)) Q:^LA(T,"O")'>^LA(T,"O",0)
S $P(^LA(T,"P"),"^",2)="OUT" L ^LA("Q") S Q=^LA("Q"),^LA("Q",Q+1)=T,^(Q+2)=T,^LA("Q")=Q+2
Q
;The MicroScan needs to have the field delimiter set to | (124)
;LF is set to @ (64). Set " to 0.
;Timeout set to a min of 20, Protocall set to ACK/NAK.
;STX = ~B, ETX = ~C, EOT = ~D, ENQ = ~E, ACK = ~F, NAK = ~U
LAMSPAN ; IHS/DIR/FJE - MICROSCAN PROTOCALL ROUTINE W/ ACK-NAK 7/20/90 09:50 ;
+1 ;;5.2;LA;;NOV 01, 1997
+2 ;;5.2;AUTOMATED LAB INSTRUMENTS;;Sep 27, 1994
A LOCK ^LA(T)
IF '$DATA(^LA(T,"P"))
SET ^("P")="MICROSCAN^IN"
+1 SET MODE=$PIECE(^LA(T,"P"),"^",2)
SET CTRL=$SELECT($FIND(IN,"~")=$LENGTH(IN):$PIECE(IN,"~",2),1:" ")
DO @MODE
LOCK
QUIT
+2 ;
IN ;C= <STX>+<LF>+<CR> or there replaced values.
+1 IF "BU"[CTRL
QUIT
IF "C"[CTRL
GOTO I2
IF CTRL["E"
SET OUT=$CHAR(6)
QUIT
+2 IF CTRL["D"
GOTO SETOUT
+3 SET C=2+13+13
FOR I=1:1:$LENGTH(IN)
SET C=C+$ASCII(IN,I)
+4 SET ^LA(T,"P1")=C#256
QUIT
I2 SET C=$ASCII(IN,1)-64*16+$ASCII(IN,2)-64
SET CHK=$SELECT($DATA(^LA(T,"P1")):^("P1"),1:-1)
SET OUT=$SELECT(C=CHK:$CHAR(6),1:$CHAR(21))
+1 IF C'=CHK
SET CNT=^LA(T,"I")-2
SET ^("I")=$SELECT(CNT'<0:CNT,1:0)
+2 QUIT
OUT ;drop into next line
IF CTRL'="F"
SET CNT=^LA(T,"O",0)-2
SET ^(0)=$SELECT(CNT'<0:CNT,1:0)
+1 ;Clean up and leave
IF '$DATA(^LA(T,"O",0))
QUIT
SET CNT=^LA(T,"O",0)+1
IF '$DATA(^LA(T,"O",CNT))
KILL ^LA(T)
QUIT
+2 SET ^(0)=CNT
SET OUT=^LA(T,"O",CNT)
+3 LOCK ^LA("Q")
SET Q=^LA("Q")+1
SET ^LA("Q")=Q
SET ^("Q",Q)=T
+4 QUIT
SETOUT ;Change to output
+1 IF '$DATA(^LA(T,"O",0))
QUIT
IF ^LA(T,"O")'>^LA(T,"O",0)
QUIT
+2 SET $PIECE(^LA(T,"P"),"^",2)="OUT"
LOCK ^LA("Q")
SET Q=^LA("Q")
SET ^LA("Q",Q+1)=T
SET ^(Q+2)=T
SET ^LA("Q")=Q+2
+3 QUIT
+4 ;The MicroScan needs to have the field delimiter set to | (124)
+5 ;LF is set to @ (64). Set " to 0.
+6 ;Timeout set to a min of 20, Protocall set to ACK/NAK.
+7 ;STX = ~B, ETX = ~C, EOT = ~D, ENQ = ~E, ACK = ~F, NAK = ~U