[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.4

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

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