6 Replies Latest reply on Sep 15, 2014 4:50 PM by jking

    Snapshot value of pipoint

    torsteins

      I (think) I have a strange behaviour in my application. 

       

      I want the snapshot value of an attribute, and the exact code is like this :  "afattribute".PIPoint.Snapshot().Value

       

      This is working as expected and gives me the current value of the attribute. The "error" is when there exists child-attributes - then the above mentioned code would return the value of the first child-attribute. 

       

      Can someone verify this, or tell me if I have done something wrong? 

       

      I currently use AF SDK 2.5.2.5396 

        • Re: Snapshot value of pipoint
          Rick Davin

          I am curious as to why you don't simply use afattribute.GetValue().Value to get the snapshot for the attribute (regardless of whether or not that attribute is a PIPoint)?

            • Re: Snapshot value of pipoint
              jking

              I have tested this on both AF 2.5.2 and 2.6.1 and I am not able to reproduce this problem.  With both versions, I am able to get the correct value back.  Here are my steps I tried to reproduce:

               

              1) Create an attribute that points to PI tag sinusoid

               

              2) Create a child attribute under the above attribute that points to sinusoidu.

               

              Then I execute the below code:

               

                         PISystems afServers = new PISystems();

               

                         AFDatabase afDB = afServers["dlwin2k8r2x64"].Databases["Database3"];

               

                         AFElement elem1 = afDB.Elements["Element7"];

               

                         AFAttribute attrib1 = elem1.Attributes["Attribute1"];

               

                         object val = attrib1.PIPoint.Snapshot().Value;

               

                         object val2 = attrib1.Attributes["Attribute1"].PIPoint.Snapshot().Value;

               

              Please tell me if you are doing anything different than this.  If  you cannot see any difference, perhaps try my code and see if you see same behavior.

               

              Thanks,

               

              Jason

              • Re: Snapshot value of pipoint
                torsteins

                Rick: Legacy reasons I guess, haven't been looking into why, I have just used the code. But - that said - if I use afattribute.GetValue().Value i am getting the correct value (and if i switch back to afattribute.PIPoint.Snapshot().Value i'm still getting the child attributes value..... strange!)

                  • Re: Snapshot value of pipoint
                    Marcos Vainer Loeff

                    Hi Torstein,

                     

                    Could you please provide us a procedure creating an AF database from scratch in order to reproduce the issue? You can create a database with one element, one attribute and some child attributes referring to the sinusoid and cdt158 PI Points. Unfortunately, it would be difficult for us to help you if we cannot reproduce it. You can also export the database information to a XML file using PI System Explorer.

                      • Re: Snapshot value of pipoint
                        torsteins

                        Hi,

                         

                        I've done some investigations with the steps asked for by Jason - and i could't reproduce the error on any other data myself. When i've checked the data from the attribute and child-attributes it all comes down to some weird mapped UOM's on the attributes and some numbers happens to be the same which caused the confusion. The data read when used PIPoint.Snapshot().Value is correct, but are mapped with different UOM in AF which gave me another number when using  just GetValue().Value ...

                         

                        Sorry for the trouble!