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

The “edu.utdallas.mavs.traffic.simulation.TrafficMain” class, that was previously created in tutorial 6.0, contains the main method that is responsible for creating, initializing, and starting the traffic simulation. Implementing this calss is the final step of implementing the Traffic Simulation module.

Implementation Steps

    1. The “TrafficMain” class contains the implementation of the “main” method that is responsible for creating, initializing, and starting the traffic simulation. The implementation of this class initializes the configuration properties for log4j which can be used to dump useful data of the simulation to an external file for further analysis. The full implementation of this class is provided in the following code.
package edu.utdallas.mavs.traffic.simulation;

import org.apache.log4j.PropertyConfigurator;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Stage;

import edu.utdallas.mavs.traffic.simulation.config.TrafficVisConfig;
import edu.utdallas.mavs.traffic.simulation.guice.SimulationModule;
import edu.utdallas.mavs.traffic.simulation.host.TrafficHost;

/**
 * Simulation of evacuation scenarios over DIVAs framework.
 */
public class TrafficMain
{
    /**
     * Simulation entry point.
     * 
     * @param args no arguments defined
     */
    public static void main(String[] args)
    {
        // reads configuration properties for log4j
        PropertyConfigurator.configure("log4j.properties");

        // disables java logging
        java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.OFF);
        
        // Register custom configurations
        TrafficVisConfig.register();


        final Injector injector = Guice.createInjector(Stage.PRODUCTION, new SimulationModule());
        injector.getInstance(TrafficHost.class).start();
    }
}

 

    1. After creating and implementing the “TrafficMain” class, the project explorer should look like the following: