package nl.tudelft.simulation.examples.dsol.mm1queue; import java.io.Serializable; import org.djutils.event.TimedEventType; import org.djutils.metadata.MetaData; import org.djutils.metadata.ObjectDescriptor; import nl.tudelft.simulation.dsol.formalisms.Resource; import nl.tudelft.simulation.dsol.simtime.SimTimeDouble; import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface; /** * The Seize is an extended Seize block which computes the servicetime.
* Copyright (c) 2003-2021 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 TimedEventType SERVICE_TIME_EVENT = new TimedEventType(new MetaData("SERVICE_TIME_EVENT", "Service Time observation", new ObjectDescriptor("serviceTime", "Service time", Double.class))); /** * constructs a new Release. * @param id the id of the Release block * @param simulator DEVSSimulatorInterface.TimeDouble; the simulator on which to schedule * @param resource Resource<Double,Double,SimTimeDouble>; the resource to be released */ public Release(final Serializable id, final DEVSSimulatorInterface.TimeDouble simulator, final Resource resource) { super(id, simulator, resource); } /** * constructs a new Release. * @param id the id of the Release block * @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 Serializable id, final DEVSSimulatorInterface.TimeDouble simulator, final Resource resource, final double amount) { super(id, simulator, resource, amount); } /** {@inheritDoc} */ @Override public 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); } } }