supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
sensor
virtual_impulse_counter.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_VIRTUAL_IMPULSE_COUNTER_H_
20
#define SRC_SUPLA_SENSOR_VIRTUAL_IMPULSE_COUNTER_H_
21
22
#include <supla-common/proto.h>
23
#include <supla/action_handler.h>
24
#include <supla/channel_element.h>
25
26
namespace
Supla {
27
28
namespace
Sensor {
29
class
VirtualImpulseCounter :
public
ChannelElement,
public
ActionHandler
{
30
public
:
31
VirtualImpulseCounter();
32
33
void
onInit
()
override
;
34
void
onLoadState
()
override
;
35
void
onSaveState
()
override
;
36
void
iterateAlways
()
override
;
37
void
handleAction(
int
event,
int
action)
override
;
38
int
handleCalcfgFromServer
(
TSD_DeviceCalCfgRequest
*request)
override
;
39
40
// Returns value of a counter at given Supla channel
41
uint64_t getCounter()
const
;
42
43
// Set counter to a given value
44
void
setCounter(uint64_t value);
45
46
// Increment the counter by 1
47
void
incCounter();
48
49
virtual
void
resetCounter();
50
51
void
setForceStateSaveOnChange(
bool
value);
52
53
protected
:
54
Supla::ApplyConfigResult applyChannelConfig(
TSD_ChannelConfig
*result,
55
bool
local)
override
;
56
void
fillChannelConfig(
void
*channelConfig,
57
int
*size,
58
uint8_t configType)
override
;
59
60
uint64_t counter = 0;
// Actual count of impulses
61
uint32_t lastReadTime = 0;
62
bool
forceStateSaveOnChange =
false
;
63
};
64
65
}
// namespace Sensor
66
}
// namespace Supla
67
68
#endif
// SRC_SUPLA_SENSOR_VIRTUAL_IMPULSE_COUNTER_H_
Supla::ActionHandler
Definition
action_handler.h:21
Supla::Sensor::VirtualImpulseCounter::onInit
void onInit() override
Third method called on element in SuplaDevice.begin().
Definition
virtual_impulse_counter.cpp:38
Supla::Sensor::VirtualImpulseCounter::onLoadState
void onLoadState() override
Second method called on element in SuplaDevice.begin().
Definition
virtual_impulse_counter.cpp:49
Supla::Sensor::VirtualImpulseCounter::iterateAlways
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition
virtual_impulse_counter.cpp:70
Supla::Sensor::VirtualImpulseCounter::handleCalcfgFromServer
int handleCalcfgFromServer(TSD_DeviceCalCfgRequest *request) override
Handles CALCFG requests from server.
Definition
virtual_impulse_counter.cpp:98
Supla::Sensor::VirtualImpulseCounter::onSaveState
void onSaveState() override
Method called periodically during SuplaDevice iteration.
Definition
virtual_impulse_counter.cpp:45
TSD_ChannelConfig
Definition
proto.h:3130
TSD_DeviceCalCfgRequest
Definition
proto.h:2311
Generated by
1.17.0