View Javadoc

1   /*
2    * @(#)Delay.java Feb 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.formalisms.flow;
11  
12  import java.rmi.RemoteException;
13  
14  import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
15  import nl.tudelft.simulation.jstats.distributions.DistContinuous;
16  import nl.tudelft.simulation.logger.Logger;
17  
18  /***
19   * The Delay object is a station which delays an entity by some time units. When
20   * an entity arrives at a delay object, dsol delays the entity by the resulting
21   * time period. During the time delay, the entity is held in the delay object.
22   * <p>
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 href="http://www.simulation.tudelft.nl">
26   * 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   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
31   *         Jacobs </a>
32   * @version 1.11 2004-03-28
33   * @since 1.0
34   */
35  public class Delay extends Station
36  {
37  	/*** delayDistribution which is the distribution defining the delay */
38  	protected DistContinuous delayDistribution;
39  
40  	/***
41  	 * Constructor for Delay.
42  	 * 
43  	 * @param simulator is the simulator
44  	 * @param delayDistribution is the delayDistribution
45  	 */
46  	public Delay(final DEVSSimulatorInterface simulator,
47  			final DistContinuous delayDistribution)
48  	{
49  		super(simulator);
50  		this.delayDistribution = delayDistribution;
51  	}
52  
53  	/***
54  	 * @see StationInterface#receiveObject(Object)
55  	 */
56  	public synchronized void receiveObject(final Object object)
57  			throws RemoteException
58  	{			
59  		super.receiveObject(object);
60  		try
61  		{
62  			this.simulator.scheduleEvent(this.delayDistribution.draw(), this,
63  					this, "releaseObject", new Object[]{object});
64  		} catch (Exception exception)
65  		{
66  			Logger.warning(this, "receiveObject", exception);
67  		}
68  	}
69  }