Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSXJOB

PSXJOB.m

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