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

INHVTMT5.m

Go to the documentation of this file.
  1. INHVTMT5 ; KAC ; 06 Aug 1999 15:34:58; Multi-threaded TCP/IP socket utilities
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. Q
  1. ;
  1. HB(INHBSENT,INHBWAIT) ; Function:
  1. ; Heartbeat/dummy msg sent to indicate when transceiver can start
  1. ; sending msgs from UNIVERSAL INTERFACE file. Adds SOM and EOM
  1. ; to start/end of msg.
  1. ;
  1. ; Called by: INHVTMT
  1. ;
  1. ;Input:
  1. ; INHBWAIT (req) flag - 1 = wait before sending hb, 0 = send now
  1. ; INBPN background process number
  1. ; INBPNM background process name
  1. ; INDEBUG debug flag
  1. ; INIP array of socket parameters
  1. ; INIP("INIT") = msg to send (w/out SOM/EOM)
  1. ; CLISRV client/server flag
  1. ; INCHNL channel opened by calling routine
  1. ;
  1. ;Output:
  1. ; INHBSENT (pbr) # of hb's sent since last hb response
  1. ;
  1. ; Returns:
  1. ; 1 - successful
  1. ; 0 - unsuccessful (shutdown transceiver)
  1. ;
  1. N INMSG,INMSGHDR,INMSGRTN
  1. ;
  1. ; Pace heartbeats
  1. I $G(INHBWAIT) D Q:'INRUNMT 0 ; quit if shutdown signalled
  1. . D:$G(INDEBUG) LOG^INHVCRA1("Waiting "_INIP("THNG")_" seconds to send heartbeat message",7)
  1. . D WAIT^INHUVUT2(INBPN,INIP("THNG"),"Waiting "_INIP("THNG")_" seconds to send heartbeat message",.INRUNMT)
  1. . S INRUNMT='INRUNMT ; wait rtns opposite
  1. ;
  1. ; Start transaction audit
  1. D:$D(XUAUDIT) TTSTRT^XUSAUD("","",INBPNM,"","DUMMYTRX TRANSMIT")
  1. ;
  1. S INMSG=INIP("INIT")
  1. I INIP("CRYPT") D
  1. . I INSTD="PDTS" D ; do not encrypt 1st hdr
  1. .. S INMSGHDR=$P(INIP("INIT"),INIP("SOD")) ; save ENP hdr
  1. .. S INMSG=$P(INIP("INIT"),INIP("SOD"),2,99999) ; msg to encrypt
  1. . D ENCRYPT^INCRYPT(.INMSG,.INMSGRTN,$L(INMSG),1,1)
  1. . S INMSG=INMSGRTN
  1. . I (INSTD="PDTS") D
  1. .. S INMSG=INMSGHDR_INIP("SOD")_INMSGRTN
  1. .. S $E(INMSG,21,24)=$TR($J($L(INMSGRTN),4)," ","0") ; encrypted length
  1. ;
  1. S INMSG=INIP("SOM")_INMSG_INIP("EOM")
  1. ;
  1. S INRUNMT=$$INRHB^INHUVUT1(INBPN,"Sending heartbeat/dummy trx") Q:'INRUNMT 0
  1. D SEND^%INET(INMSG,INCHNL,1)
  1. ;
  1. ; Post-send activities
  1. S INHBSENT=INHBSENT+1
  1. D:$G(INDEBUG) LOG^INHVCRA1("Sent heartbeat message",7)
  1. D:$D(XUAUDIT) TTSTP^XUSAUD(0) ;stop transaction audit
  1. Q 1
  1. ;
  1. ;
  1. SHUTDWN(INBPN,INCHNL) ; Shutdown LoS
  1. ;
  1. ; Called by: INHVTMT
  1. ;
  1. ; Input:
  1. ; INBPN - (req) BACKGROUND PROCESS CONTROL IEN for LoS
  1. ; INCHNL - (opt) TCP channel assigned to this server when connection
  1. ; is opened
  1. ; Output:
  1. ; None.
  1. ;
  1. D:$G(INDEBUG) LOG^INHVCRA1("SHUTDWN: Transceiver "_INBPNM,1)
  1. D:$G(INDEBUG) LOG^INHVCRA1("Shutting down TCP socket transceiver for "_INBPNM,5)
  1. ; Reroute to the destination que all "pending response" que msgs
  1. ; Allow another transceiver to send these msgs while this transceiver
  1. ; is down.
  1. D REROUTE^INHVTMT4(INDSTR,.INPEND)
  1. D CLOSE
  1. D:$G(INDEBUG) LOG^INHVCRA1("TCP socket transceiver is shutdown for "_INBPNM,5)
  1. D DEBUG^INHVCRA1(0) ; turn debugging off
  1. I $G(INIP("CRYPT")) S X=$$CRYPOFF^INCRYPT()
  1. K ^UTILITY("INREC",$J),^UTILITY("INV",$J)
  1. K ^INRHB("RUN",INBPN)
  1. L -^INRHB("RUN",INBPN)
  1. ;Stop background process audit
  1. D:$D(XUAUDIT) AUDSTP^XUSAUD
  1. Q
  1. ;
  1. CLOSE ; Close channel
  1. ;
  1. ; Called by: INHVTMT, SHUTDWN^INHVTMT5, ERR^INHVTMT5
  1. ;
  1. ; Input:
  1. ; INBPN - (req) BACKGROUND PROCESS CONTROL IEN for LoS
  1. ; INCHNL - (req) TCP channel assigned to this server when connection
  1. ; is opened
  1. ; Output:
  1. ; None.
  1. I $G(INCHNL) D
  1. . D:$G(INDEBUG) LOG^INHVCRA1("Closing connection for "_INBPNM,6)
  1. . D CLOSE^%INET(INCHNL)
  1. Q
  1. ;
  1. ERR ;Error module
  1. ;
  1. ; Called by: Error Trap set at start of INHVTMT
  1. ;
  1. N INREERR S INREERR=$$GETERR^%ZTOS
  1. ;Handle known non-fatal error conditions
  1. I $$ETYPE^%ZTFE("O") D G EN^INHVTMT
  1. .S X="ERR^INHVTMT5",@^%ZOSF("TRAP") D:$D(INCHNL) CLOSE^%INET(INCHNL)
  1. .D:$G(INDEBUG) LOG^INHVCRA1("Non-fatal error encountered in "_INBPNM,6)
  1. ;If unanticipated error is encounterd close port and quit receiver
  1. S:'$D(INBPNM) INBPNM=$P($G(^INTHPC(INBPN,0)),U) ; THIS SHOULD NOT HAPPEN
  1. D ENR^INHE(INBPN,"Fatal error encountered by TRANSCEIVER - "_INREERR_" in background process "_INBPNM)
  1. D:$G(INDEBUG) LOG^INHVCRA1("Fatal error encountered by TRANSCEIVER - "_INREERR_" in background process "_INBPNM,4)
  1. I $D(INCHNL) D CLOSE^%INET(INCHNL)
  1. I $G(INIP("CRYPT")) S X=$$CRYPOFF^INCRYPT()
  1. D REROUTE^INHVTMT4(INDSTR,.INPEND)
  1. K ^UTILITY("INREC",$J),^UTILITY("INV",$J)
  1. K ^INRHB("RUN",INBPN)
  1. L -^INRHB("RUN",INBPN)
  1. ;Stop background process audit
  1. D:$D(XUAUDIT) AUDSTP^XUSAUD
  1. X $G(^INTHOS(1,3))
  1. D DEBUG^INHVCRA1(0)
  1. Q
  1. ;
  1. ;