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

“look up” in *pdi and/or *piw Options · View
Ana-Maria
#1 Posted : Monday, July 12, 2010 9:15:53 AM
Rank: Member
Groups: Member

Joined: 10/1/2008
Posts: 22
Location: Romania
Lets image the following situation: I have tag and I only know that this from a unit, but I do not know exactly where is it (the position on the *pdi display).

Now the question: is there a possibility (a VBA solution) to do a search (a sort of lookup) in that *pdi : to input the tag and to show me where is it?
Or better to do the search in the *piw where I have link to the all *pdi of that unit (from where my tag is).

Thanks!
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.
RJK Solutions
#2 Posted : Monday, July 12, 2010 10:25:20 AM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Hi Ana-Maria,

Indeed there is a solution, in fact I touched on something similar back in 2008 (http://www.rjksolutionsltd.co.uk/forum/yaf_postst29_Replicate-Status-Report-feature-of-PIProcessBook.aspx. In later versions of ProcessBook you get a status report window that tells you what tag is used by what symbol on the display - this is what I replicated. In your case you can easily alter the code to highlight where specific tags are used. You will need to parse all datasets too as a tag could be used indirectly by a symbol via a dataset.

For a *.piw file, you just loop through all the links, opens the displays and parse the symbols as per above - but you need to run the code from a pdi as there is no VBProject for a piw file.

Let me know if you want an example (there is code in the link above) for your problem and if I get some time I will post up some code.

Cheers.
Principal Consultant
Real-Time Data Management @ Wipro Technologies
Ana-Maria
#3 Posted : Monday, July 12, 2010 12:06:13 PM
Rank: Member
Groups: Member

Joined: 10/1/2008
Posts: 22
Location: Romania
Thank you for your explanation .Actually for the moment I just imagine what it could be the solution.

An example code it will help me a lot . (what link above ? I do not see any !)

Thanks again.

RJK Solutions
#4 Posted : Monday, July 12, 2010 8:02:48 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Here is an example to search a pdi, you can expand it to cover multiple pdi's, piw's or a directory.

Code:


Private sTag As String
Private lCount As Long
Private vSymbols() As String

Sub test()
Dim disp As Display
Set disp = Application.Displays.Open("C:\Display1.pdi", True)
    Call FindSymbolsWithTag(disp, "\\piservername\sinusoid")
    Call disp.Close(False)
Set disp = Nothing
End Sub

Public Sub FindSymbolsWithTag(ByVal TheDisplay As Display, ByVal FQTag As String)

lCount = 0
sTag = LCase(Trim(FQTag))
Erase vSymbols

If FQTag = "" Then Exit Sub

Dim Sym As Symbol
For Each Sym In TheDisplay.Symbols
    Call ParseSymbol(Sym, "")
Next Sym

Dim i As Integer
For i = LBound(vSymbols) To UBound(vSymbols)
    Debug.Print vSymbols(i)
Next i

End Sub

Private Sub ParseSymbol(ByVal TheSymbol As Symbol, ByVal CompName As String)

Dim sTmpTag As String: sTmpTag = ""
If TheSymbol.IsMultiState Then
    sTmpTag = LCase(Trim("\\" & TheSymbol.GetMultiState.GetPtServerName & "\" & TheSymbol.GetMultiState.GetPtTagName))
    If sTmpTag = sTag Then
        ReDim Preserve vSymbols(lCount)
        vSymbols(lCount) = TheSymbol.Type & ", MultiState: " & TheSymbol.Name
        lCount = lCount + 1
    End If
End If

Select Case TheSymbol.Type
    Case pbSymbolComposite
        Call ParseComposite(TheSymbol, CompName)
    Case pbSymbolValue, pbSymbolBar
        sTmpTag = LCase(Trim(TheSymbol.GetTagName(1)))
        If sTmpTag = sTag Then
            ReDim Preserve vSymbols(lCount)
            vSymbols(lCount) = TheSymbol.Type & ", GetTagName: " & CompName & TheSymbol.Name
            lCount = lCount + 1
        End If
    Case pbSymbolTrend
        Dim TheTrend As Trend, iTrace As Integer
        Set TheTrend = TheSymbol
        For iTrace = 1 To TheTrend.TraceCount
            TheTrend.CurrentTrace = iTrace
            sTmpTag = LCase(Trim(TheTrend.GetTagName(iTrace)))
            If sTmpTag = sTag Then
                ReDim Preserve vSymbols(lCount)
                vSymbols(lCount) = TheSymbol.Type & ", Trace '" & iTrace & "': " & CompName & TheSymbol.Name
                lCount = lCount + 1
            End If
        Next iTrace
        Set TheTrend = Nothing
    Case pbSymbolXYPlot
        Dim TheXY As Variant, iTags As Integer
        Set TheXY = TheSymbol
        For iTags = 1 To TheXY.PtCount
            sTmpTag = LCase(Trim(TheXY.GetTagName(iTags)))
            If sTmpTag = sTag Then
                ReDim Preserve vSymbols(lCount)
                vSymbols(lCount) = TheSymbol.Type & ", Point '" & iTags & "': " & CompName & TheSymbol.Name
                lCount = lCount + 1
            End If
        Next iTags
        Set XYPlot = Nothing
End Select

End Sub

Private Sub ParseComposite(ByVal TheComposite As Composite, ByVal CompName As String)

Dim Sym As Symbol
For Each Sym In TheComposite.GroupedSymbols
    Call ParseSymbol(Sym, CompName & TheComposite.Name & " - ")
Next Sym

End Sub


Principal Consultant
Real-Time Data Management @ Wipro Technologies
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.