3 Replies Latest reply on Aug 15, 2014 11:04 AM by Gregor

    Event Pipe for multiple points

    ainwood

      I have taken the output from some tutorials and the SDK help file and used them to write an example to essentially run some code on a _OnNewValue event.  Works fine.

       

      The way I watch a point is via the PiPoint.EventPipe object. 

       

       

       
                  //Get the point
                  m_oTagPoint = piServer.PIPoints[sTag];
                  
                  if (m_oTagPoint != null)
                  {
                      //Now try to add an event pipe handler
                      try
                      {
                          //Get the event pipe
                          piEventPipe = m_oTagPoint.Data.EventPipe;
      
                          //Get the event pipe event handler
                          piPipeEvents = (_DEventPipeEvents_Event)piEventPipe;
                          piPipeEvents.OnNewValue += new _DEventPipeEvents_OnNewValueEventHandler(PI_Watcher_OnNewValue);
                      }
                      catch
                      {
      
                      }
                  }
      

       This works OK.  However, I have two questions: 

       

      1.)  Is this the correct syntax to remove the event handler in the class destructor?

       

       

       
      ~PI_Watcher()
              {
                  piPipeEvents.OnNewValue -= new _DEventPipeEvents_OnNewValueEventHandler(PI_Watcher_OnNewValue);
              }
      

       Secondly, how can I add a watcher to multiple points?

       

       

       

       

        • Re: Event Pipe for multiple points

          Hello Andrew,

           

          PIPoints is a collection object. Instead of just adding one point to the list, just add multiple and sign up for point updates. You also wouldn't need to change your event handler assignment. PI Update Manager will return all events collected. Regarding your question # 1, I do not see any explicit destructor.

           

          However, for new development projects we highly recommend developing against the Rich Data Access AF SDK 2.6 (OSIsoft.AFSDK.dll at %PIHOME%\AF\PublicAssemblies\4.0). The library is installed by the PI Asset Framework (AF) Client 2014 Install Kit available at vCampus Download Center - category "PI Asset Framework". To get the belonging help file (%PIHOME%\Help\AFSDK.chm), please install PI AF Developer Tools 2014. With regards to PI Update Manager sign-ups, please look for PIDataPipe in the help file. Example code is available in Visual Basic and C#

           

          PI SDK is based on COM while AF SDK is a managed .NET assembly. There are just a few functions in PI SDK which do not have an equivalent in AF SDK today. Especially when using the bulk calls implemented into AF SDK the performance is a lot better than with PI SDK.

            • Re: Event Pipe for multiple points
              ainwood

              Thanks.  

               

              For creating a PIPoints collection object and adding tags to it, can you please provide some sample code?  I can see how to populate a PISDK.PIPoints interface object via the .Add() method, but that method essentially searches for points matching a search criteria.  I can't see how to get a PIPoint object and add it to a PIPoint collection.  As the PISDK.PIPoints is an interface, I can't declare a new collection (this all said, I am relatively new to using COM interfaces, so struggling with it a bit).

               

              Regarding the Rich Data Access, we don't have asset framework on our PI instance.  We have a fairly old version - PI Processbook version 3.2.3, PISDK version 1.3.6.  Will the PI AF Developer tools work with this? (We have started an investigation into upgrading our PI infrastructure and software, but that won't happen until next year).

                • Re: Event Pipe for multiple points

                  Hello Andrew,

                   

                  Please accept my apology. The object to use is PISDK.PointList and not PISDK.PIPoints. You might be interested in this earlier discussion that also contains some code snippets.

                   

                  I haven't tested but you should be able using OSIsoft.AF.PI namespace of AF SDK even you do not use PI Asset Framework yet if your PI Server is at least version 3.4.380 since this is the minimum version recommended with PI AF 2014 Release Notes. PI AF Server became integrated with PI 2010 (version 3.4.385.59). The PI AF Client installation will prompt you to specify an AF Server node but as long as you don't try to connect against AF Server, there shouldn't be any issue.