Package jsl.modeling.elements.station
Class SResource
- java.lang.Object
- 
- jsl.simulation.ModelElement
- 
- jsl.simulation.SchedulingElement
- 
- jsl.modeling.elements.station.SResource
 
 
 
- 
- All Implemented Interfaces:
- ObservableIfc,- GetNameIfc,- IdentityIfc
 
 public class SResource extends SchedulingElement A SResource represents a simple resource that can have units become busy. A resource is considered busy when it has 1 or more units busy. A resource is considered idle when all available units are idle. A resource has an initial capacity, which represents the units that can be allocated. The capacity of the resource represents the maximum number of units available for use. For example, if the resource has capacity 3, it may have 2 units busy and 1 unit idle. A resource cannot have more units busy than the capacity.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class jsl.simulation.ModelElementModelElement.EventBuilderIfc<T>, ModelElement.EventScheduler<T>, ModelElement.ModelElementComparator, ModelElement.RequestBuilder, ModelElement.RequestDurationIfc, ModelElement.RequestTimeIfc, ModelElement.RequestUsingIfc, ModelElement.TimedUpdateEventAction, ModelElement.TimeUnitIfc<T>, ModelElement.WarmUpEventAction
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static intRELEASEIndicates that the resource was released for state change purposes That is, units of resource became idle.static intSEIZEIndicates that the resource was seized for state change purposes That is, units of the resource became busy.- 
Fields inherited from class jsl.simulation.ModelElementAFTER_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 SummaryConstructors Constructor Description SResource(ModelElement parent)The capacity is set to 1SResource(ModelElement parent, int capacity)The capacity represents the maximum number of units available to use when the resource is idle.SResource(ModelElement parent, int capacity, java.lang.String name)The capacity represents the maximum number of units available to use when the resource is idle.SResource(ModelElement parent, java.lang.String name)The capacity is set to 1
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringasString()Allows sub-classes to provide more detail than toString() to represent the ModelElement as a StringvoidattachStateChangeListener(SResourceStateChangeListenerIfc listener)voiddetachStateChangeListener(SResourceStateChangeListenerIfc listener)intgetCapacity()The current capacity of the resource.doublegetFractionBusy()The fraction of the capacity that is currently busyintgetInitialCapacity()Gets the initial capacity of the resourceStatisticAccessorIfcgetNBAcrossReplicationStatistic()Across replication statistics on the number busyintgetNumberAvailable()Returns the number of units that are currently available for useintgetNumberTimesReleased()Returns how many times the resource has had units returned from use.intgetNumberTimesSeized()Returns how many times the resource has had units used.intgetNumBusy()The number of units that are currently busyprotected ModelElementStategetPreviousState()StatisticAccessorIfcgetUtilAcrossReplicationStatistic()Across replication statistics on the utilizationbooleanhasAvailableUnits()Returns true if getNumberAvailable() > 0protected voidinitialize()This method should be overridden by subclasses that need actions performed to initialize prior to a replication.booleanisBusy()Checks to see if the resource is busy.booleanisIdle()Checks if the resource is idle.protected voidnotifyStateChangeListeners()voidrelease()Releases 1 unit of the resource.voidrelease(int amt)Releases amt units of the resource.voidseize()Seizes 1 unit of the resource.voidseize(int amt)Seizes amt units of the resource.voidsetInitialCapacity(int capacity)Sets the initial capacity of the resource.protected voidsetPreviousState(ModelElementState state)protected voidsetState(ModelElementState state)protected voidupdateState(int change)- 
Methods inherited from class jsl.simulation.SchedulingElementcancelEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent
 - 
Methods inherited from class jsl.simulation.ModelElementaddObserver, addObserverToModelElements, afterExperiment, afterExperiment_, afterReplication, afterReplication_, 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- 
SEIZEpublic static final int SEIZE Indicates that the resource was seized for state change purposes That is, units of the resource became busy.
 - 
RELEASEpublic static final int RELEASE Indicates that the resource was released for state change purposes That is, units of resource became idle.
 
- 
 - 
Constructor Detail- 
SResourcepublic SResource(ModelElement parent) The capacity is set to 1- Parameters:
- parent- the parent model element
 
 - 
SResourcepublic SResource(ModelElement parent, java.lang.String name) The capacity is set to 1- Parameters:
- parent- the parent model element
- name- a unique name for the resource
 
 - 
