{
initRun(false);
resetProbes();
}
fireSimulatorEvent(new SimulatorEvent(0, SimulatorEvent.Type.STARTED));
// for (int i = 0; i < myNodes.length; i++) {
// myNodes[i].setMode(mode);
// }
// //make each node produce its initial output
// for (int i = 0; i < myNodes.length; i++) {
// myNodes[i].run(startTime, startTime);
// }
//
// Casting the float to a double above causes some unexpected rounding. To avoid this
// we force the stepSize to be divisible by 0.000001 (1 microsecond)
thisStepSize=Math.round(thisStepSize*1000000)/1000000.0;
if (thisStepSize<0.000001) {
thisStepSize=0.000001;
}
int c = 0;
boolean interrupt=false;
while (time < endTime && !interrupt) {
if (c++ % 100 == 99 && myDisplayProgress) {
System.out.println("Step " + c + " " + Math.min(endTime, time + thisStepSize));
}
if (time + 1.5*thisStepSize > endTime) { //fudge step size to hit end exactly
thisStepSize = endTime - time;
}
step((float) time, (float) (time+thisStepSize));
float currentProgress = ((float) time - startTime) / (endTime - startTime);
SimulatorEvent event=new SimulatorEvent(currentProgress,
SimulatorEvent.Type.STEP_TAKEN);
fireSimulatorEvent(event);
if (event.getInterrupt()) interrupt=true;
time += thisStepSize;
}
fireSimulatorEvent(new SimulatorEvent(1f, SimulatorEvent.Type.FINISHED));
if(topLevel)
{
endRun();
}