supla-device
Loading...
Searching...
No Matches
relay_hvac_aggregator.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17*/
18
19#ifndef SRC_SUPLA_CONTROL_RELAY_HVAC_AGGREGATOR_H_
20#define SRC_SUPLA_CONTROL_RELAY_HVAC_AGGREGATOR_H_
21
22#include <supla/element.h>
23
24namespace Supla {
25namespace Control {
26
27class Relay;
28class HvacBase;
29
30class RelayHvacAggregator : public Element {
31 public:
32 struct HvacPtr {
33 HvacBase *hvac = nullptr;
34 HvacPtr *nextPtr = nullptr;
35 uint32_t lastSeenTimestamp = 0;
36 };
37
38 static RelayHvacAggregator *GetInstance(int relayChannelNumber);
39 static RelayHvacAggregator *Add(int relayChannelNumber, Relay *relay);
40 static bool Remove(int relayChannelNumber);
41 static void UnregisterHvac(HvacBase *hvac);
42
43 void registerHvac(HvacBase *hvac);
44 void unregisterHvac(HvacBase *hvac);
45 bool isHvacRegistered(HvacBase *hvac) const;
46 int getHvacCount() const;
47
48 void iterateAlways() override;
49 void setTurnOffWhenEmpty(bool turnOffWhenEmpty);
50
51 void setInternalStateCheckInterval(uint32_t intervalMs);
52
53 protected:
54 explicit RelayHvacAggregator(int relayChannelNumber, Relay *relay);
55 virtual ~RelayHvacAggregator();
56
57 private:
58 RelayHvacAggregator *nextPtr = nullptr;
59 HvacPtr *firstHvacPtr = nullptr;
60 Relay *relay = nullptr;
61 int relayChannelNumber = 0;
62 uint32_t lastUpdateTimestamp = 0;
63 uint32_t lastStateUpdateTimestamp = 0;
64 uint32_t relayInternalStateCheckIntervalMs = 10000;
65 bool turnOffWhenEmpty = true;
66 int8_t lastValueSend = -1;
67 int8_t lastRelayState = -1;
68};
69
70} // namespace Control
71} // namespace Supla
72
73#endif // SRC_SUPLA_CONTROL_RELAY_HVAC_AGGREGATOR_H_
Definition hvac_base.h:52
Definition relay.h:50
Definition hvac_base.h:52
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition relay_hvac_aggregator.cpp:155
Definition relay.h:50
Definition relay_hvac_aggregator.h:32