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

Combobox and trends Options · View
lespoils
#1 Posted : Tuesday, March 15, 2011 1:20:16 PM
Rank: Newbie
Groups: Member

Joined: 3/10/2011
Posts: 9
Location: sept-iles
hi,

Second post, still a newbie.

I'm trying to fiddle around with VBA in process book. What i have in mind is to use a combobox to change the pi tag represented in a trend.

I've read around a bit on the forum and in pipbvb.chm. Saddly, i wasn't able to figure it out by myself.

Can someone direct me to code samples and/or tutorials on how to generally use pi process book and VBA.

I do not have access to the OSIsoft vCampus, as it costs money that i do not have.

All help welcomed.

Thank you
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 : Tuesday, March 15, 2011 2:40:39 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Hello,

The pipbvb.chm help file is really good once you are familiar with the objects and symbols within ProcessBook - it will become clearer for you the more you use it.
Of course there is a ProcessBook section on our forum for ProcessBook specific code examples: http://www.rjksolutionsltd.co.uk/forum/yaf_topics9_PI-Tips-and-Tricks-PIProcessBook.aspx

For you particular scenario you need to work with the "Trend" object (see "Trend Class" in pipbvb.chm), in particular the Trend Methods "AddTrace, RemoveTrace and SetTagName" methods.

For example, if you have a Trend on your display called "Trend1" and a Combobox called "cb1" then you could have the code to change the trace shown:

Code:

Private Sub cb1_Change()

Call ThisDisplay.Trend1.SetTagName(1, cb1.Text)

End Sub


Alternatively, you could do something like the following:
Code:

Private Sub cb1_Change()

For i = 1 To ThisDisplay.Trend1.TraceCount
    Call ThisDisplay.Trend1.RemoveTrace(1)
Next i
Call ThisDisplay.Trend1.AddTrace(cb1.Text)

End Sub
Principal Consultant
Real-Time Data Management @ Wipro Technologies
lespoils
#3 Posted : Tuesday, March 15, 2011 5:29:58 PM
Rank: Newbie
Groups: Member

Joined: 3/10/2011
Posts: 9
Location: sept-iles
ok thanks i'll try this when i have more time on my hands.

i do have another probly quick question to answer.
in order to use the settagname property, do i need to make a connection to the server using vb code ? i am connected from the file-connections menu, is that ok ?
we have 3 different PI servers. if i do need to specify the server, can you show a quick example ?

thanks you for your time and for beleiving i will soon be better BigGrin
Lespoils
RJK Solutions
#4 Posted : Wednesday, March 16, 2011 9:32:22 AM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Hello,

Nope you don't need to make a connection to the server, ProcessBook already handles the connections.
If your combobox you need the full path to the tag you want, which includes the servername. For example, "\\server1\sinusoid" or for another server "\\server2\sinusoid".

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.