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

Making a selector switch visible only on TRUE state of tag return Options · View
andyevs
#1 Posted : Sunday, July 10, 2011 5:16:08 PM
Rank: Newbie
Groups: Member

Joined: 7/10/2011
Posts: 6
Location: Pembrokeshire
Hi,

I'm very new to all this ProcessBook so please excuse my ignorrance Smile

I'm in the process of putting together a few displays for my company. Most of the plant items we are looking at are in the on/off state.
The displays I have created so far are very basic and just return a multistate red or green indication.

I'd like to use a left and right selector switch to indicate which pump is in service, i.e. if pump A is running then the selector switch will point to the left and if pump B is running the switch points to the right to mimic our ouside local controls. Only one pump will be running at any one time.

I assume this will take some VBA script to make one not visible but I have no idea on that.

I hope someone can help.

Thank you in advance,

Andy
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.
milesUK
#2 Posted : Monday, July 11, 2011 1:00:25 PM
Rank: Advanced Member
Groups: Member

Joined: 5/28/2009
Posts: 75
Location: Cheshire, UK
Andy, welcome to PI and the board.

It's a pity that Multistate cannot be applied to graphic elements in a display. However you can, it seems, have Multistate graphics from the Symbol Library.

You could for instance have two pump symbols and 'grey' out the none working pump. or use the valve symbol perhaps overlaying one on top of the other and making one invisible and the other not (and vice versa) depending on the tag's on/off state.

Once you have the seeds of the idea I'm sure that your imagination will take over.

Happy display building,

Miles
MilesUK
ProcessBook v3.0.15.3
andyevs
#3 Posted : Monday, July 11, 2011 1:24:54 PM
Rank: Newbie
Groups: Member

Joined: 7/10/2011
Posts: 6
Location: Pembrokeshire
Thanks for the reply.

How would I go about making one invisible if I overlay two symbols?

Cheers,

And
milesUK
#4 Posted : Tuesday, July 12, 2011 9:33:54 AM
Rank: Advanced Member
Groups: Member

Joined: 5/28/2009
Posts: 75
Location: Cheshire, UK
Andy, I must admit to not really trying this out yesterday but I have just done a bit more.d'oh!

My idea was to use Multistate to toggle the colour of the pump between 'none' and normal. However 'none' reverts the pump to its default colours.

HOWEVER!
Contrary to what the Help pages say Multistate CAN be applied to graphics (lines, arcs, etc). BigGrin

Using this we can either:

lay down a line to represent the selector switch (or even draw your own) and change its colour based on the tag value

OR
Lay down a Symbol but overlay it with a rectangle that Multistate's between 'None' and background colour giving the impression that the pump 'disappears'.Smile

Might also be able to use VBA to horizontally or vertically flip a switch Symbol based on tag value. Don't know if VBA can be triggered by a tag change. Other the VBA code would have to run frequently to check.

Food for thought.

Miles
MilesUK
ProcessBook v3.0.15.3
squatty
#5 Posted : Tuesday, July 12, 2011 12:55:27 PM
Rank: Advanced Member

Groups: Member

Joined: 4/7/2011
Posts: 137
Location: KZN, South Africa
We also use VBA to switch between symbol library objects.

Create a display and add 6 "3D Green button (not pressed)" objects. Enable scripting on all the objects. Rename them CONDITION1......CONDITION6
Add 6 tags, in our case these are showing On/Off. Enable scripting and rename them Value1....Value6

You can now copy and paste this code in VBA and execute from any event, display_open and display_dataupdate. Keep track of the TBHandle values has each and every object in the library are different.

This code will change the object to Green->On and Red->Off and Grey->anything else (error). This is not a multistate, it is actually changing the object. If you want to be fancy you can now change the visible property to FALSE for Value1.....Value6

'GREEN = 1986299464
'RED = 1753925452
'ERROR = 1396866104

