supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
condition.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
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
*/
16
17
#ifndef SRC_SUPLA_CONDITION_H_
18
#define SRC_SUPLA_CONDITION_H_
19
20
#include "action_handler.h"
21
#include "condition_getter.h"
22
23
namespace
Supla {
24
25
class
ElementWithChannelActions
;
26
27
class
Condition :
public
ActionHandler
{
28
public
:
29
Condition(
double
threshold,
bool
useAlternativeValue);
30
Condition(
double
threshold,
ConditionGetter
*getter);
31
32
virtual
~Condition();
33
void
setSource(
ElementWithChannelActions
*src);
34
void
setClient(
ActionHandler
*clientPtr);
35
void
setSource(
ElementWithChannelActions
&src);
// NOLINT(runtime/references)
36
void
setClient(
ActionHandler
&clientPtr);
// NOLINT(runtime/references)
37
38
void
activateAction(
int
action)
override
;
39
void
handleAction(
int
event,
int
action)
override
;
40
bool
deleteClient()
override
;
41
ActionHandler
*getRealClient()
override
;
42
43
virtual
bool
checkConditionFor(
double
val,
bool
isValid =
true
);
44
45
void
setThreshold(
double
val);
46
47
protected
:
48
virtual
bool
condition(
double
val,
bool
isValid =
true
) = 0;
49
50
double
threshold = 0;
51
bool
useAlternativeValue =
false
;
52
bool
alreadyFired =
false
;
53
Supla::ElementWithChannelActions
*source =
nullptr
;
54
Supla::ActionHandler
*client =
nullptr
;
55
Supla::ConditionGetter
*getter =
nullptr
;
56
};
57
58
};
// namespace Supla
59
60
Supla::Condition
*OnLess(
double
threshold,
61
bool
useAlternativeValue =
false
);
62
Supla::Condition
*OnLessEq(
double
threshold,
63
bool
useAlternativeValue =
false
);
64
Supla::Condition
*OnGreater(
double
threshold,
65
bool
useAlternativeValue =
false
);
66
Supla::Condition
*OnGreaterEq(
double
threshold,
67
bool
useAlternativeValue =
false
);
68
Supla::Condition
*OnBetween(
double
threshold1,
69
double
threshold2,
70
bool
useAlternativeValue =
false
);
71
Supla::Condition
*OnBetweenEq(
double
threshold1,
72
double
threshold2,
73
bool
useAlternativeValue =
false
);
74
Supla::Condition
*OnEqual(
double
threshold,
75
bool
useAlternativeValue =
false
);
76
Supla::Condition
*OnInvalid(
bool
useAlternativeValue =
false
);
77
78
Supla::Condition
*OnLess(
double
threshold,
Supla::ConditionGetter
*);
79
Supla::Condition
*OnLessEq(
double
threshold,
Supla::ConditionGetter
*);
80
Supla::Condition
*OnGreater(
double
threshold,
Supla::ConditionGetter
*);
81
Supla::Condition
*OnGreaterEq(
double
threshold,
Supla::ConditionGetter
*);
82
Supla::Condition
*OnBetween(
double
threshold1,
83
double
threshold2,
84
Supla::ConditionGetter
*);
85
Supla::Condition
*OnBetweenEq(
double
threshold1,
86
double
threshold2,
87
Supla::ConditionGetter
*);
88
Supla::Condition
*OnEqual(
double
threshold,
Supla::ConditionGetter
*);
89
Supla::Condition
*OnInvalid(
Supla::ConditionGetter
*);
90
91
#endif
// SRC_SUPLA_CONDITION_H_
Supla::ActionHandler
Definition
action_handler.h:21
Supla::ConditionGetter
Definition
condition_getter.h:27
Supla::Condition
Definition
condition.h:27
Supla::ElementWithChannelActions
Definition
element_with_channel_actions.h:81
Generated by
1.17.0