source: fact/tools/PlotTempsViaGnuplot/plotTempsViaGnuplot.c@ 13445

Last change on this file since 13445 was 116, checked in by daqct3, 15 years ago
set ignore flag on executables
File size: 2.1 KB
Line 
1#include <stdio.h>
2#include <string.h>
3#include <stdlib.h>
4#include <time.h>
5 int main(int argc, char *argv[])
6{
7
8 FILE *plotfile;
9
10 char tempFilename[80];
11 long startTime=1246582381;
12 char usingStr[40];
13
14 if (argc < 3) {
15 fprintf (stderr, "usage: plot <filename.slow> Starttimemodifier e.g. 3600 \n");
16 return -1;
17 }
18 if (argc > 3) {
19 fprintf (stderr, "too many arguments: usage: plot <filename.slow> Starttimemodifier e.g. 300\n");
20 return -1;
21 }
22
23
24 time_t rawtime;
25 struct tm * timeinfo;
26
27 time ( &rawtime );
28
29 startTime = (long)rawtime;
30 strcpy(tempFilename, argv[1]);
31
32 startTime -= atoi(argv[2]);
33 rawtime -= atoi(argv[2]);
34
35 plotfile = fopen ("plot_t.plt","w");
36
37 timeinfo = localtime ( &rawtime );
38 fprintf (plotfile, "set title 'Temps since %s\n", asctime (timeinfo) );
39
40 if (plotfile!=NULL)
41 {
42 fputs ( "set xlabel 'time sec '\n"
43 "set ylabel 'T in C '\n"
44 "set grid\n"
45 ,plotfile);
46
47 sprintf(usingStr, "($10>\%d ? $10-\%d : 1/0)", startTime, startTime);
48
49 fputs("plot ",plotfile);
50
51 fprintf(plotfile, "\"%s\" using %s:12 title 'water out' with points"
52 ,tempFilename
53 ,usingStr
54 );
55
56 fputs(", \\\n", plotfile);
57 fprintf(plotfile, "\"%s\" using %s:13 title 'upper right' with points"
58 ,tempFilename
59 ,usingStr
60 );
61 fputs(", \\\n", plotfile);
62 fprintf(plotfile, "\"%s\" using %s:14 title 'upper left' with points"
63 ,tempFilename
64 ,usingStr
65 );
66 fputs(", \\\n", plotfile);
67 fprintf(plotfile, "\"%s\" using %s:15 title 'lower left' with points"
68 ,tempFilename
69 ,usingStr
70 );
71 fputs(", \\\n", plotfile);
72 fprintf(plotfile, "\"%s\" using %s:16 title 'lower right' with points"
73 ,tempFilename
74 ,usingStr
75 );
76 fputs(", \\\n", plotfile);
77 fprintf(plotfile, "\"%s\" using %s:17 title 'water in' with points"
78 ,tempFilename
79 ,usingStr
80 );
81 fputs(", \\\n", plotfile);
82 fprintf(plotfile, "\"%s\" using %s:18 title 'humidity temp' with points"
83 ,tempFilename
84 ,usingStr
85 );
86 fputs("\n", plotfile);
87
88 fputs("pause -1 \"Hit any key or press OK to continue ...\"\n",plotfile);
89
90 fclose (plotfile);
91 }
92
93 system("gnuplot plot_t.plt");
94
95 system("rm plot_t.plt");
96 return 0;
97}
Note: See TracBrowser for help on using the repository browser.