3 Replies Latest reply on Jan 22, 2013 3:51 PM by mhamel

    IPIPoints2.AddTags Maximum tag count

    bpolaski

      We have been developing a tool to help create AF structure and PI tags from an XML import file.  Using the tool usually results in trying to create 10K+ tags in one running.  To facilitate this large number of tags we decided that instead of using the PIPoints.Add method we would use the IPIPonts2.AddTags as it was to be a more efficient implementation for multiple tags.

       

      In our testing we have run into an error being thrown by the call IPIPoints2.AddTags.
      HRESULT: 0x800407B1 (Error adding tags to PIPoints collection.)

       

      This error is caught by the surrounding Try Catch and not returned as part of the PIErrors that is returned by the operation.

       

      The weird thing with the error is that it is not consistently thrown.  We can run the same import file multiple times and only get the error a few times in the runs.  It does not happen at the start of the call either, upon checking the PI server we find varying amounts of tags created before it throws the error.

       

      My question is this:
      Is there a threshold in which the IPIPoints2.AddTags starts having issues and we should do something to make smaller groups of tags to add instead of large chucks all at once?
      Is there some condition weshould be checking for, before making the call which is causing the error? 

       

      The Executing code section:

       
      try
      {
           IPIPoints2 ServerPointList = (IPIPoints2)currentPIServer.PIPoints;
           ServerPointList.AddTags(PITagList, out AddErrors, out CreatedTagList);
           if (AddErrors.Count != 0)
           {
               // if there were problems try to edit the tags.
               // This assumes the tags that had issues already existed
               // record the adderrors
               foreach (PIError error in AddErrors)
               {
                   Logging.log.Error(error.Source + " " + error.Number + " " + error.Description);
               }
               ServerPointList.EditTags(PITagList, out EditErrors);
               if (EditErrors.Count != 0)
               {
                   // if we were not able to fix the issue by editing tags
                   // remove all of the added tags and back out of the import
                   foreach (PIError error in EditErrors)
                   {
                       Logging.log.Error(error.Source + " " + error.Number + " " + error.Description);
                   }
               }
           }
      }
      catch (Exception ex)
      {
          // something outside of anything expected happened.
          Logging.log.Error("The following error Occured while the tags were being built:" + ex.Message, ex);
      }
      

       

       

      Stack Trace of the error:
      System.Runtime.InteropServices.COMException (0x800407B1): Exception from HRESULT: 0x800407B1
      at PISDK.IPIPoints2.AddTags(NamedValues pnvsTagsAndAttrs, PIErrors& hErrors, PointList& hList, PIAsynchStatus pAsynchStatus)

        • Re: IPIPoints2.AddTags Maximum tag count
          mhamel

          @Bryan: IMO, I have never seen any threshold limit imposed to IPIPoints interface. I looked over our technical support database to see if someone has ever hit this problem and this was not reported. I would be think the problem resides elsewhere.

           

          Have you taken a look at the PI Message Log to see if you would get more details on what have caused the error? What is the version of your PI Server and PI SDK?

            • Re: IPIPoints2.AddTags Maximum tag count
              bpolaski

              Mathieu,

               

              I checked the PI message logs and did not see any errors on either the system running the code or on the PI server itself.

               

              PI server version: 3.4.380.36

               

              PISDK version : 1.4.0.416

               

              Any other suggestions on things I can do to better capture the error?

                • Re: IPIPoints2.AddTags Maximum tag count
                  mhamel

                  @Brian: The PI Server 2012 (3.4.390.x) have improved several subsystems in term of performance and scalability. I know that it can handle better the tag creation. I would add that I adhere to the maxim: "Divide for conquer!” You cannot perform everything into a single action, sometimes it is inefficient or it cannot work.

                   

                  Related to your issue, there is a certain trade off to accept between individual calls and one huge call. If you consider a fixed block size of 1,000 tags, you would make 10 round-trips to create 10,000 tags. This would give some relief to the PI Server to perform quick tasks in between. I would highlight that probably the final goal is to take the less amount of time to complete the "transaction" of creating the tags by the user. The user won't really care in the number of round-trips it makes with the PI Server, but will on time spent to wait for completion. What is the good answer: 1, 5, 10, 100 round-trips? It depends of your criteria.

                   

                  If you want to continue investigating the issue with 10,000+ tag creation, I would suggest you contact our technical support and use this thread as the reference to your problem.

                   

                  I hope this helped!