4 Replies Latest reply on Jul 25, 2016 9:21 PM by Alex_UCR

    ProcessBook Trend with Variable Plot Time

    Alex_UCR

      I am making a display to show peak power usage throughout the current month, and one of things that I would like to have is a plot that shows the power usage on the day of the peak usage.

       

      For example, if I have the expression TimeStamp(TagMax('Power Received',bom('*'),'*')) it returns 7/12/2016 7:38:38 AM,

      so I want a trend that plots Power Received, starting at 12:00AM on 7/12/2016 and ending at 12:00AM on 7/13/2016.

       

      However, the value of TimeStamp(TagMax('Power Received',bom('*'),'*')) will change throughout the month each time there is a new maximum, so I want the plot times to change as well.

      For example, if there is a new maximum tomorrow (7/16/2016), I want the plot time to plot Power Received from 12:00AM on 7/16/2016 to 12:00AM on 7/17/2016.

       

      So, how would I go about doing this?  It seems like for the start and end time have to be a simple time reference like '*-1d' and '*'.

      The reason I am having trouble is because it does not seem possible to have a more complex expression or use a tag value as a start or end time.

        • Re: ProcessBook Trend with Variable Plot Time
          John Messinger

          Trend Start and End times could really only be dynamically set through code. You can use any valid PI timestamp in either the UI or via code. As you are performing an AF Analysis to get your peak usage timestamp, what type of data reference is the output being written to?

          You could dynamically set the start and end time of the trend with a little bit of VBA code reading from a Value object that contains the output of your analysis. I tried this using a string tag to receive my analysis output, mapped that tag to a Value symbol on my display, and used the following bit of code:

          Dim peak_time As Variant
          Dim trendStartTime As Date
          Dim trendEndTime As Date
          Dim vrdate As Variant
          Dim vrstatus As Variant
              
          peak_time = Value1.GetValue(vrdate, vrstatus)
          trendStartTime = Format(CDate(peak_time), "dd/mm/yyyy")
          trendEndTime = DateAdd("d", 1, trendStartTime)
              
          Trend1.SetStartAndEndTime CStr(trendStartTime), CStr(trendEndTime)
          

           

          Initially I tried using a tag of type Timestamp for my analysis output, but couldn't properly read the value in ProcessBook VBA, hence the use of the string tag instead.

          • Re: ProcessBook Trend with Variable Plot Time
            Rhys Kirk

            I would do it in PI Coresight and use Event Frames. You can generate an Event Frame around the month peak usage, then you can simply select the Event Frame in PI Coresight to set the time range as you need.

            You could have a script running to modify the start/end time of the Event Frame if the peak moves throughout the month. This way your logic isn't tied to a single display, it is accessible by multiple PI tools.

            • Re: ProcessBook Trend with Variable Plot Time
              mfoerster

              Hi Nishantha,

              both options presented above sound like a good solution to me.

               

              If you decide in favor for Processbook, please also have a look at the Processbook programmers reference (link below) for the syntax of the methods to set your timerange:

               

              p.196 -- Display.Settimerange

              p.393 -- trend.settimerange

               

              https://techsupport.osisoft.com/Downloads/File/0c9043dd-a7a3-4b49-8b62-c8f408d61c6f