source: tools/PlotTempsViaGnuplot/plot_pt100_temps.c@ 169

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