1 Reply Latest reply on Apr 28, 2010 3:42 PM by hanyong

    show date & time with PiACE

    retetes

      Hi!

      I have a problem with a equation inside Processbook, I want to show the last value and time before the actual value from the same tag with a function. To obtain this goal, I use a Pi ACE library which works fine in almost all tags, but in others tags the equation does not work. After look into processbook, I realized that the tags which fail only has one state change, and show me a wrong state and time.

      This is the equation:

      Function CambiaToolTip(nombreTM As String) As String
      Dim a As Boolean
      Dim p As PIACEPoint
      Dim t As PITime

      Set t = New PITime
      Set p = New PIACEPoint

      a = p.SetTag("labserver1", nombreTM, taTagAliasAsInput)

      On Error GoTo NoEncuentra
      t = p.FindNE("*", "*-30d", p.Value("*"))

      CambiaToolTip = Format(t.LocalDate, "dd/mm/yyyy hh:mm:ss") & " Valor:" & p.NextVal(t)
      Exit Function
      NoEncuentra:
      t.UTCSeconds = DateTime.Now()
      Resume Next

      End Function

        • Re: show date & time with PiACE
          hanyong

          Hi,

           

          Seems to me like you are trying to find the closest time where the tag has a different value as the current value instead of what you described as

          Ernesto Bedrina

          I want to show the last value and time before the actual value from the same tag with a function.

           

          If you just want to get the last value before a particular time, you can use the PrevEvent() function instead of FindNE. This would give you the previous value timestamp, even if the value is the same as the current value though. As you say, this might give a problem if there is no event within the search time or if you are using PrevEvent() and there is no previous event in the archive. This is something that we have to check and handle.

           

          Another thing is able using PI ACE library here, I am guessing that you probably can get a similar result by defining a PE calulation dataset in ProcessBook. Is there any reasons for using a PI ACE library here? There are similar PE functions to the ACE functions that you are using here.

           

          This seems like more of a "VBA programming in ProcessBook" instead of a "PI System Integration" post. I'll move the post to the other forum =)