5 Replies Latest reply on Dec 22, 2014 7:58 PM by ainwood

    How to I get the Point ID in the SDK?

    ainwood

      We have an application that imports PI Data.  The application is based on having a set of (configurable) PI tags to read, where the PI tags are defined via their tag name.  We had an event where someone decided to go through our PI Instance and standardize some of our tag naming conventions, which unfortunately broke the link to the app, and the app stopped working (it was looking for tags that no longer existed).  We have somewhat resolved to prevent this happening again through management of change processes, but I wanted to discuss other solutions.

       

      In the old PI API, you had to find the PI PointID in order to retrieve tag info / values etc.  While it added another step to retrieve the PointID from the tag name, use of the PointID is actually quite robust because it is invariant:  People can edit the tag names, units etc, and the PointID doesn't change.

       

      In the SDK, values etc are retrieved from the tag name direct.  I don't see an easy way of getting the PointID from the tag name (and vice-versa).

        • Re: How to I get the Point ID in the SDK?
          Eugene Lee

          Hi Andrew,

           

          Thanks for your question. Could you kindly tell us which SDK are you planning on using? If it is the AFSDK, here is a code snippet.

           

          static void Main(string[] args)
                  {
                      PIServer a = new PIServers().DefaultPIServer;
                   
                      PIPoint b = PIPoint.FindPIPoint("\\\\server\\cdt158");
                      Console.WriteLine(b.ID.ToString());
                      Console.ReadKey();
                  }
          

           

          where server is the name of your PI Server and cdt158 is the name of the point.

          1 of 1 people found this helpful
            • Re: How to I get the Point ID in the SDK?
              Rhys Kirk

              And, there is an overload of FindPIPoint where you can pass the pointId.

              Or, you can search for all the PI Points by FindPIPoints and pass a List of PIPointQuery specifying each pointID you're interested in.

               

              My 2p on this...an application can work in terms of either pointId or Point name but an end user would always work quicker with a tag name (or ideally an Element & Attribute name combo). You'l also find occasions where tag names are renamed, e.g. prefixed "old", and then replaced with new tags (for example instrumentation change) where it is under a new configuration but the represents the same data. In that scenario you have the same name but a different pointId.

              MOC is going to be a primary driver but you should also consider AF, as you still maintain the logical structure of your data and become somewhat ignorant to where the data actually resides - name changes etc. Your application would just retrieve the data associated with the Attribute, and if you need to change the tag then you do so outside of the realm of the application without affecting it.

            • Re: How to I get the Point ID in the SDK?
              night2day

              Hello Andrew,

               

              or for vba/Processbook/Excel...   example with sinusoid

               

               

                Dim pa As PISDK.PointAttribute

                Set pa = PISDK.Servers.DefaultServer.PIPoints("sinusoid").PointAttributes("pointid")

                debug.print "PointID = " &  pa.value

               

               

              Greetings

              Wolfgang

              • Re: How to I get the Point ID in the SDK?
                amitpatil47

                Hi Andrew,

                Here is the code that you can refer for VB .net (reading PI attributes).

                 

                Code:

                  Dim g_SDK As PISDK.PISDK

                    Dim g_SDKDlgAppObject As PISDKDlg.ApplicationObject

                 

                  Dim myServer As PISDK.Server    'PI server

                        Dim PT1 As PISDK.PIPoint    'PI Point

                        Dim myPoints As PISDK.PIPoints  'PI Points

                    

                  Dim ptatr As PISDK.PointAttribute  'To read point attributes

                    Dim point_id, descriptor, engunits, displaydigits As String  'To read PI Point attributes

                 

                  'Set PI server

                        myServer = g_SDK.Servers.Item("YourPIServer")

                        myPoints = myServer.PIPoints

                    

                  'Set PI Point

                        PT1 = myPoints.Item("tagname") 'to be replaced by your tag name

                        'Read PI Point Attributes

                  ptatr = PT1.PointAttributes.Item("pointid")

                        point_id = ptatr.Value

                        ptatr = PT1.PointAttributes.Item("Descriptor")

                        descriptor = ptatr.Value

                        ptatr = PT1.PointAttributes.Item("EngUnits")

                        engunits = ptatr.Value

                  ptatr = PT1.PointAttributes.Item("Displaydigits")

                        displaydigits = ptatr.Value


                - Amit A. Patil

                1 of 1 people found this helpful
                • Re: How to I get the Point ID in the SDK?
                  ainwood

                  Thanks, all.  This is the original SDK.  We want to upgrade our PI version to support the Asset Framework next year, and are working through that now.  But I have received answers on both, so I have what I need.  Thanks very much!