[BACK]Return to gnuplot.sm1 CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Doc

Annotation of OpenXM/src/kan96xx/Doc/gnuplot.sm1, Revision 1.9

1.9     ! takayama    1: %$OpenXM: OpenXM/src/kan96xx/Doc/gnuplot.sm1,v 1.8 2005/02/04 11:25:45 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
1.8       takayama  139:   gnuplot.read.1
1.3       takayama  140:   [(fp2fputs) [cccc nl] cat gnuplot.pfp] extension pop
                    141:   [(fp2fflush) gnuplot.pfp] extension pop
                    142:   gnuplot.read.1
1.9     ! takayama  143:   gnuplot.sync.1
1.3       takayama  144: } def
                    145:
1.1       maekawa   146: %% (plot sin(x);) gnuplot
                    147:
1.3       takayama  148:
                    149: /gnuplot.read.1 {
1.6       takayama  150:  [
                    151:   gnuplot.fifoFp tag 0 eq { }
                    152:   {
1.3       takayama  153:    {
                    154:     [(fp2select) gnuplot.fifoFp 0] extension 1 eq {
                    155:       [(fp2fgetc) gnuplot.fifoFp] extension
                    156:     } {  exit } ifelse
                    157:    } loop
1.6       takayama  158:   } ifelse
                    159:  ] { (string) dc } map cat
1.9     ! takayama  160: } def
        !           161:
        !           162: % It uses "@" to wait for the gnuplot.
        !           163: /gnuplot.sync.1 {
        !           164:   [(fp2fputs) [(print "@";) nl] cat gnuplot.pfp] extension pop
        !           165:   [(fp2fflush) gnuplot.pfp] extension pop
        !           166:   {
        !           167:     [(fp2fgetc) gnuplot.fifoFp] extension 64 eq { exit} { } ifelse
        !           168:   } loop
1.3       takayama  169: } def
                    170:
1.1       maekawa   171: /isAlive {
1.3       takayama  172:   {
                    173:     gnuplot.callingMethod 0 eq {
                    174:       isAlive.0
                    175:     } { } ifelse
                    176:     gnuplot.callingMethod 1 eq {
                    177:       isAlive.1
                    178:     } { } ifelse
                    179:     gnuplot.callingMethod 2 eq {
                    180:       (Not yet implemented.) error
                    181:     } { } ifelse
                    182:     exit
                    183:   } loop
                    184: } def
                    185:
                    186: /isAlive.0 {
1.1       maekawa   187:  [/in-isAlive /ans /i /nn] pushVariables
                    188:  [ [ gnuplot.ccc ([(getchild)] extension ) oxsubmit ] pop
                    189:     gnuplot.ccc oxpopcmo /gnuplot.pidList set
                    190:     gnuplot.pidList isArray {
                    191:     } {
                    192:       (getchild returns the following strange output.) message
                    193:        gnuplot.pidList message
                    194:       /gnuplot.pidList [  ] def
                    195:     } ifelse
                    196:     gnuplot.pidList length 0  eq {
                    197:       /ans 0 def
                    198:     } {
                    199:       /nn gnuplot.pidList length def
                    200:       0 1 nn 1 sub {
                    201:         /i set
                    202:         gnuplot.pidList i get gnuplot.pid eq {
                    203:            /isAlive.LLL goto
                    204:         } {
                    205:           (length of gnuplot.pidList = ) messagen gnuplot.pidList length message
                    206:           (gnuplot.pidList and gnuplot.pid are differenct) message
                    207:            i nn 1 sub eq {
                    208:              error
                    209:            } { } ifelse
                    210:         } ifelse
                    211:       } for
                    212:       /isAlive.LLL
                    213:       /ans 1 def
                    214:     } ifelse
                    215:     /arg1 ans def
                    216:   ] pop
                    217:   popVariables
                    218:   arg1
1.3       takayama  219: } def
                    220:
                    221: /isAlive.1 {
                    222:   1
1.1       maekawa   223: } def
                    224:
                    225: /demo0 {
                    226:   (/u/nobuki/Trash/gnuplot-3.5beta6.347.orig/demo/airfoil.dem) pushfile /ff set
                    227:   ff gnuplot
                    228: } def
                    229:
                    230: /rplot {
                    231:   /rplot.arg set
                    232:   isAlive {
                    233:     gnuplot.ccc [ ($ ) rplot.arg ( $) ( gnuplot )] cat oxsubmit
                    234:   } {
                    235:     (You peer got error. Restaring gnuplot) message
                    236:      gnuplot.ccc ( plotstart.aux ) oxsubmit
                    237:      gnuplot.ccc $ gnuplot.pid $ oxsubmit gnuplot.ccc oxpopcmo /gnuplot.pid set
                    238:     (New gnuplot.pid is ) messagen gnuplot.pid message
                    239:     (We have started new gnuplot. Try your command again.) message
                    240:   } ifelse
                    241: } def
                    242:
                    243:
                    244: /test0 {
                    245:   (Type in ctrl-C and gnuplot.ccc oxreset . ) message
                    246:   0 1 10000 {
                    247:    /i set
                    248:      [$plot cos(x+$ i toString $);$] cat rplot
                    249:   } for ;
                    250: } def
                    251:
                    252:
                    253:
                    254:
                    255: $plotstart ;   (plot sin(x);) rplot$ message
1.4       takayama  256: $plotstart.aux ; (splot x**2-y**2;) gnuplot $ message

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>