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

sample C# code to read an average value from PI Options · View
BenH
#1 Posted : Monday, July 19, 2010 6:39:00 PM
Rank: Newbie
Groups: Member

Joined: 7/10/2010
Posts: 5
Location: Hoquiam, WA
add in references to
OSIsoft.PISDK
OSIsoft.PISDKCommon
OSIsoft.PITimeServer

// PI connection
static PISDK.PISDK mySDK;
static PISDK.Server myServer;
static PISDK.PIPoints myPoints;
static PISDK.PIPoint snapPoint;
static PISDK.PIValue piValue;

struct PiTag
{
public string machineCode, piTagName, ptsPropertyCode;
public DateTime DateStart, DateEnd;
}

private void GetPIData()
{
// code needed to get pi tag

PiTag tag;

// code to populate struct tag with tag, and time offsets
try
{
snapPoint = myPoints[tag.piTagName];
step = "avg";
tagAvg = 0;
piValue = snapPoint.Data.Summary(
tag.DateStart,
tag.DateEnd,
PISDK.ArchiveSummaryTypeConstants.astAverage,
PISDK.CalculationBasisConstants.cbTimeWeighted, null);
tagAvg = Convert.ToDouble(piValue.Value.ToString());
step = "stdev";
tagStDev = 0;
piValue = snapPoint.Data.Summary(
tag.DateStart,
tag.DateEnd,
PISDK.ArchiveSummaryTypeConstants.astStdDev,
PISDK.CalculationBasisConstants.cbTimeWeighted, null);
tagStDev = Convert.ToDouble(piValue.Value.ToString());
updatePTS = true;
}
catch (System.Runtime.InteropServices.COMException comExc)
{
\\ write to log error
}
}
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.