LAXSYMDL ;MLD/ABBOTT/SLC/RAF - ABBOTT AxSYM 'DWNLD' PGM ; 6/12/96 0900;
;;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
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLAXSYMDL 2226 printed Dec 13, 2024@01:44:27 Page 2
LAXSYMDL ;MLD/ABBOTT/SLC/RAF - ABBOTT AxSYM 'DWNLD' PGM ; 6/12/96 0900;
+1 ;;5.2;AUTOMATED LAB INSTRUMENTS;**11**;Sep 27, 1994
+2 ;
+3 ; enter at proper line tag
QUIT
+4 ;
+5 ; ** NOTE **
+6 ; This routine must be invoked ONLY by LAPORT33 (LANM) as it
+7 ; requires a BI-directional interface with the AxSYM! /mld
+8 ;
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