Almost a year ago I wrote a blog about a R library to connect to OSIsoft PI and AF (ROSIsoft). The feedback was great and I tried to respond quickly.
I am also seeing more and more project with modeling and forecasting needs, which is a great development.
The problem is that the build process is rather lengthy; you have to work both in the .NET and R environments to put a package together. That is inherently a problem with scripting languages, they just don't do well with loops. So you need to build an intermediate layer between the AF-SDK objects and simple array types that R understands.
There were also other problems with the initial approach:
- The results were returned in lists, whereas most applications in R work with data.frames.
- Time Stamps were returned as string or double value (EXCEL) types instead of R date time types such as POSIXct; this required an extra conversion step in R.
- Function and variable description were missing.
- And as mentioned the build process was mostly manual.
I automated the build process and created a scripting engine in VS to write the R functions. That really helped accelerating the build process.
The library is loaded the same way:
- Installation is done manually. In RStudio select Tools\Install packages … and when the open dialog opens, change the option “Install from:” to “Packaged Archive File”
- After the installation the library is loaded with: library(ROSIsoft)
- To connect to AF and PI server use first: AFSetup() this will install dependencies such as rClr
- To connect to the PI server use the following:
- connector<-ConnectToPIWithPrompt("<PI Server>") and connector<-ConnectToAFWithPrompt("<AF Server>","AFDatabase")
And the data calls return the R time stamps:
Or for multiple values:
The package still needs a fair amount of testing and I would be happy if you would send your feedback to: firstname.lastname@example.org As I mentioned, due to the automated build process maintenance of this package should now be much easier.