8 Replies Latest reply on May 5, 2016 5:22 PM by Lonnie Bowling

    How can I programmatically update the compression settings of multiple tags?

    unagaswamy

      I would like to update the compression settings of multiple tags using the PI Web API and python.  I understand that I have to use a PATCH request. But, I could only find examples of updating tag attributes such as name, descriptor, etc.  How can update the configuration settings for a tag?

        • Re: How can I programmatically update the compression settings of multiple tags?
          Lonnie Bowling

          Hi Uma,

           

          Take a look the AF SDK documentation for possible point attributes that should be available. The PI Web API is often a wrapper for the AF SDK, so a trick is to look at the SDK documentation for more details. Here is a link that may help:

           

          PICommonPointAttributes Class

           

          I would try to use the CompressionDeviation setting and see if that works for you.

           

          Lonnie

          1 of 1 people found this helpful
          • Re: How can I programmatically update the compression settings of multiple tags?
            Eugene Lee

            Hi Uma,

             

            The keywords you are looking for are

            1.compdev

            2.compmax

            3.compmin

            4.compressing

            5.compdevpercent

             

            For example:

             

            Do a PUT to this endpoint with the value that you want for the compression deviation.

            https://<servername>/piwebapi/points/<webid>/attributes/compdev

            2 of 2 people found this helpful
            • Re: How can I programmatically update the compression settings of multiple tags?
              gregor

              Hello Uma,

               

              Adjusting PI Point attributes is what I consider a PI Administrators task and would assume tools like PI Builder being used. Can you please explain, what you are trying to accomplish?

              2 of 2 people found this helpful
              • Re: How can I programmatically update the compression settings of multiple tags?
                Marcos Vainer Loeff

                Hello Uma,

                 

                How many PI Points do you need to update their attribute? If this number is really high and performance is really important, you might want to consider developing a custom ASP.NET Web API project with PI AF SDK. I had to do that several months ago and here is the code snippet for you to refer to:

                 

                 

                                    PIPointList allPointList = new PIPointList(allPIPoints);
                                    allPointList.LoadAttributes(attributesNames);
                
                
                                    PIPointList newPointList = new PIPointList();
                
                
                                    foreach (PIPoint piPoint in allPIPoints)
                                    {
                                        bool isCorrect = true;
                                        IDictionary<string, object> attributes = piPoint.GetAttributes(attributesNames);
                                        foreach (var attribute in attributes)
                                        {
                                            if (System.Convert.ToInt32(attribute.Value) != 0)
                                            {
                                                isCorrect = false;
                                            }
                                        }
                                        if (isCorrect == false)
                                        {
                                            Log.Write("New PI Point fixed: " + piPoint.Name);
                                            newPointList.Add(piPoint);
                                        }
                                    }
                                    IDictionary<string, object> attributeValue = new Dictionary<string, object>();
                                    attributeValue.Add(PICommonPointAttributes.Compressing, 0);
                                    attributeValue.Add(PICommonPointAttributes.ExceptionDeviation, 0);
                                    newPointList.SaveAttributes(attributeValue);
                

                 

                As this is going to be a RESTful web service as well, you can still make queries against it using Python.

                 

                Hope it helps!

                1 of 1 people found this helpful
                • Re: How can I programmatically update the compression settings of multiple tags?
                  Marcos Vainer Loeff

                  Forgot to mention that the current version of PI Web API (2015 R3) enables you to update only one attribute per request, as you probably have already realized. According to enhancements description, this seems to be also valid for the upcoming release of this product (2016).

                   

                  As a result of this limitation, if you have too many PI Points, it can be slow. You can use BATCH or develop your own custom ASP.NET Web API to make this process faster.

                   

                  Hope my explanation makes more sense now!

                  1 of 1 people found this helpful