Пример #1
0
def pytest_funcarg__sim(request):
    if request.param == 'default':
        return Simulation.Simulation()
    elif request.param == 'step':
        return SimulationStep.SimulationStep()
    elif request.param == 'trace':
        return SimulationTrace.SimulationTrace()
    elif request.param == 'rt':
        return SimulationRT.SimulationRT()
    elif request.param.startswith('global'):
        if request.param.endswith('default'):
            Globals.sim = Simulation.Simulation()
        elif request.param.endswith('step'):
            Globals.sim = SimulationStep.SimulationStep()
        elif request.param.endswith('trace'):
            Globals.sim = SimulationTrace.SimulationTrace()
        elif request.param.endswith('rt'):
            Globals.sim = SimulationRT.SimulationRT()
        return Globals.sim
Пример #2
0
def test_ticker():
    """Tests SimulationRT for degree to which simulation time and wallclock
    time can be synchronized."""
    rel_speed = 10
    sim_slow = SimulationRT()
    t = Ticker(sim=sim_slow)
    sim_slow.activate(t, t.tick())
    sim_slow.simulate(until=10, real_time=True, rel_speed=rel_speed)

    for tSim, tRT in t.timing:
        assert tSim / tRT > rel_speed - 1

    rel_speed = 20
    sim_fast = SimulationRT()
    sim_fast.initialize()
    t = Ticker(sim=sim_fast)
    sim_fast.activate(t, t.tick())
    sim_fast.simulate(until=10, real_time=True, rel_speed=rel_speed)

    for tSim, tRT in t.timing:
        assert tSim / tRT > rel_speed - 1