Annotation of OpenXM/src/kan96xx/Doc/gnuplot.sm1, Revision 1.7
1.7 ! takayama 1: %$OpenXM: OpenXM/src/kan96xx/Doc/gnuplot.sm1,v 1.6 2004/12/18 01:56:03 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.7 ! takayama 110: % [(rm) gnuplot.fifo] oxshell pop % It is OS dependent.
! 111: [(unlink) gnuplot.fifo] extension
1.3 takayama 112: } def
113:
1.1 maekawa 114:
115: /gnuplot {
1.3 takayama 116: {
117: gnuplot.callingMethod 0 eq {
118: gnuplot.0
119: } { } ifelse
120: gnuplot.callingMethod 1 eq {
121: gnuplot.1
122: } { } ifelse
123: gnuplot.callingMethod 2 eq {
124: (Not yet implemented.) error
125: } { } ifelse
126: exit
127: } loop
128: } def
129:
130: /gnuplot.0 {
1.1 maekawa 131: /cccc set
132: /fd gnuplot.ff2 0 get def
133: [(sm1.socket) (write) [fd
134: [cccc 10 (string) dc] cat]] extension
135: } def
136:
1.3 takayama 137: /gnuplot.1 {
138: /cccc set
139: [(fp2fputs) [cccc nl] cat gnuplot.pfp] extension pop
140: [(fp2fflush) gnuplot.pfp] extension pop
141: gnuplot.read.1
142: } def
143:
1.1 maekawa 144: %% (plot sin(x);) gnuplot
145:
1.3 takayama 146:
147: /gnuplot.read.1 {
1.6 takayama 148: [
149: gnuplot.fifoFp tag 0 eq { }
150: {
1.3 takayama 151: {
152: [(fp2select) gnuplot.fifoFp 0] extension 1 eq {
153: [(fp2fgetc) gnuplot.fifoFp] extension
154: } { exit } ifelse
155: } loop
1.6 takayama 156: } ifelse
157: ] { (string) dc } map cat
1.3 takayama 158: } def
159:
1.1 maekawa 160: /isAlive {
1.3 takayama 161: {
162: gnuplot.callingMethod 0 eq {
163: isAlive.0
164: } { } ifelse
165: gnuplot.callingMethod 1 eq {
166: isAlive.1
167: } { } ifelse
168: gnuplot.callingMethod 2 eq {
169: (Not yet implemented.) error
170: } { } ifelse
171: exit
172: } loop
173: } def
174:
175: /isAlive.0 {
1.1 maekawa 176: [/in-isAlive /ans /i /nn] pushVariables
177: [ [ gnuplot.ccc ([(getchild)] extension ) oxsubmit ] pop
178: gnuplot.ccc oxpopcmo /gnuplot.pidList set
179: gnuplot.pidList isArray {
180: } {
181: (getchild returns the following strange output.) message
182: gnuplot.pidList message
183: /gnuplot.pidList [ ] def
184: } ifelse
185: gnuplot.pidList length 0 eq {
186: /ans 0 def
187: } {
188: /nn gnuplot.pidList length def
189: 0 1 nn 1 sub {
190: /i set
191: gnuplot.pidList i get gnuplot.pid eq {
192: /isAlive.LLL goto
193: } {
194: (length of gnuplot.pidList = ) messagen gnuplot.pidList length message
195: (gnuplot.pidList and gnuplot.pid are differenct) message
196: i nn 1 sub eq {
197: error
198: } { } ifelse
199: } ifelse
200: } for
201: /isAlive.LLL
202: /ans 1 def
203: } ifelse
204: /arg1 ans def
205: ] pop
206: popVariables
207: arg1
1.3 takayama 208: } def
209:
210: /isAlive.1 {
211: 1
1.1 maekawa 212: } def
213:
214: /demo0 {
215: (/u/nobuki/Trash/gnuplot-3.5beta6.347.orig/demo/airfoil.dem) pushfile /ff set
216: ff gnuplot
217: } def
218:
219: /rplot {
220: /rplot.arg set
221: isAlive {
222: gnuplot.ccc [ ($ ) rplot.arg ( $) ( gnuplot )] cat oxsubmit
223: } {
224: (You peer got error. Restaring gnuplot) message
225: gnuplot.ccc ( plotstart.aux ) oxsubmit
226: gnuplot.ccc $ gnuplot.pid $ oxsubmit gnuplot.ccc oxpopcmo /gnuplot.pid set
227: (New gnuplot.pid is ) messagen gnuplot.pid message
228: (We have started new gnuplot. Try your command again.) message
229: } ifelse
230: } def
231:
232:
233: /test0 {
234: (Type in ctrl-C and gnuplot.ccc oxreset . ) message
235: 0 1 10000 {
236: /i set
237: [$plot cos(x+$ i toString $);$] cat rplot
238: } for ;
239: } def
240:
241:
242:
243:
244: $plotstart ; (plot sin(x);) rplot$ message
1.4 takayama 245: $plotstart.aux ; (splot x**2-y**2;) gnuplot $ message
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>