-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollector.h
63 lines (50 loc) · 1.86 KB
/
collector.h
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
#pragma once
//#include "neighbor_manager.h"
#include "sample.h"
#include "helpers.h"
#include <string>
#include <fstream>
#include <vector>
#include <list>
#include <queue>
#include <chrono>
#include <tuple>
#include <thread>
#include <mutex>
#include <nlohmann/json.hpp>
// using DataPoint = std::tuple<int, double>;
using TxDataPoint = std::tuple<std::chrono::time_point<std::chrono::high_resolution_clock>, long>; // timestamp, value
using Clock = std::chrono::high_resolution_clock;
class NeighborManager;
class Collector {
private:
void seek_to_header();
NeighborManager* neighbor_manager;
// std::string specinterface;
// std::string netinterface;
std::string phy;
std::string txpath;
std::string rxpath;
std::string scanpath;
std::ifstream scanfile;
// diagnostics data files
std::ofstream outputscanfile = fileoutput ? std::ofstream("specdata.csv") : std::ofstream("/dev/null");
std::ofstream outputtxfile = fileoutput ? std::ofstream("txdata.csv") : std::ofstream("/dev/null");
std::mutex file_lock;
std::list<Sample*> received_series;
std::list<TxDataPoint> tx_series;
long last_net_bytes;
int sample_count = 0;
int net_count = 0;
public:
Collector(std::string& specinterface, std::string& netinterface);
void run(volatile bool* running);
std::thread start_thread(volatile bool* running);
void readSample(std::ifstream &scanfile, decltype(received_series) &received_series);
void set_neighbor_manager(NeighborManager* neighbor_manager);
nlohmann::json get_tx(size_t max_size);
double correlate(const std::vector<double>& txvector, long timeint);
double kkf_max(const std::vector<double>& txvector, long timeint);
std::tuple<int, double, std::chrono::time_point<Clock>> get_rx_power(std::chrono::milliseconds duration);
void truncate(std::chrono::milliseconds time);
};