@Override public void doInitialAction(SimulationConstructionSet scs0, SimulationConstructionSet scs1) { if (scs0.getRecordFreq() != scs1.getRecordFreq()) { throw new RuntimeException("scs0.getRecordFreq() != scs1.getRecordFreq()"); } if (nTicksInitial % scs0.getRecordFreq() != 0) { throw new RuntimeException("nTicksInitial must be divisible by record frequency!"); } SimulationConstructionSet[] scss = {scs0, scs1}; for (SimulationConstructionSet scs : scss) { scs.simulate(nTicksInitial); } for (SimulationConstructionSet scs : scss) { waitForSimulationToFinish(scs); } }
@Override public void doFinalAction(SimulationConstructionSet scs0, SimulationConstructionSet scs1) if (scs0.getRecordFreq() != scs1.getRecordFreq()) if (nTicksCompare % scs0.getRecordFreq() != 0) if (nTicksFinal % scs0.getRecordFreq() != 0)
private double getExpectedFinalTime(SimulationConstructionSet scs) { double initialTime = scs.getRobots()[0].getTime(); double recordFreq = scs.getRecordFreq(); double DT = scs.getDT(); return initialTime + recordFreq * DT; }
@Test// timeout = 30000 public void testTimingMethods() throws AWTException { scs.setDT(simulateDT, recordFrequency); double simulateDTFromSCS = scs.getDT(); assertEquals(simulateDT, simulateDTFromSCS, epsilon); scs.setRecordDT(recordDT); double recordFreqFromSCS = scs.getRecordFreq(); assertEquals(recordFreq, recordFreqFromSCS, epsilon); scs.setPlaybackRealTimeRate(realTimeRate); double realTimeRateFromSCS = scs.getPlaybackRealTimeRate(); assertEquals(realTimeRate, realTimeRateFromSCS, epsilon); scs.setPlaybackDesiredFrameRate(frameRate); double frameRateFromSCS = scs.getPlaybackFrameRate(); assertEquals(recomputedSecondsPerFrameRate, frameRateFromSCS, epsilon); int ticksPerCycle = computeTicksPerPlayCycle(simulateDT, recordFreq, realTimeRate, frameRate); double ticksPerCycleFromSCS = scs.getTicksPerPlayCycle(); assertEquals(ticksPerCycle, ticksPerCycleFromSCS, epsilon); scs.setTime(Math.PI); double timeFromSCS = scs.getTime(); assertEquals(Math.PI, timeFromSCS, epsilon); }