Class TransporterProvider
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.spatial.transporter.TransporterProvider
-
- All Implemented Interfaces:
ObservableIfc
,GetNameIfc
,IdentityIfc
public class TransporterProvider extends SchedulingElement
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.simulation.ModelElement
ModelElement.EventBuilderIfc<T>, ModelElement.EventScheduler<T>, ModelElement.ModelElementComparator, ModelElement.RequestBuilder, ModelElement.RequestDurationIfc, ModelElement.RequestTimeIfc, ModelElement.RequestUsingIfc, ModelElement.TimedUpdateEventAction, ModelElement.TimeUnitIfc<T>, ModelElement.WarmUpEventAction
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_PRIORITY
protected Queue<QObject>
myDispatchQ
protected QObjectSelectionRuleIfc<QObject>
myInitialRequestSelectionRule
Can be used to supply a rule for how the requests are selected for allocationprotected QObjectSelectionRuleIfc<QObject>
myRequestSelectionRule
Can be used to supply a rule for how the requests are selected for allocationprotected TransporterSet
myTransporterSet
-
Fields inherited from class jsl.simulation.ModelElement
AFTER_EXPERIMENT, AFTER_REPLICATION, BEFORE_EXPERIMENT, BEFORE_REPLICATION, CONDITIONAL_ACTION_REGISTRATION, DEFAULT_TIMED_EVENT_PRIORITY, INITIALIZED, MONTE_CARLO, myAfterExperimentOption, myAfterReplicationOption, myBeforeExperimentOption, myBeforeReplicationOption, myInitializationOption, myLengthOfWarmUp, myModelElements, myMonteCarloOption, myObservableComponent, myReplicationEndedOption, myTimedUpdateActionListener, myTimedUpdateEvent, myTimedUpdateInterval, myTimedUpdateOption, myTimedUpdatePriority, myWarmUpActionListener, myWarmUpEvent, myWarmUpIndicator, myWarmUpOption, myWarmUpPriority, NONE, REMOVED_FROM_MODEL, REPLICATION_ENDED, TIME_UNIT_DAY, TIME_UNIT_HOUR, TIME_UNIT_MILLISECOND, TIME_UNIT_MINUTE, TIME_UNIT_SECOND, TIME_UNIT_WEEK, TIMED_UPDATE, UPDATE, WARMUP
-
-
Constructor Summary
Constructors Constructor Description TransporterProvider(ModelElement parent)
Creates a TransporterProvider that uses a FIFO queue discipline.TransporterProvider(ModelElement parent, java.lang.String name)
Creates a TransporterProvider that uses a FIFO queue discipline.TransporterProvider(ModelElement parent, java.lang.String name, TransporterSet set)
Creates a TransporterProvider that uses the supplied set and FIFO queue disciplineTransporterProvider(ModelElement parent, java.lang.String name, TransporterSet set, Queue.Discipline discipline)
Creates a TransporterProvider that uses the supplied set and queue disciplineTransporterProvider(ModelElement parent, TransporterSet set)
Creates a TransporterProvider that uses the supplied set and FIFO queue disciplineTransporterProvider(ModelElement parent, TransporterSet set, Queue.Discipline discipline)
Creates a TransporterProvider that uses the supplied set and queue discipline
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancelRequest(QObject request)
If the request is in the dispatch queue, this removes it.void
changeDispatchQueueDiscipline(Queue.Discipline discipline)
This will change the queue discipline of the underlying QueueQueue.Discipline
getDispatchQueueInitialDiscipline()
Returns the initial discipline for the queueQObjectSelectionRuleIfc<QObject>
getInitialRequestSelectionRule()
The rule to use when this provider is initializedint
getNumberInDispatchQueue()
Returns the current number of requests in the dispatch queueQObjectSelectionRuleIfc
getRequestSelectionRule()
Returns a reference to the request selection rule.TransporterSet
getTransporterSet()
protected void
initialize()
This method should be overridden by subclasses that need actions performed to initialize prior to a replication.QObject
requestIdleTransporter(TransporterRequesterIfc requester)
This method provides a transporter to the requester.QObject
requestIdleTransporter(TransporterRequesterIfc requester, int priority)
This method provides a transporter to the requester.protected QObject
selectNextRequest()
Selects a candidate request from the queue for allocation to one of the transporter units.void
setDispatchQueueInitialDiscipline(Queue.Discipline discipline)
Sets the initial queue disciplinevoid
setInitialRequestSelectionRule(QObjectSelectionRuleIfc<QObject> rule)
The rule to use when this provider is initializedvoid
setRequestSelectionRule(QObjectSelectionRuleIfc<QObject> rule)
A request selection rule can be supplied to provide alternative behavior within the selectNextRequest() method.protected void
setTransporterSet(TransporterSet set)
protected void
transporterFreed()
-
Methods inherited from class jsl.simulation.SchedulingElement
cancelEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent
-
Methods inherited from class jsl.simulation.ModelElement
addObserver, addObserverToModelElements, afterExperiment, afterExperiment_, afterReplication, afterReplication_, asString, beforeExperiment, beforeExperiment_, beforeReplication, beforeReplication_, buildEventGenerator, cancelTimedUpdateEvent, cancelWarmUpEvent, changeParentModelElement, checkForAfterExperiment, checkForAfterReplication, checkForBeforeExperiment, checkForBeforeReplication, checkForConditionalActionRegistration, checkForInitialize, checkForMonteCarlo, checkForRemoveFromModel, checkForReplicationEnded, checkForTimedUpdate, checkForUpdate, checkForWarmUp, checkObserverState, checkWarmUpOption, clearModelElementObservers, contains, countObservers, createEntity, createEntity, createQObject, day, deleteObserver, deleteObserverFromModelElements, deleteObservers, findModelElementWithWarmUpEvent, getAfterExperimentOption, getAfterReplicationOption, getAllCounters, getAllModelElements, getAllRandomElements, getAllResponseVariables, getAllVariables, getBeforeExperimentOption, getBeforeReplicationOption, getChildModelElementIterator, getCurrentReplicationNumber, getDefaultEntityType, getExecutive, getExperiment, getId, getInitializationOption, getInitializationOrderAsString, getLeftPreOrderTraversalCount, getLengthOfWarmUp, getModel, getModelElementCompartor, getModelElementsAsString, getModelElementsAsString, getModelElementsAsString, getMonteCarloOption, getName, getNumberOfModelElements, getObserverState, getParentModelElement, getPreviousObserverState, getReplicationEndedOption, getRightPreOrderTraversalCount, getSimulation, getSpatialModel, getStringLabel, getThisElementsCounters, getThisElementsModelElements, getThisElementsRandomVariables, getThisElementsResponseVariables, getThisElementsVariables, getTime, getTimedUpdateInterval, getTimedUpdateOption, getUpdateNotificationFlag, getVariable, getWarmUpEventTime, getWarmUpOption, hour, indent, initialize_, isTimedUpdateEventScheduled, isWarmedUp, isWarmUpEventScheduled, isWarmUpScheduled, millisecond, minute, montecarlo, montecarlo_, notifyAfterExperimentObservers, notifyAfterReplicationObservers, notifyBeforeExperimentObservers, notifyBeforeReplicationObservers, notifyConditionalActionRegistrationObservers, notifyInitializationObservers, notifyMonteCarloObservers, notifyObservers, notifyObservers, notifyRemovingFromModelObservers, notifyReplicationEndedObservers, notifyTimedUpdateObservers, notifyUpdateObservers, notifyWarmUpObservers, registerConditionalActions, registerConditionalActions_, removedFromModel, removeFromModel, replicationEnded, replicationEnded_, schedule, second, seize, setAfterExperimentOption, setAfterExperimentOptionForModelElements, setAfterReplicationOption, setAfterReplicationOptionForModelElements, setBeforeExperimentOption, setBeforeExperimentOptionForModelElements, setBeforeReplicationOption, setBeforeReplicationOptionForModelElements, setInitializationOption, setInitializationOptionForModelElements, setLengthOfWarmUp, setModel, setMonteCarloOption, setMonteCarloOptionForModelElements, setName, setObserverState, setParentModelElement, setReplicationEndedOption, setReplicationEndedOptionForModelElements, setSpatialModel, setStringLabel, setTimedUpdateInterval, setTimedUpdateOption, setTimedUpdateOptionForModelElements, setUpdateNotificationFlag, setWarmUpOption, setWarmUpOptionForModelElements, stopExecutive, stopExecutive, timedUpdate, timedUpdate_, toString, update, useControls, warmUp, warmUp_, week
-
-
-
-
Field Detail
-
DEFAULT_PRIORITY
public static final int DEFAULT_PRIORITY
- See Also:
- Constant Field Values
-
myTransporterSet
protected TransporterSet myTransporterSet
-
myInitialRequestSelectionRule
protected QObjectSelectionRuleIfc<QObject> myInitialRequestSelectionRule
Can be used to supply a rule for how the requests are selected for allocation
-
myRequestSelectionRule
protected QObjectSelectionRuleIfc<QObject> myRequestSelectionRule
Can be used to supply a rule for how the requests are selected for allocation
-
-
Constructor Detail
-
TransporterProvider
public TransporterProvider(ModelElement parent)
Creates a TransporterProvider that uses a FIFO queue discipline. An empty TransporterSet is created and must be filled- Parameters:
parent
-
-
TransporterProvider
public TransporterProvider(ModelElement parent, java.lang.String name)
Creates a TransporterProvider that uses a FIFO queue discipline. An empty TransporterSet is created and must be filled- Parameters:
parent
-name
-
-
TransporterProvider
public TransporterProvider(ModelElement parent, java.lang.String name, TransporterSet set)
Creates a TransporterProvider that uses the supplied set and FIFO queue discipline- Parameters:
parent
-name
-set
-
-
TransporterProvider
public TransporterProvider(ModelElement parent, TransporterSet set)
Creates a TransporterProvider that uses the supplied set and FIFO queue discipline- Parameters:
parent
-set
-
-
TransporterProvider
public TransporterProvider(ModelElement parent, TransporterSet set, Queue.Discipline discipline)
Creates a TransporterProvider that uses the supplied set and queue discipline- Parameters:
parent
-set
-discipline
-
-
TransporterProvider
public TransporterProvider(ModelElement parent, java.lang.String name, TransporterSet set, Queue.Discipline discipline)
Creates a TransporterProvider that uses the supplied set and queue discipline- Parameters:
parent
-name
-set
-discipline
-
-
-
Method Detail
-
getTransporterSet
public final TransporterSet getTransporterSet()
-
changeDispatchQueueDiscipline
public final void changeDispatchQueueDiscipline(Queue.Discipline discipline)
This will change the queue discipline of the underlying Queue- Parameters:
discipline
-
-
getDispatchQueueInitialDiscipline
public final Queue.Discipline getDispatchQueueInitialDiscipline()
Returns the initial discipline for the queue- Returns:
-
setDispatchQueueInitialDiscipline
public final void setDispatchQueueInitialDiscipline(Queue.Discipline discipline)
Sets the initial queue discipline- Parameters:
discipline
-
-
getNumberInDispatchQueue
public final int getNumberInDispatchQueue()
Returns the current number of requests in the dispatch queue- Returns:
-
cancelRequest
public final void cancelRequest(QObject request)
If the request is in the dispatch queue, this removes it. It does this without collecting statistics on the time in queue for the request.- Parameters:
request
- Should not be null
-
requestIdleTransporter
public final QObject requestIdleTransporter(TransporterRequesterIfc requester)
This method provides a transporter to the requester. A request is created with the default priority. The request is placed in the request queue for this TransporterProvider. If the request is given an idle transporter, the request is removed from the dispatch queue and the requester is notified through the use of its idleTransporterProvided() method. If there are no idle transporters the request waits in the dispatch queue. When an idle transporter becomes available for the request, the requester is automatically notified through it idleTransporterProvided() method. The request can be by the client to see if it has been queued.- Parameters:
requester
- The requester for a transporter- Returns:
- A reference to the request.
-
requestIdleTransporter
public QObject requestIdleTransporter(TransporterRequesterIfc requester, int priority)
This method provides a transporter to the requester. A request is created with the given priority. The request is placed in the request queue for this TransporterProvider. If the request is given an idle transporter, the request is removed from the dispatch queue and the requester is notified through the use of its idleTransporterProvided() method. If there are no idle transporters the request waits in the dispatch queue. When an idle transporter becomes available for the request, the requester is automatically notified through it idleTransporterProvided() method. The request can be checked by the client to see if it has been queued.- Parameters:
requester
- The requester for a transporterpriority
- , The priority for the request- Returns:
- A reference to the request.
-
getRequestSelectionRule
public final QObjectSelectionRuleIfc getRequestSelectionRule()
Returns a reference to the request selection rule. May be null.- Returns:
-
setRequestSelectionRule
public final void setRequestSelectionRule(QObjectSelectionRuleIfc<QObject> rule)
A request selection rule can be supplied to provide alternative behavior within the selectNextRequest() method. A request selection rule, provides a mechanism to select the next request from the queue of waiting requests- Parameters:
rule
-
-
getInitialRequestSelectionRule
public final QObjectSelectionRuleIfc<QObject> getInitialRequestSelectionRule()
The rule to use when this provider is initialized- Returns:
-
setInitialRequestSelectionRule
public final void setInitialRequestSelectionRule(QObjectSelectionRuleIfc<QObject> rule)
The rule to use when this provider is initialized- Parameters:
rule
-
-
selectNextRequest
protected QObject selectNextRequest()
Selects a candidate request from the queue for allocation to one of the transporter units. The selection process does not remove the request from the queue.- Returns:
- The request that was selected to for a transporter
-
initialize
protected void initialize()
Description copied from class:ModelElement
This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called- Overrides:
initialize
in classModelElement
-
setTransporterSet
protected final void setTransporterSet(TransporterSet set)
-
transporterFreed
protected void transporterFreed()
-
-