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

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

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