Difference between revisions of "Extensions.Quantities.RelationalOperations"

From emotive
Jump to navigation Jump to search
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:'''Comparison'''}}[[Category:Quantities]]
+
{{DISPLAYTITLE:'''Relational Operations'''}}[[Category:Quantities]]
 
== Classification ==
 
== Classification ==
{{ClassificationActivity | Comparison| Sum of all numerical quantities | [[Operations]] | [[Extensions.Quantities|OTX Quantities extension]] | [[Extensions.Quantities#Terms|Overloading semantics]] | [[Extensions.Quantities.InvalidConversionException|InvalidConversionException]] | - }}
+
{{ClassificationActivity | Relational Operations| Compares the numerical quantities | [[Operations]] | [[Extensions.Quantities|OTX Quantities extension]] | [[Extensions.Quantities#Terms|Overloading semantics]] | [[Extensions.Quantities.InvalidConversionException|InvalidConversionException]] | - }}
  
 
== OTL Syntax ==
 
== OTL Syntax ==
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
QuantityTerm = QuantityTerm1 ==/!=/>/>=/</<= QuantityTerm2;
+
BooleanValue = QuantityTerm == NumericTerm;
 +
BooleanValue = QuantityTerm != NumericTerm;
 +
BooleanValue = QuantityTerm > NumericTerm;
 +
BooleanValue = QuantityTerm >= NumericTerm;
 +
BooleanValue = QuantityTerm < NumericTerm;
 +
BooleanValue = QuantityTerm <= NumericTerm;
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== Description ==
 
== Description ==
This is a term which, as a result the sum of all numerical quantities (NumericQuantity returns) with respect to their units.  
+
* 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.
  
* When '''Quantity''' values are added, the physical dimensions of the display unit of all '''Quantity''' operands shall be identical.
+
* 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 addition of 2 km + 1 m + 11 which will result in a '''Quantity''' of 2012 m.  
+
* 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).
  
* The display unit of the resulting '''Quantity''' should be set to the SI base unit corresponding to the '''Quantity''''s physical dimension. Furthermore, the display precision of the resulting '''Quantity''' shall be the maximum of the display precisions of the operands.
+
{{TermReturnValue| [[Core.DataTypes.SimpleDataType.Boolean|Boolean]] | The result of the comparision of the numerical quantities}}
 
 
{{TermReturnValue| [[Extensions.Quantities.Quantity|Quantity]] | Sum of all numerical quantities}}
 
  
 
== Properties ==
 
== Properties ==
 
{| {{TableHeader}}
 
{| {{TableHeader}}
 
{{TableRowPropertiesHeader}}
 
{{TableRowPropertiesHeader}}
{{TableRowPropertie1| QuantityTerm1 | [[Extensions.Quantities.Quantity|Quantity]] | [[Term]] | - | [1] | NumericQuantity operand to be summed}}
+
{{TableRowPropertie1| QuantityTerm | [[Extensions.Quantities.Quantity|Quantity]] | [[Term]] | - | [1] | Quantity value are compared}}
{{TableRowPropertie2| QuantityTerm2 | [[Extensions.Quantities.Quantity|Quantity]]| [[Term]] | - | [1] | NumericQuantity operand to be summed}}
+
{{TableRowPropertie2| NumericTerm | [[Numeric]]| [[Term]] | - | [1] | Numeric value are compared}}
 
|}
 
|}
  
 
== OTL Examples ==
 
== OTL Examples ==
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
Quantities.Quantity Quantity;
+
/// Local Declarations
 +
 
 +
Boolean Boolean1 = false;
  
 
/// Flow
 
/// Flow
  
Quantity = (2 [@Unit, "BL_DataLibraMIB.odx", "km"] + 1 [@Unit, "BL_DataLibraMIB.odx", "m"]) + 11;
+
Boolean1 = 8 [@Unit, "BL_DataLibraMIB.odx", "km"] != 10 [@Unit, "BL_DataLibraMIB.odx", "mile"];
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Latest revision as of 06:38, 24 June 2019

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

BooleanValue = QuantityTerm == NumericTerm;
BooleanValue = QuantityTerm != NumericTerm;
BooleanValue = QuantityTerm > NumericTerm;
BooleanValue = QuantityTerm >= NumericTerm;
BooleanValue = QuantityTerm < NumericTerm;
BooleanValue = QuantityTerm <= NumericTerm;

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.

Icons Note.png 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
QuantityTerm Quantity Term - [1] Quantity value are compared
NumericTerm Numeric Term - [1] Numeric value are compared

OTL Examples

/// Local Declarations

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