Difference between revisions of "Extensions.Quantities.RelationalOperations"
Jump to navigation
Jump to search
Line 6: | Line 6: | ||
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;"> | <syntaxhighlight lang="java" enclose="div" style="font-size: medium;"> | ||
/// Local Declarations | /// Local Declarations | ||
− | + | Boolean BooleanVariable = false; | |
/// Flow | /// Flow | ||
− | + | BooleanVariable = QuantityTerm1 ==| !=| >| >=| <| <= QuantityTerm2; | |
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 08:16, 25 October 2018
Contents
Classification
Name | Relational Operations |
Short Description | Compares the numerical quantities |
Class | Operations |
Extension | OTX Quantities extension |
Group | Overloading semantics |
Exceptions | InvalidConversionException |
Checker Rules | - |
Standard Compliant | Yes |
OTL Syntax
/// Local Declarations
Boolean BooleanVariable = false;
/// Flow
BooleanVariable = QuantityTerm1 ==| !=| >| >=| <| <= QuantityTerm2;
Description
- When Quantity values are compared using relational operators, an OTX runtime shall use the quantities' normalized values for comparison. So if e.g. a Quantity of 8 kilometers is to be compared with a Quantity of 10 miles, the runtime system shall convert both values into meters before doing the comparison.
- Furthermore, the physical dimensions of the display unit of the Quantity values being compared shall be identical – e.g. it is allowed to compare distances with each other, but it is illegal to compare a distance to a time – in that case an InvalidConversionException shall be thrown.
- If scalar operands exist, they shall be interpreted as normalized values according to the physical dimension of the Quantity operands. This allows e.g. the comparison of 2 km < 11 which will result in false (because the comparison is equivalent to comparing 2 km < 11m).
Return Value
The Term returns the value, see table below.
![]()
In OTX, Terms are categorized according to its return data type!
Data Type | Description |
Boolean | The result of the comparision of the numerical quantities |
Properties
Name | Data Type | Class | Default | Cardinality | Description |
QuantityTerm1 | Quantity | Term | - | [1] | NumericQuantity operand to be compared |
QuantityTerm2 | Quantity | Term | - | [1] | NumericQuantity operand to be compared |
OTL Examples
Boolean Boolean1 = false;
/// Flow
Boolean1 = 8 [@Unit, "BL_DataLibraMIB.odx", "km"] != 10 [@Unit, "BL_DataLibraMIB.odx", "mile"];
See also
Addition
Subtraction
Multiplication
Division
Modulo
Absolute Value
Negation