3 Replies Latest reply on Oct 2, 2018 3:25 PM by Nocodes79

    Problem writing historical data to PI Data Archive using PIValues Object

    pauljohnson

      Hi there I am having difficulty writing date values to the PI Data Archive. I am using PIValues to accumulate an array of data to write.  The timestamp is generated from the following code:

      timeStamp = CDate(topsDevice.Data(rowCnt, _timeCol)).ToString("dd/MM/yyyy hhhh:mm:ss.fff")

       

      PiValue is generated by:

       

       

      piValues.Add(topsValue.TimeStamp, topsValue.PiValue, Nothing)

       

       

       

      Data is then written to the archive by:

       

       

       

      _piServer.PIPoints(pnt.Name).Data.UpdateValues(piValues, PISDK.DataMergeConstants.dmReplaceDuplicates)

       

      The array contains 144 rows (1 value every 10 minutes).  The values contained in the array appear to be correct including the associated timestamp.  However the data is written incorrectly for some reason as  presented in the following ProcessBook trace:

       

       

      Hoping you can assist.

       

      Kind Regards

      Paul J.

        • Re: Problem writing historical data to PI Data Archive using PIValues Object
          Nocodes79

          Hi Paul,

           

          from what I understand no data is being written at all, but you have no exception from the code.

          It looks like you are using PI SDK. Why didn't you use AF SDK instead?

          Why are you using a string as timestamp? I am not sure of how the datetime string is computed later. Please check the PIValues timestamps to see if they are accepted and correctly parsed.

           

          Is that a PI server or a collective?

          Are you sending data from your laptop or from the same server? in case it is a collective, did you configure buffer on the machine you use for sending data?

          Did you check the PI Server log to check if it gives us some hint of the problem?

            • Re: Problem writing historical data to PI Data Archive using PIValues Object
              pauljohnson

              Hi Nicola, thanks for your feedback.  In answer to your questions:

               

              1/  Yep no exception from the code.  So the logical conclusion here might have been that there was an issue with how the data was being interpreted as it is written to PI.  However as you can see under point 6 below this seem not to be 'completely' true.

              2/  Unfortunately we do not have the PIAFSDK on our corporate desktop.  We are in the process of looking at a rollout of PI Vision but PIAFSDK will not be available for this exercise.

              3/  Re the timestamp there was an issue with the format of the timestamp in the CSV data, and I wanted to force the timestamp to the required format.  However have now implemented a fix in the source data, and removed the .ToString statement.  Unfortunately did not make any difference.

              4/  I am writing to a PI Server.

              5/  Sending direct from my development desktop.  Not a collective, and buffer not required.

              6/  A check on the PI Server logs reminded me that I was writing to our development server, so consequent limited history in the data archive, and earlier feedback was from data outwith the historic period covered.  Altered the source data to an appropriate date, resulted in more meaningful data content, as per the following resultant output:

               

              Server, Tagname, Value, Timestamp, Questionable, Annotated, Substituted

              FBACATENPID1, 33~AREC3~WF1A~Frequency~HZ~S~AI10~, 49.95, 01/10/2018 16:50:00, False, Not Annotated, False

              FBACATENPID1, 33~AREC3~WF1A~Frequency~HZ~S~AI10~, 49.92, 01/10/2018 17:00:02, False, Not Annotated, False

              FBACATENPID1, 33~AREC3~WF1A~Frequency~HZ~S~AI10~, 49.9, 01/10/2018 17:10:04, False, Not Annotated, False

              FBACATENPID1, 33~AREC3~WF1A~Frequency~HZ~S~AI10~, 49.97, 01/10/2018 17:20:07, False, Not Annotated, False

              FBACATENPID1, 33~AREC3~WF1A~Frequency~HZ~S~AI10~, 50, 01/10/2018 17:30:09, False, Not Annotated, False

              FBACATENPID1, 33~AREC3~WF1A~Frequency~HZ~S~AI10~, 50, 01/10/2018 17:40:12, False, Not Annotated, False

              FBACATENPID1, 33~AREC3~WF1A~Frequency~HZ~S~AI10~, 50.01, 01/10/2018 17:50:14, False, Not Annotated, False

              FBACATENPID1, 33~AREC3~WF1A~Frequency~HZ~S~AI10~, 49.96, 01/10/2018 18:00:16, False, Not Annotated, False

              FBACATENPID1, 33~AREC3~WF1A~Frequency~HZ~S~AI10~, 49.98, 01/10/2018 18:10:19, False, Not Annotated, False

               

              This looked promising however checking the data in ProcessBook still shows issues with the data:

              Curiously as you can see the trace seems to show the expected variation in values however the datapoint still reads '50'.  The above display is with the scaling parameters in the processbook set to 'Autorange',  if I change these to 'Database', we get the following:

               

              One thing I have noted, is that there is no millisecond component in the data export from PISMT, (though this might just be a restriction in the export facility).

               

              This is all most perplexing!  I have written single values to the PI Data Archive using the 'mySnapPoint.Data.UpdateValue(value, 0)' technique previously without any issues, but this is my first foray into writing a PISDK based batch interface, so my apologies if I am missing some fundamentals :-)

               

              Kind Regards

              Paul.