Index: mttroot/mtt/cc/Makefile ================================================================== --- mttroot/mtt/cc/Makefile +++ mttroot/mtt/cc/Makefile @@ -1,11 +1,11 @@ .POSIX: -ifeq (0,1) CC=g++ +ifeq (0,1) CFLAGS+=-static OCTAVE_LIBS_PATH=-L/usr/local/lib/octave OCTAVE_LIBRARIES=-loctave -lcruft -lm -lncurses -ldl -lstdc++ -lc -lkpathsea -lreadline -lf2c %.exe: %.cc @@ -45,6 +45,8 @@ $(sys)_sympar.txt: mtt $(sys) sympar txt - +# struc2gnuplot_txt.exe is used by gnuplot_rep.make to create gnuplot input file. +struc2gnuplot_txt.exe: $(MTT_CC)/struc2gnuplot_txt.cc + $(CC) -O3 -Wall -ansi -pedantic -DMAIN $(MTT_CC)/struc2gnuplot_txt.cc -o $(MTTPATH)/trans/struc2gnuplot_txt.exe ADDED mttroot/mtt/cc/struc2gnuplot_txt.cc Index: mttroot/mtt/cc/struc2gnuplot_txt.cc ================================================================== --- /dev/null +++ mttroot/mtt/cc/struc2gnuplot_txt.cc @@ -0,0 +1,106 @@ + +#include +#include +#include + + +ostream &struc2gnuplot_txt(const string sys = "sim", istream &in = cin, ostream &out = cout) +{ + typedef struct record_ record_t; + struct record_ + { + string vec; + unsigned int num; + string cmp; + string mod; + unsigned int rpt; + }; + + list Lx; + list Ly; + + record_t r; + + + // read data from struc.txt + + while (in >> r.vec >> r.num >> r.cmp >> r.mod >> r.rpt) + { + if ("state" == r.vec) + { + Lx.push_back(r); + } + else if ("output" == r.vec) + { + Ly.push_back(r); + } + } + + // write header + + out << "set data style lines" << endl + << "set xlabel \"time\"" << endl + << "set grid" << endl + << endl; + + // write states (X11) + + out << "set term X11" << endl + << "plot\\" << endl; + for (list::iterator i = Lx.begin(); i != Lx.end() ; i++) + { + if (Lx.begin() != i) + { + out << ",\\" << endl; + } + out << "\t\"MTT_work/" << sys << "_odes2.dat\" using 1:" << 2 + Ly.size() + i->num + << " axes x1y1" + << " title \"" << i->mod << "_" << i->cmp << "\""; + } + out << endl << endl << "pause(-1)" << endl << endl; + + // write states (postscript) + + out << "set term postscript eps color" << endl + << "set output \"" << sys << "_states.eps\"" << endl + << "replot" << endl << endl; + + // write outputs (X11) + + out << "set term X11" << endl + << "plot\\" << endl; + for (list::iterator i = Ly.begin(); i != Ly.end() ; i++) + { + if (Ly.begin() != i) + { + out << ",\\" << endl; + } + out << "\t\"MTT_work/" << sys << "_odes2.dat\" using 1:" << 1 + i->num + << " axes x1y1" + << " title \"" << i->mod << "_" << i->cmp << "\""; + } + out << endl << endl << "pause(-1)" << endl << endl; + + // write outputs (postscript) + + out << "set term postscript eps color" << endl + << "set output \"" << sys << "_outputs.eps\"" << endl + << "replot" << endl << endl; + + return out; +} + +#ifdef MAIN +int main(int argc, char *argv[]) +{ + if (--argc) + { + struc2gnuplot_txt(argv[1]); + } + else + { + struc2gnuplot_txt(); + } + return 0; +} +#endif // MAIN ADDED mttroot/mtt/lib/rep/gnuplot_rep.make Index: mttroot/mtt/lib/rep/gnuplot_rep.make ================================================================== --- /dev/null +++ mttroot/mtt/lib/rep/gnuplot_rep.make @@ -0,0 +1,16 @@ +# -*-makefile-*- +# create a gnuplot input file + +MTTFLAGS = $(OPTS) + +all: $(SYS)_gnuplot.$(LANG) + +$(SYS)_gnuplot.txt: $(SYS)_struc.txt $(MTTPATH)/trans/struc2gnuplot_txt.exe + $(MTTPATH)/trans/struc2gnuplot_txt.exe $(SYS) < $(SYS)_struc.txt > $(SYS)_gnuplot.txt + +$(SYS)_struc.txt: + mtt $(MTTFLAGS) $(SYS) struc txt + +$(MTTPATH)/trans/struc2gnuplot_txt.exe: + make -f $(MTT_CC)/Makefile struc2gnuplot_txt.exe +