I can think of 2 ways to do this.
1) Use PI ActiveView, which allows users to view and interact with ProcessBook Displays outside of PI ProcessBook. You can add PI ActiveView Control (which is an COM Component) and add it to your form. You just need to edit the property of the object to give it a displayurl (a pointer to your ProcessBook display.
2) If you do not have PI ActiveView (which is not included in the vCampus PI Products Kit) then another way is to create your own ActiveX from PI ProcessBook Display Control, referring to this blog post by Andreas. Step 7 indicates how to create the managed wrapper with PI ProcessBook Display Control, and you can add a reference to that in your C# project and load the display file to one of your tab pages at runtime.
This is a slight variation from Andreas' code to do so:
AxHost _pbDisplay = new AxPBDCtrl.AxPbd();
IntPtr forceCreation = _pbDisplay.Handle;
_pbDisplay.Dock = DockStyle.Fill;
AxPBDCtrl.AxPbd _AxPbd = (AxPBDCtrl.AxPbd)_pbDisplay;
_AxPbd.DisplayURL = @"C:\Users\hanyong\Documents\Display1.pdi";
Thanks to Andreas for his wonderful example on creating a Preview Handler for ProcessBook Display.
Thanks! #2 was the tip I needed.
A couple of other related questions;
1. Is there a way to launch or set the PI ProcessBook Control automation server as hidden? On the Windows taskbar I get a visible instance of the Processbook application and I would like to hide that.
2. After closing my application, the ProcessBook automation instance stays loaded even though the display control has been disposed and the variable has been set to null. Is there a simple way to release or unload the Processbook server?
Figured out #1 - just need to retrieve the Application object from the Display object, then set the Application.Visible = false;
Now for #2, I have to figure out what object is holding the Application open or forcefully call the Application.Quit method when I exit. Don't really want to call quit in case later I have multiple apps accessing the same automation server.
Since ProcessBook is running as a seperate application in this case, only by calling Quit() method will it exit. I guess another way you can do is to check whether there are still any displays (pdi) or ProcessBook (piw) opened in the application. If not then you can just call the Quit() method. I am assuming even if there are multiple apps access it, they will open up different display files.
Ummm, true: PI ActiveView isn't part of vCampus by itself, but _is_ part of the ProcessBook install - namely in the PBDCtrl.ocx control mentioned above. And I had a PDI file up and displaying in a C# Win Forms app in about 5 minutes - it's THAT easy. I didn't have to create a user control - just added the OCX to the VS Toolbox, then dragged an instance onto a form.
I don't know what the licencing ramifications are of this (very likely an end-user machine needs a license of some sort), but this will at least allow you see how the ActiveView control works.
I'm the Product Manager for PI ProcessBook and PI ActiveView. Your lovely hosts asked me to weigh in on this thread some... so here goes.
It is true that the OCX is delivered both with PI ProcessBook and PI ActiveView. However, the development on this component is very much driven by the PI ActiveView code.
To clarify somewhat, bear with me while I explain the high-level relationship among these things. PI ProcessBook and PI ActiveView share the same codebase. Essentially, new features in the core ProcessBook application get rolled into ActiveView by default unless they are specifically coded out (I belive they use something like an IFDEF statement in the ActiveView code).
The OCX, as you know, is an ActiveX control and relies on an executable to be its OLE Server. By default, the OCX will look for the ActiveView executable (acview.exe), for which it is optimized. When it finds that, there are some things that happen with caching and keeping the exe active, etcetera. Only one exe is launched regardless of how many OCX calls are made, thereby optimizing system resource usage. The URL properties are also designed to work with the acview.exe and you don't see a Task Bar icon when acview.exe is used. If the acview.exe is not found, then the procbook.exe (ProcessBook executable) will be used, but in that case you will see the Task Bar icon. This is an indication that you don't have the acview.exe installed. The behavior is different when the procbook.exe is used and we generally don't recommend that you use the OCX this way.
I hope this is somewhat helpful.
OSIsoft Product Manager
One further note: there is a registry setting for PI ActiveView that determines how long the EXE stays resident once the calling OCX controls are closed. ProcessBook doesn't have this setting.
Just to follow up on Laurie’s comments. PI ActiveView will give best results with the pbdCtrl.ocx - among the topics discussed here
- With ActiveView nothing appears on the task bar
- After the last instance of the pbdCtrl is closed the ActiveView executable will automatically close after five minutes
One other difference is that ActiveView will do a Fit-all when the display is opened. Also with the pbdCtrl you cannot edit a display.
Are there any examples of using ActiveView in a web form/application (ideally ASP.NET) with the ability to pass some values (a string and a couple datetime values) to the display during runtime, either from codebehind or client side scripting?
I would refer you to this post by Steve some time ago. As mentioned, you can find the examples to embed ActiveView into a web page using HTML 'object' tags.
As for your requirement of passing values to the display, you can access the object model Display of PI ActiveView control using vbscipt.
One example to set the display time range when the page is loaded:
<script language="vbscript" type="text/vbscript">
Pbd1.Display.SetTimeRange "*-4h", "*-1h"
<object ID="Pbd1" WIDTH="90%" HEIGHT="90%" CLASSID="CLSID:4F26B906-2854-11D1-9597-00A0C931BFC8">
<param name = "DisplayUrl" value="<link to your pdi file>"/>
You can also access the symbols and perform task like adding trace to a trend by:
You can see that accessing the object model of the Display is similar to how you would do it in VBA programming on ProcessBook. One way to do this is to try doing what you want in VBA on ProcessBook and convert it to vbscript appropriately.
If you have more questions on this, you can start a new discussion thread, since your question is quite different from the original question that started this thread.
Hope this helps
I had hoped it might be that simple on first attempt, but seems that accessing anything other than the standard object properties throws up an error. In this case when trying to access the Display property as you have above, the following error is presented:
Error: Object required: 'Pbd1.Display'
Can you let us know what you are trying to access from the PI ActiveView display. And also what is the code and .pdi file that you are using? Then it might be easier for us to figure out why you are getting the error.
Just trying to access a simple PDI. The PDI at the moment doesn't have much in it, a text object and trend object with sinusoid tag, no code behind at this point.
The code I'm using is basically a copy of your first snippet above with DisplayURL of my PDI. Which does load by the way. Even if I call the DisplayURL method on the page load event, that works. But referencing other .Display properties fails.
I was trying to see if based on users selection on a web page list/query result I could call up an activeview object and pass it a string - substation name in this case, and a date range.
I guess i have to ask you to post the exact code that you are using to find out why can be causing an error. In my testing, I tried to use the same methods to access other contents within a display as well. It has been working for me:
<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="testactiveviewaspnet._Default" %>
<head id="Head1" runat="server">
<script language="vbscript" type="text/vbscript">
Pbd1.Display.SetTimeRange "*-4h", "*-1h"
Pbd1.Display.Symbols.item("Text1").Contents = "Set CDT158"
PI ActiveView with VBScript
<param name = "DisplayUrl" value="http://localhost:26657/Trend.pdi"/>
<input type="button" value="Add Sinusoid" onclick="Add_Sinusoid_onClick()" />
<input type="button" value="Remove Sinusoid" onclick="Remove_Sinusoid_onClick()" /><br />
<input type="button" value="Change Time Range" onclick="Change_Time_Range_onClick()" /><br />
<input type="button" value="Edit Text In Display" onclick="Edit_Text_onClick()" />
The display file that i've used in the ActiveView control is attached.
trend.pdi 19.0 KB
Thanks! I've found the problem. Trying to access the objects properties/methods on the onLoad event of the page/window is probably not the way to go, as it can take a few seconds for the display to actually load after the page load event. Should've realised this sooner as we have similar challenges where we utilise some VBscript to call up Displays from our SCADA system. So will be re-thinking the approach there.
Thanks for taking the time to put that together. Worth putting that in the PI ActiveView user guide or library.
Great that you have this figure out
Thanks for the suggestion on the example. I'll look into documenting it.