supla-device
Loading...
Searching...
No Matches
virtual_binary.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_BINARY_H_
20#define SRC_SUPLA_SENSOR_VIRTUAL_BINARY_H_
21
22#include <supla/sensor/binary_base.h>
23
24#include "../action_handler.h"
25
26namespace Supla {
27namespace Sensor {
28class VirtualBinary : public BinaryBase, public ActionHandler {
29 public:
30 explicit VirtualBinary(bool keepStateInStorage = false);
31 bool getValue() override;
32 void onInit() override;
33 void handleAction(int event, int action) override;
34 void onLoadState() override;
35 void onSaveState() override;
36
37 void set();
38 void clear();
39 void toggle();
40
41 // Configure keep state in storage only before SuplaDevice.begin() and
42 // don't change it later. If it will be changed later it will break
43 // whole storage state
44 void setKeepStateInStorage(bool);
45
46 protected:
47 bool state = false;
48 bool keepStateInStorage = false;
49};
50
51}; // namespace Sensor
52}; // namespace Supla
53
54#endif // SRC_SUPLA_SENSOR_VIRTUAL_BINARY_H_
Definition action_handler.h:21
void onSaveState() override
Method called periodically during SuplaDevice iteration.
Definition virtual_binary.cpp:41
void onLoadState() override
Second method called on element in SuplaDevice.begin().
Definition virtual_binary.cpp:47
void onInit() override
Third method called on element in SuplaDevice.begin()
Definition virtual_binary.cpp:37