Skip navigation
All Places > PI Developers Club > Blog > 2012 > November
2012

We are up to a very nice and energetic start to vCampus Live! 2012. The two Hackathons, Security and Programming, are already in full action with folks jamming in the rooms. While teams in the Security Hackathon are sweating over their ideas to use car data in PI System, the folks in the Security Hackathon are defending their PI Systems against OSIsoft attackers (aka. bad guys). We are going to conclude tonight with a reception. The great event will officially open Thursday morning California time with fantastic keynotes and lots of hands-on and expert presentations.

 

Security Hackathon folks defending their turf against virtual attackers while folks in the back taking pictures of the breathtaking views of San Francisco from 36th floor windows:

 

3362.Security-Hackathon-2.jpg

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

After Part 1 and Part 2 of my blog on some fun stuff with ProcessBook I decided to do another post on the topic, most likely my last as I will soon find something else fun to do with the PI System & tools.  I tend to have a short attention span.

 

Anyway I will get right down to it.

 

vCampus Live is right around the corner, I am very excited to geek out in San Francisco.  I have seen the vCampus Live marketing banner in emails, on vCampus, on OSIsoft's TechSupport site, ... you can't miss it.  So I decide I would draw that in ProcessBook Trends.

 

This is the banner: 

 

vCampusLive2012_5F00_vCampus_5F00_page_5F00_banner_5F00_final.png

 

Well I had to modify the code I created previously, this image was much bigger than the OSIsoft logo and needed some tweaking.  Well here is the 1st attempt:

 

vCampusLiveBanner.jpeg

 

Seemed to work pretty well.  Just as a reminder, this is drawn using traces on ProcessBook Trends using only PI Points as the data source!

 

I wanted it slightly better and more clear so had to tweak some more settings including the display zoom level.  This is the final result:

 

vCampusLiveBanner3.jpeg

 

I was satisfied with that so stopped there.

 

You can even use the ProcessBook playback tool to show the trends updating to give the illusion of a scrolling banner from an image file  I was tempted to create an interface that ate an image pixel by pixel and drew it in ProcessBook but it is more work than my interest on this topic will last.

 

 

 

Next fun topic?  Not sure, feel free to post up suggestions.

I am finding the need to have a break from the norm with PI data to explore some interesting concepts with PI, which more than likely have no commercial benefit...they're just fun!

 

I blogged recently about writing my name on a ProcessBook trend.  Here is the blog post:

 

http://vcampus.osisoft.com/bloggers_place/b/rhys/archive/2012/11/02/how-my-data-visualised-itself.aspx

 

Cool, right?

 

Well I decided to go one better and draw the OSIsoft logo on a ProcessBook trend.  At first it was daunting and I seemed to scratch my head a lot in search of how I could do this, in fact I am sure I have a bald spot now.  I wanted it to look good, not the type of result where you need to squint your eyes to see the logo.  Anyway, long story short I did with some fairly simple code.  Below is how it came out after a couple of iterations to the code.  So, what do you think?

 

OSIsoft_5F00_Logo_5F00_ProcessBook.jpg

 

Feel free to guess how I achieved this.  Here is a hint (and a note for the ProcessBook team): you can only manipulate the characteristics of the 1st 12 pens of a trend even though you can have 50 traces (1st 8 pens are sequential in the enum, the last 4 jump up the enum a bit)!

Once again I take the opportunity to share when I trip up.  For the past 3+ years, I have been doing AF development and frequently need to see if an AFAttribute uses the PI Point data reference.  The need is so common that I have a little extension method that is short, simple, and sweet:

 

    public static bool UsesPIPointDR(this AFAttribute attribute)
    {
        return (attribute.DataReference != null) && (attribute.DataReference.Name == "PI Point");
    }

 

 

Maybe not so sweet.  Would you believe that tiny bit of code is actually quite sluggish, and therefore not so sweet?  Not that this is a fault of OSIsoft.  Rather, my simple little extension method is written poorly.  The much faster way to achieve the desired check is:

 

    public static bool UsesPIPointDR(this AFAttribute attribute)
    {
        return (attribute.DataReferencePlugin != null) && (attribute.DataReferencePlugIn.Name == "PI Point");
    }

 

 

It's a small, subtle difference using DataReferencePlugIn instead of DataReference but it makes a big difference with big numbers.  Let's take a look for a database remote to me going across a very slow WAN.  This database has 353 elements, well over 100,000 attributes, with 18,743 of those attributes using the PI Point data reference.  We may have closer to 200,000 attributes and we go many generations deep (up to 6).  I wrote a subroutine to load all elements, and then crawl over all attributes looking for those that are PI Points.  For today's topic, the only timing I worry about is just crawling over all attributes looking for PI Points.

 

Running the first method against DataReference took 11,542 milliseconds.  Did I mention that I have a slow WAN?  Okay, so running the second method against DataReferencePlugIn took 247 milliseconds!  It ran so bleeping fast that I assumed it was an error.  The error was that I've been using the wrong method all these years.

jlakumb

PI SDK 2012 RC2

Posted by jlakumb Nov 5, 2012

This week we posted a pre-release version of PI SDK 2012 in the Download Center.  This next PI SDK includes support for Windows 8/2012, localization of PI SDK Utility and other dialogs/controls, as well as dozens of other minor bug fixes.  We encourage you to try out these 32/64-bit RC2 versions and send questions or feedback to PISDKBeta@osisoft.com.

I am a big fan of vCampus, surely that is obvious by now, but I also really like the OSIsoft Community.  As a result I keep in touch with Nick D’Orazio and we briefly talked about this post on the Community Forum:

 

ProcessBook Trend of turbine speed showed hunting (oscillation) where non occurred.

 

We both thought it made for a cool trend, and it is good to see how data visualizes itself sometimes.  I dropped in to the conversation that in my youth (I’m a father of 2 now and getting old at 31) I spent some time playing with ProcessBook trends and could make shapes and letters with a trace.  Nick was intrigued and asked for some evidence.

 

I dusted off some DVDs in search of my code but didn’t find any.  That to me was a personal challenge; I need to re-create an example of that. So off I went…

 

 

 

Well I didn’t spend as long as I thought I would as the memories of all those late nights came flooding back.  15 minutes or so later I came up the following in ProcessBook using the Trend object. 

 

 

 

Can you spot the hidden meaning of the data?

 

image001.jpg

 

 

 

Now the mini challenge; can you figure out how I did this?

Filter Blog

By date: By tag: