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:

 

  1. The results were returned in lists, whereas most applications in R work with data.frames.
  2. 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.
  3. Function and variable description were missing.
  4. 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:

 

  1. 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”
  2. After the installation the library is loaded with: library(ROSIsoft)
  3. To connect to AF and PI server use first: AFSetup() this will install dependencies such as rClr
  4. To connect to the PI server use the following:
  5. connector<-ConnectToPIWithPrompt("<PI Server>")  and connector<-ConnectToAFWithPrompt("<AF Server>","AFDatabase"

That's it.

But the data model looks now different:

And the data calls return the R time stamps:

 

 

Or values:

Some people have asked about summary types, which is really a good way to down sample data. This function is now also returning a data.frame:

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: hamort@tqsintegration.com As I mentioned, due to the automated build process maintenance of this package should now be much easier.