'COMMENT THIS PART IF NOT NEEDED
ThisDisplay.Width = 644
ThisDisplay.Height = 285
ThisDisplay.Top = 200
ThisDisplay.Left = 100
'****************

'CONDITION1
If ThisDisplay.Symbols.Item("Value1").GetValue(vrdate, vrstatus) = "On" Then
ThisDisplay.CONDITION1.TBHandle = 1986299464
Else
If ThisDisplay.Symbols.Item("Value1").GetValue(vrdate, vrstatus) = "Off" Then
ThisDisplay.CONDITION1.TBHandle = 1753925452
Else
ThisDisplay.CONDITION1.TBHandle = 1396866104
End If
End If

'CONDITION2
If ThisDisplay.Symbols.Item("Value2").GetValue(vrdate, vrstatus) = "On" Then
ThisDisplay.CONDITION2.TBHandle = 1986299464
Else
If ThisDisplay.Symbols.Item("Value2").GetValue(vrdate, vrstatus) = "Off" Then
ThisDisplay.CONDITION2.TBHandle = 1753925452
Else
ThisDisplay.CONDITION2.TBHandle = 1396866104
End If
End If

'CONDITION3
If ThisDisplay.Symbols.Item("Value3").GetValue(vrdate, vrstatus) = "On" Then
ThisDisplay.CONDITION3.TBHandle = 1986299464
Else
If ThisDisplay.Symbols.Item("Value3").GetValue(vrdate, vrstatus) = "Off" Then
ThisDisplay.CONDITION3.TBHandle = 1753925452
Else
ThisDisplay.CONDITION3.TBHandle = 1396866104
End If
End If

'CONDITION4
If ThisDisplay.Symbols.Item("Value4").GetValue(vrdate, vrstatus) = "On" Then
ThisDisplay.CONDITION4.TBHandle = 1986299464
Else
If ThisDisplay.Symbols.Item("Value4").GetValue(vrdate, vrstatus) = "Off" Then
ThisDisplay.CONDITION4.TBHandle = 1753925452
Else
ThisDisplay.CONDITION4.TBHandle = 1396866104
End If
End If

'CONDITION5
If ThisDisplay.Symbols.Item("Value5").GetValue(vrdate, vrstatus) = "On" Then
ThisDisplay.CONDITION5.TBHandle = 1986299464
Else
If ThisDisplay.Symbols.Item("Value5").GetValue(vrdate, vrstatus) = "Off" Then
ThisDisplay.CONDITION5.TBHandle = 1753925452
Else
ThisDisplay.CONDITION5.TBHandle = 1396866104
End If
End If

'CONDITION6
If ThisDisplay.Symbols.Item("Value6").GetValue(vrdate, vrstatus) = "On" Then
ThisDisplay.CONDITION6.TBHandle = 1986299464
Else
If ThisDisplay.Symbols.Item("Value6").GetValue(vrdate, vrstatus) = "Off" Then
ThisDisplay.CONDITION6.TBHandle = 1753925452
Else
ThisDisplay.CONDITION6.TBHandle = 1396866104
End If
End If
andyevs
#6 Posted : Tuesday, July 12, 2011 2:27:39 PM
Rank: Newbie
Groups: Member

Joined: 7/10/2011
Posts: 6
Location: Pembrokeshire
Thanks for the help guys.

I've tried the code but it keeps coming up with a compile error on the vrdate and vrstatus. Any ideas what may be causing this?

Andy
squatty
#7 Posted : Tuesday, July 12, 2011 2:35:42 PM
Rank: Advanced Member

Groups: Member

Joined: 4/7/2011
Posts: 137
Location: KZN, South Africa
What version of PI-SDK are you using?
ProcessBook version?

Did you add tags/values to the display and renamed them accordingly?

If you did add tags, what type of tags digital or float, if you added float tags you should change the code accordly as this was designed for digital tags.

