14 Replies Latest reply on Mar 15, 2011 5:23 AM by jagadeesh.macherla

    Event notification based on value.

    jagadeesh.macherla

      Hi Team

       

      As we are implementing event notification based on event pipes in our application, we need to get notified only when value changed is in certain limits or in other words, we want to get notified for value change only for bounded values.

       

      For example, for tag name "A" if the value changed is above 0.5 from the previous value or value changed is between 0.5 and 1.0, then only event notification occurs.

       

      Please suggest more on this.

       

       

       

      Thanks

       

      Jagadeesh

       

       

        • Re: Event notification based on value.
          andreas

          Hi Jagadeesh,

           

          Event pipes notify for any events. If you want to filter that you may create alarm tags and implement event pipes for these tags.

            • Re: Event notification based on value.
              jagadeesh.macherla

              Hi Andreas

               

              We dont want to create new tags(alarm tags) as we want to filter the existing tags only based on the value. Is there any other way( like any method in PI SDK API) to raise notification based on value filteration?

               

              Even we did not get any help material on alarm tags in PI SDK documentation. Can you please provide an example for Alarm Tag Usage in event notification?

               

              Thanks

               

              Jagadeesh

                • Re: Event notification based on value.
                  andreas

                  Jagadeesh,

                   

                  AFAIK there is no filter mechanism in eventpipes.

                   

                  Regarding the alarm tags, you can find the documentation in the vCampus Library > vCampus PI Product Kit > Server Products > PI Server > PI Server Application User Guide > PI Alarm Subsystem.

                   

                  Afterwards you can treat the alarm tags just as normal tags in your PISDK application.

                    • Re: Event notification based on value.

                      As Andreas pointed out, there is no filter mechanism in PI SDK Event Pipes (as you might have noticed, there is a SetFilter Method signature on the EventPipe object, but it is currently not implemented).

                       

                      But even if it was implemented, I think you are better served by looking at existing products where we wrote this kind of logic (and much more) for you. Things like the PI Alarm Subsystem (mentioned by Andreas) or, more recent and more powerful, the PI Notifications product.

                        • Re: Event notification based on value.
                          jagadeesh.macherla

                          Thanks for your inputs team :)

                           

                          I have another issue. Currently I am fetching the points using following statement:

                           

                          PointList pList = myPIServer.GetPoints("tag='" + tagName + "'", null);

                           

                          My question is how can i fetch the points for multiple tags. Like, suppose, user passed the tags as "A" and "B*", does PI SDK support the point fetching for multiple tags at once? Or do i need to write the logic at my end only using iteration loops?

                           

                          Thanks

                           

                          Jagadeesh

                            • Re: Event notification based on value.
                              Ahmad Fattahi

                              Jagadeesh,

                               

                              You can use the ListData object associated with the PointList to handle batch operations on a list of PI tags. For example, see the ArcValue method and Snapshot property, among many more, of the ListData object.

                                • Re: Event notification based on value.
                                  jagadeesh.macherla

                                  Thanks Ahmad :)

                                   

                                  Another issue. Since I have implemented OnNewValueChanges event for eventpipe to notify for value changes, how can i get the delta change for value, in other words, i need to get the difference between last value and new value. I have seen the property LastValueSent in PIData object but its implemented in SDK.

                                   

                                  Can you please suggest me a way to achieve the value difference?

                                   

                                  Thanks

                                   

                                  Jagadeesh

                                    • Re: Event notification based on value.
                                      hanyong

                                      Hi Jagadeesh,

                                       

                                      I think a way to do this is to store the last value of the tag, so that you can use it for comparison when the new value is received from the EventPipe. 

                                       

                                      The idea would be something like: application get the snapshot value of the tag on startup, saving it as the last value and signing up for EventPipe's OnNewValues events. Then as new value comes in from the EventPipe, compare it with the last value according to your required logic, and replace the last value with new values (so that the last value is updated)

                                       

                                      Hope this helps.

                                        • Re: Event notification based on value.
                                          jagadeesh.macherla

                                          This will be a cumbersome task when there are large number of tags. As to maintain the history of all the tags for last value will definitely take a toll on the performance of the application. It will be helpful if PI SDK itself provides some in built method or property to get the last value of the tag.

                                           

                                          Thanks

                                           

                                          Jagadeesh

                                            • Re: Event notification based on value.
                                              hanyong

                                              You can use PI SDK methods that can read that value from the PI Server. Here's some ways that I can think of, and you can give them a try.

                                              1. PIData.RecordedValuesByCount method to read the last 2 value of the tag from the current time (which should give you the snapshot and the last value before the snapshot value, a small code snippet that does this:
                                                [PISDK.PISDK _sdk = new PISDK.PISDK();
                                                Server _svr = _sdk.Servers.DefaultServer;
                                                PIPoint _pt = _svr.PIPoints["BA:LEVEL.1"];
                                                PIValues pivalues = _pt.Data.RecordedValuesByCount(System.DateTime.Now,
                                                                              2, 
                                                                              DirectionConstants.dReverse, 
                                                                              BoundaryTypeConstants.btInside, 
                                                                              "", 
                                                                              FilteredViewConstants.fvRemoveFiltered, 
                                                                              null);
                                              2. PIData.ArcValue method with the rtBefore mode and the timestamp of the new value. The rtBefore mode will search for the 1st recorded value before the passed timestamp. So using the new value's timestamp as reference, you should get the last value before the new value.
                                                PIValue pivalue = _pt.Data.ArcValue( <<timestamp of the new value>>,  RetrievalTypeConstants.rtBefore, null);

                                              Depending on the the actual situation that you are facing, one method may be better than the other. Hope one of these would be useful to you.

                                                • Re: Event notification based on value.
                                                  jagadeesh.macherla

                                                  Han

                                                   

                                                  I have tried both the methods suggested by you in above post but getting the following error every time on both the statements:

                                                   

                                                  Failed to retrieve events from server.  [-10010] PI System Timed Out

                                                   

                                                  Can you please tell the possible cause of this?

                                                    • Re: Event notification based on value.

                                                      In the nicest way possible, I think it would be appropriate to initiate new discussion threads (with appropriate title and 'tags') when discussing new issues. This is mostly for the benefit of other members of the community and allows for better searching of desired answers. For instance, there are (at least) 3 different, unrelated topics discussed here within a thread titled "Event notification based on value"

                                                       

                                                      Just a friendly note, to help make this community and its resources more useful ;)

                                                       

                                                      Happy PI Day!!! (today is 3/14)

                                                        • Re: Event notification based on value.
                                                          hanyong

                                                          @Steve: thanks for the suggestion.

                                                           

                                                          @Jagadeesh: a quick response to the error you have. "[-10010] PI System Timed Out" suggests that your PI Server license has expired and you need to generate a new one. I'd suggest that you proceed to Download Center, follow the link to My License Activation (MLA) for generating the license for your PI Server. If you encounter problems generating the license via MLA, you can always contact our Techsupport Team who would be able to assist you in the process. 

                                                           

                                                          Hopefully, the suggested methods will work out for you when you test it after the new license is generated. As per Steve's suggestion, if you have another question in your development, you can start a new thread in the appropriate forums