For some time I've requested a better regression line visualization in ProcessBook, on behalf of one of our clients. While delivering some displays to them as part of a condition monitoring system, they needed to see the regression lines on some trends with very little amplitude. We enabled the standard regression line in the ProcessBook trend definition window, which outputs a dashed line in the same pen-color as the data point it belongs to. Since the amplitude of the trend was so low, and they needed to have a long default timerange, you could barely see it moving up and down. And when enabling the standard regression line on top of that, with the same color and a dashed line, they meant it was too confusing and disabled the whole thing.

 

After that I downloaded the old DevNet Regression line addin from the Library, to see if this suited them better. And while the visualization part of that was perfect for them, the technology turned out to be outdated. It only supported PI tags, and all of the displays for the CMS project were ERD based. It used the PI API, and didn't appear to support trusted connections to the PI server. And today "nobody" uses explicit logins (often it's even disabled), and "everybody" uses AD mappings and trusted connections.

 

Eventually I decided to take matters into my own hands, and transfer the Regression line addin into the 21st century (yes, the old one was from the 20th century). I got the code for old addin from Andreas in the vCampus team, and being that it used the PI API in Visual Basic 6 I didn't even try to get this up and running in any way before starting.

 

Using the Visual Studio templates for creating ProcessBook AddIns, I got a simple development platform up and running. I also followed a LearningLab guide I had on a USB stick after one of the first vCampus Live! events, called ".NET add-in to Implement a Custom Dataset". This was very useful since this was my first dataset addin. Previously I had only created docking window addins, and "ActiveX" addins - which can be used in Microsoft Office products as well.

 


As with most development projects I probably spent 20% of the time reaching 80% in progress. After getting the GUI as I wanted, implemented the IDataProvider3 interface from the PBObjLib assembly, and created the math to do the actual calculation, a lot of debugging was in place. Sometimes the line was drawn perfectly, other times there was only one value plotted to the trend. But eventually I got it all working. The options other than the regression line itself are the "Slope" and "Correlation coefficient". (The slope is defined for the last 24 hours).

 

I've used the standard OSIsoft UI elements as much as possible. The ERD dialog in ProcessBook seemed to be custom made, so I had to recreate that. I even simplified it a little bit. In the ProcessBook ERD feature you can open the ERD attribute selection dialog even if you don't have any elements of interest defined. Then you first have to define it, before you can select the attribute you're interested in. For simplicity I've not implemented this functionality, and in my addin you will have to define some EOI's before you open the RegressionLine addin dialogs or else the controls will be disabled. I do however plan on setting this up as a community project, so anyone wanting this (or other) functionality can easily implement it later.

 

Ok, enough writing - let's see some screenshots and then download it  

 

(Click images to see larger versions!)

 

 

 

2133.thumb_5F00_step1.jpg

 

After installing the addin and opening ProcessBook you'll find another data source in the Define Trend window. Click "RegLine" to open the dialog.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

8461.thumb_5F00_step2.jpg

 

In the RegressionLine AddIn window we can start by browsing for PI tags, and as you can see you're in a familiar environment since the standard OSIsoft UI elements are used.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2502.thumb_5F00_step3.jpg

 

After selecting a tag to see the regression line of (in this case CDT158), and also adding that tag to the trend, we get the following result:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2502.thumb_5F00_step4.jpgThe following screenshot shows the AF tab of the addin, and the rest should be pretty self-explanatory:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

As mentioned, I had to recreate the ERD Selected attribute dialog since that was not part of the UI library provided by OSIsoft. I simplified it a bit, so it's enough to either doubleclick on the attribute of your choice - or click it once before hitting the OK button.

 

1680.thumb_5F00_step5.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5314.thumb_5F00_step6.jpgIf everything is done right, you should then be able to use this addin for ERD based displays:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

So that's it. You can download the addin yourself, just unzip and run Setup.exe: RegressionAddIn.zip