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 {
36class VirtualBinary : public BinaryBase, public ActionHandler {
37 public:
38 explicit VirtualBinary(bool keepStateInStorage = false);
39 bool getValue() override;
40 void onInit() override;
41 void iterateAlways() override;
42 void handleAction(int event, int action) override;
43 void onLoadState() override;
44 void onSaveState() override;
45
47 void set();
49 void clear();
51 void toggle();
59 void setUseConfiguredTimeout(bool useConfiguredTimeout);
60
67 void setKeepStateInStorage(bool);
68
69 protected:
70 void setLogicalState(bool logicalState, bool fromTimeout = false);
71
72 bool state = false;
73 bool keepStateInStorage = false;
74 uint32_t stateChangeTimeMs = 0;
75 bool clearedByTimeout = false;
76 bool useConfiguredTimeout = true;
77};
78
79}; // namespace Sensor
80}; // namespace Supla
81
82#endif // SRC_SUPLA_SENSOR_VIRTUAL_BINARY_H_
Definition action_handler.h:21
void set()
Sets the logical state to ON.
Definition virtual_binary.cpp:94
void setUseConfiguredTimeout(bool useConfiguredTimeout)
Enables or disables timeout auto-application from the configured channel timeout value.
Definition virtual_binary.cpp:34
void clear()
Sets the logical state to OFF.
Definition virtual_binary.cpp:100
void onSaveState() override
Method called periodically during SuplaDevice iteration.
Definition virtual_binary.cpp:61
void toggle()
Toggles the logical state.
Definition virtual_binary.cpp:106
void setKeepStateInStorage(bool)
Configures whether the logical state should be persisted in storage.
Definition virtual_binary.cpp:30
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition virtual_binary.cpp:48
void onLoadState() override
Second method called on element in SuplaDevice.begin().
Definition virtual_binary.cpp:67
void onInit() override
Third method called on element in SuplaDevice.begin().
Definition virtual_binary.cpp:42