Greetings to my fellow PI Coders:
I am interested in learning how to use the AF Wrapper for ProcessBook. I entered "How to install AF Wrapper in Processbook" in the PISquare search, which yielded very limited and not useful results. So I entered "How to install AF Wrapper in Processbook" in Google and got essentially less useful results.
In searches I find descriptions and vague references to how it works, but no simple step by step instructions on how to install it. I tried opening the WrapperExample.pdi file included in the AF Wrapper download, but it throws a "compile error: can't find project or library" with the highlighted portion of code "Dim AFW as AFWrapper.Wrapper". The "instructions.txt" file included with the AF Wrapper download is woefully inadequate regarding how to install it.
Please note I have extensively coded using ProcessBook VBA accessing the Module Database, which works pretty good, but I see it as a risky option going forward as most PI developers would agree everything going forward is centered on the AF SDK. I welcome some guidance in how to install it or point me to a solid set of directions on how to install it.
In short, you need to build the AFWrapper project and then you can reference it in PI ProcessBook.
- Open AFWrapper.sln in Visual Studio.
- Make sure the project is using OSIsoft.AFSK reference build against version 126.96.36.199 CLR (Can be found in the reference properties)
- Set Target Framework to .NET 3.5 (in Project->AFWrapper Properties)
- In the Solutions Explorer do a right-click on the AFWrapper project and choose Build.
That's it. When you open PI ProcessBook VBA editor you should be able to see AFWrapper in the list of references (Tools->References).
Add AFWrapper reference and you should be good.
For the example PDI file provided with AFWrapper, you need to import AFElements.xml into a new test AF Database.
A couple of bumps I hit while getting AFWrapper to work:
- Got an exception ("ActiveX can't create object") on the following line in the example VBA:
Set AFW = New Wrapper
Fixed it by qualifying the reference:
Set AFW = New AFWrapper.Wrapper
- Not related anyhow to AFWrapper: Somehow my PB 2014 was missing the Element Relative Display feature, so ProcessBook threw an exception on the Set ERD line. This was fixed by repairing the ProcessBook installation.
I followed your instructions and it worked like a charm.
At first when I imported into Visual Studio Professional 2013 I was greeted with this warning "Visual Studio needs to make non-functional changes to this project in order to enable the project to open in Visual Studio 2013, Visual Studio 2012, and Visual Studio 2010 SP1 without impacting project behavior." and asked if I wanted to proceed, I clicked [Yes]. VS 2013 automatically 'upgraded' it to .Net Framework 4.0 so I had to fix that per your instructions. When I first opened the WrapperExample.pdi file I encountered a few issues like you such as the Set ERD line, but was able to quickly solve them. Also, for the purposes of development I set up a separate AF Database and then imported the AfElements.xml file. Back in the ProcessBook WrapperExample.PDI display this required I delete the existing element relative tree and then import the newly created set of AF Elements. After that the WrapperExample.PDI display ran error free.
Glad you got the wrapper working! One word of caution: since you had mentioned you programmatically access MDB from ProcessBook, I wanted to point out that AFSDK does not support accessing MDB directly. For accessing MDB, PISDK is still required. For most other data access needs, you should use AFSDK.
该文档由下列讨论生成：How to install AF Wrapper in ProcessBook