View Javadoc

1   /*
2    * @(#) ConsoleRunner.java Dec 1, 2003
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.dsol.tutorial.section25;
11  
12  import java.net.URL;
13  
14  import nl.tudelft.simulation.dsol.experiment.Experiment;
15  import nl.tudelft.simulation.dsol.simulators.DEVSSimulator;
16  import nl.tudelft.simulation.xml.dsol.ExperimentParser;
17  
18  /***
19   * A ConsoleRunner <br>
20   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
21   * University of Technology </a>, the Netherlands. <br>
22   * See for project information <a
23   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
24   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
25   * License (GPL) </a>, no warranty <br>
26   * 
27   * @version 1.0 Dec 1, 2003 <br>
28   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
29   *         Jacobs </a>
30   */
31  public final class ConsoleRunner
32  {
33  
34  	/***
35  	 * constructs a new ConsoleRunner
36  	 */
37  	private ConsoleRunner()
38  	{
39  		//unreachable code
40  	}
41  
42  	/***
43  	 * executes our model
44  	 * 
45  	 * @param args the experiment xml-file url
46  	 */
47  	public static void main(final String[] args)
48  	{
49  		if (args.length != 1)
50  		{
51  			System.out.println("Usage : java nl.tudelft.simulation.dsol."
52  					+ "tutorial.section24.ConsoleRunner [experiment-url]");
53  			System.exit(0);
54  		}
55  		try
56  		{
57  			//First we resolve the experiment and parse it
58  			URL experimentURL = new URL(args[0].toString());
59  			Experiment experiment = ExperimentParser
60  					.parseExperiment(experimentURL);
61  
62  			//Now we set the simulator
63  			experiment.setSimulator(new DEVSSimulator());
64  
65  			//Finally we set the model
66  			experiment.setModel(new Model());
67  
68  			//We are ready to start
69  			experiment.start();
70  		} catch (Exception exception)
71  		{
72  			exception.printStackTrace();
73  		}
74  	}
75  }