+1 (972) 883-2091
ECSS 4.220, 800 W Campbell Rd, Richardson, TX 75083–0688, US

The core of the simulation functionality which orchestrates the workflow of the simulation is fully implemented in DIVAs. The implementation of the “TrafficSimulation” class creates a “TrafficEnvironment” and binds it to the “TrafficSimulation”.

Implementation Steps

  1. Inside the package “edu.utdallas.mavs.traffic.simulation.sim” create a class named “TrafficSimulation” that extends the abstract class “Simulation” defined in the package “edu.utdallas.mavs.divas.core.sim”.
  2. The “TrafficSimulation” provides concrete implementations for the following abstract methods:
    1. “createEnvironment”: This method is responsible for creating the “TrafficEnvironment” at the simulation initialization and associating it to the “TrafficSimulation”.
    2. “tick”: This method is responsible for triggering the start of the simulation cycle. The full implementation of the class “TrafficSimulation” is provided in the following code.
   
package edu.utdallas.mavs.traffic.simulation.sim;

import java.io.Serializable;

import edu.utdallas.mavs.divas.core.msg.TickMsg;
import edu.utdallas.mavs.divas.core.sim.Simulation;
import edu.utdallas.mavs.divas.mts.MTSClient;
import edu.utdallas.mavs.traffic.simulation.sim.env.TrafficEnvironment;

/**
 * This class describes a simulation for evacuation scenarios.
 */
public class TrafficSimulation extends Simulation<TrafficEnvironment> implements Serializable
{
    private static final long serialVersionUID = 1L;

    /**
     * Creates a new instance of the simulation for traffic scenarios.
     * 
     * @param client
     *        the MTS client
     */
    public TrafficSimulation(MTSClient client)
    {
        super(client);
    }

    @Override
    protected void createEnvironment(MTSClient client)
    {
        environment = new TrafficEnvironment(client);
    }
    
    @Override
    public void tick(TickMsg tick)
    {
        super.tick(tick);
    }
}