UtilConvertUnits Method

Convert from one set of speed / temperature / pressure rain rate units to another

Definition

Namespace: ASCOM.Utilities
Assembly: ASCOM.Utilities (in ASCOM.Utilities.dll) Version: 7.1.3+4851.c5da65c2b
C#
public double ConvertUnits(
	double InputValue,
	Units FromUnits,
	Units ToUnits
)

Parameters

InputValue  Double
Value to convert
FromUnits  Units
Integer value from the Units enum indicating the value's current units
ToUnits  Units
Integer value from the Units enum indicating the units to which the input value should be converted

Return Value

Double
Input value expressed in the new units

Remarks

Conversions available:

  • metres per second <==> miles per hour <==> knots
  • Celsius <==> Fahrenheit <==> Kelvin
  • hecto Pascals (hPa) <==> milli bar(mbar) <==> mm of mercury <==> inches of mercury
  • mm per hour <==> inches per hour

Knots conversions use the international nautical mile definition (1 nautical mile = 1852m) rather than the original UK or US Admiralty definitions.

For convenience, milli bar and hecto Pascals are shown as separate units even though they have numerically identical values and there is a 1:1 conversion between them.

Exceptions

InvalidValueExceptionWhen the specified from and to units can not refer to the same value. e.g. attempting to convert miles per hour to degrees Celsius

See Also