Repository navigation
Expand file tree
/
Copy pathLogValidator.h
More file actions
66 lines (55 loc) · 2.57 KB
/
Copy pathLogValidator.h
File metadata and controls
66 lines (55 loc) · 2.57 KB
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
#pragma once
#include <fstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include "MsgStats.h"
#ifndef LOG_VALIDATOR
#define LOG_VALIDATOR
using namespace std;
namespace DmsLog {
class LogValidator {
private:
std::ifstream infile;
std::string fname;
int nSources{ 4 };
std::vector<int> idList{};
/**
* The log generated by Don's logging software will always have the first three lines as header info.
* This simple log validity checker does not need to process those three lines. Thus I simply ignore them.
*/
void ignoreHeader();
/**
* This method summarize the log processing result, produce some outputs in STDOUT.
* It reports missing message sources, empty payloads, non-varying payloads, message count and message timespan in a percentage..
*
* the returned boolean is not used so far, but it represents the log checker's perspective of viewing if the log is valid or not.
*
* \param statsMap An unordered_map that records information of IDs, including emptiness, varying or not, timespan, message count and of course, id
* \param sources The remaining source(s) that the log checker was unable to discover
* \param ts The time stamp of the last record. The first record will be one, thus we can use ts - 1 as the total number of milliseconds the log file has been active.
*
* \return Log validity. True: valid, false, invalid
*/
bool resCheck(const unordered_map<int, MsgStats> &statsMap, const unordered_set<int>& sources, const long long ts) const;
public:
LogValidator(const std::string& fname);
LogValidator(const std::string& fname, const int nSources);
~LogValidator();
/** This sets the IDs the log checker needs to check. If it is empty, no operations will be done, except the sources check, which has a value of 4, denoting {0,1,2,3}
*/
void setIdList(std::vector<int> list);
/**
* process and collect CAN ID info. Results will be judged by resCheck()
*
* \return The validity of the log file.
*/
bool processLogs();
/**
* Report the log file's file name the log validator is/will be processing.
*/
const string& getFileName() const;
};
}
#endif