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

PI - MS Access 2003 Options · View
Mike
#1 Posted : Thursday, January 20, 2011 3:16:51 PM
Rank: Newbie
Groups: Member

Joined: 1/20/2011
Posts: 1
Location: Norfolk, UK
OS: Windows XP SP3
App: MS Access 2003 SP3

Hello

Does anyne have some VBA to call three tags with criteria using MS Access?

Excel Cell formula =PISampDat(Criteria!$E$10,Criteria!$E$7,Criteria!$E$8,Criteria!$E$9, 1,"sutemap1")
Criteria!$E$10 - TARGET_HEAT_RATE_HHV, CPRFFICJ1777, CSUTJWQI2046 (Tags)
Criteria!$E$7 - 07/01/2011 00:00:00 (Start Date Time)
Criteria!$E$8 - 18/01/2011 00:00 (End Date Time)
Criteria!$E$9 - 30m (Interval)

Many thanks in advance

Regards
Mike Faulkner
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.
JLane
#2 Posted : Friday, January 28, 2011 7:45:28 PM
Rank: Newbie
Groups: Member

Joined: 1/28/2011
Posts: 4
Location: Kingsport, TN USA
With references to PISDK and PISDKCommon type libraries, this approach using the IPIData2 interface would work for one tag at a time.

Code:
Private Sub SampledDataTest()
    Dim srv As Server
    Dim pt As PIPoint
    Dim pdata As PIData
    Dim ipid2 As IPIData2
    Dim vals As PIValues
    Dim startTime As String, endTime As String, duration As String
    Dim i As Integer

    startTime = "28-Jan-2011 12:45:00"      ' could use t for today at 00:00:00
    endTime = "*"                           ' could use * for current time
    duration = "30m"                        ' calculation interval

    Set srv = Servers("MYPISERVER")
    If srv.Connected = False Then
        srv.Open
    End If
    Set pt = srv.PIPoints("MYPITAG") ' get tag
    Set pdata = pt.Data
    Set ipid2 = pdata                               ' get pointer to IPIData2 Interface
   
    Set vals = ipid2.InterpolatedValues2(startTime, endTime, duration)
   
    For i = 1 To vals.Count
        Debug.Print Format(vals(i).TimeStamp.LocalDate, "dd-MMM-yyyy hh:mm:ss"), " ", vals(i).Value
    Next i
   
    Set vals = Nothing
    Set ipid2 = Nothing
    Set pdata = Nothing
    Set pt = Nothing
    Set srv = Nothing
End Sub



After running this against a real server and tag, the following was written to the debug window:
Code:
28-Jan-2011 12:45:00                       5144
28-Jan-2011 13:15:00                       5148
28-Jan-2011 13:45:00                       5147
28-Jan-2011 14:15:00                       5147


I used the format statement to get the timestamps to appear the way I wanted. I'm sure you will want to see it a little differently, but hopefully this will help.
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.