5 Replies Latest reply on Mar 20, 2014 4:26 PM by Gregor

    PIPoint.UpdateValues doesn't add values


      I have a tag with a set of test values that I want to write to the PI server using the AF SDK. The idea is to do the following:


      1) Connect
      2) Create the PIPoint
      3) Insert values into the PIPoint
      4) Do some queries
      5) Delete the PIPoint 


      So far, 1,2 and 5 are working perfectly, but when I try to use UdateValues in step 3, nothing happens.


      Here's a simplified version of the code: 

                          IList<AFValue> afValues = new List<AFValue>();
                          foreach (var tagRecord in tag.TagRecords)
                              AFValue afv = new AFValue();
                              afv.Value = tagRecord.Value;
                              afv.Timestamp = new AFTime(tagRecord.InputTimeUtc);
                              afv.IsGood = tagRecord.Quality.IsGood();
                              afv.PIPoint = piPoint;
                          var errors = piPoint.UpdateValues(afValues, AFUpdateOption.Insert);

      When I debug, the IList afValues has all the AFValues that I want added, with correct properties. The errors object is null, indicating that there were no errors trying to run UpdateValues, but when I look at the tag in PI SMT, there are no values for the tag. I've tried with various AFUpdateOptions, but neither of them have worked.


      The PiPoint is created using CreatePIPoints with a list of pointNames (containing only one item).

        • Re: PIPoint.UpdateValues doesn't add values
          Rick Davin

          When I've experienced such weird things in the past, meaning you have code that looks right and doesn't return an error, I would later discover that the problem was with my archives, such as I had a gap or something else wrong with the archive.


          I'd be curious to see beyond line 15 if you could read the values that you just wrote.

          • Re: PIPoint.UpdateValues doesn't add values



            Can you verify that:


            1) You are not writing before the PtCreated point.....you can delete it for any AF attribute (i am assuming you are using AF as assetmodel for your PI tags


            following code looks back 180 days to find the Pt Created and deletes it. I am mixing AF SDK with PI SDK...which has become a common practice for me since i am still on AF 2010 :-(


            PIPoint pt = (PIPoint)attFromAF.RawPIPoint;


                               IPIData2 todeletePIData = (IPIData2)pt.Data;


            PIValues pvDeletePtCreated = todeletePIData .RecordedValues("*-180d", "*", BoundaryTypeConstants.btInside, string.Format("'{0}'=\"{1}\"", pt.Name, "Pt Created"), FilteredViewConstants.fvRemoveFiltered, null);


                                   todeletePIData .RemoveSpecifiedValues(pvDeletePtCreated, null);


            2) That you are not doing 'backfilling' on a pre 2012 PI server. The timestamp of the point is not before the shift time of your archive.... (see also plenty of articles on 'backfilling' on vcampus..)

              • Re: PIPoint.UpdateValues doesn't add values

                Hello Eivind,


                Another possible reason is that these points become serviced by another datasource which is buffered using PI Buffer Subsystem. According to the principle "First come, first serve." the first PI Buffer Subsystem instance will lock these points against updates from "foreign" sources.


                However, looking at the PI Data Archive (PI Server) log, you should see messages referring the point ID's of points you are trying to update. These messages will indicate what the issue is. I suggest working with Technical Support. They can support you in a remote session which is very useful and troubleshooting issues like yours is their daily bread and butter.


                Please let us know if you want us to assign a Technical Support Engineer to give you a call.