-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChannelAlert.h
More file actions
77 lines (66 loc) · 1.5 KB
/
ChannelAlert.h
File metadata and controls
77 lines (66 loc) · 1.5 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
67
68
69
70
71
72
73
74
75
76
77
#pragma once
#include <ArduinoSTL.h>
#include "Configuration.h"
#include "Data.h"
#define AlertDeviation 2
namespace MonitoringComponents {
class ChannelAlert {
public:
int actionId;
bool enabled;
bool activated;
ActionType actionType;
ChannelAlert() {
this->activated = false;
}
ChannelAlert& operator=(const ChannelAlert& rhs) {
this->actionId = rhs.actionId;
this->activated = rhs.activated;
this->enabled = rhs.enabled;
this->actionType = rhs.actionType;
return *this;
}
operator bool() {
return this->activated;
}
};
class AnalogAlert :public ChannelAlert {
public:
float setPoint;
CheckType checkType;
bool Check(float value) {
if(this->enabled){
if(checkType==CheckType::GreaterThan){
return value >= (this->setPoint-(this->setPoint*0.002f));
}else{
return value <= (this->setPoint+(this->setPoint*0.002f));
}
}else{
return false;
}
}
bool CheckAgainst(float value){
if(this->enabled){
if(this->checkType==CheckType::GreaterThan){
return value < this->setPoint;
}else{
return value > this->setPoint;
}
}
}
AnalogAlert& operator=(const AnalogAlert& rhs) {
ChannelAlert::operator=(rhs);
this->setPoint = rhs.setPoint;
this->checkType=rhs.checkType;
return *this;
}
};
class DigitalAlert :public ChannelAlert {
public:
TriggerOn triggerOn;
DigitalAlert& operator=(const DigitalAlert& rhs) {
ChannelAlert::operator=(rhs);
this->triggerOn = rhs.triggerOn;
}
};
};