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
|
From 2b9306de104f53a4d8540d33d6d912682957611f Mon Sep 17 00:00:00 2001
From: "Evgeny Alekseev (IBS Group)" <ealekseev@ibs.sila.ru>
Date: Fri, 14 Oct 2022 14:41:48 +0300
Subject: [PATCH] Fix PowerState::on thresholds going high
---
src/ADCSensor.cpp | 5 +++++
src/Thresholds.cpp | 2 +-
src/Utils.cpp | 3 ++-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index 4d47762..05e6438 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -230,6 +230,11 @@ void ADCSensor::checkThresholds(void)
{
if (!readingStateGood())
{
+ for(auto th : thresholds)
+ {
+ if(th.direction == thresholds::Direction::LOW)
+ thresholdTimer.stopTimer(th, true);
+ }
return;
}
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index 9bc8098..3880cb8 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -326,7 +326,7 @@ void ThresholdTimer::startTimer(const std::weak_ptr<Sensor>& weakSensor,
double assertValue)
{
struct TimerUsed timerUsed = {};
- constexpr const size_t waitTime = 5;
+ constexpr const size_t waitTime = 10;
TimerPair* pair = nullptr;
for (TimerPair& timer : timers)
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 7dc40c4..785b7be 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -418,6 +418,7 @@ void setupPowerMatchCallback(
auto findState = values.find(power::property);
if (findState != values.end())
{
+ powerStatusOn = false;
bool on =
std::get<std::string>(findState->second).ends_with(".Running");
if (!on)
@@ -428,7 +429,7 @@ void setupPowerMatchCallback(
return;
}
// on comes too quickly
- timer.expires_after(std::chrono::seconds(10));
+ timer.expires_after(std::chrono::seconds(20));
timer.async_wait(
[hostStatusCallback](boost::system::error_code ec) {
if (ec == boost::asio::error::operation_aborted)
|