4 Replies Latest reply on Apr 7, 2011 8:04 PM by spilon

    Setting the time of a value Symbol


      In processbook, we have the value symbol which we can set the PI tag and it will display the latest value for the PI Tag. I wish to be able to display what the value was at a certain time. Is there a way to do this in VBA? Is there a way to do this for all the value symbols on a particular display? My use case is that I am setting a time range through VBA for a trend using a user inputted value. I would like all the value symbols on the display to be set to the begin time that I use to set the trend.


      I remember their was a cursor example where depending on where the cursor was on the timeline, the value symbols would display the value at that time but I cannot find that example.


      Thank you in advance for your help in this matter.

        • Re: Setting the time of a value Symbol
          Daniel Takara



          You'll find that example here:


          techsupport.osisoft.com > Download Center >  Supporting Files > Training Materials


          Download the file "Advanced PI Client ActiveX Scripting - Course Materials" and check its document specifically on session 2.3 (The Trend_DropCursor Event).


          Hope this helps!

            • Re: Setting the time of a value Symbol

              Simple Example that loops through symbol collection and sets value symbols to the starttime of the first trend on the display:



              Sub ChangeValueTime()
              Dim x As String
              Dim sym As Symbol
              'Get StartTime of Trend
              x = ThisDisplay.Trend1.StartTime
              'Loop through symbols collection
              For Each sym In ThisDisplay.Symbols
                  'If you find a value symbol set the time to x
                  If sym.Type = 7 Then
                      sym.SetTimeRange x, x
                  End If
              Next sym
              End Sub


                • Re: Setting the time of a value Symbol

                  Technically, value symbols only have end times.  The parameter for begin time is effectively ignored.  The only reason it is there is for consistancy with other symbols that support both begin and end times.  In Dan's example, it's the END time getting set to x that causes the value symbol to display the value at the beginning of the trend.


                  If you want to get SUPER technical, the Tool Tip Statistics add-in does calculate a begin time for value symbols, but it does this by taking the duration of the dominant trend (the first one added to the display) and counting backwards from the end time.  This allows it to provide summary data for the value symbol, which in Dan's case would be the for the duration of the trend, not a 0 hr period like you might expect because the the begin and end time of the value symbol are being set to the same thing.

                    • Re: Setting the time of a value Symbol

                      I would also like to point out that the Value symbol's end time setting reacts to the regular ProcessBook display's time range. In other words, if you have one or more Value symbol(s) selected, or you do not have anything selected (i.e. everything is selected by default), then changing the display's start and end time should do the same.


                      I don't have the code handy, but in VBA that would translate into "deselecting" all symbols (emptying the Display.SelectedSymbols property, if I recall correctly), and then do Display.SetStartAndEndTime.


                      Hope this helps!