A rule that triggers based on the difference between the current and the previous measurement.
More...
#include <Rules.hpp>
|
| | StepDifferenceRule (const RuleConfig &cfg) |
| | Constructs a StepDifferenceRule from a configuration object.
|
| |
| std::string | whoAmI () override |
| | Returns the rule type name.
|
| |
| int | evaluate (const std::variant< double, std::string > &v) override |
| | Evaluates the difference between the current sensor value and the previous one.
|
| |
| double | getLastValue () override |
| | Gets the last value stored by the rule, which is used for the step difference calculation.
|
| |
| void | setLastValue (double value) override |
| | Sets the last value stored by the rule, which is used for the step difference calculation.
|
| |
| bool | hasPrevious () const override |
| | Checks if a valid previous measurement exists for the step difference calculation.
|
| |
| virtual int | getConsecutive () const |
| |
| virtual void | setConsecutive (int) |
| |
| 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 step difference value to compare against.
|
| |
| double | last_value = 0.0 |
| | The stored value from the previous measurement.
|
| |
| bool | has_previous = false |
| | Flag indicating if a valid previous measurement exists.
|
| |
|
| 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 triggers based on the difference between the current and the previous measurement.
◆ StepDifferenceRule()
| StepDifferenceRule::StepDifferenceRule |
( |
const RuleConfig & |
cfg | ) |
|
|
inlineexplicit |
Constructs a StepDifferenceRule from a configuration object.
- Parameters
-
| cfg | The configuration containing sensor_id, operator (op), threshold (value), rule_id, and priority. |
◆ evaluate()
| int StepDifferenceRule::evaluate |
( |
const std::variant< double, std::string > & |
v | ) |
|
|
inlineoverridevirtual |
Evaluates the difference between the current sensor value and the previous one.
- Parameters
-
| v | A variant containing either a valid double reading or a string representing an error state. If an error state is received, the internal state (previous value tracking) is reset. |
- Returns
- int 1 if the step difference threshold is overcome, 0 otherwise.
Reimplemented from RuleStrategy.
◆ getLastValue()
| double StepDifferenceRule::getLastValue |
( |
| ) |
|
|
inlineoverridevirtual |
Gets the last value stored by the rule, which is used for the step difference calculation.
Reimplemented from RuleStrategy.
◆ hasPrevious()
| bool StepDifferenceRule::hasPrevious |
( |
| ) |
const |
|
inlineoverridevirtual |
Checks if a valid previous measurement exists for the step difference calculation.
- Returns
- true if a previous measurement is available, false otherwise.
Reimplemented from RuleStrategy.
◆ setLastValue()
| void StepDifferenceRule::setLastValue |
( |
double |
value | ) |
|
|
inlineoverridevirtual |
Sets the last value stored by the rule, which is used for the step difference calculation.
- Parameters
-
| value | The value to be stored as the last measurement. |
Reimplemented from RuleStrategy.
◆ whoAmI()
| std::string StepDifferenceRule::whoAmI |
( |
| ) |
|
|
inlineoverridevirtual |
Returns the rule type name.
- Returns
- The string "StepDifferenceRule".
Implements RuleStrategy.
◆ has_previous
| bool StepDifferenceRule::has_previous = false |
|
private |
Flag indicating if a valid previous measurement exists.
◆ last_value
| double StepDifferenceRule::last_value = 0.0 |
|
private |
The stored value from the previous measurement.
◆ op
| std::string StepDifferenceRule::op |
|
private |
◆ sensor_id
| std::string StepDifferenceRule::sensor_id |
|
private |
The ID of the sensor this rule applies to.
◆ threshold
| double StepDifferenceRule::threshold |
|
private |
The threshold step difference value to compare against.
The documentation for this class was generated from the following file: