|
|
Rank: Member Groups: Member
Joined: 5/11/2010 Posts: 10 Location: Malaysia
|
Hi,
Are there any guidelines with reference to the above? I've 2 modes of operations for different products specs, which therefore have different sets of limits and tags for monitoring. I would like to create a macro where operations could just click the button upon mode change and all the exisiting monitoring trends (plot title, tags and limits) will switch to the current mode of operations.
Thanks.
Best Regards, SW
|
|
|
|
|
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.
|
|
|
Rank: Member Groups: Member
Joined: 10/1/2008 Posts: 22 Location: Romania
|
Here is an example for changing text and color based on the value of a tag (this is a tag that provides me the information about unit operating mode, because my unit has 2 modes : KERO and DIESEL)
Option Explicit
Dim y As Integer
Private Sub Display_Open()
ThisDisplay.Zoom = "FitAll" ' zoom to fit
Value_mod.SetTagName ("\\Server Name\" & "Tag name")
y = Value_mod.GetValue(Value_mod.DisplayTimeStamp, 1)
If y = 1 Then
ThisDisplay.TextBox1.Text = "KERO”
ThisDisplay.Txt_feed_d.Contents = "KERO from Tank A "
ThisDisplay.Txt_ feed_k.Contents = " KERO from Tank B "
Txt_ feed_k.BackgroundColor = RGB(0, 255, 0)
Txt_ feed_d.BackgroundColor = RGB(0, 255, 0)
End If
If y = 0 Then
ThisDisplay.TextBox1.Text = "DIESEL"
ThisDisplay.Txt_ feed_d.Contents = "DIESEL from Tank C "
ThisDisplay.Txt_ feed_k.Contents = " DIESEL from Tank D "
Txt_ feed_d.BackgroundColor = RGB(0, 255, 0)
Txt_ feed_k.BackgroundColor = RGB(255, 255, 255)
End If
End Sub
if you do not have tag to provide you info about the mode, you can use a button (name it “myBUT”) in the display and put THE CODE under : Private Sub myBUT_Click(ByVal lvarX As Long, ByVal lvarY As Long) ……. End Sub
Regards, Ana
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Steve, Do you have an AF server at your disposal? You may be able to use ERD (Element Relative Displays) to do what you need if I have understood you correctly. Alternatively, you will need some VBA like Ana-Maria has posted to change the trend title, and change the trace of a trend. If you want to change the PI Calculation Data then you need to manipulate DataSets in VBA - is this what you meant? Cheers. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 5/11/2010 Posts: 10 Location: Malaysia
|
Thanks a lots for the replies Ana and Rhys. Probably it wasn't clear in my first post, I've 2 modes of operation namely A and B therefore the product specification monitoring tags for these 2 different modes are also available in 2 modes e.g. 10A001A.PV and 10A001B.PV. I would like to create 2 buttons A and B, in which case when the operations are required to operate at mode A, they can just click on button A and then: 1. The tags for existing monitoring trends will change from 10A001B.PV to 10A001A.PV 2. The plot titles for the existing monitoring trends will change from "Product B Specs" to "Product A Specs" 3. The limits (which are created using PI calculation) will change from e.g. 120 degC (limit for mode B) to 100 degC (limit for mode A)
And, vice versa for mode change from mode A to mode B by clicking the button B. Can this be done by simply using VBA?
Thanks
Best Regards, SW
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/28/2009 Posts: 75 Location: Cheshire, UK
|
stvpsw, if i'm not missing the obvious this seems like a simple task of creating two seperate PB Entries in a processbook, one display for each mode of operation and clearly formatted to differentiate them. A button could toggle between them. If there is a lot of data in each display then keep both open for better performance and toggle with Ctrl-Tab or again a button with VBA perhaps. MilesUK ProcessBook v3.0.15.3
|
|
|
Rank: Member Groups: Member
Joined: 5/11/2010 Posts: 10 Location: Malaysia
|
Thanks a lots milesUK for your replies that's the easiest way am working towards that direction with a little VBA to switch between the pages and I tried Ana's code as below
Sub Macro2()
Dim y As Integer
Value.SetTagName ("\\BIN0103\40T033.PV") y = Value.GetPIValue(Value_mod.DisplayTimeStamp, 1)
If y > 290 Then
Application.Displays.Open ("c:\pipc\procbook\displayABC.pdi",True) Else
Application.Displays.Open ("c:\pipc\procbook\displayDEF.pdi",True)
End If
End Sub
But the "run-time error '424': Object required " msg keep popping up, can anyone pls help on this? I'm trying to get the current PI value from a particular tag as the condition to decide which PI files to be opened when the user click the button.
Thanks!
Regards, SW
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
stvpsw wrote: Sub Macro2()
Dim y As Integer
Value.SetTagName ("\\BIN0103\40T033.PV") y = Value.GetPIValue(Value_mod.DisplayTimeStamp, 1)
Using GetPIValue will return a PISDK.PIValue object, you need to use the GetValue method instead. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
|
Guest
|