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 };
36
37 static RelayHvacAggregator *GetInstance(int relayChannelNumber);
38 static RelayHvacAggregator *Add(int relayChannelNumber, Relay *relay);
39 static bool Remove(int relayChannelNumber);
40 static void UnregisterHvac(HvacBase *hvac);
41
42 void registerHvac(HvacBase *hvac);
43 void unregisterHvac(HvacBase *hvac);
44 bool isHvacRegistered(HvacBase *hvac) const;
45 int getHvacCount() const;
46
47 void iterateAlways() override;
48 void setTurnOffWhenEmpty(bool turnOffWhenEmpty);
49
50 protected:
51 explicit RelayHvacAggregator(int relayChannelNumber, Relay *relay);
52 virtual ~RelayHvacAggregator();
53
54 private:
55 RelayHvacAggregator *nextPtr = nullptr;
56 HvacPtr *firstHvacPtr = nullptr;
57 Relay *relay = nullptr;
58 int relayChannelNumber = 0;
59 uint32_t lastUpdateTimestamp = 0;
60 uint32_t lastStateUpdateTimestamp = 0;
61 bool turnOffWhenEmpty = true;
62 int8_t lastValueSend = -1;
63 int8_t lastRelayState = -1;
64};
65
66} // namespace Control
67} // namespace Supla
68
69#endif // SRC_SUPLA_CONTROL_RELAY_HVAC_AGGREGATOR_H_
Definition hvac_base.h:52
Definition relay.h:49
Definition hvac_base.h:52
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition relay_hvac_aggregator.cpp:148
Definition relay.h:49
Definition relay_hvac_aggregator.h:32