4 Replies Latest reply on Jul 7, 2017 12:00 PM by rohanar

    Point Attribute Not Found

    rohanar

      We are receiving these errors when using the PI-SDK.  It occurs frequently, but not consistently.  Any recommendations?

       

      1. Point attribute not found. (red text line below)
      2. Failed to fetch point attributes. At PISDK.PIPoint.get_PointAttributes() At
      3. Application: abc.exe. Description: The process was terminated due to an unhandled exception.Exception Info:System.AccessViolationException At PISDK.PointAttributes.get_Item(System.String)

       

              Dim server As Server = Nothing

              Dim pointAttributes As PointAttributes = Nothing

              Dim pointAttribute As PointAttribute = Nothing

              Dim pointAttributeValue As Object = Nothing

       

                  server = piPoint.Server

                  pointAttributes = piPoint.PointAttributes

                  pointAttribute = pointAttributes("PointID")

        • Re: Point Attribute Not Found
          Rick Davin

          Hi Rosanne,

           

          The point attribute names are case-sensitive and are usually lowercase.  So "PointID" should return Nothing, whereas "pointid" should return a good value.

           

          Here's a quick test to dump a tag's point attributes:

           

            Public Sub TestAttributes(tagname As String)
                  Dim clientSDK As New PISDK.PISDK
                  Dim dataArchive As Server = clientSDK.Servers(Environment.MachineName)
                  Dim tag As PIPoint = dataArchive.PIPoints(tagname)
                  For Each attribute As PointAttribute In tag.PointAttributes
                      Console.WriteLine("{0} = {1}", attribute.Name, attribute.Value)
                  Next
              End Sub
          

           

          If you prefer to work with dictionaries in .NET, you could also peek at this bit of code:

           

              Public Function GetAttributeDictionary(tag As PIPoint) As Dictionary(Of String, Object)
                  Dim dict As New Dictionary(Of String, Object)
                  Dim attributes As PointAttributes = tag.PointAttributes
                  For Each attribute As PointAttribute In attributes
                      dict.Add(attribute.Name.ToLowerInvariant(), attribute.Value)
                  Next
                  Return dict
              End Function
          
              Public Function GetAttribute(dict As Dictionary(Of String, Object), name As String) As Object
                  If dict Is Nothing OrElse dict.Count = 0 OrElse String.IsNullOrWhiteSpace(name) Then
                      Return Nothing
                  End If
                  Dim entry As KeyValuePair(Of String, Object) = Nothing
                  If dict.TryGetValue(name.ToLowerInvariant(), entry) Then
                      Return entry.Value
                  End If
                  ' You could throw here to denote the name/key wasn't found
                  Return Nothing
              End Function
          

           

          You would first call GetAttributeDictionary passing in a PIPoint.  This would build the dictionary.  The subsequent calls would be to call GetAttribute for the point attribute you care about.

          1 of 1 people found this helpful
          • Re: Point Attribute Not Found
            sraposo

            Hi Rosanne,

             

            Where there more information in the SDK logs? What if you do a PI SDK trace while the issue is on going?

             

             

            Also, out of curiosity why are you using the PI SDK rather than the AF SDK?

             

            Thanks,
            Seb

            1 of 1 people found this helpful