-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataLog.h
64 lines (50 loc) · 1.72 KB
/
DataLog.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 <string>
#include "concurrent/readerwriterqueue.h"
#include <unordered_map>
#include <thread>
#include "DataRow.h"
#include <map>
#include "PlotDataContainer.h"
#include "CSVLogger.h"
#include "PlotUI.h"
#include <iostream>
#include <fstream>
#include <chrono>
enum class EventType {
MESSAGE,
STAGE,
DONE,
PAUSE,
RESUME
};
class DataLog
{
inline static bool initialized = false;
inline static std::string filename = "";
inline static DataLog * datalogInstance = nullptr;
inline static PlotUI * plotUIInstance = nullptr;
inline static CSVLogger * csvLoggerInstance = nullptr;
inline static std::thread dataThread = std::thread();
inline static std::atomic_bool paused = false;
inline static std::atomic_bool done = false;
inline static std::atomic_bool uiShouldBeRunning = true;
inline static double lastTsSim = -1.0f;
inline static auto lastTsProg = std::chrono::steady_clock::now();
inline static auto startTime = std::chrono::steady_clock::now();
static void startDataThread();
DataLog();
void run();
inline static moodycamel::ReaderWriterQueue<DataRow> dataQueue = moodycamel::ReaderWriterQueue<DataRow>();
inline static std::unordered_map<std::string, double> currentData = std::unordered_map<std::string, double>();
inline static std::shared_ptr<PlotDataContainer> plotData = std::make_shared<PlotDataContainer>();
public:
static void initialize(std::string filename, bool newRun = true);
static void logData(std::string name, double value);
static void pushTimestamp(double timestamp);
static void pushEvent(EventType eventType, std::string message); //TODO: Implement
static bool isDone();
static bool uiSHouldBeRunning();
static bool isPaused();
static void cleanup(bool close = true);
};