Hi Fox,
I've been using CONTEXT.getRuntime() but I strongly get the feeling that this value is constant for when the script is fired - including when I do a force recalculate history.
As in the value is the same for each historical execution? That is not the intended behavior, nor what I observed with an Alphanumeric meta point that was doing,
return CONTEXT.getRuntime();
and then regenerated history. I could clearly see, whether my point was executing on a cron or context update, that the time returned was not the same. However, it does not change throughout the execution of the script, so,
print(CONTEXT.getRuntime()); //time the script kicked off RuntimeManager.sleep(1000); print(CONTEXT.getRuntime()); //still the time the script kicked offYou may also in some occasions want to use CONTEXT.getTimestamp(), which should always be the time of the triggering event without the possibility of server load delaying task execution by a few (or many) milliseconds creeping in as with the runtime (really only affects live values).
If you're still doing the same sort of thing I'm curious why you'd switch over to the PointValueQuery tool instead of using the last() calls like before. I didn't get too deep into what that last script is trying to achieve. Maybe the issue is that during history generation last() doesn't work properly? You could use
var pvt = p.pointValueBefore(CONTEXT.getTimestamp()+1); var pvt2 = p.pointValueBefore(pvt.time);