Compare two elements based on their text values. More...
#include <indiCompRules.hpp>


Public Types | |
| typedef std::variant< bool, std::string > | boolorerr_t |
| In-band error reporting type. | |
Public Member Functions | |
| elCompTxtRule () | |
| Default c'tor. | |
| virtual bool | value () |
| Get the value of this rule. | |
| void | property1 (pcf::IndiProperty *property) |
| Set the first property pointer. | |
| const pcf::IndiProperty * | property1 () |
| Get the first property pointer. | |
| void | element1 (const std::string &el) |
| Set the first element name. | |
| const std::string & | element1 () |
| Get the first element name. | |
| void | property2 (pcf::IndiProperty *property) |
| Set the second property pointer. | |
| const pcf::IndiProperty * | property2 () |
| Get the second property pointer. | |
| void | element2 (const std::string &el) |
| Set the second element name. | |
| const std::string & | element2 () |
| Get the second element name. | |
| virtual boolorerr_t | valid () |
| Check if this rule is valid. | |
| bool | isError (boolorerr_t rv) |
| Check if returned value indicates an error. | |
| virtual ruleComparison | defaultComparison () const |
| Get the default comparison for this rule type. | |
| void | priority (const rulePriority &p, double delay=-1) |
| Set priority of this rule. | |
| const rulePriority & | priority () |
| Get the rule priority. | |
| void | message (const std::string &m) |
| Set the message. | |
| const std::string & | message (bool settime=false) |
| Get the message. | |
| const timespec & | lastMsg () |
| double | sinceLastMsg () |
| Get the time since the last message. | |
| bool | timeToSend () |
| Check if it's time to send a message. | |
| void | messageDelay (double md) |
| Set the message delay. | |
| double | messageDelay () |
| Get the message delay. | |
| void | messageCount (int mc) |
| Set the message count. | |
| int | messageCount () |
| Get the message count. | |
| int | incMessageCount () |
| Increment the message count. | |
| void | comparison (const ruleComparison &c) |
| Set the comparison for this rule. | |
| const ruleComparison & | comparison () |
| Get the rule comparison. | |
| virtual bool | popRuntimeDiagnostic (std::string &diagnostic) |
| Pop one pending runtime diagnostic, if any. | |
| boolorerr_t | compTxt (const std::string &str1, const std::string &str2) |
| Compare two strings. | |
| boolorerr_t | compSw (const pcf::IndiElement::SwitchStateType &sw1, const pcf::IndiElement::SwitchStateType &sw2) |
| Compare two switches. | |
| boolorerr_t | compNum (const double &num1, const double &num2, const double &tol) |
| Compare two numbers. | |
| boolorerr_t | compBool (const bool &b1, const bool &b2) |
| Compare two booleans. | |
Static Public Attributes | |
| static constexpr char | name [] = "elCompTxt" |
| Name of this rule, used by config system. | |
| static constexpr double | default_info_msg_delay = 0 |
| static constexpr double | default_caution_msg_delay = 60 |
| static constexpr double | default_warning_msg_delay = 30 |
| static constexpr double | default_alert_msg_delay = 5 |
Protected Attributes | |
| int | m_type |
| The property type, from pcf::IndiProperty::Type. | |
| pcf::IndiProperty * | m_property1 { nullptr } |
| Pointer to the first property. | |
| std::string | m_element1 |
| The element name within the first property. | |
| pcf::IndiProperty * | m_property2 { nullptr } |
| Pointer to the second property. | |
| std::string | m_element2 |
| The element name within the second property. | |
| rulePriority | m_priority { rulePriority::none } |
| The reporting priority for this rule. | |
| std::string | m_message |
| The message used for notifications. | |
| timespec | m_lastMsg { 0, 0 } |
| Time the message was last sent. | |
| double | m_messageDelay { 0 } |
| Delay between sending messages. | |
| int | m_messageCount { 0 } |
| Number of times the message has been sent. | |
| ruleComparison | m_comparison { ruleComparison::Eq } |
| The comparison for this rule. | |
Compare two elements based on their text values.
Definition at line 1222 of file indiCompRules.hpp.
|
inherited |
In-band error reporting type.
Definition at line 187 of file indiCompRules.hpp.
|
inline |
Default c'tor.
Definition at line 1229 of file indiCompRules.hpp.
|
inlineinherited |
Get the rule comparison.
Definition at line 387 of file indiCompRules.hpp.
References indiCompRule::m_comparison.
Referenced by multiSwitchComboRule::multiSwitchComboRule(), and ruleCompRule::ruleCompRule().
|
inlineinherited |
Set the comparison for this rule.
| [in] | c | the new comparison |
Definition at line 377 of file indiCompRules.hpp.
References indiCompRule::m_comparison.
Referenced by libXWCTest::stateRuleEngineTest::SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), and libXWCTest::stateRuleEngineTest::SCENARIO().
|
inlineinherited |
Compare two booleans.
| [in] | b1 | the first bool to compare |
| [in] | b2 | the second bool to compare |
Definition at line 533 of file indiCompRules.hpp.
References And, Eq, Imply, indiCompRule::m_comparison, Nand, Neq, Nimply, Nor, and Or.
Referenced by ruleCompRule::value().
|
inlineinherited |
Compare two numbers.
The comparison is (num1 comp num2), e.g. (num1 < num2). A tolerance is included for floating point equality.
| [in] | num1 | the first number to compare |
| [in] | num2 | the second number to compare |
| [in] | tol | the tolerance for the comparison |
Definition at line 483 of file indiCompRules.hpp.
References Eq, Gt, GtEq, Lt, LtEq, indiCompRule::m_comparison, and Neq.
Referenced by numValRule::value(), timeDiffRule::value(), and elCompNumRule::value().
|
inlineinherited |
Compare two switches.
Switch comparison can only be Eq or Neq.
| [in] | sw1 | the first switch to compare |
| [in] | sw2 | the first switch to compare |
Definition at line 452 of file indiCompRules.hpp.
References Eq, indiCompRule::m_comparison, and Neq.
Referenced by swValRule::value(), and elCompSwRule::value().
|
inlineinherited |
Compare two strings.
String comparison can only be Eq or Neq.
| [in] | str1 | the first string to compare |
| [in] | str2 | the second string to compare |
Definition at line 422 of file indiCompRules.hpp.
References Eq, indiCompRule::m_comparison, and Neq.
Referenced by txtValRule::value(), value(), and multiSwitchComboRule::value().
|
inlinevirtualinherited |
Get the default comparison for this rule type.
comp is omitted from configuration Reimplemented in multiSwitchComboRule, and ruleCompRule.
Definition at line 226 of file indiCompRules.hpp.
References Eq.
|
inlineinherited |
Get the first element name.
Definition at line 737 of file indiCompRules.hpp.
References twoPropRule::m_element1.
|
inlineinherited |
Set the first element name.
| [in] | el | the new element name |
Definition at line 728 of file indiCompRules.hpp.
References twoPropRule::m_element1.
Referenced by loadRuleConfig(), libXWCTest::stateRuleEngineTest::SCENARIO(), and SCENARIO().
|
inlineinherited |
Get the second element name.
Definition at line 781 of file indiCompRules.hpp.
References twoPropRule::m_element2.
|
inlineinherited |
Set the second element name.
| [in] | el | the new element name |
Definition at line 772 of file indiCompRules.hpp.
References twoPropRule::m_element2.
Referenced by loadRuleConfig(), libXWCTest::stateRuleEngineTest::SCENARIO(), and SCENARIO().
|
inlineinherited |
Increment the message count.
Definition at line 364 of file indiCompRules.hpp.
References indiCompRule::m_messageCount.
|
inlineinherited |
Check if returned value indicates an error.
| [in] | rv | the return value to check |
Definition at line 190 of file indiCompRules.hpp.
Referenced by loadRuleConfig(), ruleCompRule::valid(), numValRule::value(), txtValRule::value(), swValRule::value(), timeDiffRule::value(), elCompNumRule::value(), value(), elCompSwRule::value(), multiSwitchComboRule::value(), and ruleCompRule::value().
|
inlineinherited |
Definition at line 298 of file indiCompRules.hpp.
References indiCompRule::m_lastMsg.
|
inlineinherited |
Get the message.
Optionally sets the message time to now.
| settime | If true m_lastMsg is set to now |
Definition at line 285 of file indiCompRules.hpp.
References indiCompRule::m_lastMsg, and indiCompRule::m_message.
|
inlineinherited |
Set the message.
| [in] | m | the new message |
Definition at line 276 of file indiCompRules.hpp.
References indiCompRule::m_message.
Referenced by libXWCTest::stateRuleEngineTest::TEST_CASE().
|
inlineinherited |
Get the message count.
Definition at line 371 of file indiCompRules.hpp.
References indiCompRule::m_messageCount.
|
inlineinherited |
Set the message count.
| [in] | mc | the new message count |
Definition at line 358 of file indiCompRules.hpp.
References indiCompRule::m_messageCount.
Referenced by libXWCTest::stateRuleEngineTest::TEST_CASE().
|
inlineinherited |
Get the message delay.
Definition at line 352 of file indiCompRules.hpp.
References indiCompRule::m_messageDelay.
|
inlineinherited |
Set the message delay.
| [in] | md | the new message delay |
Definition at line 346 of file indiCompRules.hpp.
References indiCompRule::m_messageDelay.
|
inlinevirtualinherited |
Pop one pending runtime diagnostic, if any.
| [out] | diagnostic | the next pending diagnostic message |
Reimplemented in multiSwitchComboRule, and ruleCompRule.
Definition at line 409 of file indiCompRules.hpp.
Referenced by ruleCompRule::popRuntimeDiagnostic().
|
inlineinherited |
Get the rule priority.
Definition at line 270 of file indiCompRules.hpp.
References indiCompRule::m_priority.
|
inlineinherited |
Set priority of this rule.
Also sets the message delay, to default for priority if not set.
| [in] | p | the new priority |
| [in] | delay | [opt] the message delay, if < 0 the default is used |
Definition at line 234 of file indiCompRules.hpp.
References alert, caution, indiCompRule::default_alert_msg_delay, indiCompRule::default_caution_msg_delay, indiCompRule::default_info_msg_delay, indiCompRule::default_warning_msg_delay, info, indiCompRule::m_messageDelay, indiCompRule::m_priority, and warning.
Referenced by libXWCTest::stateRuleEngineTest::TEST_CASE().
|
inlineinherited |
Get the first property pointer.
Definition at line 722 of file indiCompRules.hpp.
References twoPropRule::m_property1.
|
inlineinherited |
Set the first property pointer.
| mx::err::invalidarg | if property is nullptr |
| mx::err::invalidconfig | if the supplied property has the wrong type |
| [in] | property | the new property pointer |
Definition at line 703 of file indiCompRules.hpp.
References twoPropRule::m_property1, and twoPropRule::m_type.
Referenced by loadRuleConfig(), libXWCTest::stateRuleEngineTest::SCENARIO(), and SCENARIO().
|
inlineinherited |
Get the second property pointer.
Definition at line 766 of file indiCompRules.hpp.
References twoPropRule::m_property2.
|
inlineinherited |
Set the second property pointer.
| mx::err::invalidarg | if property is nullptr |
| mx::err::invalidconfig | if the supplied property has the wrong type |
| [in] | property | the new property pointer |
Definition at line 747 of file indiCompRules.hpp.
References twoPropRule::m_property2, and twoPropRule::m_type.
Referenced by loadRuleConfig(), libXWCTest::stateRuleEngineTest::SCENARIO(), and SCENARIO().
|
inlineinherited |
Get the time since the last message.
Definition at line 304 of file indiCompRules.hpp.
References indiCompRule::m_lastMsg.
Referenced by indiCompRule::timeToSend().
|
inlineinherited |
Check if it's time to send a message.
If the message delay is <= 0, this is based on message count (i.e. has it been sent). Otherwise it's based on the time since last sent
Definition at line 319 of file indiCompRules.hpp.
References indiCompRule::m_messageCount, indiCompRule::m_messageDelay, and indiCompRule::sinceLastMsg().
|
inlinevirtualinherited |
Check if this rule is valid.
The rule is valid if both property pointers are not null, and the elements are contained within their respective properties.
If not valid, the return value is a std::string with the reason. If valid, the return value is a bool set to true.
Implements indiCompRule.
Definition at line 793 of file indiCompRules.hpp.
References twoPropRule::m_element1, twoPropRule::m_element2, twoPropRule::m_property1, and twoPropRule::m_property2.
Referenced by elCompNumRule::value(), value(), and elCompSwRule::value().
|
inlinevirtual |
Get the value of this rule.
First checks if the rule is currently valid. The performs the comparison and returns the result.
| mx::err::invalidconfig | if the rule is not currently valid |
| mx::err::invalidconfig | on an error from the comparison |
Implements indiCompRule.
Definition at line 1242 of file indiCompRules.hpp.
References indiCompRule::compTxt(), indiCompRule::isError(), twoPropRule::m_element1, twoPropRule::m_element2, twoPropRule::m_property1, twoPropRule::m_property2, and twoPropRule::valid().
Referenced by audibleAlerts.personality.Operation::__str__(), audibleAlerts.personality.Transition::compare(), and SCENARIO().
|
staticconstexprinherited |
Definition at line 198 of file indiCompRules.hpp.
Referenced by indiCompRule::priority().
|
staticconstexprinherited |
Definition at line 196 of file indiCompRules.hpp.
Referenced by indiCompRule::priority().
|
staticconstexprinherited |
Definition at line 195 of file indiCompRules.hpp.
Referenced by indiCompRule::priority().
|
staticconstexprinherited |
Definition at line 197 of file indiCompRules.hpp.
Referenced by indiCompRule::priority().
|
protectedinherited |
The comparison for this rule.
Definition at line 214 of file indiCompRules.hpp.
Referenced by indiCompRule::comparison(), indiCompRule::comparison(), indiCompRule::compBool(), indiCompRule::compNum(), indiCompRule::compSw(), indiCompRule::compTxt(), and multiSwitchComboRule::valid().
|
protectedinherited |
The element name within the first property.
Definition at line 683 of file indiCompRules.hpp.
Referenced by twoPropRule::element1(), twoPropRule::element1(), twoPropRule::valid(), elCompNumRule::value(), value(), and elCompSwRule::value().
|
protectedinherited |
The element name within the second property.
Definition at line 687 of file indiCompRules.hpp.
Referenced by twoPropRule::element2(), twoPropRule::element2(), twoPropRule::valid(), elCompNumRule::value(), value(), and elCompSwRule::value().
|
protectedinherited |
Time the message was last sent.
Definition at line 207 of file indiCompRules.hpp.
Referenced by indiCompRule::lastMsg(), indiCompRule::message(), and indiCompRule::sinceLastMsg().
|
protectedinherited |
The message used for notifications.
Definition at line 205 of file indiCompRules.hpp.
Referenced by indiCompRule::message(), and indiCompRule::message().
|
protectedinherited |
Number of times the message has been sent.
Definition at line 211 of file indiCompRules.hpp.
Referenced by indiCompRule::incMessageCount(), indiCompRule::messageCount(), indiCompRule::messageCount(), and indiCompRule::timeToSend().
|
protectedinherited |
Delay between sending messages.
Definition at line 209 of file indiCompRules.hpp.
Referenced by indiCompRule::messageDelay(), indiCompRule::messageDelay(), indiCompRule::priority(), and indiCompRule::timeToSend().
|
protectedinherited |
The reporting priority for this rule.
Definition at line 202 of file indiCompRules.hpp.
Referenced by indiCompRule::priority(), and indiCompRule::priority().
|
protectedinherited |
Pointer to the first property.
Definition at line 681 of file indiCompRules.hpp.
Referenced by twoPropRule::property1(), twoPropRule::property1(), twoPropRule::valid(), elCompNumRule::value(), value(), and elCompSwRule::value().
|
protectedinherited |
Pointer to the second property.
Definition at line 685 of file indiCompRules.hpp.
Referenced by twoPropRule::property2(), twoPropRule::property2(), twoPropRule::valid(), elCompNumRule::value(), value(), and elCompSwRule::value().
|
protectedinherited |
The property type, from pcf::IndiProperty::Type.
Definition at line 679 of file indiCompRules.hpp.
Referenced by twoPropRule::property1(), and twoPropRule::property2().
|
staticconstexpr |
Name of this rule, used by config system.
Definition at line 1226 of file indiCompRules.hpp.
Referenced by loadRuleConfig().