PSXMST ;BIR/BAB,WPB-Master Module to Transmit Messages ;[ 01/28/99 2:46 PM ]
;;2.0;CMOP;**17**;11 Apr 97
Q
BID ;Set line bid retry counter
S PSXTRY=0
BID1 G:^PSX(553,1,"S")="S" STOP^PSXJOB
S PSXTME=$P($H,",",2)
U IO
W *ENQ,*TERM
BID2 R *X:PSXDLTA E D MST6 G BAD
I X=EOT R *X:PSXDLTA G:X=TERM BID2
I X=ENQ R *X:PSXDLTA D:'$T!(X'=TERM) MST1 G:'$T!(X'=TERM) BAD S PSXTME=$P($H,",",2) S PSXTRY=PSXTRY+1 G:PSXTRY>PSXTRYM BAD D MST7,LOG^PSXUTL G BID2 ;ENQ received
I X=NAK R *X:PSXDLTA D:'$T!(X'=TERM) MST2 G:'$T!(X'=TERM) BAD D MST5,LOG^PSXUTL G BAD
I X=ACK R *X:PSXDLTA D:'$T!(X'=48) MST3 G:'$T!(X'=48) BAD R *X:PSXDLTA D:'$T!(X'=TERM) MST8 G:($G(X)=TERM) OKAY
D MST4 ;if X wasn't ENQ or ACK or NAK then garbage
BAD S PSXTRY=PSXTRY+1 D FLUSH1^PSXUTL,LOG^PSXUTL G:PSXTRY'>PSXTRYM BID1
;STOP interface if bid fails more that M times
;S ^PSX(553,1,"S")="S" G STOP^PSXJOB
D MST9,LOG^PSXUTL,SETPAR^PSXSTRT
S PSXQUIT=1
;Hibernate awhile till CMOP comes on line,then try again
H 45
G ^PSXJOB
OKAY ;Bid for Master was succesful
S PSXTME=$P($H,",",2)
;Quit if Status is Stopped
G:^PSX(553,1,"S")="S" STOP^PSXJOB
;Check for transmission 'Queued'
Q:$G(PSXQRY)=1
I ('$D(^PSX(552.1,"AQ"))&('$D(^PSX(552.1,"APQ")))&($P($G(^PSX(553,1,0)),"^")["LEAVENWORTH")) W *EOT,*TERM G ^PSXJOB
I ('$D(^PSX(552.1,"AQ"))&('$D(^PSX(552.1,"APQ")))) W *EOT,*TERM G ^PSXQRY
I $G(PSXONE) S PSXB=PSXONE,PSXDA=$O(^PSX(552.1,"B",PSXB,"")) G SEND
S QUE=$S($D(^PSX(552.1,"APQ")):"APQ",1:"AQ")
S PSXDT=$O(^PSX(552.1,QUE,"")) G:'PSXDT EOT S PSXB=$O(^PSX(552.1,QUE,PSXDT,"")) G:'PSXB EOT S PSXDA=$O(^PSX(552.1,QUE,PSXDT,PSXB,"")) G:'PSXDA EOT
;Begin sending messages if any Qued
SEND I $D(^PSX(552.2,"AQ",PSXB)) G ^PSXSND
EOT S PSXTXT="BTS|",PSXLAST=1,PSXBLK=1 D XMIT^PSXSND,FILE^PSXSND
S PSXBHS=0
W *EOT,*TERM ;end of transmission, nothing to send
K PSXDT,PSXB,PSXDA,AA,PSXBLK,PSXHEX,PSXLAST,PSXLEN,PSXMSA,PSXMSGID,PSXMSH,PSXQN,PSXSUM,PSXTS,PSXTXT,PSXTSTN,REC,CNT,PSXBHS,QUE
G:$G(PSXONE) EN^PSXSTP
G ^PSXJOB
MST1 K LOG S LOG(1)="MST1 ENQ received with no terminator while Bidding for Master status." Q
MST2 K LOG S LOG(1)="MST2 NAK received with no terminator while Bidding for Master status." Q
MST3 K LOG S LOG(1)="MST3 ACK without 0 received while Bidding for Master status." Q
MST4 K LOG S LOG(1)="MST4 Garbage received while Bidding for Master status." Q
MST5 K LOG S LOG(1)="MST5 NAK received while Bidding for Master status." Q
MST6 K LOG S LOG(1)="MST6 No response from CMOP while Bidding for Master status." Q
MST7 K LOG S LOG(1)="MST7 Simultaneous bid for Master status by CMOP and DHCP." Q
MST8 K LOG S LOG(1)="MST8 ACK received with no terminator while Bidding for Master status." Q
MST9 K LOG S LOG(1)="MST9 CMOP won't respond, waiting 45 seconds to try again" Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSXMST 2818 printed Dec 13, 2024@01:44:32 Page 2
PSXMST ;BIR/BAB,WPB-Master Module to Transmit Messages ;[ 01/28/99 2:46 PM ]
+1 ;;2.0;CMOP;**17**;11 Apr 97
+2 QUIT
BID ;Set line bid retry counter
+1 SET PSXTRY=0
BID1 if ^PSX(553,1,"S")="S"
GOTO STOP^PSXJOB
+1 SET PSXTME=$PIECE($HOROLOG,",",2)
+2 USE IO
+3 WRITE *ENQ,*TERM
BID2 READ *X:PSXDLTA
IF '$TEST
DO MST6
GOTO BAD
+1 IF X=EOT
READ *X:PSXDLTA
if X=TERM
GOTO BID2
+2 ;ENQ received
IF X=ENQ
READ *X:PSXDLTA
if '$TEST!(X'=TERM)
DO MST1
if '$TEST!(X'=TERM)
GOTO BAD
SET PSXTME=$PIECE($HOROLOG,",",2)
SET PSXTRY=PSXTRY+1
if PSXTRY>PSXTRYM
GOTO BAD
DO MST7
DO LOG^PSXUTL
GOTO BID2
+3 IF X=NAK
READ *X:PSXDLTA
if '$TEST!(X'=TERM)
DO MST2
if '$TEST!(X'=TERM)
GOTO BAD
DO MST5
DO LOG^PSXUTL
GOTO BAD
+4 IF X=ACK
READ *X:PSXDLTA
if '$TEST!(X'=48)
DO MST3
if '$TEST!(X'=48)
GOTO BAD
READ *X:PSXDLTA
if '$TEST!(X'=TERM)
DO MST8
if ($GET(X)=TERM)
GOTO OKAY
+5 ;if X wasn't ENQ or ACK or NAK then garbage
DO MST4
BAD SET PSXTRY=PSXTRY+1
DO FLUSH1^PSXUTL
DO LOG^PSXUTL
if PSXTRY'>PSXTRYM
GOTO BID1
+1 ;STOP interface if bid fails more that M times
+2 ;S ^PSX(553,1,"S")="S" G STOP^PSXJOB
+3 DO MST9
DO LOG^PSXUTL
DO SETPAR^PSXSTRT
+4 SET PSXQUIT=1
+5 ;Hibernate awhile till CMOP comes on line,then try again
+6 HANG 45
+7 GOTO ^PSXJOB
OKAY ;Bid for Master was succesful
+1 SET PSXTME=$PIECE($HOROLOG,",",2)
+2 ;Quit if Status is Stopped
+3 if ^PSX(553,1,"S")="S"
GOTO STOP^PSXJOB
+4 ;Check for transmission 'Queued'
+5 if $GET(PSXQRY)=1
QUIT
+6 IF ('$DATA(^PSX(552.1,"AQ"))&('$DATA(^PSX(552.1,"APQ")))&($PIECE($GET(^PSX(553,1,0)),"^")["LEAVENWORTH"))
WRITE *EOT,*TERM
GOTO ^PSXJOB
+7 IF ('$DATA(^PSX(552.1,"AQ"))&('$DATA(^PSX(552.1,"APQ"))))
WRITE *EOT,*TERM
GOTO ^PSXQRY
+8 IF $GET(PSXONE)
SET PSXB=PSXONE
SET PSXDA=$ORDER(^PSX(552.1,"B",PSXB,""))
GOTO SEND
+9 SET QUE=$SELECT($DATA(^PSX(552.1,"APQ")):"APQ",1:"AQ")
+10 SET PSXDT=$ORDER(^PSX(552.1,QUE,""))
if 'PSXDT
GOTO EOT
SET PSXB=$ORDER(^PSX(552.1,QUE,PSXDT,""))
if 'PSXB
GOTO EOT
SET PSXDA=$ORDER(^PSX(552.1,QUE,PSXDT,PSXB,""))
if 'PSXDA
GOTO EOT
+11 ;Begin sending messages if any Qued
SEND IF $DATA(^PSX(552.2,"AQ",PSXB))
GOTO ^PSXSND
EOT SET PSXTXT="BTS|"
SET PSXLAST=1
SET PSXBLK=1
DO XMIT^PSXSND
DO FILE^PSXSND
+1 SET PSXBHS=0
+2 ;end of transmission, nothing to send
WRITE *EOT,*TERM
+3 KILL PSXDT,PSXB,PSXDA,AA,PSXBLK,PSXHEX,PSXLAST,PSXLEN,PSXMSA,PSXMSGID,PSXMSH,PSXQN,PSXSUM,PSXTS,PSXTXT,PSXTSTN,REC,CNT,PSXBHS,QUE
+4 if $GET(PSXONE)
GOTO EN^PSXSTP
+5 GOTO ^PSXJOB
MST1 KILL LOG
SET LOG(1)="MST1 ENQ received with no terminator while Bidding for Master status."
QUIT
MST2 KILL LOG
SET LOG(1)="MST2 NAK received with no terminator while Bidding for Master status."
QUIT
MST3 KILL LOG
SET LOG(1)="MST3 ACK without 0 received while Bidding for Master status."
QUIT
MST4 KILL LOG
SET LOG(1)="MST4 Garbage received while Bidding for Master status."
QUIT
MST5 KILL LOG
SET LOG(1)="MST5 NAK received while Bidding for Master status."
QUIT
MST6 KILL LOG
SET LOG(1)="MST6 No response from CMOP while Bidding for Master status."
QUIT
MST7 KILL LOG
SET LOG(1)="MST7 Simultaneous bid for Master status by CMOP and DHCP."
QUIT
MST8 KILL LOG
SET LOG(1)="MST8 ACK received with no terminator while Bidding for Master status."
QUIT
MST9 KILL LOG
SET LOG(1)="MST9 CMOP won't respond, waiting 45 seconds to try again"
QUIT