Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFAttribute.DisplayUOM Property

  • Last UpdatedNov 18, 2025
  • 4 minute read
AFAttribute.DisplayUOM Property
This property returns the display unit of measure (UOM) for the attribute's value.

Namespace:  OSIsoft.AF.Asset
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public UOM DisplayUOM { get; }
Public ReadOnly Property DisplayUOM As UOM
	Get

Dim instance As AFAttribute
Dim value As UOM

value = instance.DisplayUOM
public:
virtual property UOM^ DisplayUOM {
	UOM^ get () sealed;
}
abstract DisplayUOM : UOM with get
override DisplayUOM : UOM with get

Property Value

Type: UOM
Returns the display unit of measure (UOM) for the attribute's value determined by the DefaultUOM and the DisplayUOMGroup settings.

Implements

IAFAttributeDisplayUOM

Remarks

If the DisplayUOMGroup is not configured, then this will return the attribute's DefaultUOM. When the DisplayUOMGroup is set, then this property will return the attribute's default UOM converted to the mapped UOM as defined for the UOMGroup.

This property can be passed as the displayUOM parameter to the GetValue and AFData methods to display values in the mapped UOM as defined by the UOMGroup.

Examples

// This example will create a UOM Group with mappings, display its information,
//  and then perform some conversions.

// Get the Database
PISystems myPISystems = new PISystems();
UOMDatabase myDB = myPISystems.DefaultPISystem.UOMDatabase;

// Create a UOM Group
UOMGroup MyCustomGroup = myDB.UOMGroups.Add("MyCustomUOMGroup*");
MyCustomGroup.Description = "Custom UOM Group for Length";

// Add mappings to group
MyCustomGroup.Mappings[myDB.UOMs["ft"]] = myDB.UOMs["m"];
MyCustomGroup.Mappings[myDB.UOMs["in"]] = myDB.UOMs["cm"];
MyCustomGroup.Mappings[myDB.UOMs["nmi"]] = myDB.UOMs["km"];
MyCustomGroup.Mappings[myDB.UOMs["mi"]] = myDB.UOMs["km"];
MyCustomGroup.Mappings[myDB.UOMs["mm"]] = myDB.UOMs["cm"];
MyCustomGroup.Mappings[myDB.UOMs["sxi"]] = myDB.UOMs["cm"];
MyCustomGroup.Mappings[myDB.UOMs["yd"]] = myDB.UOMs["m"];
myDB.CheckIn();

// Display the UOM Groups
foreach (UOMGroup group in myDB.UOMGroups)
{
    Console.WriteLine("Name of UOM Group = {0}", group.Name);
    Console.WriteLine("Description = {0}", group.Description);
    Console.WriteLine("Mappings:");
    foreach (KeyValuePair<UOM, UOM> item in group.Mappings)
    {
        Console.WriteLine("    {0} ==> {1}", item.Key, item.Value);
    }
}

// Perform some conversions
AFValue origAFValue = new AFValue(55.3, AFTime.Now, myDB.UOMs["mi"]);
double mappedValue = MyCustomGroup.Convert(100.0, myDB.UOMs["yd"]);
Console.WriteLine("Convert 100.0 ft ==> {0}", mappedValue);
AFValue mappedAFValue = origAFValue.Convert(MyCustomGroup);
Console.WriteLine("Convert {0} {1} ==> {2} {3}",
    origAFValue.Value, origAFValue.UOM, mappedAFValue.Value, mappedAFValue.UOM);

// Display attribute value using Display UOM
myDB.DisplayUOMGroup = MyCustomGroup;
origAFValue = MyAttr.GetValue();
mappedAFValue = MyAttr.GetValue(MyAttr.DisplayUOM);
Console.WriteLine("GetValue {0} {1} ==> {2} {3}",
    origAFValue.Value, origAFValue.UOM, mappedAFValue.Value, mappedAFValue.UOM);
' This example will create a UOM Group with mappings, display its information,
'  and then perform some conversions.

' Get the Database
Dim myPISystems As New PISystems()
Dim myDB As UOMDatabase = myPISystems.DefaultPISystem.UOMDatabase

' Create a UOM Group
Dim MyCustomGroup As UOMGroup = myDB.UOMGroups.Add("MyCustomUOMGroup*")
MyCustomGroup.Description = "Custom UOM Group for Length"

' Add mappings to group
MyCustomGroup.Mappings(myDB.UOMs("ft")) = myDB.UOMs("m")
MyCustomGroup.Mappings(myDB.UOMs("in")) = myDB.UOMs("cm")
MyCustomGroup.Mappings(myDB.UOMs("nmi")) = myDB.UOMs("km")
MyCustomGroup.Mappings(myDB.UOMs("mi")) = myDB.UOMs("km")
MyCustomGroup.Mappings(myDB.UOMs("mm")) = myDB.UOMs("cm")
MyCustomGroup.Mappings(myDB.UOMs("sxi")) = myDB.UOMs("cm")
MyCustomGroup.Mappings(myDB.UOMs("yd")) = myDB.UOMs("m")
myDB.CheckIn()

' Display the UOM Groups
For Each group As UOMGroup In myDB.UOMGroups
    Console.WriteLine("Name of UOM Group = {0}", group.Name)
    Console.WriteLine("Description = {0}", group.Description)
    Console.WriteLine("Mappings:")
    For Each item As KeyValuePair(Of UOM, UOM) In group.Mappings
        Console.WriteLine("    {0} ==> {1}", item.Key, item.Value)
    Next
Next

' Perform some conversions
Dim origAFValue As New AFValue(55.3, AFTime.Now, myDB.UOMs("mi"))
Dim mappedValue As Double = MyCustomGroup.Convert(100.0, myDB.UOMs("yd"))
Console.WriteLine("Convert 100.0 ft ==> {0}", mappedValue)
Dim mappedAFValue As AFValue = origAFValue.Convert(MyCustomGroup)
Console.WriteLine("Convert {0} {1} ==> {2} {3}",
    origAFValue.Value, origAFValue.UOM, mappedAFValue.Value, mappedAFValue.UOM)

' Display attribute value using Display UOM
myDB.DisplayUOMGroup = MyCustomGroup
origAFValue = MyAttr.GetValue()
mappedAFValue = MyAttr.GetValue(MyAttr.DisplayUOM)
Console.WriteLine("GetValue {0} {1} ==> {2} {3}",
    origAFValue.Value, origAFValue.UOM, mappedAFValue.Value, mappedAFValue.UOM)

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

Version Information

AFSDK

Supported in: 3.1.1, 3.1.0, 3.0.2, 3.0.1, 3.0.0, 2.10.11, 2.10.5, 2.10.0, 2.10, 2.9.5

See Also

In This Topic
TitleResults for “How to create a CRG?”Also Available in