add the following to the c# references (should be registered when PI is installed, otherwise look in PIPC folder)
OSIsoft.PISDK
OSIsoft.PISDKCommon
OSIsoft.PITimeServer
// pi objects
private static PISDK.PISDK mySDK;
private static PISDK.Server myServer;
private static PISDK.PIPoint piPoint;
private static PISDK.PIValue piValue;
private static PITimeServer.PITime piTime;
private static void UpdatePI(string _PointName, DateTime _DateRead, double _Value)
{
try
{
// open the server connection move to main section
mySDK = new PISDK.PISDKClass();
myServer = mySDK.Servers["PI"];
myServer.Open(String.Empty);
// create a pi point
piPoint = myServer.PIPoints[_PointName];
// set the date and value for the pi tag
piTime = new PITimeServer.PITime();
piTime.LocalDate = _DateRead;
piValue = new PISDK.PIValue();
piValue.TimeStamp = piTime;
piValue.Value = _Value;
// update pi system: note that the update time stamp can be different from pi value time stamp
piPoint.Data.UpdateValue(piValue, "*", PISDK.DataMergeConstants.dmInsertDuplicates, null);
}
catch (System.Exception ex)
{
// log error
WriteToLog(ex.ToString(), true);
}
}