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

Populating a process book display with multi-state textboxes with contents and tags in excel Options · View
Keegan
#1 Posted : Wednesday, December 01, 2010 10:26:49 PM
Rank: Newbie
Groups: Member

Joined: 11/30/2010
Posts: 4
Location: Melbourne
Hey guys since I am not progressing from reading the other post I was wondering if anbody could help me out.

What I want to do is to create a display that will the monitior whether or not our chart recorders, plcs, pc, serves etc. are connected and running. I can do this manually through creating a textbox and making it multistate so when it is not connected (bad data) the text is red and blinking. Otherwise the text remains black.

The problem is there is 300+ different tags that we want to monitior. So manually will take a while.

Could anyone help us out with some sample code?

I have created an excel spreadsheet with the tag name in one column and the text to go into the text box in another (which is just the tag name and ip address).

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 : Thursday, December 02, 2010 1:40:22 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Here you go, it loaded 300 random tags with random text in a few seconds:

Code:

Sub LoadTagsAsSymbols()

Dim XL As Excel.Application
Set XL = New Excel.Application

Dim WB As Excel.Workbook
Set WB = XL.Workbooks.Open("C:\LoadTags.xlsx")

Dim WS As Worksheet
Set WS = WB.Worksheets("TAGS")

Dim Val As Text
Dim i As Integer, iLeft As Integer, iTop As Integer

iLeft = -15000: iTop = 15000

For i = 1 To 1000
    If WS.Range("A" & i).Value = "" Then Exit For
   
    Set Val = ThisDisplay.Symbols.Add(pbSymbolText)
        Val.Left = iLeft
        Val.Top = iTop
        Val.Contents = WS.Range("B" & i).Value
       
        If (iTop - Val.Height - 5) < (ThisDisplay.ViewTop - ThisDisplay.ViewHeight) Then
            iTop = 15000
            iLeft = iLeft + Val.Width + 1
        Else
            iTop = iTop - Val.Height - 5
        End If

        Dim MSS As MultiState
        Set MSS = Val.CreateMultiState(WS.Range("A" & i).Value)
            MSS.BlinkBadData = True
            MSS.ColorBadData = pbRed
           
        Dim MS As MSState, iMS As Integer
        For iMS = 1 To MSS.StateCount
            Set MS = MSS.GetState(iMS)
                MS.Blink = False
                MS.Color = pbBlack
            Set MS = Nothing
        Next iMS
       
        Set MSS = Nothing
    Set Val = Nothing
Next i

Set WS = Nothing

Call WB.Close(False)
Set WB = Nothing

XL.Quit
Set XL = Nothing

End Sub


Personally, I would probably create a series of small squares that are Green or Red. Then you can visually see problem areas quickly and zoom in on those areas - assuming you group the squares logically.

Anyway...enjoy!
Principal Consultant
Real-Time Data Management @ Wipro Technologies
Keegan
#3 Posted : Thursday, December 02, 2010 8:26:58 PM
Rank: Newbie
Groups: Member

Joined: 11/30/2010
Posts: 4
Location: Melbourne
Thank you so much for your help.

It worked a treat and saved me so much time.

Again Thanks
ThumbsUp
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.