NRC_ConditionJudge
条件判断类
class NRC_ConditionJudge
{
public:
/**
* @brief 变量类型
*/
enum VarType
{
CONST_, ///<常量
BOOL_, ///<布尔型
INT_, ///<整型
DOUBLE_, ///<浮点型
DIN_ ///<IO输入端口
};
/**
* @brief 判断类型
*/
enum LogicType
{
EQUAL_TO, ///<等于
LESS, ///<小于
GREATER, ///<大于
LESS_EQUAL, ///<小于等于
GREATER_EQUAL, ///<大于等于
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;
};
示例代码
//INT变量003小于DOUBLE变量005
NRC_ConditionJudge(NRC_ConditionJudge::INT_, 3, NRC_ConditionJudge::LESS, NRC_ConditionJudge::DOUBLE_, 5);
//IO输入端口2等于常量1
NRC_ConditionJudge(NRC_ConditionJudge::DIN_, 2, NRC_ConditionJudge::EQUAL_TO, NRC_ConditionJudge::CONST_, 1);