8 Replies Latest reply on Sep 27, 2018 1:01 AM by pauljohnson

    Newbie question.  How to Obtain an array/list of PiPoints Using the PISDK

    pauljohnson

      Hi there

       

           I have a requirement to put together a prototype windows service to right data to the PI Data Archive.   In order to do this I would like to retrieve an array or list of PIPoints for a specific PointSource.  Ideally I only want to hold the TagName, PointID and the InstrumentTag attributes.  How can I achieve this?  We are using version 1.4.0.416 of the PISDK.

       

      Kind Regards

      Paul Johnson

        • Re: Newbie question.  How to Obtain an array/list of PiPoints Using the PISDK
          tramachandran

          Please note that we are Deprecating the PI SDK . Also the version of PI SDK (1.4.0) you are using seems to be quite outdated and it is recommended you upgrade to newer versions if possible.

           

          Sample code snippet (v. 1.4.7)

          var mySDK = new PISDK.PISDK();
          var mySrv = mySDK.Servers["PIDATrainingSRV"];
          var search = "pointsource = 'OPC'"; // search string for filter by pointsource
          var tagsSearched = mySrv.GetPoints(search); //generate PointList 
          foreach (PIPoint t in tagsSearched) //iterate and get desired attributes
              {
                    Console.WriteLine($"{t.Name}, {t.PointAttributes.CommonAttribute(CommonAttributeConstants.cmnatrPointID).Value}" +
                          $", {t.PointAttributes.CommonAttribute(CommonAttributeConstants.cmnatrInstrumentTag).Value}");
              }
          

          You should be able to trap errors like psePICONSTANTNOTFOUND, pseCONSTENUMNOTFOUND and psePOINTATTRNOTFOUND in your code.

           

          Programming reference: PI Software Development Kit

          1 of 1 people found this helpful
            • Re: Newbie question.  How to Obtain an array/list of PiPoints Using the PISDK
              pauljohnson

              Hi there thank you for your feedback, unfortunately, I am not in a position to change the version of the PISDK, this is a corporate controlled environment.  We are in the process of evaluating our current PI architecture with a view to upgrading in the near future, however I am stuck with the current version for this exercise.  Please note I am using VB.NET.  Your sample is almost exactly the same as an attempt I made earlier today apart from the obvious syntax differences.  When I attempt to use your code I get a DISP_E_TYPEMISMATCH COM error when the GetPoints method is executed.  I suspect this may have something to do with the fact thatvb.net does not have a direct equivalent to the 'variant' datatype.  Any suggestions as to a way forward?

               

              Kind Regards

              Paul.

              • Re: Newbie question.  How to Obtain an array/list of PiPoints Using the PISDK
                pauljohnson

                HI there thank you for your feedback.  Unfortunately I am stuck with the current version of the PISDK for this exercise.  We are looking to upgrade our PI clients in the near future.  Note that I am using VB.NET.  The snippet you provided is pretty much identical to an attempt I made earlier today, apart from the syntax differences obviously.  When I attempt to run the VB equivalent of your code I get a DISP_E_TYPEMISMATCH error.  I suspect this is die to the lack of a direct equivalent to the 'var' datatype in vb.net.  My code is listed below:

                 

                Dim mySDK As Object = New PISDK.PISDK()
                Dim mySrv As Object = mySDK.Servers(_piServer)
                Dim search As Object = "pointsource = 'TOPS'"  ' search string for filter by pointsource 
                Dim tagsSearched As Object = mySrv.GetPoints(search)  'generate PointList  
                Dim t As PIPoint

                For Each t In tagsSearched
                Console.WriteLine(t.Name)
                Next