package desmoj.extensions.verkettung.util;
import desmoj.core.dist.NumericalDist;
import desmoj.core.simulator.Entity;
import desmoj.core.simulator.Event;
import desmoj.core.simulator.TimeSpan;
import desmoj.extensions.verkettung.abstractions.HasPredecessor;
import desmoj.extensions.verkettung.abstractions.HasSuccessor;
/**
* The SplitterOutput is used in the Splitter context to compose a output config fpr the splitter construct.
*
* @author Christian Mentz
*
* @param <EIn>
* the entitiy which comes in the splitter
* @param <EEx>
* the entity which leaves the splitter
*/
public abstract class SplitterOutput<EIn extends Entity, EEx extends Entity> implements HasSuccessor<EEx> {
/**
* the succsessor event the be scheduled after the splitter
*/
private Event<? super EEx> successorEvent;
/**
* the number of output parts of this output
*/
private final int numberOfOutputPartsPerOriginalEntity;
/**
* the transport time of this output
*/
private final NumericalDist<?> transportTime;
/**
* Constructor to create a Splitteroutput which can be added to an List which than can passed to the Splitter
*
* @param numberOfOutputPartsPerOriginalEntity
* the number of output parts of this output
* @param transportTime
* the transport time of this output
*/
public SplitterOutput(int numberOfOutputPartsPerOriginalEntity, NumericalDist<?> transportTime) {
this.numberOfOutputPartsPerOriginalEntity = numberOfOutputPartsPerOriginalEntity;
this.transportTime = transportTime;
}
/**
* This Method has to be overridden by the user to set the output entity
*
* @param originalEntity
* reference to the original entity
* @return the output entitiy
*/
public abstract EEx createOutputEntity(EIn originalEntity);
/**
* gets the number of parts
*
* @return the number of parts
*/
public int getNumberOfOutputPartsPerOriginalEntity() {
return numberOfOutputPartsPerOriginalEntity;
}
/**
* gets the succsessor event which has been set by the user
*
* @return the succsessor event
*/
public Event<? super EEx> getSuccessorEvent() {
return successorEvent;
}
/**
* gets the transport time of the station
*
* @return the transport time
*/
public TimeSpan getTransportTime() {
if (transportTime == null) {
return new TimeSpan(0);
} else {
return transportTime.sampleTimeSpan();
}
}
@Override
public void setSuccessor(Event<? super EEx> eventToScheduleWhenFinished) {
successorEvent = eventToScheduleWhenFinished;
}
@Override
public void setSuccessor(HasPredecessor<? super EEx> successor) {
setSuccessor(successor.getStartEvent());
}
}