To that point, question about pointValueQuery. Is there a way to return the timestamp of the resulting point value when I do something like rollupquery?
That's actually an error in the PointValueQuery's toString method I think. Thanks for bringing it to our attention! The callback's class for the rollup query in the code is
ScriptPointValueRollupCallback . If the point is a Numeric point, the callback passes a Double, but Image, Alphanumeric, Multistate, and Binary points will get DataValue objects (except for integer rollups like
To the question of finding the timestamp, it's kinda a tricky thing. What is the timestamp to give for the "First" rollup? Period start, the time the value occurred (null if missing?), or period end? Does an average occur at the beginning, middle or end of a period?
If I were to go about getting those times, I could do it by computing the number of milliseconds in the rollup period, and then add that N+1 times to the start time for the Nth period end time. However, it's probably easier to use the
ALL rollup type, which will get the AnalogStatistics (numeric), StartsAndRuntimeList (multistate, binary), or ValueChangeCounter (alphanumeric, image) objects themselves passed to the callback. These objects all have methods for
getPeriodEndTime() and then you'd need to explicitly grab to the rollup type you're looking for from the appropriate method, like,
getStartValue() for instance. There would not be any way to get the timestamp the real start value had, but you could compare it
=== with the first value and if they are not the same object then the start value precedes the period.