source: FOIAVistA/trunk/r/CMOP-PSX/PSXYSND.m@ 1154

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

initial load of FOIAVistA 6/30/08 version

File size: 3.6 KB
Line 
1PSXYSND ;BIR/HTW-Dual Transmit a Message ;[ 03/10/99 8:39 AM ]
2 ;;2.0;CMOP;**17**;11 Apr 97
3 ;Dual Line Interface Enhancement
4GETMSG ;Get first message in queue
5 S PSXQN=$O(^PSX(552.2,"AQ",PSXB,"")) K PSXPOP
6 S PSXMSGID=$P(^PSX(552.2,PSXQN,0),"^")
7 G:'PSXQN ^PSXJOB
8 G:$G(PSXBHS)'=1 HDR
9 S BHST=0
10 D GETTXT Q:$G(QRYPOP)=1
11 G:PSXPOP ^PSXJOB
12 I PSXPOP D SND8 D LOG^PSXUTL,FLUSH1^PSXUTL
13 I PSXPOP G DONE ;dont store last if mess never sent
14 S ^PSX(553,1,99)=$P(^PSX(552.2,PSXQN,0),"^") ;last message sent, wait for ACK message
15DONE W *EOT,*TERM ;send termination sequence to slave
16 D EN^PSXACK ;get ACK message
17 G ^PSXJOB
18FILE Q:$G(PSXDA)="" D NOW^%DTC S REC=PSXDA L +^PSX(552.1,REC):30 G:'$T FILE S $P(^PSX(552.1,REC,0),U,2)=3,DIE="^PSX(552.1,",DA=REC,DR="16////"_%_";18////"_$G(PSXMSH)_$G(PSXMSA)_";20////@"
19 D ^DIE L -^PSX(552.1,REC) K DIE,REC S DIK="^PSX(552.1," D IX^DIK K DA,DIK
20 S LOG(1)="Transmission # "_PSXB_" finished downloading." D LOG^PSXUTL
21 S $P(^PSX(554,1,0),"^",2)=PSXB
22 D ACK^PSXNOTE
23 Q
24HDR D TSOUT^PSXUTL
25 S PSXBLK=1,PSXBHS=0,LOG(1)="Downloading Transmission # "_PSXB D LOG^PSXUTL
26 S $P(^PSX(552.1,PSXDA,0),"^",2)=7
27 S PSXTXT="BHS|^~\&|DHCP||"_$S($G(PSXVNDR)>0:"SI BAKER",1:"ELECTROCOM")_"||"_PSXTS_"||ORM|"_PSXB_"|P|2.1|",PSXLAST=0 D XMIT G:$G(PSXPOP) ^PSXJOB
28 S PSXBLK=PSXBLK+1
29 S REC=PSXDA,PSXMSGID=PSXB
30 F CNT=0:0 S CNT=$O(^PSX(552.1,REC,"S",CNT)) Q:CNT'>0 S PSXBLK=(CNT#8)+1,PSXTXT=$G(^PSX(552.1,REC,"S",CNT,0)),PSXLAST=$S($O(^PSX(552.1,REC,"S",CNT)):0,1:1) S:PSXBLK>7 PSXBLK=0 D XMIT G:$G(PSXPOP) ^PSXJOB
31 W *EOT,*TERM
32 D EN^PSXACK K:$G(PSXBHS)>0 XTRY G:PSXBHS=1 BID1^PSXMST
33 S XTRY=$G(XTRY)+1 S LOG(1)="Batch Header Rejected by Vendor for Transmission "_$G(PSXB) D LOG^PSXUTL G:$G(XTRY)'>5 ^PSXJOB
34 I $G(XTRY)>5 S LOG(1)="Batch Header for transmission "_$G(PSXB)_" rejected max times.",LOG(2)="DHCP Stopping interface." D LOG^PSXUTL G STOP^PSXJOB
35 Q
36GETTXT F I=0:0 S I=$O(^PSX(552.2,PSXQN,"T",I)) Q:'I K PSXTXT S PSXBLK=I#8,PSXTXTN=I,PSXTXT=$G(^(PSXTXTN,0)),PSXLAST=$S($O(^PSX(552.2,PSXQN,"T",I)):0,1:1) Q:PSXTXT="" D XMIT Q:PSXPOP
37 Q
38XMIT S (PSXPOP,PSXTRYN)=0
39 S PSXLEN=$L(PSXTXT)
40 S PSXLEN=$E("00000",1,5-$L(PSXLEN))_PSXLEN
41 S PSXTXT=PSXBLK_PSXLEN_PSXTXT_$S(PSXLAST:$C(ETX),1:$C(ETB))
42 ;Get 2 byte hex Csum
43 S X=PSXTXT X ^%ZOSF("LPC") S PSXHEX=Y D HEX^PSXUTL
44 S PSXTXT=$C(STX)_PSXTXT_PSXHEX_$C(TERM)
45RETRY W PSXTXT
46 S PSXBLK=$A(PSXBLK)
47TRY R *X:PSXDLTA E D SND1 G ERROR ;look for ACK or NAK
48 I X=ACK R *X:PSXDLTA D:('$T)!(X'=PSXBLK) SND2 G:('$T)!(X'=PSXBLK) ERROR R *X:PSXDLTA D:('$T)!(X'=TERM) SND9 G:('$T)!(X'=TERM) ERROR Q
49 I X=NAK R *X:PSXDLTA D:('$T)!(X'=TERM) SND3 D SND4 G ERROR
50 I X=EOT R *X:PSXDLTA D:('$T)!(X'=TERM) SND5 D SND7 G:('$T)!(X'=TERM) ERROR S PSXTRYN=9999 G ERROR
51 D SND6
52ERROR D FLUSH1^PSXUTL,LOG^PSXUTL
53 S PSXTRYN=PSXTRYN+1
54 S PSXBLK=$C(PSXBLK)
55 G:PSXTRYN'>PSXTRYL RETRY
56 S PSXPOP=1
57 Q
58SND1 K LOG S LOG(1)="SND1 Timer A timeout after sending a line of text."_$G(PSXBLK) Q
59SND2 K LOG S LOG(1)="SND2 ACK Received with bad block number after sending line of text, ASCII ("_$G(X)_") "_X
60 S LOG(2)="Expected ASCII ("_$G(PSXBLK)_")." Q
61SND3 K LOG S LOG(1)="SND3 NAK Received with no terminator after sending a line of text." Q
62SND4 K LOG S LOG(1)="SND4 NAK Received after sending a line of text." Q
63SND5 K LOG S LOG(1)="SND5 EOT Received with no terminator after sending a line of text." Q
64SND6 K LOG S LOG(1)="SND6 Garbage received after sending a line of text. ("_X_")" Q
65SND7 K LOG S LOG(1)="SND7 EOT Received, aborting send." Q
66SND8 K LOG S LOG(1)="SND8 Aborting Send. Error processing order # "_$P($G(^PSX(552.2,PSXQN,0)),"^",1)_". Text: "_PSXTXT Q
67SND9 K LOG S LOG(1)="SND9 ACK,"_$G(PSXBLK)_" received with no terminator after sending",LOG(2)="a line of text." Q
Note: See TracBrowser for help on using the repository browser.