mikeloria

Using Event Frames(AFSDK) in Processbook VBA

Discussion created by mikeloria on Apr 6, 2011
Latest reply on Oct 30, 2015 by Johan_Van_Acker

Is it possible right now to reference the AFSDK in VBA in processbook and lookup event frames and get their begin and end times at a minimal? If yes, could someone please provide an example? or if not, will it ever be and when? I want to use the begin and end times of the event frame for setting a trend time range and possibly setting PI Point values with the begin time. A user will enter a value in a textbox such asa material ID and then they will click a button. The event frame will be retrieved and the timerange will be set for the trend. I am doing this now with the PISDK and a PI Point with the function I listed below. I am fully aware that the event frames do need to be created programmically which is what I am already doing with the PI Point.

 

Please help on this one.

 

I have found some great value in using VBA in processbook for setting the timerange of a trend based on the value of a particular PI Point. The Particular PI Point contains the begin time and end time of a material ID. I have a text box and a button that the customer clicks once they enter a material ID. The trend gets set to this time range and the user can now see how the material performed at a certain location on a prodcution line.

 
Function SetTimeRangeForProducedCoil(tag As String, id As String) As Boolean
    Dim filter As String
    ' this is to form a filter condition like 'BA:Active.1' = "Active"
    filter = "'" & tag & "' = " & Chr(34) & id & Chr(34)
    Dim svr As Server
    Set svr = PISDK.Servers.DefaultServer
    Dim pt As PIPoint
    Set pt = svr.PIPoints(tag)
    Dim pivalues As pivalues
    Set pivalues = pt.Data.RecordedValues("*", "*-30d", btInside, filter, fvRemoveFiltered)
    
    If pivalues.Count > 1 Then 'Everythinggood to go
    ' lblCoilEndTime.Caption = pivalues(1).TimeStamp.LocalDate
    ' lblCoilStartTime.Caption = pivalues(2).TimeStamp.LocalDate
    ' set the trend title
    trnd1.TrendTitle = "GLW 5CPL Temate Weld Inspection for head coil : " & tbxProducedCoil.Text
    Call trnd1.SetStartAndEndTime(pivalues(2).TimeStamp.LocalDate, _
    pivalues(1).TimeStamp.LocalDate)
    ThisDisplay.Revert
     SetTimeRangeForProducedCoil = True
    Else
     SetTimeRangeForProducedCoil = False
    End If
    
   
End Function

 

Outcomes