SResourcepublic SResource(ModelElement parent, int capacity) The capacity represents the maximum number of units available to use when the resource is idle.- Parameters:
- parent- the parent model element
- capacity- the initial capacity of the resource
 
 - 
SResourcepublic SResource(ModelElement parent, int capacity, java.lang.String name) The capacity represents the maximum number of units available to use when the resource is idle.- Parameters:
- parent- the parent model element
- capacity- the initial capacity of the resource
- name- a unique name for the resource
 
 
- 
 - 
Method Detail- 
initializeprotected void initialize() Description copied from class:ModelElementThis 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:
- initializein class- ModelElement
 
 - 
getNumberTimesSeizedpublic final int getNumberTimesSeized() Returns how many times the resource has had units used.- Returns:
- how many times the resource has had units used.
 
 - 
getNumberTimesReleasedpublic final int getNumberTimesReleased() Returns how many times the resource has had units returned from use.- Returns:
- how many times the resource has had units returned from use
 
 - 
getFractionBusypublic final double getFractionBusy() The fraction of the capacity that is currently busy- Returns:
- fraction of the capacity that is currently busy
 
 - 
getNumBusypublic final int getNumBusy() The number of units that are currently busy- Returns:
- number of units that are currently busy
 
 - 
seizepublic final void seize() Seizes 1 unit of the resource. If the resource has no units available, then an exception occurs. If getNumberAvailable() = 0 then an exception occurs.
 - 
seizepublic void seize(int amt) Seizes amt units of the resource. If amt = 0, then an exception occurs. If the resource has no units available, then an exception occurs. If the amt > getNumberAvailable() then an exception occurs.- Parameters:
- amt- the amount to seize
 
 - 
updateStateprotected void updateState(int change) 
 - 
releasepublic final void release() Releases 1 unit of the resource. If the number busy is zero, then an exception occurs.
 - 
releasepublic void release(int amt) Releases amt units of the resource. If amt is 0 then an exception occurs. If the amt is > getNumBusy() then an exception occurs- Parameters:
- amt- the amount to release
 
 - 
asStringpublic java.lang.String asString() Description copied from class:ModelElementAllows sub-classes to provide more detail than toString() to represent the ModelElement as a String- Overrides:
- asStringin class- ModelElement
- Returns:
- a detailed String representation
 
 - 
isIdlepublic final boolean isIdle() Checks if the resource is idle. The resource is idle if all available units are idle.- Returns:
- true if idle, false otherwise
 
 - 
isBusypublic final boolean isBusy() Checks to see if the resource is busy. The resource is busy if 1 or more of its units are busy.- Returns:
- true if busy
 
 - 
getCapacitypublic final int getCapacity() The current capacity of the resource.- Returns:
- the capacity
 
 - 
getNumberAvailablepublic int getNumberAvailable() Returns the number of units that are currently available for use- Returns:
- the number of units that are currently available for use
 
 - 
hasAvailableUnitspublic final boolean hasAvailableUnits() Returns true if getNumberAvailable() > 0- Returns:
- true if getNumberAvailable() > 0
 
 - 
getInitialCapacitypublic final int getInitialCapacity() Gets the initial capacity of the resource- Returns:
- the initial capacity of the resource
 
 - 
setInitialCapacitypublic final void setInitialCapacity(int capacity) Sets the initial capacity of the resource. This only changes it for when the resource is initialized.- Parameters:
- capacity- the initial capacity of the resource
 
 - 
detachStateChangeListenerpublic void detachStateChangeListener(SResourceStateChangeListenerIfc listener) 
 - 
attachStateChangeListenerpublic void attachStateChangeListener(SResourceStateChangeListenerIfc listener) 
 - 
notifyStateChangeListenersprotected void notifyStateChangeListeners() 
 - 
setStateprotected void setState(ModelElementState state) 
 - 
getPreviousStateprotected ModelElementState getPreviousState() 
 - 
setPreviousStateprotected void setPreviousState(ModelElementState state) 
 - 
getNBAcrossReplicationStatisticpublic final StatisticAccessorIfc getNBAcrossReplicationStatistic() Across replication statistics on the number busy- Returns:
 
 - 
getUtilAcrossReplicationStatisticpublic final StatisticAccessorIfc getUtilAcrossReplicationStatistic() Across replication statistics on the utilization- Returns:
 
 
- 
 
-