3

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:

enter image description here

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?

Rob Bowman
  • 7,632
  • 22
  • 93
  • 200

2 Answers2

3

The Pi code was actually fine. Problem was, my code was filtering the newly created record after the selection.

Rob Bowman
  • 7,632
  • 22
  • 93
  • 200
1

Location1 is stored as an Int32 on the PI Data Archive. The location parameter needs to be an int instead of string.

Further questions will be addressed at OSIsoft PI Square since you also have a post there.

Rick Davin
  • 1,010
  • 8
  • 10
  • Thanks Rick I will try that but how come existing Pi Points are found by the search? The only ones that don't get found are those created by the C# application – Rob Bowman Jun 22 '17 at 19:32
  • @RobBowman What happens if you omit comment out 63 and 64 and only search on 61? Is the point still not found? – Rick Davin Jun 22 '17 at 19:40
  • Yes, still not found. In fact that's how I had it written yesterday – Rob Bowman Jun 22 '17 at 19:41
  • @RobBowman When I see something so squirrely for something so simple, it's usually time for a server reboot. – Rick Davin Jun 22 '17 at 19:43
  • Haha, I know what you mean. Unfortunately this server has been rebooted several times. It's an Azure VM which I stop each night because I'm a Yorkshireman – Rob Bowman Jun 22 '17 at 19:45