Welcome to oac-tree-plugin-mathexpr's documentation!
=====================================================
.. toctree::
:maxdepth: 2
:caption: Contents:
`oac-tree-plugin-mathexpr` is a oac-tree plugin that provides functionality for processing mathematical expressions using the exprtk library.
Functionalities
---------------
oac-tree-plugin-mathexpr provides the following functionalities for processing mathematical expressions:
1. Supports variables of any numeric type supported by AnyValue
2. Supports arrays and scalars as variables
3. Automatically converts variables to doubles before processing the expression
4. Automatically converts the result back to the input type after processing the expression
Usage
-----
To use this plugin it needs to be compiled and installed in the system. The following line has to be added to the xml:
.. code-block:: xml
liboac-tree-mathexpr.so
The most basic use for this plugin is to assign a mathematical expression to a variable:
.. code-block:: xml
In this example the output of 'x+y-1' is saved in the variable "z". In assignments, the type of the output is always respected, so if in the example above the result of the expression is negative or above the maximum value possible for an uint8, the oac-tree will return an executionstatus of failure.
Expressions without assignments are evaluated as a boolean and cause the instruction to return an executionstatus of success or failure accordingly.
For example:
.. code-block:: xml
In this example, the instruction will succeed, since 'x' is bigger than 'y+2'.
Arrays can also be used:
.. code-block:: xml
Multiple assignments, even if chained, can be done in a single call:
.. code-block:: xml
An expression can be passed from a string variable:
.. code-block:: xml
.. warning::
All oac-tree plugins use an XML parser to process input functions. Please note that certain characters in your XML definitions may need to be escaped in order to avoid errors. These include:
- & (ampersand) - use &
- < (less than) - use <
- > (greater than) - use >
- " (double quotation mark) - use "
- ' (apostrophe) - use '
From the above referenced characters, the greater than (>) character works as expected, but the less than (<) causes failures. To be sure no errors related to parsing this characters it is better to escape all of them.