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

AF SDK Reference

UOM.UpdateFormula Method

  • Last UpdatedNov 18, 2025
  • 3 minute read
UOM.UpdateFormula Method
This method updates the conversion formulas for this unit of measure (UOM).

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

Syntax

public void UpdateFormula(
	UOM refUOM,
	string fromFormula,
	string toFormula
)
Public Sub UpdateFormula ( 
	refUOM As UOM,
	fromFormula As String,
	toFormula As String
)

Dim instance As UOM
Dim refUOM As UOM
Dim fromFormula As String
Dim toFormula As String

instance.UpdateFormula(refUOM, fromFormula, 
	toFormula)
public:
void UpdateFormula(
	UOM^ refUOM, 
	String^ fromFormula, 
	String^ toFormula
)
member UpdateFormula : 
        refUOM : UOM * 
        fromFormula : string * 
        toFormula : string -> unit 

Parameters

refUOM
Type: OSIsoft.AF.UnitsOfMeasureUOM
The reference unit of measure for this UOM conversion. This UOM must belong to the same UOM class and not create any circular references.
fromFormula
Type: SystemString
The formula to apply to the reference UOM to obtain this UOM. The maximum length of this parameter is 100 characters.
toFormula
Type: SystemString
The formula to apply to this UOM to obtain the reference UOM. The maximum length of this parameter is 100 characters.

Remarks

This method replaces the conversion formulas for this UOM. When possible, use the standard factor and offset conversions instead of formula-based conversions. You need to enter conversion formulas for converting both from and to the reference unit. These formulas must be reciprocals.

The formulas are written in terms of the UOM abbreviation (see the example below), and adhere to C# evaluation rules. If either of the abbreviations are not valid C# variable names, you must enclose them in brackets. Since C# is used to evaluate the expression, you can invoke standard .NET static methods such as Math.Log10 within the expression.

Examples

// This example demonstrates how to update the formula for a UOM.

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

// Create the UOM Class
UOMClass SGUOMClass = myDB.UOMClasses.Add("My Specific Gravity", "MySG", "MySG");

// Create the UOM
UOM API = myDB.UOMs.AddFormula("My API Gravity", "MyAPI", myDB.UOMs["MySG"], "141.5/MySG - 131.5 + 100", "141.5/(MyAPI+131.5) - 100");

// Update the formula
API.UpdateFormula(myDB.UOMs["MySG"], "141.5/MySG - 131.5", "141.5/(MyAPI+131.5)");
' This example demonstrates how to update the formula for a UOM.

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

' Create the UOM Class
Dim SGUOMClass As UOMClass = myDB.UOMClasses.Add("My Specific Gravity", "MySG", "MySG")

' Create the UOM
Dim API As UOM = myDB.UOMs.AddFormula("My API Gravity", "MyAPI", myDB.UOMs("MySG"), "141.5/MySG - 131.5 + 100", "141.5/(MyAPI+131.5) - 100")

' Update the formula
API.UpdateFormula(myDB.UOMs("MySG"), "141.5/MySG - 131.5", "141.5/(MyAPI+131.5)")

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


See Also

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