8 Replies Latest reply on Jun 27, 2017 12:26 PM by Rick Davin

    Can't post question - AF SDK can't find PIPoint when SMT can

    RobBowman

      When I try to post a question I get "Your content could not be saved due to an error. You may have been logged out. If this problem persists please contact your system administrator. Click here to refresh this page."

       

      IMPORTED FROM STACKOVERFLOW:

       

      I have C# application that creates a new Pi Point using the code based on  PI-AF-SDK-Basic-Samples/CreatePIPointsExample.cs at master · osisoft/PI-AF-SDK-Basic-Samples · GitHub

       

      The point seems to be created ok - here's a screen grab following a tag search in SMT:

       

      Poach.png

       

      My problem is, when my same C# application searches for the newly created Pi Point is doesn't find it. The code for the search is as follows:

           

      private static List<PIPoint> GetPiPoints(PIServer piServer)
              {
                  var criteria = GetCriteria("61");
                  var foundPoints = PIPoint.FindPIPoints(piServer, criteria).ToList();
      
                  criteria = GetCriteria("63");
                 foundPoints.AddRange(PIPoint.FindPIPoints(piServer, criteria).ToList());
      
                  criteria = GetCriteria("64");
                  foundPoints.AddRange(PIPoint.FindPIPoints(piServer, criteria).ToList());
      
                  return foundPoints;
              }
      
      private static List<PIPointQuery> GetCriteria(string location)
              {
                  List<PIPointQuery> criteria = new List<PIPointQuery>();
      
                  PIPointQuery whereClause1 = new PIPointQuery(PICommonPointAttributes.Location1, OSIsoft.AF.Search.AFSearchOperator.Equal, location);
                  PIPointQuery whereClause2 = new PIPointQuery(PICommonPointAttributes.PointSource, OSIsoft.AF.Search.AFSearchOperator.Equal, "o");
      
                  criteria.Add(whereClause1);
                  criteria.Add(whereClause2);
      
                  return criteria;
              }
      

       

       

      So, my understanding is that this should find all points that have a "location1" attribute value of 61, 63 or 61 AND a "pointSource" of "o" - I have tried uppercase and lower case "o"

       

      From the screenshot, you can see that this is the case for the newly created "Kuba_99x" tag yet it is not found in the search, although thousands of other existing tags are.

       

      Any ideas where I went wrong please?

        • Re: Can't post question
          RobBowman

          This simple question did post ok but I've had no luck with anything more complex. Please take a look at what I wanted to post: osisoft - Can't find Pi Point after create - Stack Overflow

          • Re: Can't post question
            Rick Davin

            Hi Rob,

             

            Sorry you are experiencing problems posting here.  Depending upon how complex your post, it might be rejected.  I also know certain phrases may cause rejection or else suspend the post for a Moderator to attend.

             

            The point and data security look fine.  location1 is really a int but a string apparently works in the search criteria.  I'd keep with the capital "O" for point source, though lowercase "o" should have worked.

            • Re: Can't post question - AF SDK can't find PIPoint when SMT can
              Rick Davin

              Hi Rob,

               

              Are you still having problems the day after?  Using AF SDK, can you find the point in question using a different FindPIPoints overload?

                • Re: Can't post question - AF SDK can't find PIPoint when SMT can
                  RobBowman

                  Hi Rick, thanks for fixing my post this page - I think the formatting looks even better than on Stack Overflow

                   

                  I tried changing the overload to look for the specific tag name as follows:

                   

                  var foundPoints = PIPoint.FindPIPoints(piServer, "Kuba_99x").ToList();

                   

                  Using this very specific overload the tag WAS found! Interesting, but obviously, I need the more general overload to work.

                  I am still puzzled as to why the tag is not found when using the code in my initial post? I did try calling the support desk as you suggested but I guess they were very busy.

                    • Re: Can't post question - AF SDK can't find PIPoint when SMT can
                      Rick Davin

                      A shot in the dark: are you sure that the PointSource for Kuba_99x is not 0 (zero) instead of the letter "O" that you are searching on?

                      • Re: Can't post question - AF SDK can't find PIPoint when SMT can
                        Rick Davin

                        Hi Rob,

                         

                        Could you try running the test code?

                         

                        public static void TestFind(PIServer dataArchive, string tagName)
                        {
                            var pt = PIPoint.FindPIPoint(dataArchive, tagName);
                            pt.LoadAttributes();
                        
                            var ptSource = (string)pt.GetAttribute(PICommonPointAttributes.PointSource);
                            var location1 = (int)pt.GetAttribute(PICommonPointAttributes.Location1);
                        
                            var criteria = new List<PIPointQuery>();
                            criteria.Add(new PIPointQuery(PICommonPointAttributes.Tag, AFSearchOperator.Equal, pt.Name + "*"));
                            criteria.Add(new PIPointQuery(PICommonPointAttributes.PointSource, AFSearchOperator.Equal, ptSource));
                            criteria.Add(new PIPointQuery(PICommonPointAttributes.Location1, AFSearchOperator.Equal, location1.ToString()));
                        
                            var points = new PIPointList(PIPoint.FindPIPoints(dataArchive, criteria));
                            points.LoadAttributes();
                        
                            foreach (var point in points)
                            {
                                Console.WriteLine("Tag: {0}, PS: {1}, Location1: {1}",
                                                    point.Name,
                                                    point.GetAttribute(PICommonPointAttributes.PointSource),
                                                    point.GetAttribute(PICommonPointAttributes.Location1));
                            }
                        }
                        

                         

                         

                        You would invoke it by passing in your piServer object and the literal string "Kuba_99x".