source: WorldVistAEHR/trunk/r/AUTOMATED_LAB_INSTRUMENTS-LA/LAXSYMDL.m@ 738

Last change on this file since 738 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 2.1 KB
Line 
1LAXSYMDL ;MLD/ABBOTT/SLC/RAF - ABBOTT AxSYM 'DWNLD' PGM ; 6/12/96 0900;
2 ;;5.2;AUTOMATED LAB INSTRUMENTS;**11**;Sep 27, 1994
3 ;
4 Q ; enter at proper line tag
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 ;
10DWNLD ; Download work list to the AxSYM (called by 'LANM' routine)
11 D START
12 S X="TRAP^"_LANM,@^%ZOSF("TRAP") ; reset error trap
13 G @("PH1^"_LANM)
14 ;
15START ; Call line tag to allow 'NEW' command
16 N CNT,I,X,FRM,LAQUIT,LAREAD,LARETRY,READ,TMOUT
17 S READ="S LAREAD=$$GETCH^"_LANM ; indirect read using i/f routine
18 S (I,LAQUIT,LARETRY)=0,X="ERR^LAXSYMDL",@^%ZOSF("TRAP"),TMOUT=-1
19 ;
20 L +^LA(INST,NODE) ; begin after obtaining global
21 G:'$G(^LA(INST,NODE)) OUT ; nothing to dwnld - get out
22 ;
23GETACK ; GetACK from AxSYM indicating OK to start dwnld
24 D SEND^LAXSYMU(ENQ),READ ; send wakeup ENQ to machine, get reply
25 I LAREAD'=ACK S LARETRY=LARETRY+1 G:LARETRY<7 GETACK
26 G:LARETRY=7 OUT ; too many attempts - get out
27 ;
28 F S I=$O(^LA(INST,NODE,I)) Q:'I S FRM=^(I) D Q:LAQUIT
29 .S LARETRY=0 ; init counter
30AGN .W FRM ; send frame
31 .I DEBUG D DEBG^LAXSYMU(FRM,"O")
32 .; get ACK response from AxSYM
33 .D READ
34 .; if machine NAK's, resend (6 times max)
35 .I LAREAD=21,LARETRY<7 S LARETRY=LARETRY+1 G AGN
36 .I LARETRY=7 S LAQUIT=1 Q ; reached max retries
37 .; if machine timed out go to idle
38 .I LAREAD=TMOUT S LAQUIT=1 Q
39 .Q
40 ;
41 G:LAQUIT OUT ; error - don't reset flags
42 K ^LA(INST,NODE) ; remove d/l list
43 K:NODE="O" ^LA(INST,"Q") ; remove dwnld-ready flag
44 ;
45OUT ; Exit point for excessive # retries
46 D SEND^LAXSYMU(EOT) ; indicate end of transfer
47 L -^LA(INST,NODE) ; release lock
48 ;
49 QUIT
50 ;
51READ ; Get machine's reply
52 X READ ; READ is set to 'S LAREAD=$$GETCH^LAPORTxx'
53 I DEBUG D DEBG^LAXSYMU(LAREAD,"I")
54 I LAREAD=EOT S LAREAD=ACK ; treat EOTs as ACK
55 I '$F(TMOUT_U_ACK_U_NAK_U_ENQ,LAREAD) S LAREAD=NAK ; Invalid reply=NAK
56 Q:LAREAD=TMOUT ; timed out
57 Q:LAREAD=ACK ; ACK'd if OK
58 Q:LAREAD=NAK ; NAK'd
59 G READ ; read until ACK'd, NAK'd or timed out
60 ;
61ERR ; Error Trap
62 D ^LABERR
63 K:$G(NODE)="O" ^LA(INST,"Q") ; remove d/l ready flag
64 G OUT
Note: See TracBrowser for help on using the repository browser.