source: FOIAVistA/trunk/r/AUTOMATED_LAB_INSTRUMENTS-LA/LAMIVTKC.m@ 1328

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

initial load of FOIAVistA 6/30/08 version

File size: 1.8 KB
Line 
1LAMIVTKC ;SLC/DLG - VITEK PROTOCOL CONTROLLER ;7/20/90 09:40 ;
2 ;;5.2;AUTOMATED LAB INSTRUMENTS;;Sep 27, 1994
3 ;;
4 ;Call with T set to Instrument data is to/from
5 ; P1= RESET POINT FOR INCOMING RECORDS, P3=Reset point FOR RECORDS SENT
6RCHK K LATYPE S:IN'["~" LATYPE="X" S:'$D(LATYPE) LATYPE=$E(IN,$F(IN,"~")) Q:"BCDEFUX^]"'[LATYPE S LATYPE=$S(LATYPE="]":"GS",LATYPE="^":"RS",1:LATYPE) D @LATYPE
7 Q
8B Q ;RECIEVED STX
9C Q ;RECIEVED ETX
10D I $D(^LA(T,"O",0)),^LA(T,"O")'=^LA(T,"O",0) S K=1 D OUT Q ;RECIEVED EOT
11 Q
12E S ^LA(T,"P1")=CNT+2,OUT=$C(6),%=OUT
13 ;I ^LA(T,"O",^LA(T,"P3"))[$C(29) S ^LA(T,"O",0)=^LA(T,"P2") L ^LA(T) S Q=^LA("Q")+1,^("Q")=Q,^LA("Q",Q)=T L ;OUTPUT WAS HUNG RESET FOR RETRANSMISSION
14 S T=T-BASE Q ;RECIEVED ENQ
15F S O=^LA(T,"O",0),^LA(T,"P3")=$S(^LA(T,"O",O)[$C(2):O+1,1:O) S K=1 D OUT Q ;RECIEVED ACK
16GS D CKSUM Q ;GS RECORD NEXT RECORD SHOULD BE X TYPE LENGTH 2
17RS D CKSUM Q ;RECIEVED RS DATA PACKET
18U S ^LA(T,"O",0)=^LA(T,"P3"),K=1 D OUT Q ;RECIEVED NAK
19X D CKSUM I $L(IN)=2 S OUT=$S(LASUM=LASUM1:$C(6),1:$C(21)),%=OUT S:LASUM=LASUM1 ^LA(T,"P1")=CNT+1 S T=T-BASE K LASUM,LASUM1 Q ;RECIEVED GS CKSUM PACKET
20 Q
21CKSUM S:'$D(LASUM) LASUM=0
22 S LASUM=$S(LATYPE="RS":30,LATYPE="GS":29,LATYPE="X":23,1:0)+LASUM
23 I LATYPE="X",($L(IN)>2) F I=1:1:$L(IN) S LASUM=LASUM+$A(IN,I)
24 I LATYPE="X",($L(IN)=2) S LASUM=LASUM-23,LASUM=LASUM#256,LASUM1=$F("0123456789abcdef",$E(IN,1))-2*16+($F("0123456789abcdef",$E(IN,2))-2)
25 Q
26OUT D NEXT Q:'$D(^LA(T,"O",O)) Q:%[$C(29) ;Q:%[$C(4) Q:%[$C(5)
27 S K=K+1 G OUT Q
28NEXT S O=^LA(T,"O",0)+K Q:'$D(^(O)) S %=^(O)
29 L ^LA("Q") S Q=^LA("Q")+1,^("Q")=Q,^("Q",Q)=T L Q
30ACK S LASUM1=$F("0123456789abcdef",$E(IN,121))-2*16+($F("0123456789abcdef",$E(IN,122))-2)
31 S LASUM=0 F I=1:1:120 S LASUM=LASUM+(255-$A(IN,I)+1)
32 S LASUM=LASUM#256,OUT=$S(LASUM=LASUM1:$C(6),1:$C(21)),%=OUT S T=T-BASE Q
Note: See TracBrowser for help on using the repository browser.