1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.tutorial.section42;
11
12 import java.rmi.RemoteException;
13
14 import nl.tudelft.simulation.dsol.formalisms.devs.SimEvent;
15 import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
16 import nl.tudelft.simulation.jstats.distributions.DistContinuous;
17 import nl.tudelft.simulation.jstats.distributions.DistUniform;
18 import nl.tudelft.simulation.jstats.streams.StreamInterface;
19 import nl.tudelft.simulation.logger.Logger;
20
21 /***
22 * A Warehouse <br>
23 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
24 * University of Technology </a>, the Netherlands. <br>
25 * See for project information <a
26 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
27 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
28 * License (GPL) </a>, no warranty <br>
29 *
30 * @version 1.0 Dec 8, 2003 <br>
31 * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
32 * Jacobs </a>
33 */
34 public class Warehouse implements SellerInterface
35 {
36 /*** simulator. the simulator to schedule on */
37 private DEVSSimulatorInterface simulator = null;
38
39 /*** the delivery or leadTime */
40 private DistContinuous leadTime = null;
41
42 /***
43 * constructs a new Warehouse
44 *
45 * @param simulator the simulator to schedule on
46 * @throws RemoteException on network failure
47 */
48 public Warehouse(final DEVSSimulatorInterface simulator)
49 throws RemoteException
50 {
51 super();
52 this.simulator = simulator;
53
54 StreamInterface stream = this.simulator.getReplication().getStream(
55 "default");
56 this.leadTime = new DistUniform(stream, 0.5, 1.0);
57 }
58
59 /***
60 * @see nl.tudelft.simulation.dsol.tutorial.section42.SellerInterface
61 * #order(nl.tudelft.simulation.dsol.tutorial.section42.BuyerInterface,
62 * long)
63 */
64 public void order(final BuyerInterface buyer, final long amount)
65 {
66 try
67 {
68 this.simulator.scheduleEvent(new SimEvent(this.simulator
69 .getSimulatorTime()
70 + this.leadTime.draw(), this, buyer, "receiveProduct",
71 new Long[]{new Long(amount)}));
72 } catch (Exception exception)
73 {
74 Logger.warning(this, "order", exception);
75 }
76 }
77 }