PI Software Development Kit PI-SDK
Agenda The expanded class hierarchy Data access with the PI-SDK The PITimeServer library Multi-threading and the PI-SDK OSI and the PI-SDK Troubleshooting tips Coming attractions Questions
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.0
PI-SDK 1.1
PI-SDK 2.0
Data Access with the PI-SDK PIData and ListData The access paths Value Format What do values look like now? PIValues capabilities What can I do with the values? Writing Values
PIData
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 – More than a datatype
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 Oop s
The EventPipe Object Get from a PIPoint or a PointList Collects value changes Count property Take, Peek methods First In, First Out (FIFO). OnNewValue event Can 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 query Sends an event when done Provides for progress bar Many calls can be asynchronous PIPoint.Data archive retrieval PointList.Data archive retrieval PIValues.RecordSet Server. GetPoints, GetPointsSQL PISDK.GetPoints MessageLog.List
Using PIAsynchStatus Dim WithEvents asy As PIAsynchStatus Set asy = New PIAsynchStatus Dim pv As PIValues Set 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 zones Servers 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 drift Even 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 PITimeServer Independent 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 information Offset from UTC Summer/winter time change rules Historical changes in rules Every device is assigned one Server, client, instrument PITimeZoneInfos collection All known time zones on this client User 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 zone TimeZoneInfo property Parses time strings Microsoft 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 “ * hours ” Property values change constantly Referenced to a known clock source Server clock Client clock Device clock, user-defined
ITimeInterval Object Represents a kind of interval Name, ShortName:month, mo MemberLo, MemberHi: 1, 12 Member(Short)Name: January, Jan, … Operations: given a time— What month is it? When did that month start? Add or Subtract n months How many months between two times?
TimeIntervals Collection Contains all intervals known on the client Interval servers Installed via registry entry Standard: year, month, day, week, weekday, yearday, hour, minute, second User-defined: whatever you want Shift, Plant day Fiscal year/month/week/quarter
Threading Release 1 was apartment-threaded Release 2 will be free-threaded Apartment-neutral Uses the Free-Threaded Marshaler (FTM)
If It Ain’t Broke… Apartment-threading works correctly But performance is unacceptable
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 systems Point creation User/Group management Batch Event File Interface Integration with batch systems UNIINT Flexible attribute retrieval PIlog32.dll and sdkreg.dll
Troubleshooting Tips After the setup Read the setuppisdk.log Run AboutPI-SDK The 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 Redirected Generic_local hostname:portnumber For example: Generic_local bilbo:5450 Local pinetmgr Generic_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-SDK Check error message Check setup
What if? Can’t connect Is server running? Client side Ping, apisnap, ProcessBook Server side Check 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.Description Often includes server specific errors Intermittent errors If it used to work, suspect the server PI-SDK web page Reported Problems
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?