AnsweredAssumed Answered

C# SDK - How to find the number of times a tag is under a certain value

Question asked by jscotti on Jan 14, 2015
Latest reply on Mar 2, 2015 by viveks

I need some help,

I am trying to find the amount of times a tag is under a certain value for the past 30 days.

I've posted my code below,

It doesn't seem to be working because no matter what I change the expression to it always shows either 1 or 0

            _pisdk = new PISDK.PISDK();
            PISDK.Server piServer = _pisdk.Servers["SERVER"];
            PISDK.Server myServer;
            PISDK.PIPoints myPoints;
            PISDK.PIPoint myPoint;
            PISDK.PIData myPIdata;
            PISDK.IPIData2 ipidata2;
            PISDKCommon.NamedValues nvsSum;
            PISDK.PIValues pvs;
            myPoints = piServer.PIPoints;
            myPoint = myPoints["TAG"];
            myPIdata = myPoint.Data;
            ipidata2 = myPIdata as PISDK.IPIData2;
            string expression = "'TAG' < 40";
            nvsSum = ipidata2.FilteredSummaries("*-30d", "*", "", expression, PISDK.ArchiveSummariesTypeConstants.asTotal, PISDK.CalculationBasisConstants.cbTimeWeighted, PISDK.FilterSampleTypeConstants.fstExpRecordedValues);
            int p = nvsSum.Count;