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

INTSEND.m

Go to the documentation of this file.
  1. INTSEND ;JD; 13 May 96 12:19; "Generic" socket transceiver
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. ;
  1. ;This is an interactive transmitter routine. It first sends a message,
  1. ;then waits for an ack, then sends another msg, etc.
  1. ;The counterpart routine is INTSREC, which receives first, then
  1. ;sends an ack, etc.
  1. ;
  1. ;This runs similar to INHVTAPT
  1. EN(INEXPAND,INDA,DIE) ;Entry point
  1. ; Input:
  1. ; INEXPAND - 0 display to screen, 1 don't display to screen
  1. ; INDA - ien of criteria
  1. ; DIE - Criteria File
  1. N INPOP,INBPN,INIP,CLISRV,INXDST,INDEST,INCHNL,INMEM,ING,INDATA
  1. K ^UTILITY("INTHU",DUZ)
  1. ;update messages
  1. D UPDTSND^INTSUT3(INDA)
  1. ;clear channel, set background process ien
  1. S INCHNL="",INBPN=+$$VAL^DWRA(4001.1,20,2,DIE,INDA)
  1. S INPOP=1
  1. ;initialize parameters
  1. D INIT1^INTSUT(INDA,.INBPN,.INIP,.CLISRV,.INXDST,.INDEST,.INPOP)
  1. Q:'INPOP
  1. I CLISRV,INIP("ADDR")'="" S INIP("ADDR")="" D DISPLAY^INTSUT1("IP Address not needed for a Server")
  1. I 'CLISRV,INIP("ADDR")="" D DISPLAY^INTSUT1("No IP Address designated for client") Q
  1. ;open socket
  1. D OPEN^INTSUT(CLISRV,.INIP,.INMEM,.INCHNL,.INPOP)
  1. I INPOP D
  1. .;client init string
  1. .I $L(INIP("INIT"))+$L(INIP("ACK")) D
  1. ..;if client initialize as client
  1. ..I 'CLISRV D CLINIT^INTSUT(.INIP,.INCHNL,.INMEM,.INPOP) Q:'INPOP
  1. ..;if server initialize as server
  1. ..I CLISRV D SRVINIT^INTSUT(.INIP,.INCHNL,.INMEM,.INPOP) Q:'INPOP
  1. .I INPOP D DISPLAY^INTSUT1("Socket ready to start send/receive.")
  1. .;Loop until a transaction exists on the destination queue
  1. .I INPOP D LOOP(.INCHNL,.INIP,.INDEST,.INXDST,INEXPAND,.INPOP,INDA)
  1. D EXIT^INTSUT(.INCHNL,INBPN,.INIP,CLISRV)
  1. Q
  1. LOOP(INCHNL,INIP,INDEST,INXDST,INEXPAND,INPOP,INDA) ;Loop /send and receive messages
  1. ; Input:
  1. ; INCHNL - port channel
  1. ; INIP - TCP/IP paramters
  1. ; INDEST - array of destinations
  1. ; INPOP - 0 stop, 1 continue
  1. ; INDA - ien of Criteria
  1. N INSND,OUT,RCVE,INARY,INEXTN,INEXTUIF,INLASTN,INUPDAT,INOPT
  1. S (INSND,OUT,RCVE,INLASTN,INUPDAT)=0
  1. F D Q:OUT!'INPOP
  1. .K INARY,INEXTUIF
  1. .S (INEXTN,INLASTN)=$O(^UTILITY("INTHU",DUZ,$J,INLASTN))
  1. .I INEXTN S INEXTUIF=$O(^UTILITY("INTHU",DUZ,$J,INEXTN,""))
  1. .;Pre process
  1. .I $G(INIP("PRE"))'="" D PRE^INTSUT2(INDA,INIP("PRE"),.INEXTUIF,.INARY)
  1. .Q:'$$POSTPRE^INTSUT2(INDA,.INARY,.INEXTUIF,.INLASTN,.INPOP,.INUPDAT)
  1. .;last entry in utility and nothing updated in post process so QUIT
  1. .I 'INLASTN S OUT=1 Q
  1. .I '$D(^INTHU(+$G(INEXTUIF),0)) D DISPLAY^INTSUT1("Invalid or missing Universal Interface entry "_$G(INEXTUIF)) S INPOP=0 Q
  1. .N INERR,INDATA,ING,ER,INOUT
  1. .S INOUT=0
  1. .D DISPLAY^INTSUT1("Ready to send")
  1. .;loop until done
  1. .F INSND=1:1:INIP("STRY") D Q:'INPOP!INOUT
  1. ..D DISPLAY^INTSUT1("Sending message "_$P($G(^INTHU(INEXTUIF,0)),U),0,INEXTUIF)
  1. ..;Expanded display
  1. ..I 'INEXPAND D EXPNDIS^INTSUT1(INEXTUIF)
  1. ..F S ER=$$SEND^INHUVUT(INEXTUIF,INCHNL,.INIP) Q:'ER
  1. ..D RECEIVE^INTSREC(.INIP,.INCHNL,.INXDST,.INDEST,INEXPAND,.INPOP,INDA,1,.INOUT)
  1. .I INSND>INIP("STRY") D DISPLAY^INTSUT1("Send retries ("_$G(INIP("STRY"))_") exceeded.")
  1. .;set message to complete
  1. .D ULOG^INHU(INEXTUIF,"C")
  1. ;save criteria tests if they were updated in the pre or post
  1. I INUPDAT D
  1. .N INOPT
  1. .S INOPT("TYPE")="TEST",INOPT("NONINTER")=1
  1. .S X=$$SAVE^INHUTC1(.INOPT,INDA,"U")
  1. Q