From e001307409e922f7a77efe068e185569270e88d7 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (laptop)" <j.wuttke@fz-juelich.de> Date: Wed, 16 Mar 2011 20:09:10 +0100 Subject: [PATCH] towards curve/external via fifo --- pub/src/curve.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++-- pub/src/dualplot.cpp | 4 ++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/pub/src/curve.cpp b/pub/src/curve.cpp index 3c710850..6477ce93 100644 --- a/pub/src/curve.cpp +++ b/pub/src/curve.cpp @@ -107,9 +107,28 @@ ask_again: " c: external curve evaluation command (hc for help)\n"\ " ci: external command followed by interpolation (hci for help)\n"; goto ask_again; + } else if ( expr=="hc" ) { + cout << + "the external curve evaluation command must:\n"\ + "- read from stdin a whitespace separated list of:\n"\ + " - 1*int: the number of parameters M\n"\ + " - M*double: the parameters\n"\ + " - 1*int: the number of data points N\n"\ + " - N*double: the data points\n"\ + "- write to stdout a whitespace separated list of:\n"\ + " - N*double: the curve values\n"; + // "for examples, see /usr/local/share/frida/demo-curve-c" + } else if ( expr=="hci" ) { + cout << + "the external curve evaluation command must:\n"\ + "- read from stdin a whitespace separated list of:\n"\ + " - 1*int: the number of parameters M\n"\ + " - M*double: the parameters\n"\ + "- write to stdout a whitespace separated list of:\n"\ + " - 1*int: the number of data pairs N\n"\ + " - N*2*double: a sequence of data pairs: x0 y0 x1 y1 x2 y2 ...\n"; } else if ( expr=="c" ) { evaMode = COlc::_SCR; - throw "not yet implemented"; expr = sask( "Curve evaluation command ?" ); np = iask( "Number of parameters ?" ); } else if ( expr=="ci" ) { @@ -149,7 +168,28 @@ void COlc::curve_val_vec( vector<double>* ret, const vector<double>& vt, throw "BUG: tree_curve_val did not get vectorial result"; *ret = val.v; } - } else if ( evaMode==_SCR_INTP ) { + } else if ( evaMode==_SCR || evaMode==_SCR_INTP ) { + + string par_fifo = string("/tmp/par-") + getenv( "LOGNAME" ); + + mystd::system( "rm -f "+par_fifo ); + if (mkfifo( par_fifo.c_str(), 0666 )) + throw "SYSTEM ERROR cannot make fifo " + par_fifo + + " needed for external curve call"; + +/* + mystd::system( "gnuplot -title " + strg(iPlot) + " -noraise" + + " < " + par_fifo + " &" ); + + // we use open instead of fopen or ofstream, + // because we need non-blocking mode. + if (!(gp_fifo = open(par_fifo.c_str(), O_WRONLY))) + throw "SYSTEM ERROR cannot open fifo " + par_fifo + + ": will not be able to print"; + fcntl(gp_fifo,F_SETFL,O_NONBLOCK); + + gp_write( string("set terminal x11") ); +*/ FILE *F; if( !(F = fopen("/ram/pars", "w")) ) throw "BUG: cannot write system call pars"; diff --git a/pub/src/dualplot.cpp b/pub/src/dualplot.cpp index 94169823..82dddf04 100644 --- a/pub/src/dualplot.cpp +++ b/pub/src/dualplot.cpp @@ -32,7 +32,7 @@ CPlot::CPlot( uint _iPlot, bool _logx, bool _logy ) : mystd::system( "rm -f "+fn_fifo ); if (mkfifo( fn_fifo.c_str(), 0666 )) - throw "SEVERE SYSTEM ERROR cannot make fifo " + fn_fifo + + throw "SYSTEM ERROR cannot make fifo " + fn_fifo + ": will not be able to print"; mystd::system( "gnuplot -title " + strg(iPlot) + " -noraise" + @@ -41,7 +41,7 @@ CPlot::CPlot( uint _iPlot, bool _logx, bool _logy ) : // we use open instead of fopen or ofstream, // because we need non-blocking mode. if (!(gp_fifo = open(fn_fifo.c_str(), O_WRONLY))) - throw "SEVERE SYSTEM ERROR cannot open fifo " + fn_fifo + + throw "SYSTEM ERROR cannot open fifo " + fn_fifo + ": will not be able to print"; fcntl(gp_fifo,F_SETFL,O_NONBLOCK); -- GitLab