-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnvmes.cpp
109 lines (95 loc) · 3.05 KB
/
nvmes.cpp
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "nvmes.hpp"
#include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp>
#include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp>
#include <xyz/openbmc_project/Sensor/Value/server.hpp>
namespace phosphor
{
namespace nvme
{
void NvmeSSD::checkSensorThreshold()
{
int8_t value = ValueIface::value();
int8_t criticalHigh = CriticalInterface::criticalHigh();
int8_t criticalLow = CriticalInterface::criticalLow();
int8_t warningHigh = WarningInterface::warningHigh();
int8_t warningLow = WarningInterface::warningLow();
auto criticalAlarmLowState = CriticalInterface::criticalAlarmLow();
auto criticalAlarmHighState = CriticalInterface::criticalAlarmHigh();
auto warningAlarmLowState = WarningInterface::warningAlarmLow();
auto warningAlarmHighState = WarningInterface::warningAlarmHigh();
bool criticalAlarmLow = (value <= criticalLow);
bool criticalAlarmHigh = (value >= criticalHigh);
bool warningAlarmLow = (value <= warningLow);
bool warningAlarmHigh = (value >= warningHigh);
CriticalInterface::criticalAlarmHigh(criticalAlarmHigh);
CriticalInterface::criticalAlarmLow(criticalAlarmLow);
WarningInterface::warningAlarmHigh(warningAlarmHigh);
WarningInterface::warningAlarmLow(warningAlarmLow);
if (criticalAlarmHighState != criticalAlarmHigh)
{
if (criticalAlarmHigh)
{
CriticalInterface::criticalHighAlarmAsserted(value);
}
else
{
CriticalInterface::criticalHighAlarmDeasserted(value);
}
}
if (criticalAlarmLowState != criticalAlarmLow)
{
if (criticalAlarmLow)
{
CriticalInterface::criticalLowAlarmAsserted(value);
}
else
{
CriticalInterface::criticalLowAlarmDeasserted(value);
}
}
if (warningAlarmHighState != warningAlarmHigh)
{
if (warningAlarmHigh)
{
WarningInterface::warningHighAlarmAsserted(value);
}
else
{
WarningInterface::warningHighAlarmDeasserted(value);
}
}
if (warningAlarmLowState != warningAlarmLow)
{
if (warningAlarmLow)
{
WarningInterface::warningLowAlarmAsserted(value);
}
else
{
WarningInterface::warningLowAlarmDeasserted(value);
}
}
}
void NvmeSSD::setSensorThreshold(int8_t criticalHigh, int8_t criticalLow,
int8_t warningHigh, int8_t warningLow)
{
CriticalInterface::criticalHigh(criticalHigh);
CriticalInterface::criticalLow(criticalLow);
WarningInterface::warningHigh(warningHigh);
WarningInterface::warningLow(warningLow);
}
void NvmeSSD::setSensorMaxMin(int8_t maxValue, int8_t minValue)
{
ValueIface::maxValue(maxValue);
ValueIface::minValue(minValue);
}
void NvmeSSD::setSensorValueToDbus(const int8_t value)
{
ValueIface::value(value);
}
void NvmeSSD::setSensorAvailability(bool avail)
{
AvailabilityInterface::available(avail);
}
} // namespace nvme
} // namespace phosphor