PI Software Development Kit PI-SDK
Dec 23, 2015
PI Software Development Kit
PI-SDK
Agenda
The expanded class hierarchyData access with the PI-SDKThe PITimeServer libraryMulti-threading and the PI-SDKOSI and the PI-SDKTroubleshooting tipsComing attractionsQuestions
Class Hierarchy
PI-SDK 1.0 The current release
PI-SDK 1.1 PI-Batch and the Module Database
PI-SDK 2.0 Data Access
PI-SDK 1.0PISDK
PISDKVersion
PointAttribute
NamedValues
NamedValue
DigitalState
MessageLog
LogMessages
LogMessage
AliasesPathAliases
Servers
StateSet
AttributeSets
PointClass
PIPoints
PIPoint
PointAttributes
PointClasses
PIGroup
PIUser
StateSets
ServerVersion
PIGroups
PIUsers
Server
PIContexts
PointList
PI-SDK 1.1
AllPIModulesPIBatch
PIBatchDB
PIBatchList
PIHeading
PIHeadings PIModuleDB
PIModuleTemplates
PIProducts
PIProductTemplates
PIProperties
PIPropertyPISubBatch
PISubBatchDefinitions
PISubBatches
PITransferRecord
PITransferRecordDB
PITransferRecordList
PIUnitBatches
Server
PIModules
PIUnitBatchPISubBatchDefinition
PIAliases
PIAlias
PIProduct
PIModule PIUnitBatchRules
PIProductTemplate
PIModuleTemplate
PIUnitBatchList
PI-SDK 2.0
PIValue
PIValues
PointValue
PointValueList
PointValueLists
PointValues
EventPipe
PIPoint
ExceptionSpecs
Data
PIPoints
Server
ListData
PointList
Data Access with the PI-SDK
PIData and ListData The access paths
Value FormatWhat do values look like now?
PIValues capabilitiesWhat can I do with the values?
Writing Values
PIData
PIPoint
DataSnapshot : PIValueUseExceptions : Boolean = TRUELastValueChecked : PIValueLastValueSent : PIValueParent : PIPointCollecting : Boolean = falseRetrievalAttributes : NamedValues = NULLExceptionSpecs : Logical View::PI Data Objects::ExceptionSpecsEventPipe : Logical View::PI Data Objects::EventPipe
CreateDigitalState()CreateSystemState()TimedValues()ArcValue()UpdateValues()UpdateValue()RemoveValues()Summary()RecordedValues()InterpolatedValues()PlotValues()RecordedValuesByCount()RecordedValuesAvailable()Summaries()
Data
Data.RecordedValues()
Start time and end time as Variant
Boundary type
Filter expression
Show filtered
Asynchronous
Returns a PIValues collection
What’s in a PIValue?
PIValues PIValue DigitalState
PITime
NamedValueNamedValues
VARIANTValue
TimeStamp
Attributes
PIValues – More than a datatype
PIValuesCount : long_NewEnum : LPUNKNOWNDirection : DirectionConstants = dForwardReadOnly : VARIANT_BOOLRecordset : Recordset = initval
ApplyFilter()Add()Merge()Copy()Find()Item()Summary()TimeInCondition()CountInCondtion()
Writing values to PI
UpdateValue and UpdateValues
RemoveValues
Demo
Retrieving PIValues
Advanced Topics
Event pipes
Using asynchronous calls
Problem: Alarm Application
Your app must catch every event
But you can’t listen all the time
Polling may miss an event
Oops
The EventPipe Object
Get from a PIPoint or a PointList
Collects value changes
Count property
Take, Peek methodsFirst In, First Out (FIFO).
OnNewValue eventCan be throttled to avoid event overload
Problem: Long Queries
Long blocking calls inhibit user response and slow down your application
But breaking the query into small chunks may reduce efficiency
Server does redundant work
More network calls
PIAsynchStatus Object
Lets you monitor the status of a querySends an event when doneProvides for progress barMany calls can be asynchronous
PIPoint.Data archive retrievalPointList.Data archive retrievalPIValues.RecordSetServer. GetPoints, GetPointsSQLPISDK.GetPointsMessageLog.List
Using PIAsynchStatus
Dim WithEvents asy As PIAsynchStatusSet asy = New PIAsynchStatus
Dim pv As PIValuesSet pv = MyPoint.Data.RecordedValues (“*-1h”, “*”, , , , asy)Rem pv.Count should be zero...
Private Sub a_OnStatusChange If asy.Status = csCompleted Then ...
Time in the SDK
Classic problems: summer time, time zones, clock drift
The solution: PITimeServer
Time—The Problems
Summer time (DST)What are the rules for this location?
What were the rules last year?We must track historic changes
Does my computer follow the rules?It probably doesn’t even know them.
Even if it does (NT), it may not follow them.
Time—The Problems
Time zonesServers can be in various time zones
Clients can be in a different time zone from any server
Queries must be interpreted in the time zone of the server
Time—The Problems
Clock driftEven in the same time zone, the client clock may not be exactly the same as the server clock
Real-time data inputs to a server should be timestamped with the server clock, i.e. adjusted for clock drift
Historical inputs should not be adjusted for clock drift
Time—The Problems
Time intervals (days, months, shifts)Is 1 day = 24 hours?
Not always, if you observe summer time
On March 30, what does this mean?“* - 1 month”
Can I define my plant shift schedule?
Time—The Solutions
PITimeServerIndependent COM server DLL
Does not require PISDK.DLL for support
Defines these objects:PITime, PITimeFormat, DynamicTime
PITimeZoneInfos, PITimeZoneInfo
DeviceTimeZones
TimeIntervals, ITimeInterval
PITimeZoneInfo object
Encapsulates time zone informationOffset from UTCSummer/winter time change rulesHistorical changes in rules
Every device is assigned oneServer, client, instrument
PITimeZoneInfos collectionAll known time zones on this clientUser can add or remove zones
Time Objects: PITime
Lightweight, server-independent
Translates wallclock to UTC using client-node time zone information
Operations:UTCSeconds property
UTCFileTime property
LocalDate property
SetToCurrent method
Time Objects: PITimeFormat
Superset of PITime
Knows its time zoneTimeZoneInfo property
Parses time stringsMicrosoft format (localized) or PI format
Formats output strings
Works with time intervals“subtract 3 weeks”
Time Objects: DynamicTime
Superset of PITimeFormat
Represents a moving time, such as “*” or “* - 4.5 hours”
Property values change constantly
Referenced to a known clock sourceServer clock
Client clock
Device clock, user-defined
ITimeInterval Object
Represents a kind of intervalName, ShortName:month, moMemberLo, MemberHi: 1, 12Member(Short)Name: January, Jan, …
Operations: given a time—What month is it?When did that month start?Add or Subtract n monthsHow many months between two times?
TimeIntervals Collection
Contains all intervals known on the client
Interval serversInstalled via registry entry
Standard: year, month, day, week, weekday, yearday, hour, minute, second
User-defined: whatever you wantShift, Plant day
Fiscal year/month/week/quarter
Threading
Release 1 was apartment-threaded
Release 2 will be free-threadedApartment-neutral
Uses the Free-Threaded Marshaler (FTM)
If It Ain’t Broke…
Apartment-threading works correctly
But performance is unacceptable7,000
0.8
35
3,700
0
1
10
100
1,000
10,000
Accesses per Second (x 1000)
Same Apartment
Cross-Apartment
Required
Free-Threaded
Why Should I Care?
Multi-threaded design is natural for many applications
Interfaces—thread per scan class
Displays—thread per graphic
Today, this mostly affects C++ developers
VB7 will support free-threading
OSI and the PI-SDK
Redesigns of existing products
New products in development
Existing products
Redesigns for the PI-SDK
PI-ProcessBook
PI-DataLink
Sigmafine
PI-BatchView
PI-Profiles
New Applications
PI-PointBuilder
PI-AlarmView
Real-time SQC Point Manager
PI-AutoPointSynch
These are demonstrated Tuesday afternoon.
Controls and Libraries
PI-BatchView 3.0
Module Database Controls
Tag search
New Interfaces
PI-Perfmon
OPC
ICCP
Existing Products
Embedded PI systemsPoint creation
User/Group management
Batch Event File InterfaceIntegration with batch systems
UNIINT 3.2.0Flexible attribute retrieval
PIlog32.dll and sdkreg.dll
Troubleshooting Tips
After the setupRead the setuppisdk.log
Run AboutPI-SDKThe new apisnap
AboutPI-SDK
Version Info
Timeout Info
Hidden Connect Button
Connecting
Manage your Servers Here
Server Management
Communication Layers
What’s a pinetmgr and do I need one?
What’s a redirector and how is it configured?
~\pipc\dat\pisubsys.cfg
Pisubsys.cfg
RedirectedGeneric_local hostname:portnumber
For example:
Generic_local bilbo:5450
Local pinetmgrGeneric_local \\.\pipe\rendevouz file path
For example:
Generic_local \\.\pipe\e:\PI\dat\piv3.rdz
What if?
Remember AboutPI-SDK = apisnap
Can’t run AboutPI-SDKCheck error message
Check setup
What if?
Can’t connectIs server running?
Client sidePing, apisnap, ProcessBook
Server sideCheck services.(Net start, or services applet)
Does piconfig work?
Does pisnap work?
Is the local pinetmgr service running?
Try using a redirector
What if?
Err.DescriptionOften includes server specific errors
Intermittent errorsIf it used to work, suspect the server
PI-SDK web pageReported Problems
http://support.osisoft.com/progtools/pisdk/
Coding Problems
Try the examples in the help file
Try the sample applications on the web
Isolate the problem
Send small examples that demonstrate the problem to tech support.
Coming Attractions
PI-SDK 1.1 ModuleDatabase/ PIBatch
PI-SDK 2.0 Data
Any beyond
PI-SDK
Questions?