Closed Puckfist closed 6 years ago
Here is a simple script, querying the last twenty days for rollups and data for data point id = 1,
var now = new Date().getTime(); var then = now - 86400000*20;
var callback = function(val) { print(val); }
//Twenty days of 1-day-maximum rollup, using ALL the whole statistics object is passed to the callback PointValueQuery.rollupQuery([1], then, now, callback, MAXIMUM, 1, DAY); //Twenty days of values without bookends PointValueQuery.query([1], then, now, false, callback);
Currently if one wishes to get statistics or values from points in a script, these need to be done in chunks to rollup a period or process a set of values (cannot stream them from the DB in the point wrappers). Thus I have added a PointValueQuery which is basically a wrapper for streamed, possibly rolled up, multiqueries (no multiple array functionality from API, callbacks are always time ordered, you can simple iterate the series if you want series ordering), with two methods,
query([dataPointIds], long from, long to, boolean bookend, IdPointValueTime callback): void rollupQuery([dataPointIds], long from, long to, Object callback, int rollupType, int rollupPeriods, int rollupPeriodType): void
And now the rollup names in Common.ROLLUP_CODES except "NONE" appear in the scripting contexts referring to the values in Common.Rollups