-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_plot.cc
69 lines (60 loc) · 1.42 KB
/
main_plot.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
*
*
* @author Laurent Winkler based on work by Valentin Bourqui
* @date May 2015
* @brief A small executable used to plot an existing CSV file
*
*
*/
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include "POPSensorData.h"
using namespace std;
int main(int argc, char** argv)
{
if(argc != 2)
{
cout << "usage: " << argv[0] << " data.csv" << popcendl;
exit(0);
}
try
{
POPSensorData data;
ifstream ifs;
ifs.open(argv[1]);
data.ReadFromFile(ifs);
ifs.close();
cout << "Read " << data.GetSize() << " records" << popcendl;
stringstream ss;
ss << "mkdir -p " << argv[1] << "_plots";
system(ss.str().c_str());
// Create one plot per sensor id with all measurement
for(auto id : data.GroupAllIds())
{
string target = string(argv[1]) + "_plots/sensor" + to_string(id) + ".html";
cout << "Create " << target << popcendl;
data.PrintToPlot(target, id);
}
// Create one plot per measurement with all sensors
for(auto mt : data.GroupAllMeasurementTypes())
{
string target = string(argv[1]) + "_plots/" + explainMeasurementType(mt) + ".html";
cout << "Create " << target << popcendl;
data.PrintToPlot(target, mt);
}
}
catch(std::exception &e)
{
cerr<<"Exception caught in " << argv[0] << ": " << e.what() << popcendl;
return 1;
}
catch(...)
{
cerr<<"Exception caught in popwin main loop" << argv[0] << popcendl;
return 1;
}
return 0;
}