Skip navigation
All Places > PI Developers Club > Blog > 2011 > June

This is vCampus' 1000th day! We are standing here celebrating our great and lively community because of all your contributions and great energy. On behalf of everyone at OSIsoft we would like to thank you for making all this happen. We have proudly represented more than 1800 individuals, and more than 600 organizations via 10,000 posts on our forums. Your success in creating more value out of investment in PI infrastructure is what we strive everyday. Please keep up the great job and make your community thrive!


Interestingly enough Thursday June 30 is named "Social Media Day" to celebrate the great effects social media have had on our professional and personal lives in the past few years. As the social place for all PI System developers, architects, system administrators, geeks, and enthusiasts we would like to congratulate you for the great community we have formed together. With best wishes for our community to grow better and more fruitful everyday.


As a tangible step to observe this day, we added a "Follow us on Twitter" button to the vCampus pages. By simply clicking on it you can easily follow OSIsoft vCampus on Twitter and stay abreast of the community news; follow us now and be the first to know



PI is wrong!

Posted by RJKSolutions Jun 28, 2011

No, I am not referring to OSIsoft's data historian but to the mathematical circle constant 'PI'; Tau is, apparently, right and PI is wrong.


March 14th is 'PI day' but today (June 28th) is 'Tau day' and you call read all about it in the Tau Manifesto or in Bob Palais' PI is wrong publication.


Hopefully no one in OSIsoft's marketing department panics at my blog title (or decides to rebrand the products, e.g. "Tau Coresight") .

Ahmad Fattahi

Social Media Day

Posted by Ahmad Fattahi Employee Jun 27, 2011

This Thursday June 30, 2011 is the Social Media Day. As THE online community for the PI System developers we are very pleased and proud to be part of this big picture. We have been great beneficiaries of the great social platform we have formed together on OSIsoft vCampus.

A lot of us use Microsoft .NET in their daily efforts to create applications for the PI system. It seems there is still somewhat of a 50/50 spread between VB.NET and C# developers. I myself am an avid C# developer, and I really like the language. The fact that I’m not a VB.NET programmer has nothing to do with the language itself, but it’s more about my history as a developer.








C# (and .NET in general) has a lot of really nice features, and it keeps getting better with every release. With every release, new major functionality becomes available. For instance, the introduction of generics in .NET 2.0, the introduction of WCF/WPF in .NET 3.0, the introduction of LINQ and lambda’s in .NET 3.5, and now the introduction of dynamic typing in .NET 4.0.








A lot of the times, these major changes go accompanied by some lesser changes. A lot of the time, the lesser changes are there to make the bigger changes possible. For instance, LINQ (a big change) relies heavily on ‘Extension Methods’ (a lesser change). Lambdas are also a very big part of LINQ, and these are getting more and more accepted. The acceptance of a more functional programming paradigm embedded into an object oriented language seems to be a very smart decision, that works really well for us programmers.








In this blog post series, I would like to have a look at some of the lesser known constructs in C#. It’s sometimes difficult to decide which ones are ‘lesser known’. It could be that you are already familiar with some of them, but I’m sure there will be some that you are not that familiar with!







The ‘yield’ keyword

I think this is a prime example of a lesser known, and therefore lesser used, construct that could really affect your programming style in a good way.








The yield keyword is used in what we call iterators. An iterator can be a method, get accessor or operator that returns a collection that can be enumerated. A very good example of using this would be an implementation of the ‘GetEnumerator()’ method. This method is being used when you use a foreach statement to loop over a collection (for instance an array or List<T>). You can only use the yield statement when returning an IEnumerable<T> or derivative.








Let’s say, we want to create a method that returns a collection of data. A simple example would be:






static void Main(string[] args)
            var sinusoid = GetSinus(1, 10);
            foreach (var number in sinusoid)

        public static List GetSinus(double from, double to)
            List returnList = new List();
            Console.WriteLine("Getting sinus");
            for (double i = from; i < to; i++)
                var sin = Math.Sin(i);

            return returnList;





As you can see, in order for us to create a collection of sinusoid values, we first create a new empty List<double>. We use a ‘for’ loop to go through the input range, and we add every calculated sinusoid value to the list. Once we are done, we return the entire list.








If we run this code, the output will be:










