AnsweredAssumed Answered

How can I handle 1-1-1970 being passed to my GetValue method?

Question asked by vincent.spaa on Feb 23, 2015
Latest reply on Feb 25, 2015 by vincent.spaa

I have a custom data reference which has the following implementation of GetValue and GetValues:


public override AFValues GetValues(object context, AFTimeRange timeRange, int numberOfValues,
    AFAttributeList inputAttributes, AFValues[] inputValues)
    AFValues valuesCollection = new AFValues();
    DateTime start = timeRange.StartTime.LocalTime;
    start = new DateTime(start.Year, start.Month, start.Day, start.Hour, 0, 0, DateTimeKind.Local);
    DateTime end = timeRange.EndTime.LocalTime;
    end = new DateTime(end.Year, end.Month, end.Day, end.Hour, 0, 0, DateTimeKind.Local);

    while (start <= end)
        start = start.AddHours(1);

    return valuesCollection;

public override AFValue GetValue(object context, object timeContext, AFAttributeList inputAttributes, AFValues inputValues)

    AFTime time = timeContext == null
        ? DateTime.Now
        : ((AFTime)timeContext).LocalTime;

    return Calculate((time).LocalTime);

And the following relevant properties:

public override AFDataReferenceMethod SupportedMethods
        return AFDataReferenceMethod.GetValue | AFDataReferenceMethod.GetValues;

public override OSIsoft.AF.Data.AFDataMethods SupportedDataMethods
    get { return DefaultSupportedDataMethods; }

When using the new AF SDK (2.6), AF Client (2014) and DataLink (2014) everything works fine. The timestamp passed to GetValue and GetValues is exactly as I'd expect.

When I switch to AF SDK 2.5.2 and DataLink 2013 I get some strange behavior. Trending the values in Processbook still works fine but running PISampData from DataLink results in 1-1-1970 being passed to the timeContext parameter of my GetValue method.

Needless to say, this causes the Data Reference to produce the wrong values.


As mentioned in this discussion: How can I handle a call to GetValues in a custom DR? (which is about the same data reference), the inputAttributes and inputValues are empty since the data reference does not use data from anything other than 2 AF Tables.


Is there something I need to add to be backwards compatible with the older AF SDK?