View Javadoc

    1   /*
    2    * @(#)Station.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.event.EventProducer;
    16
    17  /***
    18   * A station is an object which can accept other objects. *
    19   * <p>
    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 href="http://www.simulation.tudelft.nl">
    23   * 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   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
    28   *         Jacobs </a>
    29   * @version 1.2 2004-03-26
    30   * @since 1.0
    31   */
    32  public abstract class Station extends EventProducer implements StationInterface
    33  {
    34  	/*** simulator is the simulator on which behavior is scheduled */
    35  	protected DEVSSimulatorInterface simulator;
    36
    37  	/***
    38  	 * destination refers to the next station in the process-model chain
    39  	 *
    40  	 * @uml.property name="destination"
    41  	 */
    42  	protected StationInterface destination;
    43
    44
    45  	/***
    46  	 * constructs a new Station.
    47  	 *
    48  	 * @param simulator is the simulator on which behavior is scheduled
    49  	 */
    50  	public Station(final DEVSSimulatorInterface simulator)
    51  	{
    52  		super();
    53  		this.simulator = simulator;
    54  	}
    55
    56  	/***
    57  	 * @see StationInterface#receiveObject(Object)
    58  	 */
    59  	public void receiveObject(final Object object) throws RemoteException
    60  	{
    61  		this.fireEvent(StationInterface.RECEIVE_EVENT, 1.0, this.simulator
    62  				.getSimulatorTime());
    63  	}
    64
    65  	/***
    66  	 * @see StationInterface#setDestination(StationInterface)
    67  	 *
    68  	 * @uml.property name="destination"
    69  	 */
    70  	public void setDestination(final StationInterface destination)
    71  	{
    72  		this.destination = destination;
    73  	}
    74
    75  	/***
    76  	 * releases an object
    77  	 *
    78  	 * @param object is the entity
    79  	 * @throws RemoteException on network failure
    80  	 */
    81  	protected synchronized void releaseObject(final Object object)
    82  			throws RemoteException
    83  	{
    84  		this.fireEvent(StationInterface.RELEASE_EVENT, 0.0, this.simulator
    85  				.getSimulatorTime());
    86  		if (this.destination != null)
    87  		{
    88  			this.destination.receiveObject(object);
    89  		}
    90  	}
    91
    92  	/***
    93  	 * Returns the destination.
    94  	 *
    95  	 * @return the destination station
    96  	 *
    97  	 * @uml.property name="destination"
    98  	 */
    99  	public StationInterface getDestination()
    100 	{
    101 		return this.destination;
    102 	}
    103
    104 }