| 1 | PSXJOB ;BIR/BAB,WPB-Interface Background Job ;[ 02/12/99  1:26 PM ]
 | 
|---|
| 2 |  ;;2.0;CMOP;**17**;11 Apr 97
 | 
|---|
| 3 |  ;Watches line for incoming data and the outgoing queue.
 | 
|---|
| 4 |  ;Hands off control to the Master or Slave module.
 | 
|---|
| 5 | EN ;Set E TIMER
 | 
|---|
| 6 |  S PSXTRASH=0,PSXTME=$P($H,",",2)
 | 
|---|
| 7 | READX ;Read one character, expecting ENQ
 | 
|---|
| 8 |  G:^PSX(553,1,"S")="S" STOP
 | 
|---|
| 9 |  I $P($G(^PSX(553,1,0)),"^")["LEAVENWORTH" G R1
 | 
|---|
| 10 |  I $G(PSXQRY)=1 G ^PSXQRY
 | 
|---|
| 11 | R1 R *X:$S($O(^PSX(552.1,"AQ",0)):0,1:5)
 | 
|---|
| 12 |  ;if read timed out, check if timer E expired or queue has outgoing
 | 
|---|
| 13 |  ;messages then goto master, otherwise reset params & continue idling
 | 
|---|
| 14 |  E  D CHKE^PSXUTL G:PSXTMOUT!$D(^PSX(552.1,"AQ")) BID^PSXMST D SETPAR^PSXSTRT G READX
 | 
|---|
| 15 |  ;If ENQ,TERM send ACK0 and goto slave(Rec'd bid for master)
 | 
|---|
| 16 |  ;Else flush garbage from buffer and continue idling
 | 
|---|
| 17 |  E  D TRASH
 | 
|---|
| 18 |  G:PSXTRASH>300 EN^PSXSTP G READX
 | 
|---|
| 19 | TRASH ;Trash received while idling!!
 | 
|---|
| 20 |  S PSXTRASH=PSXTRASH+1 D FLUSH1^PSXUTL I '(PSXTRASH#5) D JOB1,LOG^PSXUTL
 | 
|---|
| 21 |  Q
 | 
|---|
| 22 | JOB1 K LOG
 | 
|---|
| 23 |  S LOG(1)="JOB1 Unexpected character ("_X_") has been received ("_PSXTRASH_") times "
 | 
|---|
| 24 |  S LOG(2)="while Idling. Check INTERFACE connection."
 | 
|---|
| 25 |  Q
 | 
|---|
| 26 | STOP K LOG S LOG(1)="JOB2 Stop interface request detected from DHCP."
 | 
|---|
| 27 |  D LOG^PSXUTL
 | 
|---|
| 28 |  G EN^PSXSTP
 | 
|---|
| 29 | STRT ;Enter here when starting the interface
 | 
|---|
| 30 |  ;Flush buffers
 | 
|---|
| 31 |  D FLUSH1^PSXUTL
 | 
|---|
| 32 |  W *EOT,*TERM
 | 
|---|
| 33 |  K LOG S LOG(1)="JOB0 STARTING THE INTERFACE"
 | 
|---|
| 34 |  D LOG^PSXUTL
 | 
|---|
| 35 |  G EN
 | 
|---|