andrew_Inwood

Event Pipe for multiple points

Discussion created by andrew_Inwood on Aug 14, 2014
Latest reply on Aug 15, 2014 by Gregor

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?

 

 

 

 

Outcomes