A rule that requires a condition to be met for a specified number of consecutive measurements.
More...
#include <Rules.hpp>
|
| | StatefulRule (const RuleConfig &cfg) |
| | Constructs a StatefulRule from a configuration object.
|
| |
| std::string | whoAmI () override |
| | Returns the rule type name.
|
| |
| int | getConsecutive () const override |
| | Gets the number of consecutive measurements required for the rule to trigger.
|
| |
| void | setConsecutive (int value) override |
| | Sets the number of consecutive measurements required for the rule to trigger.
|
| |
| int | evaluate (const std::variant< double, std::string > &v) override |
| | Evaluates the sensor value and updates the consecutive match counter.
|
| |
| virtual double | getLastValue () |
| |
| virtual void | setLastValue (double) |
| |
| virtual bool | hasPrevious () const |
| |
| virtual int | evaluate (const ResultMap &results) |
| | Evaluates correlation rules based on the results of other primary rules.
|
| |
| virtual | ~RuleStrategy ()=default |
| | Virtual destructor for safe polymorphic deletion.
|
| |
| const std::string & | id () const |
| | Gets the unique identifier of the rule.
|
| |
| const std::string & | priority () const |
| | Gets the priority level of the rule.
|
| |
|
| std::string | sensor_id |
| | The ID of the sensor this rule applies to.
|
| |
| std::string | op |
| | The comparison operator.
|
| |
| double | threshold |
| | The threshold value to compare against.
|
| |
| int | consecutive |
| | The target number of consecutive condition matches required.
|
| |
| int | current_consecutive = 0 |
| | The current sequence length of consecutive matches.
|
| |
|
| static bool | compare (double left, double right, const std::string &op) |
| | A static helper function to perform logical comparisons.
|
| |
| std::string | rule_id |
| | The unique identifier for this rule instance.
|
| |
| std::string | rule_priority |
| | The execution priority of this rule.
|
| |
A rule that requires a condition to be met for a specified number of consecutive measurements.
◆ StatefulRule()
| StatefulRule::StatefulRule |
( |
const RuleConfig & |
cfg | ) |
|
|
inlineexplicit |
Constructs a StatefulRule from a configuration object.
- Parameters
-
| cfg | The configuration containing consecutive_measurements along with standard rule parameters. |
◆ evaluate()
| int StatefulRule::evaluate |
( |
const std::variant< double, std::string > & |
v | ) |
|
|
inlineoverridevirtual |
Evaluates the sensor value and updates the consecutive match counter.
- Parameters
-
| v | A variant containing either a valid double reading or a string representing an error state. |
- Returns
- int 1 if the consecutive count reaches the threshold, 0 otherwise.
Reimplemented from RuleStrategy.
◆ getConsecutive()
| int StatefulRule::getConsecutive |
( |
| ) |
const |
|
inlineoverridevirtual |
Gets the number of consecutive measurements required for the rule to trigger.
Reimplemented from RuleStrategy.
◆ setConsecutive()
| void StatefulRule::setConsecutive |
( |
int |
value | ) |
|
|
inlineoverridevirtual |
Sets the number of consecutive measurements required for the rule to trigger.
- Parameters
-
| value | The number of consecutive measurements to be set. |
Reimplemented from RuleStrategy.
◆ whoAmI()
| std::string StatefulRule::whoAmI |
( |
| ) |
|
|
inlineoverridevirtual |
Returns the rule type name.
- Returns
- The string "StatefulRule".
Implements RuleStrategy.
◆ consecutive
| int StatefulRule::consecutive |
|
private |
The target number of consecutive condition matches required.
◆ current_consecutive
| int StatefulRule::current_consecutive = 0 |
|
private |
The current sequence length of consecutive matches.
◆ op
| std::string StatefulRule::op |
|
private |
◆ sensor_id
| std::string StatefulRule::sensor_id |
|
private |
The ID of the sensor this rule applies to.
◆ threshold
| double StatefulRule::threshold |
|
private |
The threshold value to compare against.
The documentation for this class was generated from the following file: