LAXSYMDL ; IHS/DIR/FJE - ABBOTT AxSYM 'DWNLD' PGM 5/10/94 ;
;;5.2;LA;;NOV 01, 1997
;;5.2;AUTOMATED LAB INSTRUMENTS;**11**;Sep 27, 1994
;
Q ; enter at proper line tag
;
; ** NOTE **
; This routine must be invoked ONLY by LAPORT33 (LANM) as it
; requires a BI-directional interface with the AxSYM! /mld
;
DWNLD ; Download work list to the AxSYM (called by 'LANM' routine)
D START
S X="TRAP^"_LANM,@^%ZOSF("TRAP") ; reset error trap
G @("PH1^"_LANM)
;
START ; Call line tag to allow 'NEW' command
N CNT,I,X,FRM,LAQUIT,LAREAD,LARETRY,READ,TMOUT
S READ="S LAREAD=$$GETCH^"_LANM ; indirect read using i/f routine
S (I,LAQUIT,LARETRY)=0,X="ERR^LAXSYMDL",@^%ZOSF("TRAP"),TMOUT=-1
;
L +^LA(INST,NODE) ; begin after obtaining global
G:'$G(^LA(INST,NODE)) OUT ; nothing to dwnld - get out
;
GETACK ; GetACK from AxSYM indicating OK to start dwnld
D SEND^LAXSYMU(ENQ),READ ; send wakeup ENQ to machine, get reply
I LAREAD'=ACK S LARETRY=LARETRY+1 G:LARETRY<7 GETACK
G:LARETRY=7 OUT ; too many attempts - get out
;
F S I=$O(^LA(INST,NODE,I)) Q:'I S FRM=^(I) D Q:LAQUIT
.S LARETRY=0 ; init counter
AGN .W FRM ; send frame
.I DEBUG D DEBG^LAXSYMU(FRM,"O")
.; get ACK response from AxSYM
.D READ
.; if machine NAK's, resend (6 times max)
.I LAREAD=21,LARETRY<7 S LARETRY=LARETRY+1 G AGN
.I LARETRY=7 S LAQUIT=1 Q ; reached max retries
.; if machine timed out go to idle
.I LAREAD=TMOUT S LAQUIT=1 Q
.Q
;
G:LAQUIT OUT ; error - don't reset flags
K ^LA(INST,NODE) ; remove d/l list
K:NODE="O" ^LA(INST,"Q") ; remove dwnld-ready flag
;
OUT ; Exit point for excessive # retries
D SEND^LAXSYMU(EOT) ; indicate end of transfer
L -^LA(INST,NODE) ; release lock
;
QUIT
;
READ ; Get machine's reply
X READ ; READ is set to 'S LAREAD=$$GETCH^LAPORTxx'
I DEBUG D DEBG^LAXSYMU(LAREAD,"I")
I LAREAD=EOT S LAREAD=ACK ; treat EOTs as ACK
I '$F(TMOUT_U_ACK_U_NAK_U_ENQ,LAREAD) S LAREAD=NAK ; Invalid reply=NAK
Q:LAREAD=TMOUT ; timed out
Q:LAREAD=ACK ; ACK'd if OK
Q:LAREAD=NAK ; NAK'd
G READ ; read until ACK'd, NAK'd or timed out
;
ERR ; Error Trap
D ^LABERR
K:$G(NODE)="O" ^LA(INST,"Q") ; remove d/l ready flag
G OUT
LAXSYMDL ; IHS/DIR/FJE - ABBOTT AxSYM 'DWNLD' PGM 5/10/94 ;
+1 ;;5.2;LA;;NOV 01, 1997
+2 ;;5.2;AUTOMATED LAB INSTRUMENTS;**11**;Sep 27, 1994
+3 ;
+4 ; enter at proper line tag
QUIT
+5 ;
+6 ; ** NOTE **
+7 ; This routine must be invoked ONLY by LAPORT33 (LANM) as it
+8 ; requires a BI-directional interface with the AxSYM! /mld
+9 ;
DWNLD ; Download work list to the AxSYM (called by 'LANM' routine)
+1 DO START
+2 ; reset error trap
SET X="TRAP^"_LANM
SET @^%ZOSF("TRAP")
+3 GOTO @("PH1^"_LANM)
+4 ;
START ; Call line tag to allow 'NEW' command
+1 NEW CNT,I,X,FRM,LAQUIT,LAREAD,LARETRY,READ,TMOUT
+2 ; indirect read using i/f routine
SET READ="S LAREAD=$$GETCH^"_LANM
+3 SET (I,LAQUIT,LARETRY)=0
SET X="ERR^LAXSYMDL"
SET @^%ZOSF("TRAP")
SET TMOUT=-1
+4 ;
+5 ; begin after obtaining global
LOCK +^LA(INST,NODE)
+6 ; nothing to dwnld - get out
IF '$GET(^LA(INST,NODE))
GOTO OUT
+7 ;
GETACK ; GetACK from AxSYM indicating OK to start dwnld
+1 ; send wakeup ENQ to machine, get reply
DO SEND^LAXSYMU(ENQ)
DO READ
+2 IF LAREAD'=ACK
SET LARETRY=LARETRY+1
IF LARETRY<7
GOTO GETACK
+3 ; too many attempts - get out
IF LARETRY=7
GOTO OUT
+4 ;
+5 FOR
SET I=$ORDER(^LA(INST,NODE,I))
IF 'I
QUIT
SET FRM=^(I)
Begin DoDot:1
+6 ; init counter
SET LARETRY=0
AGN ; send frame
WRITE FRM
+1 IF DEBUG
DO DEBG^LAXSYMU(FRM,"O")
+2 ; get ACK response from AxSYM
+3 DO READ
+4 ; if machine NAK's, resend (6 times max)
+5 IF LAREAD=21
IF LARETRY<7
SET LARETRY=LARETRY+1
GOTO AGN
+6 ; reached max retries
IF LARETRY=7
SET LAQUIT=1
QUIT
+7 ; if machine timed out go to idle
+8 IF LAREAD=TMOUT
SET LAQUIT=1
QUIT
+9 QUIT
End DoDot:1
IF LAQUIT
QUIT
+10 ;
+11 ; error - don't reset flags
IF LAQUIT
GOTO OUT
+12 ; remove d/l list
KILL ^LA(INST,NODE)
+13 ; remove dwnld-ready flag
IF NODE="O"
KILL ^LA(INST,"Q")
+14 ;
OUT ; Exit point for excessive # retries
+1 ; indicate end of transfer
DO SEND^LAXSYMU(EOT)
+2 ; release lock
LOCK -^LA(INST,NODE)
+3 ;
+4 QUIT
+5 ;
READ ; Get machine's reply
+1 ; READ is set to 'S LAREAD=$$GETCH^LAPORTxx'
XECUTE READ
+2 IF DEBUG
DO DEBG^LAXSYMU(LAREAD,"I")
+3 ; treat EOTs as ACK
IF LAREAD=EOT
SET LAREAD=ACK
+4 ; Invalid reply=NAK
IF '$FIND(TMOUT_U_ACK_U_NAK_U_ENQ,LAREAD)
SET LAREAD=NAK
+5 ; timed out
IF LAREAD=TMOUT
QUIT
+6 ; ACK'd if OK
IF LAREAD=ACK
QUIT
+7 ; NAK'd
IF LAREAD=NAK
QUIT
+8 ; read until ACK'd, NAK'd or timed out
GOTO READ
+9 ;
ERR ; Error Trap
+1 DO ^LABERR
+2 ; remove d/l ready flag
IF $GET(NODE)="O"
KILL ^LA(INST,"Q")
+3 GOTO OUT