Class MeasuringUnit
Represents a measuring unit such as meter, millimeter, m/s, rad/s2. A unit belongs to a quantity. For example meter and millimeter belongs to the quantity length, and m/s belongs to the quantity velocity.
Namespace: ABB.Robotics.RobotStudio
Assembly: ABB.Robotics.RobotStudio.dll
Syntax
public sealed class MeasuringUnit
Constructors
View SourceMeasuringUnit(string, int, double, double, int, int)
Initializes a new instance of the MeasuringUnit class.
Declaration
public MeasuringUnit(string name, int identifier, double factorSI, double offsetSI, int displayDecimals, int editDecimals)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| int | identifier | |
| double | factorSI | |
| double | offsetSI | |
| int | displayDecimals | |
| int | editDecimals |
Properties
View SourceBuiltIn
Gets a value indicating whether the MeasuringUnit is built in. A builtin measuringunit cannot be removed from a Quantity.
Declaration
public bool BuiltIn { get; }
Property Value
| Type | Description |
|---|---|
| bool | The identifier of the measuring unit. |
Remarks
The identifier is unique within the quantity and maps to the unit enumerations of the Quantity class.
DisplayDecimals
Gets or sets the number of decimals to display when a numeric value of the measuring unit shall be displayed as text in a user interface.
Declaration
public int DisplayDecimals { get; set; }
Property Value
| Type | Description |
|---|---|
| int | The number of decimals to display when a numeric value of the measuring unit shall be displayed as text in a user interface. |
DisplayName
Gets the display name of the measuring unit. This name is localized and depends on current locale.
Declaration
public string DisplayName { get; }
Property Value
| Type | Description |
|---|---|
| string | The display name of the measuring unit. |
EditDecimals
Gets or sets the number of decimals to display when a numeric value of the measuring unit is edited.
Declaration
public int EditDecimals { get; set; }
Property Value
| Type | Description |
|---|---|
| int | The number of decimals to display when a numeric value of the measuring unit is edited. |
Name
Gets the name of the measuring unit.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string | The name of the measuring unit. |
ShowUnit
Returns true if the unit's DisplayName shall be shown together with values.
Declaration
public bool ShowUnit { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
View SourceConvertFromSI(double)
Converts a value from SI unit to the unit represented by the MeasuringUnit.
Declaration
public double ConvertFromSI(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value to convert from SI unit. |
Returns
| Type | Description |
|---|---|
| double | The value converted to the unit represented by the MeasuringUnit. |
ConvertFromSIToDisplayString(double)
Converts a value expressed in SI unit to a string that can be displayed in a user interface. the number of decimlas specified by the MeasuringUnit is used.
Declaration
public string ConvertFromSIToDisplayString(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The SI value to convert to a display string. |
Returns
| Type | Description |
|---|---|
| string | The display string. |
ConvertFromSIToDisplayString(double, int)
Converts a value expressed in SI unit to a string that can be displayed in a user interface. the number of decimals specified by the MeasuringUnit is used.
Declaration
public string ConvertFromSIToDisplayString(double value, int numDecimals)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The SI value to convert to a display string. |
| int | numDecimals | The number of decimals to use |
Returns
| Type | Description |
|---|---|
| string | The display string. |
ConvertToSI(double)
Converts a value expressed in the unit represented by the MeasuringUnit to a value expressed in the corresponding SI unit.
Declaration
public double ConvertToSI(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value to convert to SI unit. |
Returns
| Type | Description |
|---|---|
| double | The value in SI unit. |
ConvertToSIFromDisplayString(string)
Converts a value expressed in SI unit to a string that can be displayed in a user interface. The number of decimals to use can be specified.
Declaration
public double ConvertToSIFromDisplayString(string displayString)
Parameters
| Type | Name | Description |
|---|---|---|
| string | displayString | The SI value to convert to a display string. |
Returns
| Type | Description |
|---|---|
| double | The display string. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The argument is not valid. |
IsValidDisplayCharacter(char)
Returns a value indicating whether the specified character is valid in the string representation the MeasuringUnit.
Declaration
public static bool IsValidDisplayCharacter(char displayCharacter)
Parameters
| Type | Name | Description |
|---|---|---|
| char | displayCharacter | The character to test for validity. |
Returns
| Type | Description |
|---|---|
| bool | A value indicating whether the specified character is valid. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The argument is not valid. |
IsValidDisplayString(string)
Returns a value indicating whether the specified string is a valid string representation of the MeasuringUnit.
Declaration
public static bool IsValidDisplayString(string displayString)
Parameters
| Type | Name | Description |
|---|---|---|
| string | displayString | The character to test for validity. |
Returns
| Type | Description |
|---|---|
| bool | A value indicating whether specified string is a valid string representation of the MeasuringUnit. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The argument is not valid. |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |