Difference between revisions of "Extensions.Quantities.Quantity"
Jump to navigation
Jump to search
(6 intermediate revisions by 2 users not shown) | |||
Line 7: | Line 7: | ||
==Literal== | ==Literal== | ||
− | The syntax for [[Literals| Literals for complex data types]] | + | The syntax for [[Literals| Literals for complex data types]] will be used, a '''QuantityLiteral''' is the code representation of a value of type NumericQuantity. |
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;"> | <syntaxhighlight lang="java" enclose="div" style="font-size: medium;"> | ||
Line 14: | Line 14: | ||
{{ConversionTable | | {{ConversionTable | | ||
− | Integer=Returns the value of Quantity in integer value, float value | + | Integer=Returns the value of Quantity in integer value, float value will be truncated | IntegerSample=<tt>Integer val = ToInteger(5.5 [@Unit, "BL_DataLibraMIB.odx", "km", 0]); // Returns 5</tt> | |
− | Float=Returns the value of Quantity in float value | FloatSample=<tt>Float val = ToFloat( | + | Float=Returns the value of Quantity in float value | FloatSample=<tt>Float val = ToFloat(5.5 [@Unit, "BL_DataLibraMIB.odx", "km", 0]); // Returns 5.5</tt> | |
− | String=Returns the value of Quantity in string value | StringSample=<tt>String s = ToString( | + | String=Returns the value of Quantity in string value | StringSample=<tt>String s = ToString(5.5 [@Unit, "BL_DataLibraMIB.odx", "km", 0]); // Returns "5.5"</tt> |
}} | }} | ||
==Sample== | ==Sample== | ||
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;"> | <syntaxhighlight lang="java" enclose="div" style="font-size: medium;"> | ||
− | Quantity | + | Quantities.Quantity QuantityVariable = 5 [@Unit, "BL_DataLibraMIB.odx", "km/h", 0]; |
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | == See also == | ||
+ | [[Extensions.Quantities.Conversions|Conversions]] |
Latest revision as of 03:15, 13 September 2019
Classification
Name | Quantity |
Short Description | A numeral value which has a display unit associated with it. |
Class | Simple Data Type |
Base Data Type | SimpleType |
Default Value | A Quantity with a base value of 0.0 and a dimensionless unit. |
Provide a Literal | Yes |
SpecifiedBy | ISO 13209-3 |
Standard Compliant | Yes |
Description
A Quantity represents anumeral value which has a display unit associated with it. For instance, the value "5" is described more specifically by a Quantity that also contains information about the unit of the value, e.g. "5 km/h".
Literal
The syntax for Literals for complex data types will be used, a QuantityLiteral is the code representation of a value of type NumericQuantity.
Value = Literal
Core Conversion
The following table shows the rules for conversion to another data type:
Conversion | Result | Sample |
ToBoolean | Undefined (should not be used) | |
ToInteger | Returns the value of Quantity in integer value, float value will be truncated | Integer val = ToInteger(5.5 [@Unit, "BL_DataLibraMIB.odx", "km", 0]); // Returns 5 |
ToFloat | Returns the value of Quantity in float value | Float val = ToFloat(5.5 [@Unit, "BL_DataLibraMIB.odx", "km", 0]); // Returns 5.5 |
ToString | Returns the value of Quantity in string value | String s = ToString(5.5 [@Unit, "BL_DataLibraMIB.odx", "km", 0]); // Returns "5.5" |
ToByteField | Undefined (should not be used) |
Sample
Quantities.Quantity QuantityVariable = 5 [@Unit, "BL_DataLibraMIB.odx", "km/h", 0];