-
Notifications
You must be signed in to change notification settings - Fork 5
/
Seismometer.h
82 lines (59 loc) · 1.27 KB
/
Seismometer.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// Created by enrico on 12/07/15.
//
#ifndef GALILEO_TERREMOTI_SEISMOMETER_H
#define GALILEO_TERREMOTI_SEISMOMETER_H
#include "Accelerometer.h"
#include "Config.h"
typedef struct {
unsigned long ts;
double accel;
bool overThreshold;
} RECORD;
/**
* Seismometer class
*/
class Seismometer {
public:
/**
* Init seismometer class
*/
void init();
/**
* Tick (if no threaded)
*/
void tick();
/**
* Get accelerometer name
* @return Get accelerometer name
*/
std::string getAccelerometerName();
unsigned int getStatProbeSpeed();
double getQuakeThreshold();
double getCurrentAVG();
double getCurrentSTDDEV();
void setSigmaIter(double);
double getSigmaIter();
void resetLastPeriod();
/**
* Get Seismometer instance (singleton)
*/
static Seismometer *getInstance();
private:
Seismometer();
void addValueToAvgVar(double val);
Accelerometer *accelero;
bool inEvent;
unsigned long lastEventWas;
//Collector *serverCollector;
double partialAvg = 0;
double partialStdDev = 0;
unsigned int elements = 0;
double quakeThreshold = 1;
double sigmaIter = 3;
unsigned long statLastCounterTime = 0;
unsigned int statLastCounter = 0;
unsigned int statProbeSpeed = 0;
static Seismometer *instance;
};
#endif //GALILEO_TERREMOTI_SEISMOMETER_H