AnsweredAssumed Answered

PI data is missing/overwritten

Question asked by pachalad on Jun 23, 2016
Latest reply on Aug 8, 2016 by gregor



I'm having issue with pushing PI Data into the historian using the SDK. The issue I'm having is that the only data being saved is the first point and last point. For example, if I'm pushing points (1,2,3,4,5), only points 1 and 5 are saved. I've created a small application to test this behavior (below), I've run it on a colleagues machine and it successfully added all the points. So I've narrowed the issue down to my machine. I've reinstalled and updated all of the Pi software.


I'm using version 4 of the SDK and I've tried running it using .net 4.5 to 4.6 and got the same problem. An interesting behavior I found is that if I add a breakpoint after the UpdateValues and wait a couple of seconds before continuing, it successfully adds the point. Although, using a Thread.Sleep won't add the point. I've tried using the PiPoint.UpdateValue/s method and I get the same issue. While steeping through the application, without waiting, I can see the data being added via the Pi System Management Tools but then they either get deleted or overwritten on the next iteration. There are no errors being returned.


Does anyone have any suggestions on what I can do to solve my problem?



  server = new PIServers()[PiServer_AF];
  var pipoints =  PIPoint.FindPIPoints(server, "DominiksPiPoint");
  Console.WriteLine("Deleting pi points {0} points",pipoints.Count());
  var error = server.DeletePIPoints(pipoints.Select(point => point.Name));
  PIPoint myPoint=server.CreatePIPoint("DominiksPiPoint");
  Console.WriteLine("Starting to write PI points");
  for (int i=0; i < 20; i++)
      List<AFValue> updates = new List<AFValue>();
      AFTime myTime = new AFTime(DateTimeOffset.Now.UtcTicks);
      AFValue value = new AFValue();
      value.Timestamp = myTime;
      value.Value = i;
      value.PIPoint = myPoint;
      var errors = server.UpdateValues(updates, OSIsoft.AF.Data.AFUpdateOption.NoReplace);
      if (errors != null)
         foreach (var err in errors.Errors)
   var points = PIPoint.FindPIPoint(server, "DominiksPiPoint");
   AFValues values = points.RecordedValues(new AFTimeRange("*-2h", "*"), AFBoundaryType.Inside, "", false);
   foreach (var value in values)
        Console.WriteLine("My Value is {0} at time {1}",value.Value,value.Timestamp);