-
Notifications
You must be signed in to change notification settings - Fork 0
/
globalstate.h
55 lines (52 loc) · 1.42 KB
/
globalstate.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
#ifndef GLOBALSTATE_H
#define GLOBALSTATE_H
#include <map>
#include <chrono>
#include <mutex>
#include <condition_variable>
#include <vector>
#include <QFile>
#include <QTextStream>
#include <exception>
#include <random>
class GlobalState
{
public:
using timePoint = std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<qulonglong, std::ratio<1>>>;
static GlobalState & getInstance(){
static GlobalState gs;
return gs;
}
std::mutex packetsMutex;
std::mutex espMutex;
std::condition_variable espCv;
volatile int espCount;
volatile int espStatus;
GlobalState(GlobalState &)= delete ;
GlobalState & operator=(GlobalState &)=delete;
const QHash<qulonglong, std::pair<double, double>> & getStations();
const timePoint & getTime();
void updateTime();
unsigned long getIteration();
unsigned short getPort();
void parse();
void randomizeChannel();
double getScale();
int8_t getCoefficientA();
double getCoefficientN();
uint8_t getChannel();
private:
GlobalState();
QHash<qulonglong, std::pair<double, double>> stations;
timePoint time;
unsigned long iteration;
std::mutex timeMutex;
unsigned short port;
uint8_t channel;
std::minstd_rand randomEngine;
std::uniform_int_distribution<> randomDistribution;
int8_t coefficientA;
double coefficientN;
double scale;
};
#endif // GLOBALSTATE_H