5 Replies Latest reply on Aug 30, 2010 7:22 PM by spilon

    Adding Multiple tags at once IPIPoints2 C#


      I'm currently trying to create an application that Parses a text file and pulls out the neccesary information required to create a list of tags ~3500 for now. Nothing wrong with my Parsing the textfile (and if there was I wouldn't bother you fine people with that ). So far I take the desired tagName, description, units, classname, and if applicable digitalset and attempt to add them to the PI Server via IPIPoints2.AddTags in a manner similar to this:


      PISDK.Server myServer = g_SDK2.Servers[servPickList2.SelectedServerName.ToString()];     // server object from the name in server pick list
      PISDK.IPIPoints2 IPIP2 = (PISDK.IPIPoints2)myServer.PIPoints;
      PISDKCommon.NamedValues nvsAddRemove = new PISDKCommon.NamedValues();
      PISDKCommon.PIErrors myAddErrors = new PISDKCommon.PIErrors();
      PISDK.PointList myPtList = new PISDK.PointList();
      PISDKCommon.PIErrors myRemoveErrors = new PISDKCommon.PIErrors();
      string tagName = "";
      string trueMsg = "";
      string falseMsg = "";
      object descriptor = "";
      object engUnits = "";
      object pointType = "";
      object className = "classic";
      object digitalSet = "";
      object pointSource = "L";
      foreach (string item in listOfNeccesaryInformation)
          String[] cs1 = item.Split(';');
          PISDKCommon.NamedValues nvsTagAttr = new PISDKCommon.NamedValues();
          tagName = cs1[0].Trim();
          engUnits = cs1[2].Trim();
          trueMsg = cs1[3].Trim();
          falseMsg = cs1[4].Trim();
          descriptor = cs1[5].Trim() + " LocationId: " + cs1[ 6].Trim() + " ValueId: " + cs1[7].Trim();
          pointType = PISDK.PointTypeConstants.pttypFloat32; //digital if applicable
          nvsTagAttr.Add("ptclassName", ref className);
          nvsTagAttr.Add("pointtype", ref pointType);
          nvsTagAttr.Add("Descriptor", ref descriptor);
          nvsTagAttr.Add("EngUnits", ref engUnits);
          nvsTagAttr.Add("pointsource", ref pointSource);
          object nvsTagAttr2 = nvsTagAttr;
          nvsAddRemove.Add(tagName, ref nvsTagAttr2);
      IPIP2.AddTags(nvsAddRemove, out myAddErrors, out myPtList, null);


      No compile issues but when I run through the loop it doesn't create any of the points. If I debug it "myAddErrors" has ~3500 errors (I guess is what it means), can someone tell me what I'm doing wrong, or at least how to access the errors that are listed under "myAddErrors"?




      -Thank You



        • Re: Adding Multiple tags at once IPIPoints2 C#

          Here is a little code snippet:

          foreach (PISDKCommon.PIError myError in myAddErrors)

          Possible reasons are already existing tags, limited access rights, etc. Just let us know what you get as error message and we might be able to help further.

            • Re: Adding Multiple tags at once IPIPoints2 C#

              Thank you very much Andreas, and I do have the error message. I thought it was pretty straight forward when I saw it at first, but there must be something I'm not understanding.


              Error adding tags to PIPoints collection.[-12216] Maximum licensed aggregate
              Point/Module Count exceeded. (FatalError)


              That is the error message. I assumed it meant that the PI Server I was trying to add the points to was full, it had ~16100 points. Most of which were dummy points, so I removed several thousand and tried again, same error message. Anyone have any ideas, any help is very much appreciated.




              -Thank you

                • Re: Adding Multiple tags at once IPIPoints2 C#

                  Couple things here: this message has to do with both PI Points and PI Modules (in the PI Module Database), so make sure you count Modules as well as PI Points (might be the source of your problem, if you are using Module Database extensively...). The Licensing plug-in in SMT should give you the breakdown of these numbers


                  By default, the PI Server provided in the vCampus PI Products Kit is limited to 10,000 - should you have a specific need for more, please contact us at vCampus@osisoft.com and we'll see what we can do.


                  One other thing is, you might want to restart the PI Base Subsystem. Or even the PI Server as a whole, if you are using an older version of PI... I seem to recall there was a problem with PIBaseSS allowing point creation again after coming back under threshold, on an older version of PI...