Discover How to Programmatically Generate PI Coresight Displays with

Discover How to Programmatically
Generate PI Coresight Displays with
the Right Data Items and Time Range
Michael Weiss, OSIsoft
Agenda
•
•
•
•
•
What is PI Coresight?
Integrating with PI Coresight
Code sample
PI ProcessBook Add-In sample
Discussion
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
2
What is PI Coresight?
PI Coresight is an intuitive, web-based tool that
delivers fast, easy, and secure access to all your
PI System data.
With PI Coresight you can easily perform ad hoc
analysis, discover answers, and share your
insights with others.
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
3
PI Coresight Architecture
•
Silverlight User Interface
•
Web Services in middle tier
•
PI System and SQL Server
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
4
PI Coresight Demo
Watch for…
•
•
•
“Displays”
“Symbols”
The URLs in the browser
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
5
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
6
Why Integrate?
Allows a user to quickly open “interesting” data in
PI Coresight without requiring a preexisting
display or manual work.
• Selected data items in PI Process Book, PI
DataLink, PI WebParts, PI Notification (likely
future features available from OSIsoft)
• Custom applications
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
7
Building a sample application
1.
Find and connect to the PI Coresight Web
Service
2.
Make the Web Service call to create a display
3.
Open the Display
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
8
Step 1: Find and Connect
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
9
Find and connect to service
•
•
•
We’ll need the URLs to both UI website and
the Web Services
Stored in site’s default PI AF server by PI
Coresight installer
PI AF Path:
\\AFServer\Configuration\OSIsoft\PI Coresight | Coresight URL
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
10
Find and connect - Authentication
•
Any application that connects to the PI
Coresight Web Services must support
Windows Authentication.
•
By default the authentication mode is
“Negotiate” (Kerberos).
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
11
Adding a Web Service Reference
•
.NET applications require a Web Reference
in order to call the Web Service.
•
Other platforms may require a similar step.
•
http://<yourwebserver>/Coresight/Services/St
orage/CoresightStorage.svc
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
12
Web Reference, continued
Add the bolded line temporarily to
Coresight\Services\Web.config:
…
<serviceBehaviors>
<behavior name="CoresightBehavior">
<serviceThrottling …/>
<serviceMetadata httpGetEnabled="true" />
</behavior>
…
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
13
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
14
Step 2: Make the call
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
15
Making the call - NewAdHocDisplay
NewDisplayInfo NewAdHocDisplay (
string cog,
string namePrefix,
AccessLevel level )
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
16
The COG
•
•
•
•
•
A common way to share data and context
between PI System applications
By data we mean PI Tags and/or PI AF Attributes
grouped into an abstract symbols
By context we mean a time range
XML
Focus on the COG features PI Coresight Trends
support
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
17
Major COG elements
Databases
A list of PI System and PI AF servers
Datasources
PI Tags or AF Elements (links to a Database)
Symbols
Groups of Datasources (links to one or more Datasources)
Context
Time ranges (links to nothing, for whole Display)
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
18
COG Structure
Databases
PI
Id = “1”
AF
Id = “2”
1 per unique PI
Server or PI AF
Database
Datasources
PIData
DbRef=“1”
Tag
Id=“Tag1”
Symbols
AFData
DbRef=“2”
Symbol
Id=“s1”
AFAttribute
Id=“Attrib1”
Datasource
Id=“Tag1”
1 per Trend
symbol, multiple
children =
multiple Traces
1 pair per unique Tag or Attribute
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
19
COG Time
• Under an XML Tag: <Context><TimeRange>
• Date and Time (Rfc3339)
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'FFFFFFFK"
• Just time
"HH':'mm':'ss'.'FFFFFFFK“
• Or PI’s relative time notation (“*”, “*-8h”, etc)
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
20
The other parameters
Name Prefix
The name of the new Display. PI Coresight will append a
unique number to this name.
Access Level
Should the new Display be Public (anyone can view) or
Private (accessible only by the author).
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
21
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
22
Step 3: Open the Display
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
23
Opening the Display
•
•
•
Web Service call returns new Id
Create a URL
Email it
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
24
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
25
Not shown
•
•
•
•
•
Calling Establish
Localization support
Client GUIDs
XSD Validation
Programmatically creating COGs
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
26
PI ProcessBook Add-in
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
27
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
28
What’s subject to change?
Endpoints
– The paths of the URLs may change
– AF Configuration may include additional URLs
– Method calls intended for external consumption may be
grouped together into a single “endpoint”
Code
– Expect code libraries (if provided) and XSDs will be updated.
Service References may need a refresh.
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C
29
Thank you
©
C o p y r i g h t
2 0 1 1
O S I s o f t ,
L L C