Annotation of OpenXM/src/kan96xx/Doc/gnuplot.sm1, Revision 1.6
1.6 ! takayama 1: %$OpenXM: OpenXM/src/kan96xx/Doc/gnuplot.sm1,v 1.5 2004/12/17 00:13:08 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
1.6 ! takayama 61: [(fp2mkfifo) gnuplot.fifo] extension /gnuplot.status set
! 62:
! 63: gnuplot.status -1 eq {
! 64: (Warning: mkfifo failed.) message
! 65: } { } ifelse
! 66:
1.3 takayama 67: gnuplot.fifo message
68: [(fp2popen) plot.gnuplotexec (w)] extension /gnuplot.pfp set
1.4 takayama 69: (Started gnuplot) message
70:
1.5 takayama 71: [(fp2fputs) [(set print ") gnuplot.fifo (" ; ) nl ] cat
1.3 takayama 72: gnuplot.pfp ] extension message
1.5 takayama 73: [(fp2fflush) gnuplot.pfp] extension message
74: [(fp2fputs) [(set mouse ; ) nl ] cat gnuplot.pfp ] extension message
1.3 takayama 75: [(fp2fflush) gnuplot.pfp] extension message
1.4 takayama 76:
77: [(fp2fopen) gnuplot.fifo (r)] extension /gnuplot.fifoFp set
78: % This must be the last. Otherwise, fopen is blocked.
1.6 ! takayama 79: % When mkfifo fails, then gnuplot.fifoFp will be null. (old cygwin)
1.4 takayama 80: /gnuplot.pid -2 def % dummy.
81: gnuplot.pid message
82: } def
83:
84: /plotstop {
85: gnuplot.ccc $ plotstop.aux $ oxsubmit
1.3 takayama 86: } def
87:
88: /plotstop.aux {
89: {
90: gnuplot.callingMethod 0 eq {
91: plotstop.aux.0
92: } { } ifelse
93: gnuplot.callingMethod 1 eq {
94: plotstop.aux.1
95: } { } ifelse
96: gnuplot.callingMethod 2 eq {
97: (Not yet implemented.) error
98: } { } ifelse
99: exit
100: } loop
101: } def
102:
103: /plotstop.aux.0 { } def
104: /plotstop.aux.1 {
105: [(fp2fclose) gnuplot.pfp] extension pop
1.6 ! takayama 106: gnuplot.fifoFp tag 0 eq { }
! 107: {
! 108: [(fp2fclose) gnuplot.fifoFp] extension pop
! 109: } ifelse
1.3 takayama 110: [(rm) gnuplot.fifo] oxshell pop
111: } def
112:
1.1 maekawa 113:
114: /gnuplot {
1.3 takayama 115: {
116: gnuplot.callingMethod 0 eq {
117: gnuplot.0
118: } { } ifelse
119: gnuplot.callingMethod 1 eq {
120: gnuplot.1
121: } { } ifelse
122: gnuplot.callingMethod 2 eq {
123: (Not yet implemented.) error
124: } { } ifelse
125: exit
126: } loop
127: } def
128:
129: /gnuplot.0 {
1.1 maekawa 130: /cccc set
131: /fd gnuplot.ff2 0 get def
132: [(sm1.socket) (write) [fd
133: [cccc 10 (string) dc] cat]] extension
134: } def
135:
1.3 takayama 136: /gnuplot.1 {
137: /cccc set
138: [(fp2fputs) [cccc nl] cat gnuplot.pfp] extension pop
139: [(fp2fflush) gnuplot.pfp] extension pop
140: gnuplot.read.1
141: } def
142:
1.1 maekawa 143: %% (plot sin(x);) gnuplot
144:
1.3 takayama 145:
146: /gnuplot.read.1 {
1.6 ! takayama 147: [
! 148: gnuplot.fifoFp tag 0 eq { }
! 149: {
1.3 takayama 150: {
151: [(fp2select) gnuplot.fifoFp 0] extension 1 eq {
152: [(fp2fgetc) gnuplot.fifoFp] extension
153: } { exit } ifelse
154: } loop
1.6 ! takayama 155: } ifelse
! 156: ] { (string) dc } map cat
1.3 takayama 157: } def
158:
1.1 maekawa 159: /isAlive {
1.3 takayama 160: {
161: gnuplot.callingMethod 0 eq {
162: isAlive.0
163: } { } ifelse
164: gnuplot.callingMethod 1 eq {
165: isAlive.1
166: } { } ifelse
167: gnuplot.callingMethod 2 eq {
168: (Not yet implemented.) error
169: } { } ifelse
170: exit
171: } loop
172: } def
173:
174: /isAlive.0 {
1.1 maekawa 175: [/in-isAlive /ans /i /nn] pushVariables
176: [ [ gnuplot.ccc ([(getchild)] extension ) oxsubmit ] pop
177: gnuplot.ccc oxpopcmo /gnuplot.pidList set
178: gnuplot.pidList isArray {
179: } {
180: (getchild returns the following strange output.) message
181: gnuplot.pidList message
182: /gnuplot.pidList [ ] def
183: } ifelse
184: gnuplot.pidList length 0 eq {
185: /ans 0 def
186: } {
187: /nn gnuplot.pidList length def
188: 0 1 nn 1 sub {
189: /i set
190: gnuplot.pidList i get gnuplot.pid eq {
191: /isAlive.LLL goto
192: } {
193: (length of gnuplot.pidList = ) messagen gnuplot.pidList length message
194: (gnuplot.pidList and gnuplot.pid are differenct) message
195: i nn 1 sub eq {
196: error
197: } { } ifelse
198: } ifelse
199: } for
200: /isAlive.LLL
201: /ans 1 def
202: } ifelse
203: /arg1 ans def
204: ] pop
205: popVariables
206: arg1
1.3 takayama 207: } def
208:
209: /isAlive.1 {
210: 1
1.1 maekawa 211: } def
212:
213: /demo0 {
214: (/u/nobuki/Trash/gnuplot-3.5beta6.347.orig/demo/airfoil.dem) pushfile /ff set
215: ff gnuplot
216: } def
217:
218: /rplot {
219: /rplot.arg set
220: isAlive {
221: gnuplot.ccc [ ($ ) rplot.arg ( $) ( gnuplot )] cat oxsubmit
222: } {
223: (You peer got error. Restaring gnuplot) message
224: gnuplot.ccc ( plotstart.aux ) oxsubmit
225: gnuplot.ccc $ gnuplot.pid $ oxsubmit gnuplot.ccc oxpopcmo /gnuplot.pid set
226: (New gnuplot.pid is ) messagen gnuplot.pid message
227: (We have started new gnuplot. Try your command again.) message
228: } ifelse
229: } def
230:
231:
232: /test0 {
233: (Type in ctrl-C and gnuplot.ccc oxreset . ) message
234: 0 1 10000 {
235: /i set
236: [$plot cos(x+$ i toString $);$] cat rplot
237: } for ;
238: } def
239:
240:
241:
242:
243: $plotstart ; (plot sin(x);) rplot$ message
1.4 takayama 244: $plotstart.aux ; (splot x**2-y**2;) gnuplot $ message
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>