Skip to main content

NRC_ConditionJudge

Condition judgment class

class NRC_ConditionJudge
{
public:
/**
* @brief Variable type
*/
enum VarType
{
CONST_, ///<Constant
BOOL_, ///<Boolean
INT_, ///<Integer
DOUBLE_, ///<Double
DIN_ ///<IO input port
};
/**
* @brief Judgment type
*/
enum LogicType
{
EQUAL_TO, ///<equal to
LESS, ///<less than
GREATER, ///<greater than
LESS_EQUAL, ///<less than or equal to
GREATER_EQUAL, ///<greater than or equal to
NOT_EQUAL_TO ///<not equal to
};
NRC_ConditionJudge() :
firstType(INT_), firstNum(1), judgeType(EQUAL_TO), secondType(CONST_), secondNum(0)
{
}
NRC_ConditionJudge(VarType firstType, int firstNum, LogicType judgeType, VarType secondType, int secondNum) :
firstType(firstType), firstNum(firstNum), judgeType(judgeType), secondType(secondType), secondNum(secondNum)
{
}
VarType firstType;
int firstNum;
LogicType judgeType;
VarType secondType;
int secondNum;
};

Sample code

//The INT variable 003 is less than the DOUBLE variable 005
NRC_ConditionJudge(NRC_ConditionJudge::INT_, 3, NRC_ConditionJudge::LESS, NRC_ConditionJudge::DOUBLE_, 5);
//The IO input port 2 is equal to constant 1
NRC_ConditionJudge(NRC_ConditionJudge::DIN_, 2, NRC_ConditionJudge::EQUAL_TO, NRC_ConditionJudge::CONST_, 1);