2 Replies Latest reply on Jun 3, 2015 1:20 PM by pthivierge

    How to configure PIPoint DR to return Hourly Average for 12 hours

    JFors

      I would like to be able to retrieve a typical Datalink query where I want the last 12 hours of hourly average values for a tag.  I've configured an AFAttribute to get the 1 hour Average and can see it within PIExplorer to be a good value.  From within code I've tried to call the GetValues method of the instanciated AFAttribute:

                  if (MyTimeRange != null)

                          {

                              templist = tempAtt.GetValues(MyTimeRange, 0, null);

                          }

      which fails with an exception:

                    {"[-11111] Error with summary calculation time array"}

       

      Would appreciate help on how to construct this query using the PIPoint DR or ?

       

      Thanks John

        • Re: How to configure PIPoint DR to return Hourly Average for 12 hours
          bshang

          Hi John,

           

          Is this AFAttribute (tempAtt in the code) a PIPointDR? Can you show a screenshot how it was configured to retrieve the hourly average? What is the range of MyTimeRange? It might help to write this to the debugger or Console. Prior cases in which the error appeared indicated issues with the passed in time range. Looking at the full PIPointDR configuration would help us troubleshoot additionally though. Could you also post more of the code?

           

          An alternative (and preferred) mechanism for getting 1hr averages over a 12 hr period would be to use the AFAttribute.Data.Summaries() method.

          AFData.Summaries Method

          public IDictionary<AFSummaryTypes, AFValues> Summaries(
          AFTimeRange timeRange,
          AFTimeSpan summaryDuration,
          AFSummaryTypes summaryType,
          AFCalculationBasis calcBasis,
          AFTimestampCalculation timeType
          )
          

           

          The timeRange would be 12hr and the summaryDuration would be 1hr. The summaryType enum would be AFSummaryTypes.Average. I believe Summaries() is what Datalink also uses to grab the averages.

          • Re: How to configure PIPoint DR to return Hourly Average for 12 hours
            pthivierge

            Hello John,

             

            Did Barry’s proposed solution worked for you?

            If so you can mark it as correct answer, otherwise please let us know if you if you have more questions or what you did to solve your problem.