Let’s introduce a method that does the same, but uses the ‘yield’ keyword.




   public static IEnumerable GetSinus(double from, double to)


            Console.WriteLine("Getting sinus");

            for (double i = from; i < to; i++)

                yield return Math.Sin(i);



There are several changes to this method implementation. For instance, the return value is a ‘IEnumerable<double>’. We don’t use a returnlist here. We just loop trough the range using a ‘for’ loop, and we return our calculated sinus value using the ‘yield return’ statement.





If we run the application with our new GetSinus method, the output will be:


















Something has changed in the output… I invite you to have a look at the first code sample, and both output samples. You will notice something is off… We will come back to that later.






In addition to the ‘yield return <expression>’ statement, we can also use ‘yield break’, which is implemented in the following example:








 public static IEnumerable GetSinus(double from, double to)


            Console.WriteLine("Getting sinus");

            for (double i = from; i < to; i++)

                if (i > 5)

                    yield break;


                    yield return Math.Sin(i);




This example will break off the iteration when i > 5. This means that it will break out of the for loop, and ends the execution of this method. You can for instance use this if you trap exceptions in  your iterator block, and want to end iteration when an error occurs.






Back to the output of the two samples…










You will notice that the “Looping” and “Getting sinus” writelines are executed in a different order. We can see that in this example the “Getting sinus” writeline is executed after the “Looping” writeline. This means, that the actual method gets executed when running the foreach loop. But, how can this be? We created the variable ‘sinusoid’, and assigned the output of the ‘GetSinus’ method before the foreach loop.








This behavior is called ‘Defered Execution’, or sometimes called ‘lazy execution’. This means that an expression is not evaluated until its realized value is needed. In this case, the value isn’t needed until the foreach loop. That’s why the “Getting Sinus” writeline is executed after the ‘Looping” writeline. If you have used LINQ or LINQtoSQL before, you may have noticed this behavior also.








For this sample, we can negate this behavior by changing the assignment of the ‘sinusoid’ variable to:


var sinusoid = GetSinus(1, 10).ToList();




In this case, the realized values of the GetSinus iterator are needed immediately, because we are using the .ToList() extension method to create List<double>.






The purpose of ‘Defered Execution’ is to improve performance when manipulating large data collections. This is especially true when working with multiple ‘chained’ queries or manipulations.






One effect of this lazy evaluation is that you can ‘reuse’ your expression, for instance, after your data changes. Let’s see an example of that:






 static void Main(string[] args)
            //Create an array of ints
            var numbers = new int[] { 1, 5, 7, 8, 2, 7, 9, 4, 3 };
            //Create a LINQ query that selects all numbers lower than 5
            var lowNumbers = from n in numbers

                             where n < 5

                             select n;

            //Print all the low numbers
            Console.WriteLine("First time printing low numbers");
            foreach (var lowNumber in lowNumbers)


            //Loop trough the numbers array, and decrease every number by 2

            for (int i = 0; i < numbers.Length; i++)


 = numbers
 - 2;

            //Print all the low numbers again, using the same lowNumbers variable
            Console.WriteLine("Second time printing low numbers");
            foreach (var lowNumber in lowNumbers)




The output of this example will be:








This is, at first sight, a bit counter-intuitive. Shouldn’t the result of the assigned ‘lownumbers’ variable be the same throughout the whole execution of this code? This is how ‘Defered Execution’ behaves.




The best way to see it is that ‘lowNumbers’ is not assigned the output of the LINQ query, but it is assigned the LINQ query itself. Every time the realized values of ‘lowNumbers’ are needed, the LINQ query gets executed.




Again, we can negate this effect by assigning ‘lownumbers’ like this:




var lowNumbers = (from n in numbers


                             where n < 5


                             select n).ToList();




In this way, the realized values of the LINQ query are immediately needed to create the List<double> using the .ToList() extension method.


If we do that, the output of our sample will be:
















This shows we negated the ‘Lazy evaluation’ by making it ‘Eager Evaluation’, using the .ToList() method.




We can use the ‘yield’ statement to create iterator blocks. Iterator blocks return collections of type ‘IEnumerable<T>’ or derivatives.


When we use the ‘yield’ statement, we don’t need any temporary collections that we will return. By using the ‘yield’ statement, we use less code and it will be better readable.


Iterator blocks use Lazy Evaluation, we can negate the lazy evaluation by immediately assigning the realized values.


