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
}
}