package nl.tudelft.simulation.examples.dsol.mm1queue;
import java.rmi.RemoteException;
import nl.tudelft.simulation.dsol.formalisms.Resource;
import nl.tudelft.simulation.dsol.simtime.SimTimeDouble;
import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
import nl.tudelft.simulation.event.EventType;
/**
* The Seize is an extended Seize block which computes the servicetime.
* (c) copyright 2003 Delft University of Technology , the Netherlands.
*
* See for project information www.simulation.tudelft.nl
* License of use: General Public License (GPL) , no warranty
* @version 2.0 21.09.2003
* @author Peter Jacobs
*/
public class Release extends nl.tudelft.simulation.dsol.formalisms.flow.Release.TimeDouble
{
/** */
private static final long serialVersionUID = 1L;
/** SERVICE_TIME_EVENT is fired when a customer is released. */
public static final EventType SERVICE_TIME_EVENT = new EventType("SERVICE_TIME_EVENT");
/**
* constructs a new Release.
* @param simulator the simulator on which to schedule
* @param resource the resource to be released
*/
public Release(final DEVSSimulatorInterface.TimeDouble simulator, final Resource resource)
{
super(simulator, resource);
}
/**
* constructs a new Release.
* @param simulator the simulator on which to schedule
* @param resource the resource to be released
* @param amount the amount to be released
*/
public Release(final DEVSSimulatorInterface.TimeDouble simulator, final Resource resource,
final double amount)
{
super(simulator, resource, amount);
}
/** {@inheritDoc} */
@Override
public final synchronized void releaseObject(final Object object) throws RemoteException
{
if (object instanceof Customer)
{
Customer customer = (Customer) object;
double serviceTime = this.simulator.getSimulatorTime().get() - customer.getEntranceTime();
this.fireTimedEvent(Release.SERVICE_TIME_EVENT, serviceTime, this.simulator.getSimulatorTime());
super.releaseObject(object);
}
}
}