·         In lazy evaluation, a single element of the source collection is processed during each call to the iterator. This is the typical way in which iterators are implemented.


·         In eager evaluation, the first call to the iterator will result in the entire collection being processed. A temporary copy of the source collection might also be required. For example, the OrderBy method has to sort the entire collection before it returns the first element.

Further reads

The ‘yield’ statement on MSDN


Iterators on MSDN


Deferred Execution and Lazy Evaluation in LINQ to XML on MSDN


101 LINQ Samples: Query Execution

Hi everyone!


Rhys blogged about how he thought it was important to be able to wave at PI using the Microsoft Kinect sensor. I took this as a challenge, and bought one ... I started coding, and here is a short demo video of the results so far.


Click the link to view the video! I hope you enjoy it! (best viewed in 720P)


View the video on youtube!





The Internet Corporation for Assigned Names and Numbers (ICANN) just announced an agreement that would expand the generic top-level domains as early as summer 2012.


So there will be some new company for the old and familiar .com, .net, .info. and others. Applicants can submit their applications for domains like .coke, .nyc, .tennis, and similar as early as later this year. This could have lots of marketing value for big companies and brands. There can be security benefits as well.


All this comes with some hefty cost though. ICANN charges $185,000 per domain application, which typically must include about 150 pages of policy documents. Technical setup takes another $100,000 or so and upkeep can cost an additional $100,000 each year.


How about .PI?

Skeletal PI

Posted by RJKSolutions Jun 17, 2011

A quick blog post, apologies (or maybe a blessing) for the lack of the usual waffling in my posts.  I mentioned about the Kinect for Windows SDK in one of my other blog posts, well it is now officially available for free from Microsoft Research!  Read all about it here.


Never mind all this 'cloud' nonsense, being able to wave at PI is what everyone wants!  


How about an OSIsoft vCampus competition for the first novel development of Kinect with PI?



Last week Microsoft and Fujitsu announced a date for the very first implementation of the Windows Azure Appliance by Fujitsu. It is coming in August 2011.


Windows Azure Appliance is a container pre-configured with hundreds or thousands of machines running Windows Azure platform. Dell and HP are expected to follow Fujitsu soon. The longer vision is that smaller organizations will be given the platform to run their own Cloud.


It means the private Clouds are one step closer to reality. This should mitigate security concerns which is one of the biggest issues of hosting large data systems such as PI System.


Hello fellow vCampus members! As most of you already know, I recently joined OSIsoft. After being involved with vCampus for quite a long time as a partner, I now have the pleasure to speak to you as a vCampus Team member.

The next vCampus Live! will already be the third vCampus event!  As a community, we can all agree this is really ourevent. A lot of tech talk, great networking possibilities, and not a lot of marketing talk.

We have received a lot of feedback on the previous events, and one thing really stands out: We want more hands-on experience during the event.

OSIsoft has listened to this, and has changed the format. For the next vCampus Live! event, there will be much more hands-on labs, specially made for the occasion. This means:  less PowerPoint, more interaction, and more coding!

We are still working on the precise topics of the hands-on labs. This is where we, as the community can step in.

What we would like to ask you is:

·         What topics do you want to get more hands-on experience with?

·         How do you think this event can help you become an even better PI Developer?

We live in very exciting times, new technologies emerge in rapid pace. We are moving into a new era of computing. The future is happening right now! Be a part of this, and join us by commenting below.  Also you can email us at with your comments. Help us to make this event the best PI Tech event ever!

Please also make sure you register for the PI Coresight webinar on June 15!






Over on the tech. support web site we have posted a bulletin regarding issues that have been found with PI ACE 2010 R2 that could intermittently impact calculation results


A review has been completed, issues identified and we are verifying one last item, prior to starting testing for PI ACE 2010 R2 SP1


PI ACE 2010 R2 SP1 will be a full release of PI ACE 2010 R2 including fixes for the issues discussed in the bulletin and additional items. Once PI ACE 2010 R2 SP1 is available we'll retire PI ACE 2010 R2


The product roadmap now includes an entry for PI ACE 2010 R2 SP1 and is the official location to see planned/release information.


That said as this blog is being written we are targeting July 2011 for SP1


Glenn Moffett | OSIsoft - Product Management

