supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
suplet
thermometer_group.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_SUPLET_THERMOMETER_GROUP_H_
20
#define SRC_SUPLA_SUPLET_THERMOMETER_GROUP_H_
21
22
#include <stdint.h>
23
#include <supla/suplet/virtual_channel.h>
24
25
#ifndef SUPLA_SUPLET_THERMOMETER_GROUP_MAX_SOURCES
26
#define SUPLA_SUPLET_THERMOMETER_GROUP_MAX_SOURCES 8
27
#endif
28
29
namespace
Supla {
30
namespace
Suplet {
31
32
enum class
ThermometerGroupMode : uint8_t {
33
Avg = 1,
34
Min = 2,
35
Max = 3,
36
};
37
38
struct
ThermometerGroupConfig
{
39
uint8_t version = 1;
40
ThermometerGroupMode mode = ThermometerGroupMode::Avg;
41
uint16_t refreshIntervalMs = 1000;
42
uint8_t sourceCount = 0;
43
int16_t sourceChannels[SUPLA_SUPLET_THERMOMETER_GROUP_MAX_SOURCES] = {};
44
};
45
46
class
ThermometerGroup :
public
VirtualThermometer {
47
public
:
48
ThermometerGroup(uint8_t subDeviceId,
49
int
channelNumber,
50
const
ThermometerGroupConfig
&config);
51
52
void
iterateAlways
()
override
;
53
double
calculateValue()
const
;
54
const
ThermometerGroupConfig
&getConfig()
const
;
55
56
private
:
57
struct
GroupValue {
58
bool
hasOnlineSource =
false
;
59
bool
hasValidValue =
false
;
60
double
value = TEMPERATURE_NOT_AVAILABLE;
61
};
62
63
static
bool
isValidTemperature(
double
value);
64
GroupValue calculateGroupValue()
const
;
65
66
ThermometerGroupConfig
config = {};
67
uint32_t lastRefreshMs = 0;
68
};
69
70
bool
parseThermometerGroupConfig(
const
uint8_t *data,
71
uint16_t dataSize,
72
ThermometerGroupConfig *config);
73
bool
serializeThermometerGroupConfig(
const
ThermometerGroupConfig &config,
74
uint8_t *data,
75
uint16_t dataSize,
76
uint16_t *writtenSize =
nullptr
);
77
78
}
// namespace Suplet
79
}
// namespace Supla
80
81
#endif
// SRC_SUPLA_SUPLET_THERMOMETER_GROUP_H_
Supla::Suplet::ThermometerGroup::iterateAlways
void iterateAlways() override
Method called on each SuplaDevice iteration.
Supla::Suplet::ThermometerGroupConfig
Definition
thermometer_group.h:38
Generated by
1.17.0