YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Rapid PI - Spot the difference PISDK.PIModuleDB vs AFSDK.AFDatabase Options · View
RJK Solutions
#1 Posted : Wednesday, July 01, 2009 11:36:42 AM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
Following on from converting a PIModuleDB to AF Elements & Attributes, here are some code snippets to show how to achieve in AF what you used to do in PIModule Database.

Connecting to the PIModuleDB
Code:

' PISDK
Dim PIMDB As PISDK.PIModuleDB = New PISDK.PISDK().Servers.DefaultServer.PIModuleDB
' AFSDK - PISDK.PIModuleDB = AFSDK.AFDatabase
Dim AFMDB As OSIsoft.AF.AFDatabase = New OSIsoft.AF.PISystems().DefaultPISystem.Databases.DefaultDatabase


Retrieving a PIModule
Code:

' PISDK
Dim PIMod As PISDK.PIModule = PIMDB.PIModules("ModuleName").PIModules("1").PIModules("2").PIModules("3")
' AFSDK - PISDK.PIModule = AFSDK.Asset.AFElement
Dim AFEmnt As OSIsoft.AF.Asset.AFElement = AFMDB.Elements("ModuleName").Elements("1").Elements("2").Elements("3")


Retrieving a PIProperty
Code:

' PISDK
Dim PIProp As PISDK.PIProperty = PIMod.PIProperties("Property1")
Dim sPIProp As String = PIProp.Value().ToString()
' AFSDK - PISDK.PIProperty = AFSDK.Asset.AFAttribute
Dim AFAtt As OSIsoft.AF.Asset.AFAttribute = AFEmnt.Attributes("Property1")
Dim sAFAtt As String = AFAtt.GetValue().ToString()


Retrieving a PIAlias
Code:

' PISDK
Dim PIAls As PISDK.PIAlias = PIMod.PIAliases("MyPIAlias")
Dim oPIAls As PISDK.PIValue = CType(PIAls.DataSource.Data.Snapshot.Value(), PISDK.PIValue)
' AFSDK - PISDK.PIAlias = AFSDK.Asset.AFAttribute using PI Point Data Reference
Dim AFAls As OSIsoft.AF.Asset.AFAttribute = AFEmnt.Attributes("MyPIAlias")
If AFAls.DataReference.Name = "PI Point" Then ' Important to check the AF DataReference
    Dim vAFAls As OSIsoft.AF.Asset.AFValue = AFAls.GetValue()
    Dim oAFAls As PISDK.PIValue = CType(vAFAls.ToPIValue(), PISDK.PIValue)
End If


This is only a small set of what can be achieved using the PI Analysis Framework and RJK Solutions actively encourage you to get using AF as soon as possible!
Principal Consultant
Real-Time Data Management @ Wipro Technologies
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.