'CONDITION1
If ThisDisplay.Symbols.Item("Value1").GetValue(vrdate, vrstatus) >= 123 Then
ThisDisplay.CONDITION1.TBHandle = 1986299464
Else
If ThisDisplay.Symbols.Item("Value1").GetValue(vrdate, vrstatus) < 123 Then
ThisDisplay.CONDITION1.TBHandle = 1753925452
Else
ThisDisplay.CONDITION1.TBHandle = 1396866104
End If
End If

andyevs
#8 Posted : Tuesday, July 12, 2011 2:46:09 PM
Rank: Newbie
Groups: Member

Joined: 7/10/2011
Posts: 6
Location: Pembrokeshire
I'm using version 1.3.3

I did add tags and values and they automatically came up named Value1 etc.

They were also digital so "ON", "OFF".

When I go into the code properties of GetValue, it doesn't show anything related to vrdate or vrstatus?




squatty
#9 Posted : Wednesday, July 13, 2011 7:20:29 AM
Rank: Advanced Member

Groups: Member

Joined: 4/7/2011
Posts: 137
Location: KZN, South Africa
Andyevs, we are using SDK 1.3.8.388 which COULD explain the issues you are having. Is it possible that you can update your SDK on a test machine and see if this solves the problems.

You can also try and declare vrDate and vrStatus. Below you will see an extract from the PI ProcessBook VBA reference.

Dim vrDate As Variant
Dim vrStatus as Variant
Dim MyValue as Variant


MyValue = Value.GetValue(vrDate, vrStatus) 'Value is your actual symbol in processbook
MsgBox "Value: " + CStr(MyValue)
MsgBox "Date: " + CStr(vrDate) + ", Status: " + CStr(vrStatus)
milesUK
#10 Posted : Wednesday, July 13, 2011 9:30:47 AM
Rank: Advanced Member
Groups: Member

Joined: 5/28/2009
Posts: 75
Location: Cheshire, UK
andy, when you added the Symbols to the display did you rename those. I think that is what squatty implied.

Quote:
Create a display and add 6 "3D Green button (not pressed)" objects. Enable scripting on all the objects. Rename them CONDITION1......CONDITION6

miles
MilesUK
ProcessBook v3.0.15.3
squatty
#11 Posted : Wednesday, July 13, 2011 9:37:47 AM
Rank: Advanced Member

Groups: Member

Joined: 4/7/2011
Posts: 137
Location: KZN, South Africa
Just a question, we can't upload images here from work, say thank you to the proxy server for that. Is there any other way we can upload images to the forums?

milesUK, thxs for pointing out the renaming of the Objects?
RJK Solutions
#12 Posted : Wednesday, July 13, 2011 2:20:20 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Another option with minimal VBA code, hooking in to the multistate events of a symbol.

Add a rectangle, name it "SELECTOR_TRIGGER". Multistate it with your tag and set the states.
Now add the "Selector Switch 1 (left)" symbol to the display and name it "SELECTOR_SWITCH".

Then in the VBA editor you can react to changes in the states:

Code:

Private Sub SELECTOR_TRIGGER_StateChanged(bCancelDefault As Boolean)

Select Case SELECTOR_TRIGGER.GetMultiState.CurrentState
    Case 0: SELECTOR_SWITCH.TBHandle = 1726525040 ' LEFT
    Case 1: SELECTOR_SWITCH.TBHandle = 528880497 ' RIGHT
End Select

End Sub


If you have more than one of these on a display, then just wrap them up in to a more general method where you pass the symbol name that just changed state.
Principal Consultant
Real-Time Data Management @ Wipro Technologies
andyevs
#13 Posted : Wednesday, July 13, 2011 5:24:10 PM
Rank: Newbie
Groups: Member

Joined: 7/10/2011
Posts: 6
Location: Pembrokeshire
Thank you so much for all the help.
RJK, this is the perfect solution for my problem. It works a treat. ThumbsUp

I dare say I'll be back on here with more questions in the near future.
RJK Solutions
#14 Posted : Wednesday, July 13, 2011 9:43:03 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
No problem BigGrin
Feel free to come back with even more questions.
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.