I remember at this years user conference in San Francisco someone (naming no names Alex ) asked me where I find the time to post on vCampus, well here is an example.  Currently I have Ethan (you all must know Ethan by now) who currently has a case of chicken pox lying on one arm whilst I am typing with the other hand; typing with one hand is harder than it sounds and takes ages!  Anyway, enough of the waffling let's get to the real reason for this blog post...


OSIsoft has been talking about search quite a lot recently and the project they are running to have a single, unified search system that will be part of Coresight and find it's way in to the other PI client tools.  So far I am liking what I hear from OSIsoft on what the search system will bring, so I am looking forward to that.  Shortly after this I started archiving some prototype projects I once started in PI and came across a project that was a spin off from an archiving of video streams in to the PI system that we had on vCampus.  This soon got me thinking about searching video streams for data (image recognition...) swiftly followed by what I was having for dinner that night.  Once I got my thoughts back on track I wondered about the possibilities of being able to search within a video stream for significant events (this spawned other thoughts of event frames) or somehow find any video streams that have a match to a complex search criteria (even trawling the words spoken in a video stream).  


So I set off with my best friend Google (may be I should call on Bing one day) and within minutes, no seconds, I came across MAVIS on Microsoft Research.  MAVIS = 'Microsoft Research Audio Video Indexing System'.  Rather than repeat the content from the article, I highly recommend you read the MAVIS article.  Here is another MAVIS link.


I understand some control systems currently archive video streams of a process that can be shown along the same timeline of process data in the historian, but what if you could search the video in PI for either words that are spoken or image recognition (e.g. flaring) along side your process data in one query!


Interested to hear your thoughts.


After hearing the Microsoft talk at the regional seminar in Barcelona about how Kinect is being used by some developers, I'm off to hunt down the non-commercial SDK for Kinect next.
Coresight gestures here we come!

Ahmad Fattahi

Windows 8 Sneak Peek

Posted by Ahmad Fattahi Employee Jun 2, 2011

Microsoft just released a video and some details previewing the next Windows known as Windows 8. The major UI features that catch one's eye are:

  • It is designed for touch
  • "Apps" are now central pieces in the user experience
  • "Tiles" are replacing icons

To see the video for yourself follow this link.





The first version of PI for Streaminsight is released!


PI for StreamInsight is a new product from OSIsoft and is part of the PI analytical components and modules. Developers create Language Integrated Queries (LINQ) to process and analyze events, which are streamed in and out of Microsoft StreamInsight using adapters. PI for StreamInsight includes adapters for reading events as they arrive at the PI Server and writing events to the PI Server. Applications of Microsoft StreamInsight include data quality processing and event detection.

For more information about PI for StreamInsight and Microsoft StreamInsight see:


      OSIsoft User Conference 2011 – Developing Analytics Over Streaming Data with Microsoft StreamInsight & PI for StreamInsight


      OSIsoft Virtual Campus Live! 2010 - Complex Event Processing (CEP) with PI for StreamInsight (requires login)


The user conference presentation provides examples of how LINQ queries can be a good way to query data and how StreamInsight compares to other PI Analytical components




Also, as a fyi - we are working on an updated set of samples for the vCampus site!


Glenn Moffett | OSIsoft - Product Management

OSIsoft vCampus Live! has been a big event for members of this community, a chance for us to meet face to face and share our experiences and learn about working and developing with the PI System. This year's OSIsoft vCampus Live! was originally scheduled to happen on the week of 12th of September 2011, which falls on the same week as the Microsoft BUILD. In view of this conflict, we have decided that this annual event will be pushed back to a later date.


This was not an easy decision for us; our developers and product managers are always eager to share with you news about the PI System face to face. But at the same time we are all interested in attending Microsoft BUILD and learn about upcoming Windows technology, so that we can utilize these technology advancements to bring you an even better PI System in the future. Some of our vCampus Community members are also considering the Microsoft BUILD event to stay abreast on Windows technology. Hence, instead of making it a tough decision between the two events, we decided to reconsider the time of OSIsoft vCampus Live! event.


We are also taking this opportunity to evaluate how you want the next OSIsoft vCampus Live! to be like. We have set up a survey about OSIsoft vCampus Live! a couple of weeks ago. If you still haven't given us your feedback, there is still time to do so @


In the meantime, stay tuned for more information about OSIsoft vCampus Live!





Filter Blog

By date: By tag: