diff --git a/.gitignore b/.gitignore index 22b80c9dc3..b40917524e 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ /conf/%gconf.xml /conf/srtm_data/* /conf/maps_data/* +/conf/gps/ublox_conf # /doc/pprz_algebra/ /doc/pprz_algebra/headfile.log @@ -99,6 +100,7 @@ /sw/logalizer/plotter /sw/logalizer/gtk_export.ml /sw/logalizer/sd2log +/sw/logalizer/plotprofile # /sw/simulator/ /sw/simulator/gaia diff --git a/sw/logalizer/Makefile b/sw/logalizer/Makefile index 4768fac813..01dd11580b 100644 --- a/sw/logalizer/Makefile +++ b/sw/logalizer/Makefile @@ -27,7 +27,7 @@ OCAMLC = ocamlc OCAMLOPT = ocamlopt INCLUDES= $(shell ocamlfind query -r -i-format xml-light) $(shell ocamlfind query -r -i-format lablgtk2) -I ../lib/ocaml -all: play plotter plot sd2log +all: play plotter plot sd2log plotprofile play : log_file.cmo play_core.cmo play.cmo @echo OL $@ @@ -105,6 +105,9 @@ MORE_CFLAGS = -DHAVE_DLFCN_H=1 -DSTDC_HEADERS=1 -I. -I. -I.. -g -O2 -I/usr/ disp3d: disp3d.c $(CC) $(MORE_CFLAGS) -g -o $@ $^ $(MORE_FLAGS) +plotprofile: plotprofile.c + gcc -g -O2 -Wall `pkg-config glib-2.0 --cflags` -o $@ $^ `pkg-config glib-2.0 --libs` `pcre-config --libs` -lglibivy + test1: test1.c $(CC) $(MORE_CFLAGS) -g -o $@ $^ $(MORE_FLAGS) -lglut diff --git a/sw/logalizer/plotprofile.c b/sw/logalizer/plotprofile.c new file mode 100644 index 0000000000..39f0cdcf2a --- /dev/null +++ b/sw/logalizer/plotprofile.c @@ -0,0 +1,138 @@ + +/* + +http://users.softlab.ntua.gr/~ttsiod/gnuplotStreaming.html + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define HEIGHT_SPAN 20000 + +FILE *Gplt, *Gplh; +int32_t alt = 0; +int32_t temp[HEIGHT_SPAN] = {0}; +int32_t humid[HEIGHT_SPAN] = {0}; + +void on_GPS(IvyClientPtr app, void *user_data, int argc, char *argv[]){ +/* + + + + + + + + + + + + + + +7.73 11 GPS 0 55577549 665183336 0 -4310 0 0 1642 345957748 31 0 +*/ + + int32_t _alt; + + _alt = atoi(argv[5]); + alt = _alt / 100; +// if ((_alt/100) < HEIGHT_SPAN) alt = _alt; + +// printf("alt %f\n", (float) _alt/100.); +} + +void on_TMP_STATUS(IvyClientPtr app, void *user_data, int argc, char *argv[]){ +/* + + + + +*/ + + float _temp; + int i; + + _temp = atof(argv[2]); + if (alt < HEIGHT_SPAN) temp[alt] = _temp * 100; + +// printf("temp %f\n", _temp); + fprintf(Gplt, "plot '-' w points pt 0 title \"Temp\"\n"); + for (i = 0; i < HEIGHT_SPAN; i++){ + if (temp[i] != 0) fprintf(Gplt, "%f %d\n", temp[i]/100., i); + } + fprintf(Gplt,"e\n"); +} + +void on_SHT_STATUS(IvyClientPtr app, void *user_data, int argc, char *argv[]){ +/* + + + + + + +*/ + + float _humid; + int i; + + _humid = atof(argv[3]); + if (alt < HEIGHT_SPAN) humid[alt] = _humid * 100; + +// printf("humid %f\n", _humid); + fprintf(Gplh, "plot '-' w points pt 0 title \"Humid\"\n"); + for (i = 0; i < HEIGHT_SPAN; i++){ + if (humid[i] != 0) fprintf(Gplh, "%f %d\n", humid[i]/100., i); + } + fprintf(Gplh,"e\n"); +} + +int main( int argc, char* argv[] ) +{ + double xmint, xmaxt, xminh, xmaxh, ymin, ymax; + GMainLoop *ml; + + ml = g_main_loop_new(NULL, FALSE); + + IvyInit ("IvyPlotProfile", "IvyPlotProfile READY", NULL, NULL, NULL, NULL); + IvyBindMsg(on_GPS, NULL, "^(\\S*) GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); + IvyBindMsg(on_TMP_STATUS, NULL, "^(\\S*) TMP_STATUS (\\S*) (\\S*)"); + IvyBindMsg(on_SHT_STATUS, NULL, "^(\\S*) SHT_STATUS (\\S*) (\\S*) (\\S*) (\\S*)"); +// IvyBindMsg(on_SHT_STATUS, NULL, "^(\\S*) DPICCO_STATUS (\\S*) (\\S*) (\\S*) (\\S*)"); + IvyStart("127.255.255.255"); + + xmint = 5; + xmaxt = 35; + xminh = 0; + xmaxh = 100; + ymin = 500; + ymax = 2300; + + Gplt = popen("gnuplot -geometry 300x300 -noraise","w"); + setlinebuf(Gplt); + fprintf(Gplt, "set xrange[%f:%f]\n", xmint, xmaxt); + fprintf(Gplt, "set yrange[%f:%f]\n", ymin, ymax); + + Gplh = popen("gnuplot -geometry 300x300 -noraise","w"); + setlinebuf(Gplh); + fprintf(Gplh, "set xrange[%f:%f]\n", xminh, xmaxh); + fprintf(Gplh, "set yrange[%f:%f]\n", ymin, ymax); + + g_main_loop_run(ml); + + fclose(Gplt); + fclose(Gplh); + return 0; +}