pi software development kit pi-sdk. agenda the expanded class hierarchy data access with the pi-sdk...

52
PI Software Development Kit PI-SDK

Upload: lewis-morrison

Post on 23-Dec-2015

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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

PI Software Development Kit

PI-SDK

Page 2: 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

Agenda

The expanded class hierarchyData access with the PI-SDKThe PITimeServer libraryMulti-threading and the PI-SDKOSI and the PI-SDKTroubleshooting tipsComing attractionsQuestions

Page 3: 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

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

Page 4: 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

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

Page 5: 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

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

Page 6: 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

PI-SDK 2.0

PIValue

PIValues

PointValue

PointValueList

PointValueLists

PointValues

EventPipe

PIPoint

ExceptionSpecs

Data

PIPoints

Server

ListData

PointList

Page 7: 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

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

Page 8: 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

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

Page 9: 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

Data.RecordedValues()

Start time and end time as Variant

Boundary type

Filter expression

Show filtered

Asynchronous

Returns a PIValues collection

Page 10: 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

What’s in a PIValue?

PIValues PIValue DigitalState

PITime

NamedValueNamedValues

VARIANTValue

TimeStamp

Attributes

Page 11: 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

PIValues – More than a datatype

PIValuesCount : long_NewEnum : LPUNKNOWNDirection : DirectionConstants = dForwardReadOnly : VARIANT_BOOLRecordset : Recordset = initval

ApplyFilter()Add()Merge()Copy()Find()Item()Summary()TimeInCondition()CountInCondtion()

Page 12: 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

Writing values to PI

UpdateValue and UpdateValues

RemoveValues

Page 13: 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

Demo

Retrieving PIValues

Page 14: 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

Advanced Topics

Event pipes

Using asynchronous calls

Page 15: 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

Problem: Alarm Application

Your app must catch every event

But you can’t listen all the time

Polling may miss an event

Oops

Page 16: 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

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

Page 17: 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

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

Page 18: 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

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

Page 19: 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

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 ...

Page 20: 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

Time in the SDK

Classic problems: summer time, time zones, clock drift

The solution: PITimeServer

Page 21: 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

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.

Page 22: 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

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

Page 23: 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

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

Page 24: 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

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?

Page 25: 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

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

Page 26: 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

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

Page 27: 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

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

Page 28: 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

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”

Page 29: 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

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

Page 30: 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

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?

Page 31: 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

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

Page 32: 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

Threading

Release 1 was apartment-threaded

Release 2 will be free-threadedApartment-neutral

Uses the Free-Threaded Marshaler (FTM)

Page 33: 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

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

Page 34: 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

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

Page 35: 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

Redesigns of existing products

New products in development

Existing products

Page 36: 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

Redesigns for the PI-SDK

PI-ProcessBook

PI-DataLink

Sigmafine

PI-BatchView

PI-Profiles

Page 37: 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

New Applications

PI-PointBuilder

PI-AlarmView

Real-time SQC Point Manager

PI-AutoPointSynch

These are demonstrated Tuesday afternoon.

Page 38: 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

Controls and Libraries

PI-BatchView 3.0

Module Database Controls

Tag search

Page 39: 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

New Interfaces

PI-Perfmon

OPC

ICCP

Page 40: 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

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

Page 41: 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

Troubleshooting Tips

After the setupRead the setuppisdk.log

Run AboutPI-SDKThe new apisnap

Page 42: 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

AboutPI-SDK

Version Info

Timeout Info

Hidden Connect Button

Page 43: 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

Connecting

Manage your Servers Here

Page 44: 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

Server Management

Page 45: 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

Communication Layers

What’s a pinetmgr and do I need one?

What’s a redirector and how is it configured?

~\pipc\dat\pisubsys.cfg

Page 46: 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

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

Page 47: 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

What if?

Remember AboutPI-SDK = apisnap

Can’t run AboutPI-SDKCheck error message

Check setup

Page 48: 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

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

Page 49: 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

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/

Page 50: 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

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.

Page 51: 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

Coming Attractions

PI-SDK 1.1 ModuleDatabase/ PIBatch

PI-SDK 2.0 Data

Any beyond

Page 52: 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

PI-SDK

Questions?