OHLCPlugInView: fix occasional window time overlap
This commit is contained in:
@ -86,9 +86,7 @@ public class OHLCPlugInView extends ViewSupport {
|
||||
*/
|
||||
private DateTime getTimestamp(EventBean event) {
|
||||
ExprEvaluator evaluator = timestampExpression.getForge().getExprEvaluator();
|
||||
//Long l = (Long)evaluator.evaluate(new EventBean[] {event}, true, agentContext);
|
||||
return (DateTime)evaluator.evaluate(new EventBean[] {event}, true, agentContext);
|
||||
//return toDateTime(l);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,16 +131,17 @@ public class OHLCPlugInView extends ViewSupport {
|
||||
// create open window
|
||||
windowStartTime = makeWindowStartTime(timestamp, interval);
|
||||
windowEndTime = makeWindowEndTime(windowStartTime, interval);
|
||||
scheduleCallback(windowEndTime);
|
||||
}
|
||||
|
||||
if (!inWindow(timestamp)) {
|
||||
// past current window.
|
||||
// post and create a new one.
|
||||
postData();
|
||||
scheduleCallback();
|
||||
|
||||
windowStartTime = makeWindowStartTime(timestamp, interval);
|
||||
windowEndTime = makeWindowEndTime(windowStartTime, interval);
|
||||
scheduleCallback(windowEndTime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,7 +161,9 @@ public class OHLCPlugInView extends ViewSupport {
|
||||
return timestamp.minus(intoPeriod);
|
||||
}
|
||||
|
||||
private static DateTime makeWindowEndTime(DateTime startTime, Duration interval) {
|
||||
private static DateTime makeWindowEndTime(DateTime startTime,
|
||||
Duration interval)
|
||||
{
|
||||
if (startTime == null || interval == null) return null;
|
||||
|
||||
return startTime.plus(interval.getMillis());
|
||||
@ -201,7 +202,7 @@ public class OHLCPlugInView extends ViewSupport {
|
||||
/**
|
||||
* Set up a callback to post an event when our time window expires.
|
||||
*/
|
||||
private void scheduleCallback() {
|
||||
private void scheduleCallback(DateTime endTime) {
|
||||
SchedulingService sched = agentContext.getStatementContext().getSchedulingService();
|
||||
if (handle != null) {
|
||||
// remove old schedule
|
||||
@ -210,7 +211,7 @@ public class OHLCPlugInView extends ViewSupport {
|
||||
}
|
||||
|
||||
DateTime currentTime = toDateTime(sched.getTime());
|
||||
DateTime targetTime = windowEndTime.plusSeconds(LATE_EVENT_SLACK_SECONDS);
|
||||
DateTime targetTime = endTime.plusSeconds(LATE_EVENT_SLACK_SECONDS);
|
||||
long callbackTime = targetTime.getMillis() - currentTime.getMillis();
|
||||
|
||||
ScheduleHandleCallback callback = new ScheduleHandleCallback() {
|
||||
|
||||
Reference in New Issue
Block a user