/** This method will run the simulation using the previously set scenario data. */ public void start() { checkRunning(); log.info("Prepare Scenario ..."); this.scenario.prepare(); log.info("Running Scenario with seed=" + getSeed()); long startTime = System.currentTimeMillis(); log.info("Simulation started..."); this.running = true; try { scheduler.start(); finishedWithoutError = true; } catch (Exception e) { log.error("Simulator run stopped because of error", e); finishedWithoutError = false; } finally { this.running = false; } log.info("Simulation finished."); long runTime = System.currentTimeMillis() - startTime; long minutes = (long) Math.floor((runTime) / 60000); long secs = (runTime % 60000) / 1000; log.info("Realtime Duration of experiment (m:s) " + minutes + ":" + secs); log.info("Simulated time is " + getSimulatedRealtime()); }
/** * Reset the simulator, so that it can be configured again for another simulation run without to * restart the Java Virtual Machine. This is especially usefull for JUnit tests. */ void reset() { checkRunning(); // TODO may be there should be default values for some of them monitor = new DefaultMonitor(); scenario = null; scheduler = new Scheduler(true); seed = 0; }
/** * Sets the end time at which the simulation framework will finish at the latest the simulation , * irrespective if there are still unprocessed events in the event queue. * * @param endTime point in time at which the simular will finish at the latest */ public void setFinishAt(long endTime) { checkRunning(); this.scheduler.setFinishAt(endTime); }
/** * Sets the monitor which has to be configured by using the XML file with the configuration data. * * @param monitor monitor predefined in the XML file with the configuration data. */ public void setMonitor(Monitor monitor) { checkRunning(); this.monitor = monitor; }
/** * This method sets the seed of the global random generator which can be obtained using the static * getRandom()-method. * * @param seed the seed to configure the global random generator */ public void setSeed(long seed) { checkRunning(); this.seed = seed; randomGen.setSeed(seed); }
/** * Set the scenario (protocol stack, network topology etc.) which will be used to run the * simulation. * * @param scenario simulation scenario to be used */ public void setScenario(Scenario scenario) { checkRunning(); this.scenario = scenario; }