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

Moving element based on pi tag Options · View
civatrix
#1 Posted : Friday, January 15, 2010 1:40:42 PM
Rank: Newbie
Groups: Member

Joined: 1/14/2010
Posts: 7
I have a display file for a hoist and I would like to be able to move the bucket up and down the screen based on a depth tag being recorded in PI. I have a fairly strong programming background so I'm pretty sure I can figure the logic out for my self. I'm more looking specific syntax for accessing pi tags and manipulating objects.

Thanks,
Civatrix
Sponsor  
 
RJK Solutions
#2 Posted : Friday, January 15, 2010 7:27:06 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 409
Location: Cheshire, United Kingdom.
Hi Civatrix,

Welcome to the forum.

There are a couple of options at your disposal, depends how you want to do it.
If you have a Value symbol on your display, you can get the PI tag name being used and the value being displayed. This is all achieved without any other references.
The other option is to have a reference to PISDK and access data that way, then manipulate the symbols.

Symbols on a display are all placed using Top, Left, Width, Height - a Display's top left corner starts at (-15000,15000) (Left, Top). Left increases to the right and Top decreases down.

I did a quick example with some VBA code so you get the idea of manipulating with just ProcessBook object and symbol libraries.

Code:

Private Sub HOISTHEIGHT_DataUpdate()

Const Multiplier As Integer = 20

' Get the value of the Value symbol "HoistHeight"
Dim vValue As Double, vStatus As Variant
vValue = ThisDisplay.HOISTHEIGHT.GetValue("*", vStatus)

' For specific methods of a value symbol you cast the Symbol to type Value symbol.
Dim ValueSymbol As Value
Set ValueSymbol = ThisDisplay.HOISTHEIGHT
    vValue = ValueSymbol.GetValue("*", vStatus)
Set ValueSymbol = Nothing

' Next, set the height of the Line symbol
Dim LineSymbol As Line
Set LineSymbol = ThisDisplay.HOIST
    ' Set the hoist height, we will use multiplier for visual effect
    LineSymbol.Height = vValue * Multiplier
   
' Now move the bucket to the end of the hoist
Dim Bucket As Rectangle
Set Bucket = ThisDisplay.Symbols("HOISTBUCKET")
    Bucket.Top = (LineSymbol.Top - LineSymbol.Height)
    Bucket.Left = (LineSymbol.Left + (LineSymbol.Width / 2)) - (Bucket.Width / 2)
Set Bucket = Nothing

Set LineSymbol = Nothing

End Sub


For this I just used "sinusoid" as the Hoist Height value and added a Value symbol named "HOISTHEIGHT". I added a Line symbol name "HOIST" and a Rectangle symbol named "HOISTBUCKET".

You could also use some tricks with a Bar symbol to simulate the hoist cable...I'll leave that one for now to see if this is along the lines of what you were after.
RJK Solutions attached the following image(s):
ProcessBook_Hoist.jpg (23kb) downloaded 7 time(s).


OSIsoft PI System Specialists
PI consultancy on PI Systems, PISDK, AFSDK, OLEDB etc and PI custom developments. Well pretty much anything to do with PI!


civatrix
#3 Posted : Friday, January 15, 2010 9:14:59 PM
Rank: Newbie
Groups: Member

Joined: 1/14/2010
Posts: 7
This is exactly what I wanted, thanks a lot. But one more thing.

How do I get my display to continuously run this code?

Thanks,
Civatrix
RJK Solutions
#4 Posted : Friday, January 15, 2010 9:24:53 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 409
Location: Cheshire, United Kingdom.
Sorry I forgot to explain one more thing.

I placed the code within the "DataUpdate" event of the "HOISTHEIGHT" symbol, so whenever ProcessBook delivers new data for that Value symbol, it triggers the event. So as the data changes, the Hoist will move the bucket.

There are a series of events associated with a ProcessBook symbol and with a display.
Alternatively you could run this code from the "Display_DataUpdate" event and check for new data but it is more efficient to run it from the actual Value symbol's event.

As a reference, OSI made a great document to help you as you dig deeper with ProcessBook manipulation (oh and don't forget to post back on here Smile ), it is "..\PIPC\Help\pipbvb.chm".

Cheers,

Rhys.



OSIsoft PI System Specialists
PI consultancy on PI Systems, PISDK, AFSDK, OLEDB etc and PI custom developments. Well pretty much anything to do with PI!


civatrix
#5 Posted : Friday, January 15, 2010 10:02:59 PM
Rank: Newbie
Groups: Member

Joined: 1/14/2010
Posts: 7
Wow, thanks a lot for the quick reply. Again exactly what I needed.

Thanks
Civatrix
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.