vitorfarias

Count Events Digital State Tag over a period

Discussion created by vitorfarias on Jun 11, 2014
Latest reply on Jun 12, 2014 by xwang

Hi, I need to count how many times one Digital tag  State change over a period...

 

 

 

I tested this way:

 

 

 
        public int contarEventos(string tag, string timeinicial, string timefinal, string estado) 
        {
            PISDK.PIValues _PIValues;
            PITimeFormat timeini = formataData(timeinicial);
            PITimeFormat timefin = formataData(timefinal);
            PIPoint piPoint = this.piServer.PIPoints[tag];
            IPIData2 ipiData2 = (IPIData2)piPoint.Data;
            IPICalculation ipiCalc = (IPICalculation)this.piServer;

            string filexpr = "('" + tag + "' = " + '"' + estado + '"' + ")";

            PISDKCommon.NamedValues namedValues = ipiCalc.ExpressionSummaries(timeini,
                                                                              timefin,
                                                                              null,
                                                                              filexpr, 
                                                                              PISDK.ArchiveSummariesTypeConstants.asAll,
                                                                              PISDK.CalculationBasisConstants.cbEventWeightedExcludeMostRecentEvent,
                                                                              SampleTypeConstants.stRecordedValues,
                                                                              null,
                                                                              null);
            object _o = "Count";
            _PIValues = (PISDK.PIValues)namedValues.get_Item(ref _o).Value;


            return (int)_PIValues[1].Value;
        }

 

 

but I'm not sure if it is the best way...

Outcomes