3 Replies Latest reply on Jun 3, 2013 9:00 AM by hanyong

    Sample .NET Code for getting the advanced calculation with the use of PI Web services

    cw.ng

      Hi all,

       

      I cannot figure out how to compute the total of a range of events with the use of advanced calculation of PI Web service.

       

      Would you provide me some C# codes?

       

      Best Regards

       

      Wo

        • Re: Sample .NET Code for getting the advanced calculation with the use of PI Web services
          hanyong

          Hi Chung Wo,

           

          IYou can use the GetPISummaryData method exposed by PITimeSeries to get aggregated data of a tag.

           
          PITimeSeriesClient tsClient = new PITimeSeriesClient();
          
          PISummaryDataRequest request = new PISummaryDataRequest();
          request.Path = @"pi:\\hanyonge6230\cdt158";
          request.TimeRange = new TimeRange();
          request.TimeRange.Start = "Y";
          request.TimeRange.End = "T";
          request.PISummaryManner = new PISummaryManner();
          request.PISummaryManner.TimeStep = "1d";
          request.PISummaryManner.SummaryValue = PISummaryMannerSummaryValue.Total;
          request.PISummaryManner.WeightType = PISummaryMannerWeightType.TimeWeighted;
          
          PISummaryDataRequest[] requests = new PISummaryDataRequest[] { request };
          
          TimeSeries[] results = tsClient.GetPISummaryData(requests);
          

           Above is a sample for getting the time-weighted total for a day (yesterday 00:00 to today 00:00). You can adjust the timestep if you are trying to aggregate smaller time period within the specified time range for example hourly total for the whole of yesterday.

           

          Hope this helps