Package jsl.simulation
Class ModelElementState
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.ModelElementState
-
- All Implemented Interfaces:
ObservableIfc,StateAccessorIfc,GetNameIfc,IdentityIfc
- Direct Known Subclasses:
Component.ComponentState
public class ModelElementState extends ModelElement implements StateAccessorIfc
ModelElementState models a state that can be entered and exited with statistics tabulated. It represents a "permanent" state as it is part of the model element hierarchy.
-
-
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 protected StatemyStateprotected java.util.SortedSet<StateEnteredListenerIfc>myStateEnteredListeners-
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 ModelElementState(ModelElement parent)ModelElementState(ModelElement parent, java.lang.String name)ModelElementState(ModelElement parent, java.lang.String name, boolean useStatistic)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachStateEnteredListener(StateEnteredListenerIfc listener)voiddetachStateEnteredListener(StateEnteredListenerIfc listener)voidenter()Causes the state to be entered at the current simulation timevoidenter(double time)Causes the state to be entered with the time entered set to the supplied valuedoubleexit()Causes the state to be exited at the current simulation timedoubleexit(double time)Causes the state to be exited with the time exited recorded as the supplied timedoublegetNumberOfTimesEntered()Gets the number of times the state was entereddoublegetNumberOfTimesExited()Gets the number of times the state was exitedbooleangetSojournTimeCollectionFlag()Indicates whether or not statistics should be collected on the sojourn times within the statejava.util.Optional<Statistic>getSojournTimeStatistic()Gets a statistic that collected sojourn timesStateAccessorIfcgetStateAccessor()Allows the accumulated state information to be accesseddoublegetTimeStateEntered()Gets the time that the state was last entereddoublegetTimeStateExited()Gets the time that the state was last exiteddoublegetTotalTimeInState()Gets the total time spent in the stateprotected voidinitialize()This method should be overridden by subclasses that need actions performed to initialize prior to a replication.booleanisEntered()Gets whether or not the state has been enteredprotected voidnotifyStateEnteredListeners()protected voidonEnter()can be overwritten by subclasses to perform work when the state is enteredprotected voidonExit()can be overwritten by subclasses to perform work when the state is exitedvoidresetSojournTimeStatistics()Resets the statistics collected on the sojourn time in the statevoidresetStateCollection()Resets the counters for the number of times a state was entered, exited, and the total time spent in the statevoidturnOffSojournTimeCollection()Turns off statistical collection of the sojourn times in the statevoidturnOnSojournTimeCollection()Turns on statistical collection for the sojourn time in the stateprotected voidwarmUp()This method should be overridden by subclasses that need actions performed at the warm up event during each replication.-
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_, week
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsl.utilities.GetNameIfc
getName
-
Methods inherited from interface jsl.utilities.IdentityIfc
getId
-
Methods inherited from interface jsl.simulation.StateAccessorIfc
getTimeInState
-
-
-
-
Field Detail
-
myState
protected State myState
-
myStateEnteredListeners
protected java.util.SortedSet<StateEnteredListenerIfc> myStateEnteredListeners
-
-
Constructor Detail
-
ModelElementState
public ModelElementState(ModelElement parent)
-
ModelElementState
public ModelElementState(ModelElement parent, java.lang.String name)
-
ModelElementState
public ModelElementState(ModelElement parent, java.lang.String name, boolean useStatistic)
-
-
Method Detail
-
attachStateEnteredListener
public void attachStateEnteredListener(StateEnteredListenerIfc listener)
-
detachStateEnteredListener
public void detachStateEnteredListener(StateEnteredListenerIfc listener)
-
notifyStateEnteredListeners
protected void notifyStateEnteredListeners()
-
getStateAccessor
public final StateAccessorIfc getStateAccessor()
Allows the accumulated state information to be accessed- Returns:
- the StateAccessorIfc
-
enter
public final void enter()
Causes the state to be entered at the current simulation time
-
enter
public final void enter(double time)
Causes the state to be entered with the time entered set to the supplied value- Parameters:
time- the time entered
-
exit
public final double exit()
Causes the state to be exited at the current simulation time- Returns:
- the time of exit
-
exit
public final double exit(double time)
Causes the state to be exited with the time exited recorded as the supplied time- Parameters:
time- the time exited- Returns:
- the time spent in the state as a double
-
getSojournTimeCollectionFlag
public final boolean getSojournTimeCollectionFlag()
Indicates whether or not statistics should be collected on the sojourn times within the state- Returns:
- Returns the collect sojourn time flag.
-
turnOnSojournTimeCollection
public final void turnOnSojournTimeCollection()
Turns on statistical collection for the sojourn time in the state
-
turnOffSojournTimeCollection
public final void turnOffSojournTimeCollection()
Turns off statistical collection of the sojourn times in the state
-
resetSojournTimeStatistics
public final void resetSojournTimeStatistics()
Resets the statistics collected on the sojourn time in the state
-
resetStateCollection
public final void resetStateCollection()
Resets the counters for the number of times a state was entered, exited, and the total time spent in the state
-
getNumberOfTimesEntered
public final double getNumberOfTimesEntered()
Description copied from interface:StateAccessorIfcGets the number of times the state was entered- Specified by:
getNumberOfTimesEnteredin interfaceStateAccessorIfc- Returns:
- A double representing the number of times entered
-
getNumberOfTimesExited
public final double getNumberOfTimesExited()
Description copied from interface:StateAccessorIfcGets the number of times the state was exited- Specified by:
getNumberOfTimesExitedin interfaceStateAccessorIfc- Returns:
- A double representing the number of times exited
-
getSojournTimeStatistic
public final java.util.Optional<Statistic> getSojournTimeStatistic()
Description copied from interface:StateAccessorIfcGets a statistic that collected sojourn times- Specified by:
getSojournTimeStatisticin interfaceStateAccessorIfc- Returns:
- A statistic for sojourn times or null if use statistic was false
-
getTimeStateEntered
public final double getTimeStateEntered()
Description copied from interface:StateAccessorIfcGets the time that the state was last entered- Specified by:
getTimeStateEnteredin interfaceStateAccessorIfc- Returns:
- A double representing the time that the state was last entered
-
getTimeStateExited
public final double getTimeStateExited()
Description copied from interface:StateAccessorIfcGets the time that the state was last exited- Specified by:
getTimeStateExitedin interfaceStateAccessorIfc- Returns:
- A double representing the time that the state was last exited
-
getTotalTimeInState
public final double getTotalTimeInState()
Description copied from interface:StateAccessorIfcGets the total time spent in the state- Specified by:
getTotalTimeInStatein interfaceStateAccessorIfc- Returns:
- a double representing the total sojourn time
-
isEntered
public final boolean isEntered()
Description copied from interface:StateAccessorIfcGets whether or not the state has been entered- Specified by:
isEnteredin interfaceStateAccessorIfc- Returns:
- True means that the state has been entered
-
initialize
protected 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 classModelElement
-
warmUp
protected void warmUp()
Description copied from class:ModelElementThis method should be overridden by subclasses that need actions performed at the warm up event during each replication. It is called once during each replication if the model element reacts to warm up actions.- Overrides:
warmUpin classModelElement
-
onEnter
protected void onEnter()
can be overwritten by subclasses to perform work when the state is entered
-
onExit
protected void onExit()
can be overwritten by subclasses to perform work when the state is exited
-
-