4 Replies Latest reply on Dec 7, 2011 12:01 AM by andreas

    AF Eventing Issue

    sandeep.narang

      Hi Team

       

       

       

      We are using OnChange() method to capture the changed elements/attrbiutes in AF Database. Here we need to capture the change on addition/change/deletion.

       

      The issue which we are facing is that wheneve any element/attribute is changed or inserted, we are always geting the AFChangeAction as SubObjectRefresh in event args  parameter e of OnChange() function.

       

      Whereas as per our requirement , we should get the AFChangeAction as SubObjectAdd in case of insertion and SubObjectChange in case of updation.

       

      Another issue is that if there is any way so that we get the identification of the attribute involved in Change/Add/Deletion?

       

       

       

      Thanks and Regards

       

      Sachin

        • Re: AF Eventing Issue
          jagadeesh.macherla

          Any suggestions team?

            • Re: AF Eventing Issue
              andreas

              Sachin - if you add an element, you should get a SubObjectAdd event, and to find out the parent you can use the GUID that is in e.ParentID.

               

              I just verified that by adding the following code to the example from the PI AF documentation:

               
                          Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.000") + " " + "Object Changed Event Raised");
                          Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.000") + "Action: " + e.Action.ToString());
                          Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.000") + "Parent: " + e.ParentID.ToString());
              
                          if (e.Action.ToString().Equals("SubObjectAdd",StringComparison.OrdinalIgnoreCase)) 
                          {
                              OSIsoft.AF.Asset.AFElement myElement;
                              myElement = myDB.Elements[e.ParentID];
                              Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.000") + "Parent: " + myElement.GetPath());
                          }
              

               

                • Re: AF Eventing Issue
                  jagadeesh.macherla

                  Hi Andreas,

                   

                  Thanks for your reply!!!

                   

                  Here if I change the attribute value then it raises the SubObjectRefresh event. And also after addition if I CheckIn the changes then it raises Change followed by SubObjectRefresh event. So it's hard to distinguish whether attribute value has been changed based on SubObjectRefresh event as it is raises many times.

                   

                  If I am able to come to know that there is change in attribute value, it will solve my half problem. As My requirement is that if we make any changes (Value Change/ Addition/ Deletion) into element, it will notify me.

                   

                  And one more thing Is there a way to get the deleted element information?

                   

                  Thanks,

                   

                  Sachin

                    • Re: AF Eventing Issue
                      andreas

                      Sachin - I checked with the PI AF developer. When changes are made externally, then the entire element is updated during a refresh.  In this case, the PI AF SDK does not report individual changes for each attribute, but rather, issues one event that the element was refreshed and changes are available. The reason is simply for performance – tracking and sending numerous events would add considerable overhead.