AnsweredAssumed Answered

PIPointList.RecordedValue Bug and Workaround

Question asked by rdavin Employee on Nov 18, 2015
Latest reply on Jan 16, 2017 by rdavin

UPDATE: Nov 23, 2015.  I have posted a new workaround #2 in a reply below.

 

I deleted my original post on this as I wanted to come up with more clear up examples of the buggy behavior.  I can definitely claim that there is a bug in AF 2.7 with PIPointList.RecordedValue that occurs under certain conditions, most notably if the retrieved archive value is a SYSTEM digital state.  In a reply further below, I have posted one possible workaround but further testing reveals that workaround #1 does NOT work when the list has more than 1 itemWorkaround #2 does work, however.

 

General comments:

  • The bug does not occur in AF 2.6.
  • The bug is producible in AF 2.7.  My limited test used Float32 and Digital tags.  I did not test other point types.
  • The bug occurs with PIPointList.RecordedValue but not with PIPoint.RecordedValue.
  • The bug occurs with AFRetrievalMode.AtOrBefore, Before, and Exact.  I did not test other modes.
  • If the archived value for AtOrBefore is a valid Float32, the bug does not occur.
  • However, if the archived value for AtOrBefore is a SYSTEM digital state, the bug occurs!

 

Updated Comments 11/19/2015:

  • I tested against a Digital tag.  It too shows the bug.
  • So far the bug happens only with SYSTEM digital states.  That is to say when the value's IsGood=false.
  • I tested against modes of Before and Exact.  It didn't surprise me that Before also had the bug, but I was shocked (and disturbed) that Exact also has it.
  • When I don't have an event at Exact time, and the previous AFValue was a SYSTEM state, the bug returns the exact time with the previous Value rather than a Value of "No Data".

 

I created a brand new tag today with this complete archive history:

 

No Result

1/1/2000 12:00:00 AM

100

1/1/2009 12:00:00 AM

No Result

2/1/2009 12:00:00 AM

 

For the RecordedValue call, the parameters will be:

 

time

1/7/2014 12:00:00 AM

mode

AFRetrievalMode.AtOrBefore

 

Here is C# code to illustrate bug:

 

var server = PIServer.FindPIServer("RKPISRV");
server.Connect();

var tag = PIPoint.FindPIPoint(server, "Test/Float32");

var time = new AFTime( new DateTime(2014, 1, 7, 0, 0, 0, DateTimeKind.Utc) );

var mode = AFRetrievalMode.AtOrBefore;

var list = new PIPointList();
list.Add(tag);

var snapshot = tag.Snapshot();
var value1 = tag.RecordedValue(time, mode);

var results = list.RecordedValue(time, mode);
var value2 = results.Results[0];

Console.WriteLine($"PI Server:  {server.Name}");
Console.WriteLine($"PI Point:  {tag.Name}");
Console.WriteLine($"Snapshot:  {snapshot.Value} at {snapshot.Timestamp}");
Console.WriteLine();
Console.WriteLine($"Time:  {time}");
Console.WriteLine($"Retrieval Mode:  {mode}");
Console.WriteLine();
Console.WriteLine($"PIPoint.RecordedValue    :  {value1.Value} at {value1.Timestamp}");
Console.WriteLine($"PIPointList.RecordedValue:  {value2.Value} at {value2.Timestamp}");

 

The code was developed in Visual Studio 2015 targeting a .NET 4.5 Framework.  On my development box, I referenced the AF 2.7.5.7166 library for my build but the lib is not copied to local nor set to specific version.  That way I can run the same code against a 2.6 client as well as 2.7.  In order to do so, I must use the obsolete PIPoint.Snapshot to be able to run under 2.6.

 

The PI Server version used in my tests is PI Server 2012 SP 1.

 

Results on AF 2.6.1.6238 Client:

 

PI Server:  RKPISRV

PI Point:  Test/Float32

Snapshot:  No Result at 2/1/2009 12:00:00 AM

 

Time:  1/7/2014 12:00:00 AM

Retrieval Mode:  AtOrBefore

 

PIPoint.RecordedValue    :  No Result at 2/1/2009 12:00:00 AM

PIPointList.RecordedValue:  No Result at 2/1/2009 12:00:00 AM

 

Results on AF 2.7.5.7166 Client:

 

PI Server:  RKPISRV

PI Point:  Test/Float32

Snapshot:  No Result at 2/1/2009 12:00:00 AM

 

Time:  1/7/2014 12:00:00 AM

Retrieval Mode:  AtOrBefore

 

PIPoint.RecordedValue    :  No Result at 2/1/2009 12:00:00 AM

PIPointList.RecordedValue:  No Result at 1/7/2014 12:00:00 AM

Outcomes