supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
sensor
general_purpose_meter.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_SENSOR_GENERAL_PURPOSE_METER_H_
20
#define SRC_SUPLA_SENSOR_GENERAL_PURPOSE_METER_H_
21
22
#include "general_purpose_channel_base.h"
23
#include <supla/action_handler.h>
24
25
namespace
Supla {
26
namespace
Sensor {
27
class
GeneralPurposeMeter :
public
GeneralPurposeChannelBase
,
28
public
ActionHandler {
29
public
:
30
#pragma pack(push, 1)
31
struct
GPMMeterSpecificConfig
{
32
uint8_t counterType = 0;
33
uint8_t includeValueAddedInHistory = 0;
34
uint8_t fillMissingData = 0;
35
};
36
#pragma pack(pop)
37
38
explicit
GeneralPurposeMeter(MeasurementDriver *driver =
nullptr
,
39
bool
addMemoryVariableDriver =
true
);
40
41
void
onLoadConfig
(
SuplaDeviceClass
*sdc)
override
;
42
Supla::ApplyConfigResult
applyChannelConfig
(
TSD_ChannelConfig
*result,
43
bool
local)
override
;
44
void
fillChannelConfig
(
void
*channelConfig,
45
int
*size, uint8_t configType)
override
;
46
void
handleAction(
int
event,
int
action)
override
;
47
int
handleCalcfgFromServer
(
TSD_DeviceCalCfgRequest
*request)
override
;
48
void
onLoadState
()
override
;
49
void
onSaveState
()
override
;
50
51
// Set counter to a given value
52
void
setCounter(
double
newValue);
53
// Increment the counter by incrementBy or by valueStep when incrementBy = 0
54
void
incCounter(
double
incrementBy = 0);
55
// Decrement the counter by decrementBy or by valueStep when decrementBy = 0
56
void
decCounter(
double
decrementBy = 0);
57
void
setValueStep(
double
newValueStep);
58
void
setResetToValue(
double
newResetToValue);
59
60
void
setCounterResetSupportFlag(
bool
support);
61
// Enable or disable keeping state in Storage
62
void
setKeepStateInStorage(
bool
keep);
63
64
uint8_t getCounterType()
const
;
65
uint8_t getIncludeValueAddedInHistory()
const
;
66
uint8_t getFillMissingData()
const
;
67
68
void
setCounterType(uint8_t counterType,
bool
local =
true
);
69
void
setIncludeValueAddedInHistory(uint8_t includeValueAddedInHistory,
70
bool
local =
true
);
71
void
setFillMissingData(uint8_t fillMissingData,
bool
local =
true
);
72
73
protected
:
74
void
saveMeterSpecificConfig();
75
double
valueStep = 1;
76
double
resetToValue = 0;
77
bool
isCounterResetSupported =
true
;
78
bool
keepStateInStorage =
false
;
79
80
GPMMeterSpecificConfig
meterSpecificConfig = {};
81
};
82
83
};
// namespace Sensor
84
};
// namespace Supla
85
#endif
// SRC_SUPLA_SENSOR_GENERAL_PURPOSE_METER_H_
SuplaDeviceClass
Definition
SuplaDevice.h:163
Supla::Sensor::GeneralPurposeChannelBase::GeneralPurposeChannelBase
GeneralPurposeChannelBase(MeasurementDriver *driver=nullptr, bool addMemoryVariableDriver=true)
Constructor.
Definition
general_purpose_channel_base.cpp:35
Supla::Sensor::GeneralPurposeMeter::onLoadState
void onLoadState() override
Second method called on element in SuplaDevice.begin().
Definition
general_purpose_meter.cpp:308
Supla::Sensor::GeneralPurposeMeter::onLoadConfig
void onLoadConfig(SuplaDeviceClass *sdc) override
Supla::Element::onLoadConfig() - called by SuplaDeviceClass::loadConfig() during initialization.
Definition
general_purpose_meter.cpp:40
Supla::Sensor::GeneralPurposeMeter::onSaveState
void onSaveState() override
Method called periodically during SuplaDevice iteration.
Definition
general_purpose_meter.cpp:301
Supla::Sensor::GeneralPurposeMeter::applyChannelConfig
Supla::ApplyConfigResult applyChannelConfig(TSD_ChannelConfig *result, bool local) override
Applies new Channel Config (i.e.
Definition
general_purpose_meter.cpp:59
Supla::Sensor::GeneralPurposeMeter::handleCalcfgFromServer
int handleCalcfgFromServer(TSD_DeviceCalCfgRequest *request) override
Handles CALCFG requests from server.
Definition
general_purpose_meter.cpp:249
Supla::Sensor::GeneralPurposeMeter::fillChannelConfig
void fillChannelConfig(void *channelConfig, int *size, uint8_t configType) override
Fills Channel Config.
Definition
general_purpose_meter.cpp:120
GeneralPurposeMeter::GPMMeterSpecificConfig
Definition
general_purpose_meter.h:31
TSD_ChannelConfig
Definition
proto.h:3130
TSD_DeviceCalCfgRequest
Definition
proto.h:2311
Generated by
1.17.0