9 Replies Latest reply on Feb 12, 2016 7:14 PM by Gaurav Agrawal

    Filtering FindPIPoints by Point Class

    Steve Boyko

      I am trying to build a tag search dialog to allow the user to enter a tag mask and select a point class to limit the search. I'm having trouble with the query syntax and would appreciate some help. Here's my code so far:

       

              Dim coll As IEnumerable(Of PIPoint)

              Dim criteria As List(Of String)

       

              criteria = New List(Of String)

              criteria.Add("Name='" + ctrlSearch.Text + "'")

              If cmbPointClass.SelectedIndex > 0 Then      ' not just "all"

                  criteria.Add("PointClass=" + cmbPointClass.Text)

              End If

              coll = PIPoint.FindPIPoints(Form1.pisrv, criteria)

              lstTags.Items.Clear()

              For Each p In coll

                  lstTags.Items.Add(p.Name)

              Next

       

      It never returns anything in the collection. What am I doing wrong? Thanks in advance for the help.

        • Re: Filtering FindPIPoints by Point Class
          dng

          Hi Steve,

           

          To search for a tag according to tag mask as well as point class, consider using the PIIPoint.FindPIPoints(PIServer, IList(Of IEnumerable(Of PIPointQuery))) overload method. Declare criteria as as a List(Of IEnumerable(Of PIPointQuery)) instead. E.g.

           

                  Dim coll As IEnumerable(Of PIPoint)
                  Dim criteria As List(Of IEnumerable(Of PIPointQuery))
          
                  Dim ptQuery1 As PIPointQuery
                  Dim ptQuery2 As PIPointQuery
          
                  criteria = New List(Of IEnumerable(Of PIPointQuery))
          
                  ptQuery1 = New PIPointQuery("Tag", Search.AFSearchOperator.Equal, "sin*")
                  ptQuery2 = New PIPointQuery("PtClassName", Search.AFSearchOperator.Equal, "Classic")
          
                  criteria.Add({ptQuery1, ptQuery2})
          
                  coll = PIPoint.FindPIPoints(Form1.pisrv, criteria)
                  lstTags.Items.Clear()
                  For Each p As PIPoint In coll
                      lstTags.Items.Add(p.Name)
                  Next
          

           

          Feel free to replace "sin*" and "Classic" with the result from the search dialog.

          2 of 2 people found this helpful
            • Re: Filtering FindPIPoints by Point Class
              Gaurav Agrawal

              Hi Daphne ,

               

              I also have the same requirement as that of Steve, but in my case I am trying to filter tags based on point source and interface ID(Location1), and since I have a couple of interfaces, I want to search tags within a array of Location1 parameter.

               

              As per your suggestion, I have used PIPointquery to create queries, and using AF SDK reference I have used AFSearchOperator.In method which takes an array as input.

              I have created an array of Location1 parameter which  I am passing to this function as shown below;

               

                          int[] Location1Array = new int[] { 51, 52, 53, 54, 55, 56, 57, 58, 59 };

                          IEnumerable<PIPointQuery> criteria;

               

                        PIPointQuery query1 = new PIPointQuery("PointSource",OSIsoft.AF.Search.AFSearchOperator.Equal,"D");

                        PIPointQuery query2 = new PIPointQuery("Location1", OSIsoft.AF.Search.AFSearchOperator.In, Location1Array.ToString());

               

                          criteria = (new List<PIPointQuery>() { query1, query2,});

                         PIPointList PIPoints = new PIPointList(PIPoint.FindPIPoints(myPIserver,criteria,null));

               

               

              but FindPIPoints function in my code is giving me System.NotSupporttedException as I am passing  criteria to the function

               

              Kindly suggest what step I am doing wrong and how to correct it?

               

              Regards,

              Gaurav Agrawal

                • Re: Filtering FindPIPoints by Point Class
                  asorokina

                  The In search operator appears to be not supported in PIPointQuery, see the remarks chapter here: PIPointQuery.Operator Property

                   

                  In this case you can use one of the following overloads:

                  PIPoint.FindPIPoints Method (PIServer, String, Boolean, IEnumerable(String), AFSearchTextOption)

                  PIPoint.FindPIPoints Method (PIServer, IList(IEnumerable(PIPointQuery)), IEnumerable(String))

                   

                  Here is an example of the first overload:

                   

                  PIPointList PIPoints = new PIPointList(PIPoint.FindPIPoints(myPIserver, "(PointSource:=R AND Location1:=0) OR (PointSource:=R AND Location1:=1)", false, null));

                   

                   

                  And here is an example of the second overload:

                   

                  List<IEnumerable<PIPointQuery>> queriesToOR = new List<IEnumerable<PIPointQuery>>();
                  
                  
                              for (int i = 51; i <= 59; i++)
                              {
                                  List<PIPointQuery> criteria = new List<PIPointQuery>();
                                  criteria.Add(new PIPointQuery("PointSource", OSIsoft.AF.Search.AFSearchOperator.Equal, "D"));
                                  criteria.Add(new PIPointQuery("Location1", OSIsoft.AF.Search.AFSearchOperator.Equal, i.ToString()));
                                  queriesToOR.Add(criteria);
                              }
                  
                  
                              PIPointList PIPoints = new PIPointList(PIPoint.FindPIPoints(myPIserver, queriesToOR, null));
                  

                  :

                  1 of 1 people found this helpful
                    • Re: Filtering FindPIPoints by Point Class
                      Marcos Vainer Loeff

                      Hello,

                       

                      Another solution would be to find all PI Points with the PointSource = "D" and 50 < Location1 < 60. In order to do that, we will need to find:

                       

                      - piPoints1 with the PI Points PointSource = "D" and  Location1  > 50

                      - piPoints2 with the PI Points PointSource = "D" and  Location1  < 60

                      - And finally, piPoints will intersect the PI Points from piPoints1 and piPoints2.

                       

                      Please refer to the code snippet below for more information:

                       

                                  PIPointQuery ptQuery1 = new PIPointQuery("PointSource", OSIsoft.AF.Search.AFSearchOperator.Equal, "D");
                                  PIPointQuery ptQuery2 = new PIPointQuery("Location1", OSIsoft.AF.Search.AFSearchOperator.GreaterThan, "50");
                                  PIPointQuery ptQuery3 = new PIPointQuery("Location1", OSIsoft.AF.Search.AFSearchOperator.LessThan, "60");
                      
                      
                      
                      
                                  IEnumerable<PIPoint> piPoints1 = PIPoint.FindPIPoints(piServer, new PIPointQuery[] { ptQuery1, ptQuery2 });
                                  IEnumerable<PIPoint> piPoints2 = PIPoint.FindPIPoints(piServer, new PIPointQuery[] { ptQuery1, ptQuery3 });
                                  IEnumerable<PIPoint> piPoints = null;
                                  if ((piPoints1.Count() > 0) && (piPoints2.Count() > 0))
                                  {
                                      piPoints = piPoints1.Intersect(piPoints2);
                                  }
                      

                       

                      Hope it helps!

                      • Re: Filtering FindPIPoints by Point Class
                        Gaurav Agrawal

                        Thanks Anna and Marcos!!

                         

                        It worked for me, and as Gregor suggested, I followed Anna approach on this . Thanks a lot guys for your valuable inputs.

                         

                        Regards,

                        Gaurav Agrawal

                  • Re: Filtering FindPIPoints by Point Class
                    asorokina

                    Hi Steve,

                     

                    Have you considered using AF SDK UI PIPointTagSearchPage component?

                    1 of 1 people found this helpful