YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

sample C# code to update pi tag Options · View
BenH
#1 Posted : Monday, July 19, 2010 6:28:42 PM
Rank: Newbie
Groups: Member

Joined: 7/10/2010
Posts: 5
Location: Hoquiam, WA
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);
}

}
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.