Package jsl.modeling.resource
Class ResourceSingleFailureEvent
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.resource.ResourceSingleFailureEvent
-
- All Implemented Interfaces:
ObservableIfc
,GetNameIfc
,IdentityIfc
public class ResourceSingleFailureEvent extends SchedulingElement
Models a single failure event that can effect many resource units. If no resource units are attached then a warning message occurs. If you really do not want to attach resource units and do not want the warning then use setNoResourceUnitWarningOption(false)
-
-
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 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 ResourceSingleFailureEvent(ModelElement parent, RandomIfc eventDuration, RandomIfc initialStartTimeRV)
ResourceSingleFailureEvent(ModelElement parent, RandomIfc eventDuration, RandomIfc initialStartTimeRV, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFailureEventListener(FailureEventListenerIfc listener)
Adds a listener to react to failureStarted eventvoid
addResourceUnit(ResourceUnit resourceUnit)
Adds a resource unit to the failure eventvoid
addResourceUnits(java.util.Collection<ResourceUnit> units)
void
addResourceUnits(ResourcePool pool)
protected void
beforeExperiment()
This method should be overridden by subclasses that need logic to be performed prior to an experiment.protected void
beforeReplication()
Allows each replication to start at a different time and to have a different failure duration.protected void
cancelFailure()
Causes the single event to be canceled if it has not yet occurred.protected void
failureEnded(JSLEvent event)
Subclasses can override this method to provide behavior after the failure ends This method occurs before any failure event listeners are notified of the end of the failureprotected void
failureStarted(JSLEvent event)
Subclasses can override this method to provide behavior when the event starts This method occurs before any associated resources start the failure and before any failure event listeners are notified of the start of the eventboolean
getAutoStartProcessOption()
The default is falsedouble
getDuration()
double
getEventStartTime()
boolean
getNoResourceUnitWarningOption()
boolean
hasResourceUnits()
protected void
initialize()
This method should be overridden by subclasses that need actions performed to initialize prior to a replication.boolean
isStarted()
boolean
isStopped()
Once stopped, it cannot be restarted.boolean
isSuspended()
protected void
notifyFailureEventListenersFailureCompleted()
Used internally to notify failure event listeners that the failure completedprotected void
notifyFailureEventListenersFailureStarted()
Used internally to notify failure event listeners that the failure startedvoid
removeFailureEventListener(FailureEventListenerIfc listener)
Removes the listener from the eventvoid
resume()
If the failure process is suspended (and started and not stopped), then it is resumed.protected void
scheduleFailure(double time)
Schedules the failure event and the end of the failurevoid
setEventDurationInitialRandomSource(RandomIfc eventDuration)
void
setNoResourceUnitWarningOption(boolean option)
void
start()
Start the process at the current time.void
start(double time)
Starts the failure event process.void
start(GetValueIfc value)
Causes the failure process to start at getTime() + value.getValue().void
stop()
If the failure process is started, then it is stopped (i.e.void
suspend()
If the failure process has been started (but not suspended or stopped) then will be suspended.-
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_, 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
-
-
-
-
Constructor Detail
-
ResourceSingleFailureEvent
public ResourceSingleFailureEvent(ModelElement parent, RandomIfc eventDuration, RandomIfc initialStartTimeRV)
- Parameters:
parent
- a parent model elementeventDuration
- the duration of the eventinitialStartTimeRV
- the initial starting time for the event
-
ResourceSingleFailureEvent
public ResourceSingleFailureEvent(ModelElement parent, RandomIfc eventDuration, RandomIfc initialStartTimeRV, java.lang.String name)
- Parameters:
parent
- a parent model elementeventDuration
- the duration of the eventinitialStartTimeRV
- the initial starting time for the eventname
- the name of model element
-
-
Method Detail
-
setEventDurationInitialRandomSource
public void setEventDurationInitialRandomSource(RandomIfc eventDuration)
- Parameters:
eventDuration
- the source of randomness for the event duration
-
beforeReplication
protected void beforeReplication()
Allows each replication to start at a different time and to have a different failure duration.- Overrides:
beforeReplication
in classModelElement
-
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
-
getEventStartTime
public final double getEventStartTime()
- Returns:
- the time that the event will occur
-
getDuration
public final double getDuration()
- Returns:
- the duration of the event for this replication
-
getAutoStartProcessOption
public final boolean getAutoStartProcessOption()
The default is false- Returns:
- true if failure process will start automatically upon initialization
-
addFailureEventListener
public final void addFailureEventListener(FailureEventListenerIfc listener)
Adds a listener to react to failureStarted event- Parameters:
listener
- the listener to add
-
removeFailureEventListener
public final void removeFailureEventListener(FailureEventListenerIfc listener)
Removes the listener from the event- Parameters:
listener
- the listener to remove
-
getNoResourceUnitWarningOption
public final boolean getNoResourceUnitWarningOption()
- Returns:
- true means that a warning will occur if there are no resource units attached when running the simulation
-
setNoResourceUnitWarningOption
public final void setNoResourceUnitWarningOption(boolean option)
- Parameters:
option
- true means that a warning will occur if there are no resource units attached when running the simulation
-
beforeExperiment
protected void beforeExperiment()
Description copied from class:ModelElement
This method should be overridden by subclasses that need logic to be performed prior to an experiment. The beforeExperiment method allows model elements to be setup prior to the first replication within an experiment. It is called once before any replications occur.- Overrides:
beforeExperiment
in classModelElement
-
start
public final void start()
Start the process at the current time. In other words in getTime() + 0.0 into the future.
-
start
public final void start(GetValueIfc value)
Causes the failure process to start at getTime() + value.getValue().- Parameters:
value
- the GetValueIfc object that should be used get the value of the starting time
-
start
public final void start(double time)
Starts the failure event process. If the process is already started, nothing happens
-
scheduleFailure
protected final void scheduleFailure(double time)
Schedules the failure event and the end of the failure- Parameters:
time
- the time that the failure should occur
-
cancelFailure
protected final void cancelFailure()
Causes the single event to be canceled if it has not yet occurred.
-
stop
public final void stop()
If the failure process is started, then it is stopped (i.e. it will not occur). If it has not been started nothing happens. If it has already been stopped, nothing happens.
-
resume
public final void resume()
If the failure process is suspended (and started and not stopped), then it is resumed. This reschedules the failure event to the original failure event time for the replication.
-
suspend
public final void suspend()
If the failure process has been started (but not suspended or stopped) then will be suspended. Otherwise nothing happens
-
isStarted
public final boolean isStarted()
- Returns:
- true if the failure process is started (i.e. scheduled to occur)
-
isStopped
public final boolean isStopped()
Once stopped, it cannot be restarted.- Returns:
- true if the failure process is stopped.
-
isSuspended
public final boolean isSuspended()
- Returns:
- true if the failure process is suspended.
-
addResourceUnit
public final void addResourceUnit(ResourceUnit resourceUnit)
Adds a resource unit to the failure event- Parameters:
resourceUnit
- must not be null. Repeats are silently ignored.
-
hasResourceUnits
public final boolean hasResourceUnits()
- Returns:
- true if resource units have been added to the failure event
-
addResourceUnits
public final void addResourceUnits(java.util.Collection<ResourceUnit> units)
- Parameters:
units
- the resource units to add. Must not be null
-
addResourceUnits
public final void addResourceUnits(ResourcePool pool)
- Parameters:
pool
- the ResourcePool to add resource units from, must not be null
-
notifyFailureEventListenersFailureStarted
protected final void notifyFailureEventListenersFailureStarted()
Used internally to notify failure event listeners that the failure started
-
notifyFailureEventListenersFailureCompleted
protected final void notifyFailureEventListenersFailureCompleted()
Used internally to notify failure event listeners that the failure completed
-
failureStarted
protected void failureStarted(JSLEvent event)
Subclasses can override this method to provide behavior when the event starts This method occurs before any associated resources start the failure and before any failure event listeners are notified of the start of the event- Parameters:
event
- the event that started the failure
-
failureEnded
protected void failureEnded(JSLEvent event)
Subclasses can override this method to provide behavior after the failure ends This method occurs before any failure event listeners are notified of the end of the failure- Parameters:
event
- the event that ended the failure
-
-