1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.tutorial.section25;
11
12 import java.rmi.RemoteException;
13
14 import nl.tudelft.simulation.dsol.SimRuntimeException;
15 import nl.tudelft.simulation.dsol.formalisms.devs.SimEvent;
16 import nl.tudelft.simulation.dsol.formalisms.devs.SimEventInterface;
17 import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
18
19 /***
20 * The Customer class as presented in section 2.5 in the DSOL tutorial.
21 * <p>
22 * (c) copyright 2003-2004 <a href="http://www.simulation.tudelft.nl"> Delft
23 * University of Technology </a>, the Netherlands. <br>
24 * See for project information <a href="http://www.simulation.tudelft.nl">
25 * www.simulation.tudelft.nl </a> <br>
26 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
27 * License (GPL) </a>, no warranty <br>
28 *
29 * @version 1.1 Sep 6, 2004 <br>
30 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja">Peter Jacobs </a>
31 */
32 public class Customer
33 {
34 /*** the simulator we can schedule on */
35 private DEVSSimulatorInterface simulator = null;
36
37 /***
38 * constructs a new Customer
39 *
40 * @param simulator The simulator to use.
41 */
42 public Customer(final DEVSSimulatorInterface simulator)
43 {
44 super();
45 this.simulator = simulator;
46 this.generateOrder();
47 }
48
49 /***
50 * generates a new Order
51 */
52 private void generateOrder()
53 {
54 try
55 {
56 Order order = new Order("Television", 2.0);
57 System.out.println("ordered " + order + " @ time="
58 + this.simulator.getSimulatorTime());
59
60
61 SimEventInterface simEvent = new SimEvent(this.simulator
62 .getSimulatorTime() + 2.0, this, this, "generateOrder",
63 null);
64 this.simulator.scheduleEvent(simEvent);
65 } catch (SimRuntimeException simRuntimeException)
66 {
67 simRuntimeException.printStackTrace();
68 } catch (RemoteException simRuntimeException)
69 {
70 simRuntimeException.printStackTrace();
71 }
72 }
73 }