source: FOIAVistA/trunk/r/RPC_BROKER-XWB/XWBM2MT.m@ 1783

Last change on this file since 1783 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 6.1 KB
Line 
1XWBM2MT ;OIFO-Oakland/REM - M2M Broker Example ;05/16/2002 14:09
2 ;;1.1;RPC BROKER;**28**;Mar 28, 1997
3 ;
4 QUIT
5 ;
6EN(CONTX,RPCN) ;Entry point to hard code IP,PORT,AV
7 S IP="127.0.0.1",PORT=9800,AV="QQQQ11;11ZZZZ.."
8 D EN1(CONTX,RPCN,PORT,IP,AV)
9 Q
10 ;
11EN1(CONTX,RPCN,PORT,IP,AV) ;
12 N I
13 ;Entry point that passes in needed parameters. If use this entry point,
14 ; need to set up params first.
15 ;CONTX - Name of context
16 ;RPCN - RPC name
17 ;PORT - port number
18 ;IP - IP address
19 ;AV - access/verify codes
20 ;XWBOPEN - set this flag before call to keep connection open after call.
21 K REQ,STATE,RPC
22 S U="^" I $G(DUZ)'>0 W !,"Please Call XUP first!" Q
23 D HOME^%ZIS U IO
24 W !!,"Test a M2M call to ",CONTX," context."
25 D OPEN(PORT,IP,AV)
26 I XWBSTATE("M2M","OPEN")=0 D HOME^%ZIS U IO W !,"Didn't get port open or AV failed." Q
27 I '$$SETCONTX^XWBM2MC(CONTX) D HOME^%ZIS U IO W !,"Didn't get Context" G EXIT
28 ;This code is run if called from EN3
29 I $G(RMFLAG)=1 D
30 .D CLEARP
31 .D SETPARAM(1,"STRING","RAUL TEST")
32 D HOME^%ZIS U IO
33 W !,"Call ",RPCN," - RPC."
34 I '$$CALLRPC^XWBM2MC(RPCN,"REQ",1) D HOME^%ZIS U IO W !,"Could not run RPC."
35 W !,"Result: " F I=1:1 Q:'$D(REQ(I)) W !,REQ(I)
36 W !
37 K RMFLAG
38 I $G(XWBOPEN)=1 Q ;flag to quit and keep connection open
39 ;
40EXIT D CLOSE
41 Q
42 ;
43EN2 ;Entry point that hard sets IP,PORT,AV,CONTEXT,RPC.
44 ;RMFLAG - if RMGLAG=1, it will set PARAM in EN1.
45 N IP,PORT,AV,CONTX,RPCN,RMFLAG
46 S RMFLAG=1
47 ;S IP="10.4.229.21",PORT="9800",AV="2287CTD;11ZZZZ.." ;BayPines Cache
48 S IP="127.0.0.1",PORT=9800,AV="QQQQ11;11ZZZZ.."
49 S CONTX="XWB BROKER EXAMPLE",RPCN="XWB EXAMPLE ECHO STRING"
50 D EN1(CONTX,RPCN,PORT,IP,AV)
51 Q
52 ;
53EN3(VAL) ;Just runs RPC; need to OPEN, SETCONTX then CLOSE. Or just call after
54 ; connection has been done. **ONLY WORKS FOR TESTING IN DEV,XWB**
55 N STR,ROOT,RPC,RES
56 S ^TMP("XWBM2MTEST",$J,"TYPE")="STRING"
57 S ^TMP("XWBM2MTEST",$J,"VALUE")=VAL
58 S ROOT=$NA(^TMP("XWBM2MTEST",$J))
59 I '$$PARAM^XWBM2MC(1,ROOT) W !,"PARAM failed." Q 0
60 S RPC="ZZRM TEST RPC",RES="RESPONSE"
61 I '$$CALLRPC^XWBM2MC(RPC,RES,0) Q 0 ;D HOME^%ZIS U IO W !,"Could not run RPC."
62 K ^TMP("XWBM2MTEST")
63 Q 1
64 ;
65ECHOSTR ;Example of Echo String
66 N XWBSTR,XWBIP,XWBPORT,XWBAV,Y
67 S XWBIP="",XWBPORT="",XWBAV=""
68 K DIR S DIR(0)="FAU^1:50",DIR("A")="Enter String: ",DIR("B")="TEST STRING"
69 D ^DIR I $D(DIRUT) Q
70 S XWBSTR=$$CHARCHK^XWBUTL(Y)
71 D CLEARP
72 D SETPARAM(1,"STRING",XWBSTR)
73 I $G(XWBFLAG) D EN("XWB BROKER EXAMPLE","XWB EXAMPLE ECHO STRING") K XWBFLAG Q
74 D USERIP Q:$G(XWBQUIT)
75 D EN1("XWB BROKER EXAMPLE","XWB EXAMPLE ECHO STRING",XWBPORT,XWBIP,XWBAV)
76 D CLEAN
77 Q
78 ;
79WP ;Example of WP
80 N XWBSTR,XWBIP,XWBPORT,XWBAV
81 S XWBIP="",XWBPORT="",XWBAV=""
82 D CLEARP
83 I $G(XWBFLAG) D EN("XWB BROKER EXAMPLE","XWB EXAMPLE WPTEXT") K XWBFLAG Q
84 D USERIP Q:$G(XWBQUIT)
85 D EN1("XWB BROKER EXAMPLE","XWB EXAMPLE WPTEXT",XWBPORT,XWBIP,XWBAV)
86 D CLEAN
87 Q
88 ;
89LARRY ;Example of passing Array (mult).
90 N XWBIP,XWBPORT,XWBAV
91 S XWBIP="",XWBPORT="",XWBAV=""
92 D CLEARP
93 S XWBPARMS("PARAMS",1,"TYPE")="ARRAY"
94 S XWBPARMS("PARAMS",1,"VALUE","Raul")="Programmer"
95 S XWBPARMS("PARAMS",1,"VALUE","Susan")="Tech Writter"
96 S XWBPARMS("PARAMS",1,"VALUE","Dan")="Project Mgr"
97 I $G(XWBFLAG) D EN("XWB BROKER EXAMPLE","XWB M2M EXAMPLE LARRY") K XWBFLAG Q
98 D USERIP Q:$G(XWBQUIT)
99 D EN1("XWB BROKER EXAMPLE","XWB M2M EXAMPLE LARRY",XWBPORT,XWBIP,XWBAV)
100 D CLEAN
101 Q
102 ;
103LARRYRP(XWBY,XWBARR,XWBSTR) ;Remote procedure for local array
104 NEW XWBX,XWBLINE
105 ;
106 SET XWBLINE=0
107 I $G(XWBSTR)'="" S XWBY(1)=$G(XWBSTR) S XWBLINE=1
108 SET XWBX="" FOR SET XWBX=$O(XWBARR(XWBX)) QUIT:XWBX="" DO
109 .S XWBLINE=XWBLINE+1
110 .S XWBY(XWBLINE)=XWBX_" / "_XWBARR(XWBX)
111 Q
112 ;
113LARRSTR ;Example of passing Array (mult) and String.
114 N XWBIP,XWBPORT,XWBAV
115 S XWBIP="",XWBPORT="",XWBAV=""
116 D CLEARP
117 S XWBPARMS("PARAMS",1,"TYPE")="ARRAY"
118 S XWBPARMS("PARAMS",1,"VALUE","Raul")="Programmer"
119 S XWBPARMS("PARAMS",1,"VALUE","Susan")="Tech Writter"
120 S XWBPARMS("PARAMS",1,"VALUE","Dan")="Project Mgr"
121 S XWBPARMS("PARAMS",2,"TYPE")="STRING"
122 S XWBPARMS("PARAMS",2,"VALUE")="String and Array (MULT) TEST"
123 I $G(XWBFLAG) D EN("XWB BROKER EXAMPLE","XWB M2M EXAMPLE LARRY") K XWBFLAG Q
124 D USERIP Q:$G(XWBQUIT)
125 D EN1("XWB BROKER EXAMPLE","XWB M2M EXAMPLE LARRY",XWBPORT,XWBIP,XWBAV)
126 D CLEAN
127 Q
128 ;
129REF ;Example of passing a value by reference
130 N XWBREF,Y,XWBSTR,XWBIP,XWBPORT,XWBAV
131 S XWBIP="",XWBPORT="",XWBAV=""
132 K DIR S DIR(0)="FAU^1:50",DIR("A")="Enter Reference Value: ",DIR("B")="DT"
133 D ^DIR I $D(DIRUT) Q
134 S XWBREF=$$CHARCHK^XWBUTL(Y)
135 D CLEARP
136 D SETPARAM(1,"REF",XWBREF)
137 I $G(XWBFLAG) D EN("XWB BROKER EXAMPLE","XWB M2M EXAMPLE REF") K XWBFLAG Q
138 D USERIP Q:$G(XWBQUIT)
139 D EN1("XWB BROKER EXAMPLE","XWB M2M EXAMPLE REF",XWBPORT,XWBIP,XWBAV)
140 D CLEAN
141 Q
142 ;
143REFRP(RET,PARAM) ;Remote procedure for value passed by reference
144 S RET(0)=PARAM
145 Q
146 ;
147USERIP ;Get IP,Port,AV from user for connection.
148 N Y
149 S XWBQUIT=0
150 K DIR S DIR(0)="FAU^1:50",DIR("A")="Enter IP: ",DIR("B")="127.0.0.1"
151 D ^DIR I $D(DIRUT) S XWBQUIT=1 Q
152 S XWBIP=Y
153 K DIR S DIR(0)="FAU^1:50",DIR("A")="Enter PORT: ",DIR("B")="9800"
154 D ^DIR I $D(DIRUT) S XWBQUIT=1 Q
155 S XWBPORT=Y
156 K DIR S DIR(0)="FAU^1:50",DIR("A")="Enter AV: ",DIR("?")="e.g. Smith;11PASSWORD!! "
157 D ^DIR I $D(DIRUT) S XWBQUIT=1 Q
158 S XWBAV=Y
159 K DIR S DIR(0)="FAU^1:50",DIR("A")="Enter CONTEXT: ",DIR("B")="XWB BROKER EXAMPLE"
160 D ^DIR I $D(DIRUT) S XWBQUIT=1 Q
161 S XWBCONTX=Y
162 I $G(XWBREPFL) D
163 .K DIR S DIR(0)="FAU^1:50",DIR("A")="Enter REPS: "
164 .D ^DIR I $D(DIRUT) S XWBQUIT=1 Q
165 .S XWBREPS=Y
166 Q
167 ;
168OPEN(PORT,IP,AV) ;Opens connection to server.
169 ;S IP="127.0.0.1",PORT="9800",AV="QQQQ11;11ZZZZ.." ;Local
170 ;S IP="10.4.229.21",PORT="9800",AV="2287CTD;11ZZZZ.." ;BayPines Cache
171 S XWBSTATE("M2M","OPEN")=$$CONNECT^XWBM2MC(PORT,IP,AV)
172 Q
173 ;
174CLOSE ;Close the connection.
175 S X=$$CLOSE^XWBM2MC()
176 S XWBSTATE("M2M","OPEN")=0
177 D CLEAN
178 K X,XWBOPEN
179 Q
180 ;
181CLEARP ;Clear the PARAMS array
182 I '$G(XWBDBUG) K XWBPARMS
183 D PRE^XWBM2MC
184 Q
185 ;
186SETPARAM(INDEX,TYPE,VALUE) ;Set a Params entry
187 S XWBPARMS("PARAMS",INDEX,"TYPE")=TYPE
188 S XWBPARMS("PARAMS",INDEX,"VALUE")=VALUE
189 Q
190 ;
191CLNTMP ;Kills the TMP("XWB*"
192 K ^TMP("XWBM2M"),^TMP("XWBM2MVLC"),^TMP("XWBM2MRPC"),^TMP("XWBM2MRL")
193 K ^TMP("XWBM2ME"),^TMP("XWBM2M"),^TMP("XWBM2ML")
194 Q
195 ;
196CLEAN ;
197 K REQ,XWBCONTX
198 Q
199 ;
Note: See TracBrowser for help on using the repository browser.