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

AF SDK Reference

PIPoint.UpdateValues Method (IList(AFValue), AFUpdateOption, AFBufferOption)

PIPoint.UpdateValues Method (IList(AFValue), AFUpdateOption, AFBufferOption)

  • Last UpdatedJan 12, 2026
  • 5 minute read
PIPoint.UpdateValues Method (IList(AFValue), AFUpdateOption, AFBufferOption)
Update multiple values for the PIPoint.

Namespace:  OSIsoft.AF.PI
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.2.0.7

Syntax

public AFErrors<AFValue> UpdateValues(
	IList<AFValue> values,
	AFUpdateOption updateOption,
	AFBufferOption bufferOption
)
Public Function UpdateValues ( 
	values As IList(Of AFValue),
	updateOption As AFUpdateOption,
	bufferOption As AFBufferOption
) As AFErrors(Of AFValue)

Dim instance As PIPoint
Dim values As IList(Of AFValue)
Dim updateOption As AFUpdateOption
Dim bufferOption As AFBufferOption
Dim returnValue As AFErrors(Of AFValue)

returnValue = instance.UpdateValues(values, 
	updateOption, bufferOption)
public:
AFErrors<AFValue^>^ UpdateValues(
	IList<AFValue^>^ values, 
	AFUpdateOption updateOption, 
	AFBufferOption bufferOption
)
member UpdateValues : 
        values : IList<AFValue> * 
        updateOption : AFUpdateOption * 
        bufferOption : AFBufferOption -> AFErrors<AFValue> 

Parameters

values
Type: System.Collections.GenericIListAFValue
The list of values with an associated PIPoint for each value.
updateOption
Type: OSIsoft.AF.DataAFUpdateOption
Indicates how to treat duplicate values in the archive.
bufferOption
Type: OSIsoft.AF.DataAFBufferOption
An enumeration value that specifies buffering option.

Return Value

Type: AFErrorsAFValue
If there are no errors, then is returned. Otherwise an AFErrorsTKey instance containing error information is returned.

Remarks

For successful data write through Buffer, this method requires that PI Buffer Subsystem (PIBufSS) needs to be correctly pre-configured with Buffering Manager. Currently, buffering data through PIBufSS has a limitation where error feedback from PI Data Archive cannot be returned to the caller.

Data write through Buffer will be fanned to Collective members.

Important note Important
Exception reporting is not handled automatically by the AF SDK. Historically, exception reporting has been handled by the application writing data (i.e. Uniint-based interfaces).

Examples

// This example demonstrates how to update values to PIPoint.
// Note: For successul write through Buffer, PI Buffer Subsystem needs to be correctly pre-configured with PI Buffer Manager. 

// Get the Database and UOMs
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
AFDatabase myDB = myPISystem.Databases.DefaultDatabase;

// Find a PIPoint and create its new values
AFTime newStartTime = new AFTime("T-1d", CultureInfo.CurrentCulture);
AFValues newValues = new AFValues();
Random randomValues = new Random();

// Find a PIPoint to Update
PIServer piServer = PIServers.GetPIServers().DefaultPIServer;
int dataCount = 5; //Create 5 new values to update
AFTime newTime = newStartTime;
PIPoint point;
if (!PIPoint.TryFindPIPoint(piServer, "MyTestPoint#1", out point))
{
    point = piServer.CreatePIPoint("MyTestPoint#1");
}
for (int i = 0; i < dataCount; i++)
{
    AFValue newValue = new AFValue(randomValues.NextDouble(), newTime);
    newValues.Add(newValue);
    newTime = newTime.LocalTime.AddMinutes(10);
}
AFTime newEndTime = newTime;

// Get the Recorded Values for the PIPoint
AFValues recordedValues = point.RecordedValues(new AFTimeRange(newStartTime, newEndTime), AFBoundaryType.Inside,
    null, false);
Console.WriteLine("Recorded Values:");
foreach (AFValue value in recordedValues)
{
    Console.WriteLine("  {0}: '{1} {2}' at '{3}'",
        value.Attribute, value.Value, value.UOM, value.Timestamp);
}

// Get the Buffer Option
// Note: If not specified in AFSDK.config, the buffer option is defaulted to "BufferIfPossible". 
Console.WriteLine("Current Buffer Option: {0}", AFData.BufferOption);

// Set the Buffer Option to "Buffer" if it is not already, which will be valid throughout this client instance.
if (AFData.BufferOption != AFBufferOption.Buffer)
{
    AFData.BufferOption = AFBufferOption.Buffer;
    Console.WriteLine("Current Buffer Option for this instance has been changed to: {0}", AFData.BufferOption);
}

//1. Update the PIPoint Values and Display any Errors
AFErrors<AFValue> errorsWithBuffer =
    point.UpdateValues(newValues, AFUpdateOption.InsertNoCompression); //Insert or InsertNoCompression
Thread.Sleep(1000);

if (errorsWithBuffer != null && errorsWithBuffer.HasErrors)
{
    Console.WriteLine("\nErrors returned from PIPoint.UpdateValues:");

    // Display Value errors
    if (errorsWithBuffer.Errors != null && errorsWithBuffer.Errors.Count > 0)
    {
        foreach (var item in errorsWithBuffer.Errors)
        {
            Console.WriteLine("  AFValue '{0}': {1}", item.Key, item.Value);
        }
    }

    // Display error from the PI Data Archive
    if (errorsWithBuffer.PIServerErrors != null && errorsWithBuffer.PIServerErrors.Count > 0)
    {
        foreach (var item in errorsWithBuffer.PIServerErrors)
        {
            Console.WriteLine("  AFValue '{0}': {1}", item.Key, item.Value);
        }
    }

    // Display PI System errors
    if (errorsWithBuffer.PISystemErrors != null && errorsWithBuffer.PISystemErrors.Count > 0)
    {
        foreach (var item in errorsWithBuffer.PISystemErrors)
        {
            Console.WriteLine("  AFValue '{0}': {1}", item.Key, item.Value);
        }
    }
}


//2. Alternatively, one can specify buffer option in the UpdateValues method
AFErrors<AFValue> errorsWithBufferIfPossible =
    point.UpdateValues(newValues, AFUpdateOption.InsertNoCompression, AFBufferOption.BufferIfPossible);
Thread.Sleep(1000);

// Get the Updated Recorded Values for the PIPoint
AFValues recordedValuesUpdated = point.RecordedValues(new AFTimeRange(newStartTime, newEndTime), AFBoundaryType.Inside,
    null, false);
Console.WriteLine("\nUpdated Recorded Values:");
foreach (AFValue value in recordedValuesUpdated)
{
    Console.WriteLine("  {0}: '{1} {2}' at '{3}'",
        value.Attribute, value.Value, value.UOM, value.Timestamp);
}

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, 2.9, 2.8.5, 2.8, 2.7.5, 2.7, 2.6

See Also

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