YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Value Change Options · View
mstatler
#1 Posted : Thursday, May 19, 2011 8:52:10 PM
Rank: Newbie
Groups: Member

Joined: 5/19/2011
Posts: 2
Location: USA
I have a boiler with several blowers. When a blower is running, the tag value is "true", when it is off, it is "false". Does anyone know how to find, using VBA in ProcessBook how to find the last time the value changed?
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
Shem
#2 Posted : Friday, May 20, 2011 1:45:07 PM
Rank: Member
Groups: Member

Joined: 5/5/2011
Posts: 22
Location: Moscow
You can use this code
Code:

Private Sub My_Function()

Dim srv As Server
Dim TagName As String
Dim pt As PIPoint
Dim pv As PIvalue
Set srv = Servers("Your_PIserver")

TagName = "cdm158"
Set pt = srv.PIPoints(TagName)
Set pv = pt.Data.Snapshot

Do
If pv.Value <> pt.Data.ArcValue(pv.TimeStamp, rtBefore).Value Then
    Exit Do
Else
    Set pv = pt.Data.ArcValue(pv.TimeStamp, rtBefore)
End If
Loop Until 1 <> 1

MsgBox "Time changed: " & pv.TimeStamp.LocalDate

End Sub


If at you many identical values in archive it can last long time (about several minutes)
In that case, it is possible to enter restriction on depth of sample of archive. For example if value didn't change 5 days not to continue search, and to tell to the user that value didn't change more than 5 days
mstatler
#3 Posted : Friday, May 20, 2011 3:32:50 PM
Rank: Newbie
Groups: Member

Joined: 5/19/2011
Posts: 2
Location: USA
Works great! Thanks!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.