UOM.Convert Method
- Last UpdatedNov 18, 2025
- 3 minute read
- PI System
- AF SDK 2024 R2
- Developer
Namespace: OSIsoft.AF.UnitsOfMeasure
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public double Convert( Object fromValue, UOM fromUOM )
Public Function Convert ( fromValue As Object, fromUOM As UOM ) As Double Dim instance As UOM Dim fromValue As Object Dim fromUOM As UOM Dim returnValue As Double returnValue = instance.Convert(fromValue, fromUOM)
public: double Convert( Object^ fromValue, UOM^ fromUOM )
member Convert : fromValue : Object * fromUOM : UOM -> float
Parameters
- fromValue
- Type: SystemObject
The value to be converted. Normally, this is sent as a double. - fromUOM
- Type: OSIsoft.AF.UnitsOfMeasureUOM
The unit of measure of the specified value. If this is not specified, or is specified, then the unit of measure should be specified in the fromValue by passing it as a string.
Return Value
Type: DoubleReturns the value converted to this unit of measure.
Exceptions
| Exception | Condition |
|---|---|
| InvalidCastException | Thrown when the conversion cannot be performed. |
Remarks
The UOM class for the specified parameter must match the class for this UOM. If the two UOMs share the same reference object, or are a direct reference to each other, then the conversion is done directly using these reference units. This allows fewer mathematical operations and reduces the loss of precision during conversion. Otherwise, the canonical unit-of-measure factors are used to convert.
Optionally, you can specify for the fromUOM parameter and specify the units in the input parameter if it is represented in string notation. For example, "100.0 ft". In this case, the Convert function looks up the UOM from the text name or abbreviation that follows the floating point number.