SuperdenseTime nextBreakpoint = (SuperdenseTime) _breakpoints
.first();
if (_debugging) {
_debug("The first breakpoint is at " + nextBreakpoint);
}
Time breakpointTime = nextBreakpoint.timestamp();
double result = breakpointTime.subtract(getModelTime())
.getDoubleValue();
if (result < suggestedStep) {
if (result < 0.0) {
throw new InternalErrorException(
"Missed a breakpoint at time " + breakpointTime
+ ". Current time is " + getModelTime());
}
suggestedStep = result;
if (_debugging) {
_debug("----- Revising step size due to breakpoint to "
+ suggestedStep);
}
}
}
// Next ensure the selected step size does not take us
// past the stop time.
// NOTE: This test could possibly be eliminated by
// putting the stop time on the breakpoint table. Be sure,
// however, that this results in the right number of
// events generated at the stop time. This is very tricky,
// and probably not worth the effort.
Time targetTime = getModelTime().add(suggestedStep);
if (targetTime.compareTo(_stopTime) > 0) {
suggestedStep = _stopTime.subtract(getModelTime()).getDoubleValue();
if (_debugging) {
_debug("----- Revising step size due to stop time to "
+ suggestedStep);
}