270 likes | 512 Views
PI on the Web: A Primer for PI Users. Omicron Consulting 1998 PI System Users’ Conference. Why Put PI Data on Web Pages?. Cheap seats for occasional users Quick access net-wide Get closer to your customers. Plain Vanilla vs. Rich Presentation. Plain Vanilla Any browser, any platform
E N D
PI on the Web: A Primer for PI Users Omicron Consulting 1998 PI System Users’ Conference
Why Put PI Data on Web Pages? • Cheap seats for occasional users • Quick access net-wide • Get closer to your customers
Plain Vanilla vs. Rich Presentation • Plain Vanilla • Any browser, any platform • No special configuration at the client • Ad hoc static slice of data • Rich Presentation • Rich features of PI & COM • More muscle on the client • Configuration and licensing
Tools • Microsoft FrontPage for the gateway page • WYSIWYG editing of the table, form controls • Visual InterDev for the server • Tools for managing data sources • Code editor features for scripts
Forms 101 • Start a form: specify an action <!-- Create a form. The action is to POST the form to scripts/pi_gate.asp. --> <form action="scripts/pi_gate.asp" method="POST"> <div align="center"><center> • The values of the form fields are passed to the ASP page as <name, value> pairs
Forms 101 (cont’d) • Use an HTML table to align input fields <table border="0" cellspacing="4" width="40%" ><tr> <td width="50%"><font size="3" face="Arial"><strong>User ID:</strong></font></td> <td width="50%" ><input type="text" size="20” name="UID" value="pidemo"></td></tr> <tr> <td width="50%"><font face="Arial"><strong>Password:</strong></font></td> <td width="50%"><input type="password" size="20” name="pwd" value="pidemo"></td></tr> <tr> <td width="50%"><font size="3" face="Arial"><strong>Specify Tag:</strong></font><font face="Arial"> </font></td> • Other options: pick source names for different servers, views
Forms 101 (cont’d) • End the table, add a button to submit the form </table> </center></div><p align="center"><input type="submit" name="B1" value="Retrieve Avgs"></p> </form>
ReturnHTML RequestHTML PI HTML and ADO WWW Server Browser *.ASP IIS HTTP ADO OLEDB PI-ODBC Files
ASP: COM meets PI-ODBC • Use Active Data Objects (ADO) to manipulate ODBC on the server • Include SQL utilities <!--#include file="ADOVBS.inc"--> <!--#include file="IASUtil.asp"--> • Make a connection to an ODBC DSN ConnectionString = "dsn=PISource;UID=" & Request("UID") & ";pwd=" & Request("pwd") Set Connection = Server.CreateObject("ADODB.Connection") Connection.Open ConnectionString
ASP - ADO (cont’d) • Format and execute a query tag = SQLEncode(Request("tag")) start_time = SQLEncode(Request("start")) end_time = SQLEncode(Request("end")) SQLStmt = "SELECT value, pctgood " SQLStmt = SQLStmt & "FROM piavg " SQLStmt = SQLStmt & "WHERE tag = '" & tag & "' AND time >= DATE('" & start_time & "') " SQLStmt = SQLStmt & "AND time <= DATE('" & end_time & "') AND timestep =RELDATE(""1h"") " Set RS = Connection.Execute(SQLStmt)
ASP - ADO (cont’d) • Create table cells as you step through the data <table border="4"><caption align="top"><strong>Hourly Averages</strong></caption> <% CurrentRecord = 0 Do While CheckRS(RS) If CurrentRecord = 0 Then %> <tr> <th><b>Value</b></th> <th><b>Percent Good</b></th> </tr> <% End If %> <tr><td><%= RS("value") %></td> <td><%= RS("pctgood") %></td></tr><% RS.MoveNext CurrentRecord = CurrentRecord + 1 Loop %></table>
Plain Vanilla Part II: Displays • PI-ProcessBook 2.0 adds VBA scripting and the ability to save displays to Web related formats • Server-side app periodically saves a live display to a static-format file • ASP page generates a page with a link to the requested image
Tools • FrontPage to layout the gateway page • Visual InterDev • No visual component to the ASP, just scripts • PI-ProcessBook to configure display files, run the script
Plain Vanilla Displays: The Code <body> <% Rem Derive the proper PNG filename imgname = "../pbimgs/" + Request("Display") + ".png" Rem Save the filename for use outside this script scope Session("PNGname") = imgname %> <p><img src="<%=Session("PNGname")%>"> </p> </body>
You Are There! • Self-contained • Starting parameters are defined in the page • Displays are linked into the page • Interactive • Scripts may allow users to modify page parameters • Displays may update within the page
Requirements • Windows • Internet Explorer • PI-ProcessBook
Getting ProcessBook • Install from a self-extracting executable • Large file • Licensing issues • Add a link • <a href="pb20b2.exe">Install PI-ProcessBook 2.0</a> • Make sure the .exe is not in a directory with execute permissions
Tools • Microsoft FrontPage • WYSIWYG layout of the page • Syntax for embedded objects handled for you • PI-ProcessBook to configure display files
Embedding Displays in HTML • First embed an instance of the “PI Display Document” <object id="Display" name="Display” classid="clsid:4F26B906-2854-11D1-9597-00A0C931BFC8” border="0" width="590" height="273></object>
Get the Component • Allow for component download <object id="Display" name="Display" classid="clsid:4F26B906-2854-11D1-9597-00A0C931BFC8" codebase="pbdctrl.ocx" border="0" width="590" height="273"></object>
Specify a Display • Provide the URL of a PI-ProcessBook display file <object id="Display" name="Display" classid="clsid:4F26B906-2854-11D1-9597-00A0C931BFC8" codebase="pbdctrl.ocx" border="0" width="590" height="273"><param name="DisplayURL" valuetype="ref" value="demo.pdi"></object>
Automate the Display • Two Properties • DisplayURL to change display files • Display to access the display object model, e.g., MyDisplay.Display.SetTimeRange “*-4h”, “*-1h”
Security Issues • Plain vanilla • Security is controlled on the server • ASPs must have script or execute permission • ISAPI DLLs must have execute permission • No special requirements for the client • Rich Presentation • Open the PI port number in the firewall to update a display outside the firewall
Summary • Pick a Suitable Model • Create ASPs or HTML • Support configuration • PI-ProcessBook network installation • Display component download • Security Issues • Create display files if needed