Annotation of OpenXM/src/kan96xx/Doc/gnuplot.sm1, Revision 1.5
1.5 ! takayama 1: %$OpenXM: OpenXM/src/kan96xx/Doc/gnuplot.sm1,v 1.4 2004/12/16 11:41:58 takayama Exp $
1.1 maekawa 2: %%% 1999, 6/7 Mon.
3: [(parse) (ox.sm1) pushfile] extension
4: [(getenv) (OpenXM_HOME)] extension /OpenXM_HOME set
5:
1.5 ! takayama 6: [OpenXM_HOME (/bin/gnuplot)] cat /plot.gnuplotexec set
1.4 takayama 7: %(gnuplot) /plot.gnuplotexec set
1.1 maekawa 8:
9: (SSkan/lib/plot.sm1 for ox_sm1_gnuplot. 1999/09/03. ) message
10:
1.4 takayama 11: /gnuplot.callingMethod 1 def % 0 : old, 1 : pipe, 2: file
1.5 ! takayama 12: % If your gnuplot is version 3, then set the callingMethod to 0.
1.3 takayama 13:
1.1 maekawa 14: /plotstart {
15: sm1connectr
16: ox.ccc 1 copy /gnuplot.ccc set
17: (Your peer is set to gnuplot.ccc) message
18: gnuplot.ccc $[(parse) (gnuplot.sm1) pushfile] extension $ oxsubmit
19: gnuplot.ccc $ plotstart.aux $ oxsubmit
20: gnuplot.ccc $ gnuplot.pid $ oxsubmit gnuplot.ccc oxpopcmo /gnuplot.pid set
21: } def
22:
23: /plotstart.aux {
1.3 takayama 24: {
25: gnuplot.callingMethod 0 eq {
26: plotstart.aux.0
27: } { } ifelse
28: gnuplot.callingMethod 1 eq {
29: plotstart.aux.1
30: } { } ifelse
31: gnuplot.callingMethod 2 eq {
32: (Not yet implemented.) error
33: } { } ifelse
34: exit
35: } loop
36: } def
37: /plotstart.aux.0 {
1.1 maekawa 38: /peer [(oxGetPort) (localhost)] extension def
39: [(sm1.socket) (close) [peer 2 get]] extension %% close the second.
40: /myport peer 1 get def
41: /myportStr peer 1 get toString def
42:
43: (port number = ) messagen myportStr message
44:
45: [(forkExec)
46: [ plot.gnuplotexec
47: [(r) myportStr] cat
48: ]
49: [ 3 4 << peer 0 get >> ] %% close ox_sm1 channel, this channel.
50: 0
51: ] extension /gnuplot.pid set
52: (gnuplot.pid = ) messagen gnuplot.pid message
53:
54: [(sm1.socket) (accept) [peer 0 get ]] extension /gnuplot.ff2 set
55: (Accepted ) messagen
56: gnuplot.ff2 message
57: } def
58:
1.3 takayama 59: /plotstart.aux.1 {
60: [(getUniqueFileName) (/tmp/gnuplot.fifo.tmp)] extension /gnuplot.fifo set
61: [(fp2mkfifo) gnuplot.fifo] extension message
62: gnuplot.fifo message
63: [(fp2popen) plot.gnuplotexec (w)] extension /gnuplot.pfp set
1.4 takayama 64: (Started gnuplot) message
65:
1.5 ! takayama 66: [(fp2fputs) [(set print ") gnuplot.fifo (" ; ) nl ] cat
1.3 takayama 67: gnuplot.pfp ] extension message
1.5 ! takayama 68: [(fp2fflush) gnuplot.pfp] extension message
! 69: [(fp2fputs) [(set mouse ; ) nl ] cat gnuplot.pfp ] extension message
1.3 takayama 70: [(fp2fflush) gnuplot.pfp] extension message
1.4 takayama 71:
72: [(fp2fopen) gnuplot.fifo (r)] extension /gnuplot.fifoFp set
73: % This must be the last. Otherwise, fopen is blocked.
74: /gnuplot.pid -2 def % dummy.
75: gnuplot.pid message
76: } def
77:
78: /plotstop {
79: gnuplot.ccc $ plotstop.aux $ oxsubmit
1.3 takayama 80: } def
81:
82: /plotstop.aux {
83: {
84: gnuplot.callingMethod 0 eq {
85: plotstop.aux.0
86: } { } ifelse
87: gnuplot.callingMethod 1 eq {
88: plotstop.aux.1
89: } { } ifelse
90: gnuplot.callingMethod 2 eq {
91: (Not yet implemented.) error
92: } { } ifelse
93: exit
94: } loop
95: } def
96:
97: /plotstop.aux.0 { } def
98: /plotstop.aux.1 {
99: [(fp2fclose) gnuplot.pfp] extension pop
1.4 takayama 100: [(fp2fclose) gnuplot.fifoFp] extension pop
1.3 takayama 101: [(rm) gnuplot.fifo] oxshell pop
102: } def
103:
1.1 maekawa 104:
105: /gnuplot {
1.3 takayama 106: {
107: gnuplot.callingMethod 0 eq {
108: gnuplot.0
109: } { } ifelse
110: gnuplot.callingMethod 1 eq {
111: gnuplot.1
112: } { } ifelse
113: gnuplot.callingMethod 2 eq {
114: (Not yet implemented.) error
115: } { } ifelse
116: exit
117: } loop
118: } def
119:
120: /gnuplot.0 {
1.1 maekawa 121: /cccc set
122: /fd gnuplot.ff2 0 get def
123: [(sm1.socket) (write) [fd
124: [cccc 10 (string) dc] cat]] extension
125: } def
126:
1.3 takayama 127: /gnuplot.1 {
128: /cccc set
129: [(fp2fputs) [cccc nl] cat gnuplot.pfp] extension pop
130: [(fp2fflush) gnuplot.pfp] extension pop
131: gnuplot.read.1
132: } def
133:
1.1 maekawa 134: %% (plot sin(x);) gnuplot
135:
1.3 takayama 136:
137: /gnuplot.read.1 {
138: [
139: {
140: [(fp2select) gnuplot.fifoFp 0] extension 1 eq {
141: [(fp2fgetc) gnuplot.fifoFp] extension
142: } { exit } ifelse
143: } loop
144: ] { (string) dc } map cat
145: } def
146:
1.1 maekawa 147: /isAlive {
1.3 takayama 148: {
149: gnuplot.callingMethod 0 eq {
150: isAlive.0
151: } { } ifelse
152: gnuplot.callingMethod 1 eq {
153: isAlive.1
154: } { } ifelse
155: gnuplot.callingMethod 2 eq {
156: (Not yet implemented.) error
157: } { } ifelse
158: exit
159: } loop
160: } def
161:
162: /isAlive.0 {
1.1 maekawa 163: [/in-isAlive /ans /i /nn] pushVariables
164: [ [ gnuplot.ccc ([(getchild)] extension ) oxsubmit ] pop
165: gnuplot.ccc oxpopcmo /gnuplot.pidList set
166: gnuplot.pidList isArray {
167: } {
168: (getchild returns the following strange output.) message
169: gnuplot.pidList message
170: /gnuplot.pidList [ ] def
171: } ifelse
172: gnuplot.pidList length 0 eq {
173: /ans 0 def
174: } {
175: /nn gnuplot.pidList length def
176: 0 1 nn 1 sub {
177: /i set
178: gnuplot.pidList i get gnuplot.pid eq {
179: /isAlive.LLL goto
180: } {
181: (length of gnuplot.pidList = ) messagen gnuplot.pidList length message
182: (gnuplot.pidList and gnuplot.pid are differenct) message
183: i nn 1 sub eq {
184: error
185: } { } ifelse
186: } ifelse
187: } for
188: /isAlive.LLL
189: /ans 1 def
190: } ifelse
191: /arg1 ans def
192: ] pop
193: popVariables
194: arg1
1.3 takayama 195: } def
196:
197: /isAlive.1 {
198: 1
1.1 maekawa 199: } def
200:
201: /demo0 {
202: (/u/nobuki/Trash/gnuplot-3.5beta6.347.orig/demo/airfoil.dem) pushfile /ff set
203: ff gnuplot
204: } def
205:
206: /rplot {
207: /rplot.arg set
208: isAlive {
209: gnuplot.ccc [ ($ ) rplot.arg ( $) ( gnuplot )] cat oxsubmit
210: } {
211: (You peer got error. Restaring gnuplot) message
212: gnuplot.ccc ( plotstart.aux ) oxsubmit
213: gnuplot.ccc $ gnuplot.pid $ oxsubmit gnuplot.ccc oxpopcmo /gnuplot.pid set
214: (New gnuplot.pid is ) messagen gnuplot.pid message
215: (We have started new gnuplot. Try your command again.) message
216: } ifelse
217: } def
218:
219:
220: /test0 {
221: (Type in ctrl-C and gnuplot.ccc oxreset . ) message
222: 0 1 10000 {
223: /i set
224: [$plot cos(x+$ i toString $);$] cat rplot
225: } for ;
226: } def
227:
228:
229:
230:
231: $plotstart ; (plot sin(x);) rplot$ message
1.4 takayama 232: $plotstart.aux ; (splot x**2-y**2;) gnuplot $ message
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>