package nl.tudelft.simulation.examples.dsol.mm1queue; 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.
* Copyright (c) 2003-2018 Delft University of Technology , the Netherlands. *
* See for project information www.simulation.tudelft.nl
* License of use: General Public License (GPL) , no warranty
* @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 DEVSSimulatorInterface.TimeDouble; the simulator on which to schedule * @param resource Resource<Double,Double,SimTimeDouble>; the resource to be released */ public Release(final DEVSSimulatorInterface.TimeDouble simulator, final Resource resource) { super(simulator, resource); } /** * constructs a new Release. * @param simulator DEVSSimulatorInterface.TimeDouble; the simulator on which to schedule * @param resource Resource<Double,Double,SimTimeDouble>; the resource to be released * @param amount double; 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) { if (object instanceof Customer) { Customer customer = (Customer) object; double serviceTime = this.simulator.getSimulatorTime() - customer.getEntranceTime(); this.fireTimedEvent(Release.SERVICE_TIME_EVENT, serviceTime, this.simulator.getSimulatorTime()); super.releaseObject(object); } } }