}
public final void startSimulation() {
loopCount = 0;
Event nextEvent = null;
LogicalProcess nextLP = null;
double previousSimTime;
long previousRealTime;
flowControl.registerExecutiveMethod("org.mitre.sim.exec.flex.FlexExecutive.startSimulation ()V");
while (true) {
// msg("StartSimulation top of loop, timeNow = " + timeNow);
// msg("Q: " + eventManager);
previousRealTime = System.currentTimeMillis();
//Elaborate Dormant LPs
while (dormantLPs.size() > 0) {
nextLP = (LogicalProcess) dormantLPs.removeLast();
//msg("Elaborate " + nextLP.toString());
flowControl.elaborate(nextLP);
nextLP.setState(LogicalProcessState.READY);
eventManager.enqueueEvent(nextLP);
populationManager.addLP(nextLP);
}
//Evaluate triggers
Collection lpsToBeActivated = triggerManager.evaluate();
if (lpsToBeActivated != null) {
for (Iterator i = lpsToBeActivated.iterator(); i.hasNext(); ) {
nextLP = (LogicalProcess)i.next();
eventManager.removeEvent(nextLP);
nextLP.setNextTime(timeNow);
nextLP.setState(LogicalProcessState.READY);
eventManager.enqueueEvent(nextLP);
}
}
//Evaluate triggers