A straightforward rule that compares a single sensor measurement against a threshold.
More...
#include <Rules.hpp>
|
| | SimpleRule (const RuleConfig &cfg) |
| | Constructs a SimpleRule 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 sensor value against the configured threshold.
|
| |
| virtual int | getConsecutive () const |
| |
| virtual double | getLastValue () |
| |
| virtual void | setConsecutive (int) |
| |
| 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 (e.g., ">", "<", "==").
|
| |
| double | threshold |
| | The threshold value to compare against.
|
| |
|
| 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 straightforward rule that compares a single sensor measurement against a threshold.
◆ SimpleRule()
Constructs a SimpleRule from a configuration object.
- Parameters
-
| cfg | The configuration containing sensor_id, operator (op), threshold (value), rule_id, and priority. |
◆ evaluate()
| int SimpleRule::evaluate |
( |
const std::variant< double, std::string > & |
v | ) |
|
|
inlineoverridevirtual |
Evaluates the sensor value against the configured threshold.
- Parameters
-
| v | A variant containing either a valid double reading or a string representing an error state ("E"). |
- Returns
- int 1 if the rule condition is triggered, 0 otherwise (including error cases).
Reimplemented from RuleStrategy.
◆ whoAmI()
| std::string SimpleRule::whoAmI |
( |
| ) |
|
|
inlineoverridevirtual |
Returns the rule type name.
- Returns
- The string "SimpleRule".
Implements RuleStrategy.
◆ op
| std::string SimpleRule::op |
|
private |
The comparison operator (e.g., ">", "<", "==").
◆ sensor_id
| std::string SimpleRule::sensor_id |
|
private |
The ID of the sensor this rule applies to.
◆ threshold
| double SimpleRule::threshold |
|
private |
The threshold value to compare against.
The documentation for this class was generated from the following file: