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

AF SDK Reference

UOMGroup Class

  • Last UpdatedNov 18, 2025
  • 7 minute read
UOMGroup Class
The UOMGroup represents a group of UOM mappings.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AF.UnitsOfMeasureUOMGroup

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

Syntax

[SerializableAttribute]
public sealed class UOMGroup : AFObject, 
	IComparable<UOMGroup>
<SerializableAttribute>
Public NotInheritable Class UOMGroup
	Inherits AFObject
	Implements IComparable(Of UOMGroup)

Dim instance As UOMGroup
[SerializableAttribute]
public ref class UOMGroup sealed : public AFObject, 
	IComparable<UOMGroup^>
[<SealedAttribute>]
[<SerializableAttribute>]
type UOMGroup =  
    class
        inherit AFObject
        interface IComparable<UOMGroup>
    end

The UOMGroup type exposes the following members.

Properties

  NameDescription
Public property
Database
This read-only property allows access to the UOMDatabase associated with this object.
Public property
Description
Read/write property that provides a more detailed description of the object.
Public property
ID
Read-only property that provides a unique identifier for the object to be used for quick access that is not dependent upon the index.
(Inherited from AFObject.)
Public property
Identity
This read-only property contains identity of the object.
(Inherited from AFObject.)
Public property
IsDeleted
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.)
Public property
Mappings
Gets the dictionary of UOM (unit of measure) mappings defined for this UOMGroup.
Public property
Name
Read/write property that identifies the name of the object.
Public property
PISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public property
UniqueID
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.)

Methods

  NameDescription
Public method
CompareTo(Object)
Compares this instance with a specified Object.
(Inherited from AFObject.)
Public method
CompareTo(AFObject)
Compares this instance with a specified AFObject.
(Inherited from AFObject.)
Public methodCode example
Convert
This method converts the specified value from the specified unit of measure (UOM) to the mapped UOM represented by this UOMGroup.
Public method
Equals(Object)
Determines whether the specified Object is equal to the current object.
(Inherited from AFObject.)
Public method
Equals(AFObject)
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.)
Public method
GetHashCode
Gets the hash code for this instance of the object which is suitable for use in hashing algorithms and data structures like a hash table.
(Inherited from AFObject.)
Public method
GetPath
Returns the full path to the object, using just the names.
(Inherited from AFObject.)
Public method
GetPath(AFObject)
Returns the path to the object relative from another object.
(Inherited from AFObject.)
Public method
GetPath(AFEncodeType, AFObject)
Returns the path to the object relative from another object, using the name and/or id as specified by encodeType.
(Inherited from AFObject.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
Persist
This method returns the persistence string for the object.
(Inherited from AFObject.)
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFObject.)

Remarks

An attribute template defines the DefaultUOM for all attributes created from the template. Users located in different locations around the world would like to see the attribute values returned in their preferred units (e.g. 'US Customary' or 'Metric') instead of the template’s default UOM. The UOMGroup provides a way for users to define a mapping between two different UOMs.

The DisplayUOMGroup property can be set to a UOMGroup to specify the mapping used when returning the attribute's DisplayUOM. The attribute's DisplayUOM would be used as the desiredUOM parameter when retrieving values to display in the user's selected display UOM group.

The Supports(PISystemFeatures) method can be used to check if the PISystem supports the UomGroup feature.

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