Evaluate Class


A mathematical expression evaluation operator. More...

Header: #include <Evaluate>
Inherits: ArgumentableOperator<T>

Public Functions

Evaluate(const CDPPropertyBase &in)

Reimplemented Public Functions

virtual void Configure(XMLPrimitive *operatorXML) override
virtual void Create(const char *shortName, CDPBaseObject *pParent) override
virtual void FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const override
virtual std::string GetNodeTypeName() const override
virtual unsigned int Process() override

Additional Inherited Members

Detailed Description

A mathematical expression evaluation operator.

This CDP operator can be used to modify signal based on complex mathematical expressions with unlimited number of arguments.


ExpressionMathematical expression to evaluate. 13 mathematical operators, ternary operator and 25 different functions are supported.


Unlimited number of arguments with any name except "Input"Arguments to use in calculation. Parameter with name "Input" is reserved and can be used to include in expression with signal value before evaluation.

Evaluate operator arguments can be routed from another signal, parameter or property.

The power of the Evaluate operator

The Evaluate operator is a very powerful and flexible operator that can be used to do complex signal arithmetic without any C++ programming. Just add the named arguments to the Evaluate operator (values to the arguments can be routed from signals, properties or parameters) and specify the mathematical expression to calculate the output value. In every processing cycle this evaluation expression (that can refer to any of the named arguments in any combination) is used, and output value is calculated based on that.

Just to illustrate the power of Evaluate operator, below are examples how it can be used instead of many other, specialized CDP operators:

CDP operatorEvaluate operator Expression that can be used instead
AddOperatorInput + Argument1 + Argument2 + Argument3
SubOperatorInput - Argument1 - Argument2 + Argument3
MulOperatorInput * Argument1 * Argument2 * Argument3
DivOperatorInput / Argument1 / Argument2 / Argument3
ForceOperatorForceActive ? ForceValue : Input
InputSelectorOperator(Input > RangeMin && Input < RangeMax) ? InputA : InputB
InvertOperator<bool>Input == 0 ? 1 : 0
MinMaxLimitermax(min(Input, Max), Min)
Input > Max ? Max : ( Input < Min ? Min : Input )
NormalPositionOperator<bool>NormalPosition==0 ? Input : (Input==0 ? 1 : 0)

Note: The power and flexibility of the Evaluate operator does not come without cost. The Evaluate operator requires much more computing power than other specialized operators. Consider using specialized operators instead of the Evaluate operator if your system CPU power is very limited. Or alternatively, you can create your own custom operator (via Library->Add New Operator wizard) and program needed functionality in C++.


Below is an example plot with Sine signal (cyan) and the same signal with Evaluate operator with property parameters:

Evaluate ExpressionInput >A ? Input + 0.2 : (Input - 0.1) ^ B

Mathematical operators supported by Evaluate

&&logical and1
||logical or2
<=less or equal4
>=greater or equal4
!=not equal4
<less than4
>greater than4
^raise x to the power of y7

Ternary Operator

Evaluate supports the "if then else" operator. It uses lazy evaluation in order to make sure only the necessary branch of the expression is evaluated.

?:if then else operatorC++ style syntax

Mathematical functions supported by Evaluate

Function# of argumentsExplanation
sin1sine function
cos1cosine function
tan1tangens function
asin1arcus sine function
acos1arcus cosine function
atan1arcus tangens function
sinh1hyperbolic sine function
cosh1hyperbolic cosine
tanh1hyperbolic tangens function
asinh1hyperbolic arcus sine function
acosh1hyperbolic arcus tangens function
atanh1hyperbolic arcus tangens function
log21logarithm to the base 2
log101logarithm to the base 10
log1logarithm to base e (2.71828...)
ln1logarithm to base e (2.71828...)
exp1e raised to the power of x
sqrt1square root of a value
sign1sign function -1 if < 0; 1 if > 0
rint1round to nearest integer
abs1absolute value
minunlimitedmin of all arguments
maxunlimitedmax of all arguments
sumunlimitedsum of all arguments
avgunlimitedmean value of all arguments

See also Argument.

Member Function Documentation

Evaluate::Evaluate(const CDPPropertyBase &in)

Constructs a Evaluate with input in.

[override virtual] void Evaluate::Configure(XMLPrimitive *operatorXML)

Reimplemented from CDPBaseObject::Configure().

Configure arguments and then create muParser variable array based on them and also "Input" variable Do this once in Configure() instead of Process() for speed (as argument count and names can not change at runtime).

[override virtual] void Evaluate::Create(const char *shortName, CDPBaseObject *pParent)

Reimplemented from CDPBaseObject::Create().

[override virtual] void Evaluate::FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const

Reimplemented from CDPNode::FillNodeChildren().

[override virtual] std::string Evaluate::GetNodeTypeName() const

Reimplemented from CDPNode::GetNodeTypeName().

[override virtual] unsigned int Evaluate::Process()

Reimplemented from CDPOperatorBase::Process().

Value "Input" variable and all arguments, expression string and then let muParser calculate the output value. Also catch muParser evaluation errors and in error set signal status to STATUS_SIGNAL_FAULT. In successful evaluation returns STATUS_OK.