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

INTSREC.m

Go to the documentation of this file.
  1. INTSREC ;JPD ; 13 May 98 12:09; Generic receiver, enhanced functions
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. ;
  1. ;This is an interactive transmitter/receiver routine supporting
  1. ;enhanced functionality.
  1. ;It receives a message, sends an ack, receives a message, etc.
  1. ;The process can function as either a server or a client, depending
  1. ;on the parameters. See notes below.
  1. ;
  1. ;This runs similar to INHVTAPR
  1. Q
  1. EN(INEXPAND,INDA,DIE) ;
  1. ;Input:
  1. ; INEXPAND - 0 - don't expand, 1 - expand
  1. ; INDA - ien of 4001.1 file
  1. ; DIE - 4001.1
  1. N INBPN,INIP,CLISRV,INXDST,INDEST,INPOP,INDEBUG,J,INTT,MS
  1. ;Background process
  1. S INBPN=+$$VAL^DWRA(4001.1,20,2,DIE,INDA)
  1. ;Initialize variables
  1. D INIT1^INTSUT(INDA,.INBPN,.INIP,.CLISRV,.INXDST,.INDEST,.INPOP)
  1. Q:'INPOP
  1. I INIP("PORT")="" D DISPLAY^INTSUT1("No port Designated") Q
  1. ;open socket
  1. D OPEN^INTSUT(CLISRV,.INIP,.INMEM,.INCHNL,.INPOP)
  1. I INPOP,$L(INIP("INIT")) D
  1. .;If opening as a Client Send Init String
  1. .I 'CLISRV D CLINIT^INTSUT(.INIP,.INCHNL,.INMEM,.INPOP)
  1. .;If opening as server
  1. .I CLISRV D SRVINIT^INTSUT(.INIP,.INCHNL,.INMEM,.INPOP)
  1. ;receiver data
  1. I INPOP D RECEIVE(.INIP,.INCHNL,.INXDST,.INDEST,INEXPAND,.INPOP,INDA)
  1. ;close socket
  1. D EXIT^INTSUT(.INCHNL,INBPN,.INIP,CLISRV)
  1. Q
  1. RECEIVE(INIP,INCHNL,INXDST,INDEST,INEXPAND,INPOP,INDA,INRONLY,INOUT) ;
  1. ;Input:
  1. ; INIP - Parameters
  1. ; INCHNL - port channel
  1. ; INXDST - Destination Determination xeq
  1. ; INDEST - destinations
  1. ; INEXPAND - 0 - don't expand, 1 - expand
  1. ; INPOP - 0 stop 1 continue
  1. ; INDA - ien of Criteria
  1. ; INRONLY - 1 Receive only and send no ack, 0 receive then send ack
  1. ;Output:
  1. ; (opt) INOUT - out of loop
  1. ;
  1. N INERR,ER,INMEM,ING,INDATA,INLP,RUN,X,Y,Z,ACKUIF,INUPDAT,INRCVE
  1. S INRONLY=+$G(INRONLY),INOUT=$G(INOUT),(INUPDAT,INRCVE)=0
  1. F X=1:1 S Y=$T(DEST+X) Q:Y'[";;" S Z=$TR($P(Y,";;")," ",""),INDEST(Z)=$P(Y,";;",2)
  1. F INLP=1:1:INIP("RTRY") D Q:'INPOP!INOUT D DSPHNG Q:'INPOP
  1. .I 'INRONLY,$G(INIP("PRE"))'="" D PRE^INTSUT2(INDA,INIP("PRE"),"",.INARY) Q:'$$POSTPRE^INTSUT2(INDA,.INARY,.INEXTUIF,.INLASTN,.INPOP,.INUPDAT)
  1. .S ING="INDATA" K @ING,INERR
  1. .S ER=$$RECEIVE^INHUVUT(.ING,.INCHNL,.INIP,.INERR,.INMEM)
  1. .K INMS,MS
  1. .I ER,$$ERROR^INTSUT(ER,.INERR,.INRCVE,.INPOP) Q
  1. .Q:'INPOP
  1. .;evaluate data
  1. .D EVAL^INTSUT(.INIP,.ING,.INDEST,.ACKUIF,.INERR,.INXDST,ER,.INMSG,INRONLY) Q:'INPOP
  1. .D DISPLAY^INTSUT1("Received Successfully "_$P($G(^INTHU(+$G(INMSG),0)),U),0,+$G(INMSG))
  1. .;if we saved incoming message/UIF ien exists
  1. .I $G(INMSG)>0 D
  1. ..;mark the message complete
  1. ..D ULOG^INHU(INMSG,"C")
  1. ..;expand message
  1. ..I 'INEXPAND D EXPNDIS^INTSUT1(INMSG)
  1. .;receive only
  1. .I INRONLY S INOUT=1
  1. .;if not receive only evaluate and send ack
  1. .I 'INRONLY D
  1. ..I $G(INIP("POST"))'="" D POST^INTSUT2(INDA,.ACKUIF,.INARY)
  1. ..Q:'$$POSTPRE^INTSUT2(INDA,.INARY,.ACKUIF,.INLASTN,.INPOP,.INUPDAT)
  1. ..D SEND(ACKUIF,INCHNL,.INIP,.INLOOP,INEXPAND)
  1. ..S INLP=1
  1. ;not recieve only and updated tests in prepost
  1. I 'INRONLY,INUPDAT D
  1. .N INOPT
  1. .S INOPT("TYPE")="TEST",INOPT("NONINTER")=1
  1. .D SAVE^INHUTC1(.INOPT,INDA,"U")
  1. Q
  1. DSPHNG ;hang then display
  1. D DISPLAY^INTSUT1("Waiting to receive. Hanging "_INIP("RHNG")_" seconds")
  1. H INIP("RHNG")
  1. Q
  1. SEND(ACKUIF,INCHNL,INIP,INLOOP,INEXPAND) ;Send outgoing ack.
  1. ; Input:
  1. ; ACKUIF - Universal Interface file ien for ack
  1. ; INCHNL - tcp/ip channel
  1. ; INIP - Parameters
  1. ; INLOOP - Receive retry count
  1. ; INEXPAND - 0 expand 1 don't expand
  1. I 'ACKUIF D DISPLAY^INTSUT1("ACK not sent")
  1. I ACKUIF D
  1. .D DISPLAY^INTSUT1("Transmitting commit acknowledgement")
  1. .I 'INEXPAND D EXPNDIS^INTSUT1(ACKUIF)
  1. .S ER=$$SEND^INHUVUT(.ACKUIF,INCHNL,.INIP)
  1. .I 'ER D DISPLAY^INTSUT1("Ack sent - Successful transmission")
  1. .S INLOOP=0
  1. Q
  1. RECSTR(INV,INCHNL,INIP) ;
  1. ; Input:
  1. ; INV - gets set in PARSE^INHUVUT1
  1. ; INV(1) if line terminated by $c(13), or is first line of many in seg
  1. ; INV(1,1), INV(1,2)... for overflow nodes until terminated
  1. ; INCHNL - tcp/ip channel
  1. ; INIP - Parameters
  1. N APDONE,APREC,AP,NULLREAD,NORESP,INSMIN
  1. S (APDONE,APREC,AP)="",(NULLREAD,NORESP)=0,INREC="REC"
  1. S INSMIN=$S($P($G(^INRHSITE(1,0)),U,14):$P(^(0),U,14),1:2500)
  1. F D Q:APDONE!NORESP
  1. .D RECV^%INET(.APREC,.INCHNL,INIP("RTO"),1)
  1. .I $G(APREC(0))["Remote end disconnect" D Q
  1. ..D DISPLAY^INTSUT1(APREC(0))
  1. ..S INPOP=0,APDONE=1
  1. .I APREC=""!(APREC[$C(28)) S APDONE=1
  1. .S APREC=$TR(APREC,$C(11))
  1. .I '$L(APREC) D Q
  1. ..S NULLREAD=NULLREAD+1 S:NULLREAD>INIP("RTRY") NORESP=1
  1. .I $S<INSMIN,INREC'["^" D
  1. ..K ^UTILITY("INREC",$J)
  1. ..M ^UTILITY("INREC",$J)=@INREC K @INREC S INREC="^UTILITY(""INREC"","_$J_")"
  1. .S AP=AP+1,@INREC@(AP)=APREC
  1. Q:'$D(APREC)
  1. D PARSE^INHUVUT1
  1. K @INREC
  1. Q
  1. DEST ; get valid destinations
  1. ORMO01 ;;TEST INTERACTIVE
  1. ;