supla-device
Loading...
Searching...
No Matches
binary_base.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_BINARY_BASE_H_
20#define SRC_SUPLA_SENSOR_BINARY_BASE_H_
21
22#include <supla/channels/binary_sensor_channel.h>
23#include <supla/element_with_channel_actions.h>
24
26
27namespace Supla {
28
29class Io;
30
31namespace Sensor {
32class BinaryBase : public ElementWithChannelActions {
33 public:
34 BinaryBase();
35 virtual ~BinaryBase();
36 virtual bool getValue() = 0;
37 void iterateAlways() override;
38 Channel *getChannel() override;
39 const Channel *getChannel() const override;
40 void onLoadConfig(SuplaDeviceClass *) override;
41 void onRegistered(Supla::Protocol::SuplaSrpc *suplaSrpc) override;
42 uint8_t applyChannelConfig(TSD_ChannelConfig *config,
43 bool local = false) override;
44 void handleChannelConfigFinished() override;
45
46 void setServerInvertLogic(bool invertLogic);
47 void setReadIntervalMs(uint32_t intervalMs);
48 void purgeConfig() override;
49 void fillChannelConfig(void *channelConfig, int *size) override;
50
51 protected:
52 uint32_t lastReadTime = 0;
53 uint32_t readIntervalMs = 100;
54 BinarySensorChannel channel;
55 bool defaultConfigReceived = false;
56};
57
58} // namespace Sensor
59} // namespace Supla
60
61
62#endif // SRC_SUPLA_SENSOR_BINARY_BASE_H_
Definition binary_sensor_channel.h:25
Definition channel.h:33
Definition SuplaDevice.h:93
Definition io.h:33
Definition supla_srpc.h:55
void onRegistered(Supla::Protocol::SuplaSrpc *suplaSrpc) override
Method called each time when device successfully registers to Supla server.
Definition binary_base.cpp:65
void handleChannelConfigFinished() override
Handles "channel config finished" message from server.
Definition binary_base.cpp:147
void purgeConfig() override
Removes all configration data related to the element from Storage::Config.
Definition binary_base.cpp:54
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition binary_base.cpp:121
void onLoadConfig(SuplaDeviceClass *) override
First method called on element in SuplaDevice.begin().
Definition binary_base.cpp:37
Definition proto.h:2912