11 Replies Latest reply on Nov 16, 2012 12:44 PM by mhalhead

    Receive PI notification programmactically

    recursionsw

      Hi,

       

      I am developing an application in c#  that needs to set watch on the PI points (that have been configured to generate notification when certain conditions are met). My code needs to be notified when watched points have events. The application is not UI based. Is there a sample code I can take a look for this purpose?

       

      Thanks!

       

       

       

       

       

       

       

       

        • Re: Receive PI notification programmactically
          mhamel

          @Neil: What you are looking for is called signing up for updates or event pipes. I suggest you take a look at the PI Application Development Course workbook in chapter 7 under the section called Event Pipes. You can also use this link to refer to a past webinar.

           

           You can also search the different threads referring to EventPipe or Event Pipe by using the search box in the upper right corner of each page.

            • Re: Receive PI notification programmactically
              yyao

              Where can I find the PI Application Development Course workbook? Thanks!

                • Re: Receive PI notification programmactically
                  Ahmad Fattahi

                  The course has its own section in vCampus Training Center. Good luck!

                    • Re: Receive PI notification programmactically
                      Asle Frantzen

                      And if you want to do what you actually ask for in the subject of your post (use PI Notifications) you can start by downloading the PI Notification Developer Tools from the Download section (Under Analysis), then create an ANNotificationList in your program, and sign up for InstanceEvents and ContactEvents from that list to be able to react when ever something happens for the notification.

                       

                      You're probably best off using EventPipes directly with PI tags for now, but later you might use AF Server and PI Notifications.

                        • Re: Receive PI notification programmactically
                          yyao

                          Thanks for the reply.

                           

                          I am so new to OSI PI so I am still having lots of questions regarding eventpipes and PI notification:

                           

                          1. What is the main difference between eventpipes and PI notification? From what I have learning so far, I think eventpipes only pass events about a tag that has changed values but PI notification will actually raise an alarm when the value change cross a preset threshold...is my understanding correct?

                           

                          2. Our app needs to receive the alarm notification from PI server. For example, for PI tag "CDT158", if the value of the tag is greater than 200 than our app needs to be notified. If the value is 198, then our app will not get the alarm notification from PI. Can this be accomplished through eventpipes as well? Or we need to use PI notification?

                           

                          3. Our app needs to write acknowledgement back to PI server after receiving an alarm of a tag. Should we do this with eventpipes or PI notification?

                           

                          Thanks for your help.

                            • Re: Receive PI notification programmactically

                              Yifei Yao

                              What is the main difference between eventpipes and PI notification? From what I have learning so far, I think eventpipes only pass events about a tag that has changed values but PI notification will actually raise an alarm when the value change cross a preset threshold...is my understanding correct?
                              As of today, PI Notifications are generally focused on a specific point in time and they are more of an "active" mechanism (with the concepts of delivering notifications, as well as acknowledgement and escalation of those), whereas PI Event Frames actually "frame" event with 2 points in time and are generally more of a "passive" paradigm (i.e. used for analytics, reporting, etc.)

                               

                              Yifei Yao

                              Our app needs to receive the alarm notification from PI server. For example, for PI tag "CDT158", if the value of the tag is greater than 200 than our app needs to be notified. If the value is 198, then our app will not get the alarm notification from PI. Can this be accomplished through eventpipes as well? Or we need to use PI notification?
                              Event Pipes in PI SDK look at "raw data", so you would have look A) get all value changes from cdt158, and B) look up and react when the value is greater than 200. If you want to get alarms for the "processed" data (i.e. you already know the value is greater than 200), then you can use PI Notifications. Another approach might be to set up a Performance Equations (PE) tag to do the pre-processing (e.g. look at tag conditions and toggle the value between Alarm and Normal) and then have your EventPipe based on that.

                               

                              Yifei Yao

                              Our app needs to write acknowledgement back to PI server after receiving an alarm of a tag. Should we do this with eventpipes or PI notification?
                              That would be better served by PI Notifications.

                                • Re: Receive PI notification programmactically
                                  yyao

                                  Thanks for the reply.

                                   

                                  Our app will not do any analysis on the values of PI points. It is my assumption that PI points will be configured of notification state (for example, HIHI when the value is greater than 200) through the PI system explore. Our customer is running the PI server and our app will connect to the PI server to receive alarms for those preconfigured alarms (when the conditions are met). I think based on what I have learned so far I need to use PI notification. I have looked some notification examples but still seem at a loss as how to subscribe to a PI point,  listen to the notification, and writing ack back. Can you point me to some examples specifically address those issues? Thanks!

                                   

                                  -Yifei

                                    • Re: Receive PI notification programmactically

                                      I would kindly suggest you start by learning about PI Notifications in general, using both the User Manual and the various videos on the YouTube OSIsoft Learning Channel. Here is the sub-category for PI Notifications: [View:http://www.youtube.com/playlist?list=PL5227D1AFF2A40A6B&feature=plcp].

                                        • Re: Receive PI notification programmactically
                                          mhalhead

                                          Yifei,

                                           

                                          Quickly reading through this post I would be inclined to look at the following approach; although I don't know all the details of you application.

                                           

                                          I would use PI Notifications (PINS) to handle all the event logic; e.g. when to trigger a notification. I would use the web services delivery channel (standard out the box DC) as the mechanism to send the notifications. This means that your application would have to consist of a web service to which PINS can connect. The one question I would have is how you would handle the acknowledgement; you could always go via the standard out the box acknowledgment website.

                                           

                                          IMHO this is quite a nice solution as it will create a clean decoupled solution with you writing the least amount of code.

                                           

                                          I'm assuming that your customer has AF and Notifications?

                                           

                                          As a general comment. I feel that PINS is a very misunderstood technology. It is largely sold as a mechanism to send emails; I blame the sales reps for this. We are using it for all sorts of things; notifications to SAP-PM (a work in progress), sending data to vendors and the obligatory notify people.

                                            • Re: Receive PI notification programmactically
                                              mikeloria

                                              I am looking for a similar solution. I was not considering the web service approach because the capturing of the event is dependent upon the web service which adds complexity. If the web service is not running or is unavailable (network), the event may be lost and unrecoverable (or at least we would not have knowledge as to what happened during the time it was unavailable. I was considering creating the XML file for each event which is a total decoupled approach but has its own caveats.

                                               

                                              Is there anyway to ensure that all event are captured with a web service (maybe a comparison routine)? anyway to create a process that retrieves events "after the fact" if needed?

                                                • Re: Receive PI notification programmactically
                                                  mhalhead

                                                  Hi Mike,

                                                   

                                                  This is admittedly an issue of using a web services. In our case it didn't matter that much.

                                                   

                                                  If losing events is a big issue an option would be to use a message queue; something like MSMQ. This would require that you write a custom DC to put the messages onto the queue. You would then have another process which reads the messages off the queue and processes them. The messages on the queue are only removed once they have been successfully processed.  

                                                   

                                                  MSMQ is a pretty robust technology with things like guaranteed delivery.