- PSXJOB ;BIR/BAB,WPB-Interface Background Job ;[ 02/12/99 1:26 PM ]
- ;;2.0;CMOP;**17**;11 Apr 97
- ;Watches line for incoming data and the outgoing queue.
- ;Hands off control to the Master or Slave module.
- EN ;Set E TIMER
- S PSXTRASH=0,PSXTME=$P($H,",",2)
- READX ;Read one character, expecting ENQ
- G:^PSX(553,1,"S")="S" STOP
- I $P($G(^PSX(553,1,0)),"^")["LEAVENWORTH" G R1
- I $G(PSXQRY)=1 G ^PSXQRY
- R1 R *X:$S($O(^PSX(552.1,"AQ",0)):0,1:5)
- ;if read timed out, check if timer E expired or queue has outgoing
- ;messages then goto master, otherwise reset params & continue idling
- E D CHKE^PSXUTL G:PSXTMOUT!$D(^PSX(552.1,"AQ")) BID^PSXMST D SETPAR^PSXSTRT G READX
- ;If ENQ,TERM send ACK0 and goto slave(Rec'd bid for master)
- ;Else flush garbage from buffer and continue idling
- E D TRASH
- G:PSXTRASH>300 EN^PSXSTP G READX
- TRASH ;Trash received while idling!!
- S PSXTRASH=PSXTRASH+1 D FLUSH1^PSXUTL I '(PSXTRASH#5) D JOB1,LOG^PSXUTL
- Q
- JOB1 K LOG
- S LOG(1)="JOB1 Unexpected character ("_X_") has been received ("_PSXTRASH_") times "
- S LOG(2)="while Idling. Check INTERFACE connection."
- Q
- STOP K LOG S LOG(1)="JOB2 Stop interface request detected from DHCP."
- D LOG^PSXUTL
- G EN^PSXSTP
- STRT ;Enter here when starting the interface
- ;Flush buffers
- D FLUSH1^PSXUTL
- W *EOT,*TERM
- K LOG S LOG(1)="JOB0 STARTING THE INTERFACE"
- D LOG^PSXUTL
- G EN
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSXJOB 1380 printed Jan 18, 2025@02:45:32 Page 2
- PSXJOB ;BIR/BAB,WPB-Interface Background Job ;[ 02/12/99 1:26 PM ]
- +1 ;;2.0;CMOP;**17**;11 Apr 97
- +2 ;Watches line for incoming data and the outgoing queue.
- +3 ;Hands off control to the Master or Slave module.
- EN ;Set E TIMER
- +1 SET PSXTRASH=0
- SET PSXTME=$PIECE($HOROLOG,",",2)
- READX ;Read one character, expecting ENQ
- +1 if ^PSX(553,1,"S")="S"
- GOTO STOP
- +2 IF $PIECE($GET(^PSX(553,1,0)),"^")["LEAVENWORTH"
- GOTO R1
- +3 IF $GET(PSXQRY)=1
- GOTO ^PSXQRY
- R1 READ *X:$SELECT($ORDER(^PSX(552.1,"AQ",0)):0,1:5)
- +1 ;if read timed out, check if timer E expired or queue has outgoing
- +2 ;messages then goto master, otherwise reset params & continue idling
- +3 IF '$TEST
- DO CHKE^PSXUTL
- if PSXTMOUT!$DATA(^PSX(552.1,"AQ"))
- GOTO BID^PSXMST
- DO SETPAR^PSXSTRT
- GOTO READX
- +4 ;If ENQ,TERM send ACK0 and goto slave(Rec'd bid for master)
- +5 ;Else flush garbage from buffer and continue idling
- +6 IF '$TEST
- DO TRASH
- +7 if PSXTRASH>300
- GOTO EN^PSXSTP
- GOTO READX
- TRASH ;Trash received while idling!!
- +1 SET PSXTRASH=PSXTRASH+1
- DO FLUSH1^PSXUTL
- IF '(PSXTRASH#5)
- DO JOB1
- DO LOG^PSXUTL
- +2 QUIT
- JOB1 KILL LOG
- +1 SET LOG(1)="JOB1 Unexpected character ("_X_") has been received ("_PSXTRASH_") times "
- +2 SET LOG(2)="while Idling. Check INTERFACE connection."
- +3 QUIT
- STOP KILL LOG
- SET LOG(1)="JOB2 Stop interface request detected from DHCP."
- +1 DO LOG^PSXUTL
- +2 GOTO EN^PSXSTP
- STRT ;Enter here when starting the interface
- +1 ;Flush buffers
- +2 DO FLUSH1^PSXUTL
- +3 WRITE *EOT,*TERM
- +4 KILL LOG
- SET LOG(1)="JOB0 STARTING THE INTERFACE"
- +5 DO LOG^PSXUTL
- +6 GOTO EN