var pvd = this.pvd;
if(!pvd) {
pvd = this.pvd = com.serotonin.m2m2.Common.databaseProxy.newPointValueDao();
}
print( p.value );
print( p.time );
var loggedValue = pvd.getPointValueBefore( p.getDataPointWrapper().getId(), p.time + 1 );
print( loggedValue.doubleValue ); //if numeric point
print( loggedValue.time );
While this could perhaps be more straightforward, I am having a tough time figuring out why one would be polling a virtual data source to get an interval logging rollup and then compute something off the interval values. It would seem to me to make more sense to record all data from the edge data source, and use the statistics functions in the scripting environment to compute the interval value you wish to use in the script body. That way if you have some anomalies you can still view the original data.