Class EventGenerator
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.EventGenerator
-
- All Implemented Interfaces:
EventGeneratorIfc,ObservableIfc,GetNameIfc,IdentityIfc
- Direct Known Subclasses:
EntityGenerator,JobGenerator
public class EventGenerator extends SchedulingElement implements EventGeneratorIfc
This class allows for the periodic generation of events similar to that achieved by "Create" modules in simulation languages. This class works in conjunction with the EventGeneratorActionIfc which is used to listen and react to the events that are generated by this class.Classes can supply an instance of an EventGeneratorActionIfc to provide the actions that take place when the event occurs. Alternatively, if no EventGeneratorActionIfc is supplied, by default the generator(JSLEvent event) method of this class will be called when the event occurs. Thus, sub-classes can simply override this method to provide behavior for when the event occurs. If no EventGeneratorActionIfc is supplied and the generate() method is not overridden, then the events will still occur; however, no meaningful actions will take place.
Of particular note is the use of initial parameters:
initial time of first event (default = Constant.ZERO)
initial time between events (default = Constant.POSITIVE_INFINITY)
initial maximum number of events (default = Long.MAX_VALUE)
initial ending time (default = Double.POSITIVE_INFINITY)
These parameters control the initial state of the generator at the start of each replication. The generator is re-initialized to these values at the start of each replication. There are also parameters for each of these that can be changed during a replication. The effect of that change is only within the current replication.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceEventGenerator.ActionStepIfcstatic interfaceEventGenerator.BuildStepIfcprotected static classEventGenerator.EventGeneratorBuilderstatic interfaceEventGenerator.TimeBetweenEventsStepIfc-
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 intEVENT_PRIORITYDetermines the priority of the event generator's events The default is DEFAULT_PRIORITY - 1 A lower number implies higher priority.-
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 EventGenerator(ModelElement parent)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, EventGeneratorActionIfc listener)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, java.lang.String name)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst, RandomIfc timeUntilNext)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, long maxNum)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, long maxNum, double timeUntilLast)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, long maxNum, double timeUntilLast, java.lang.String name)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, java.lang.String name)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, RandomIfc timeUntilFirst)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.EventGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, java.lang.String name)Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EventGenerator.ActionStepIfcbuilder(ModelElement parent)protected voidgenerate(JSLEvent event)This method should be overridden by sub-classes that do not supply an EventGeneratorActionIfc to model the action that occur when the event happens.doublegetEndingTime()Gets the currently planned ending time of the generator.EventGeneratorActionIfcgetEventGeneratorListener()Gets the listener for the events to the supplied EventGeneratorActionIfc.intgetEventPriority()The priority of the events for the generatordoublegetInitialEndingTime()Returns the ending time that is to be used when the generator is initialized for each replication.longgetInitialMaximumNumberOfEvents()Returns the maximum number of events that is used for initializing each replicationRandomIfcgetInitialTimeBetweenEvents()Returns the time between events used to initialize each replicationRandomIfcgetInitialTimeUntilFirstEvent()Gets the RandomIfc that will be used at the beginning of each replication to generate the time until the first eventlonggetMaximumNumberOfEvents()Gets the maximum number of actions for the generator.longgetNumberOfEventsGenerated()Gets the number of events that have been generated by the generatorbooleangetStartOnInitializeFlag()This flag indicates whether or not the generator will automatically start at the beginning of a replication when initialized.RandomIfcgetTimeBetweenEvents()Gets the random source controlling the time between eventsprotected voidincrementNumberOfEvents()Increments the number of actions and checks if the number of actions is greater than the maximum number of actions.protected voidinitialize()This method should be overridden by subclasses that need actions performed to initialize prior to a replication.booleanisEventPending()booleanisGeneratorDone()This method checks to see if the generator is done.booleanisGeneratorStarted()booleanisSuspended()Indicates whether or not the generator has been suspendedprotected voidremovedFromModel()This method should be overridden by subclasses that need actions performed when a model element is removed from a modelvoidresume()Resume the generation of events according to the time between event distribution.protected voidscheduleFirstEvent(double t)Schedules the first event at current time + tprotected voidscheduleFirstEvent(GetValueIfc r)Schedules the first event at current time + r.getValue()voidsetEndingTime(double endingTime)Sets the ending time for generating events for the current replication.voidsetEventGeneratorListener(EventGeneratorActionIfc listener)Sets the listener for the events to the supplied EventGeneratorActionIfcvoidsetEventPriority(int priority)Lower means earlier (higher priority).voidsetInitialEndingTime(double endingTime)This value is used to set the ending time for generating actions for each replication.voidsetInitialMaximumNumberOfEvents(long maxNumEvents)Sets the the maximum number of events to be used to initialize each replication.voidsetInitialTimeBetweenEvents(RandomIfc timeBtwEvents)Sets the time between events and the maximum number of events to be used to initialize each replication.voidsetInitialTimeBetweenEventsAndMaxNumEvents(RandomIfc timeBtwEvents, long maxNumEvents)Sets the time between events and the maximum number of events to be used to initialize each replication.voidsetInitialTimeUntilFirstEvent(RandomIfc timeUntilFirst)Sets the RandomIfc representing the time until the first event that is used at the beginning of each replication to generate the time until the first event.voidsetMaximumNumberOfEvents(long maxNum)Sets the maximum number of events for the generator.voidsetStartOnInitializeFlag(boolean flag)Sets the flag that indicates whether or not the generator will automatically start at the beginning of a replication when initializedvoidsetTimeBetweenEvents(RandomIfc timeUntilNext)Sets the time between event random source.voidsetTimeBetweenEvents(RandomIfc timeBtwEvents, long maxNumEvents)Sets the time between events and the maximum number of events for the generator.voidsuspend()Suspends the generation of events and cancels the next scheduled event from the generatorvoidturnOffGenerator()This method turns the generator off, the next scheduled generation event will NOT occur, i.e.voidturnOnGenerator()If the generator was not started upon initialization at the beginning of a replication, then this method can be used to start the generator The generator will be started 0.0 time units after the call If this method is used when the generator is already started it does nothing.voidturnOnGenerator(double t)If the generator was not started upon initialization at the beginning of a replication, then this method can be used to start the generator The generator will be started t time units after the call If this method is used when the generator is already started it does nothing.voidturnOnGenerator(RandomIfc r)If the generator was not started upon initialization at the beginning of a replication, then this method can be used to start the generator The generator will be started r.getValue() time units after the call If this method is used when the generator is already started it does nothing.-
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_, 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
-
EVENT_PRIORITY
public static final int EVENT_PRIORITY
Determines the priority of the event generator's events The default is DEFAULT_PRIORITY - 1 A lower number implies higher priority.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EventGenerator
public EventGenerator(ModelElement parent)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events. The default maximum number of events to generate is infinite (Long.MAX_VALUE) Default time between next is infinity. The default time of the first event is 0.0- Parameters:
parent- the parent model element
-
EventGenerator
public EventGenerator(ModelElement parent, EventGeneratorActionIfc listener)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events. The default maximum number of events to generate is infinite (Long.MAX_VALUE) Default time between next is infinity. The default time of the first event is 0.0- Parameters:
parent- the parent model elementlistener- This listener supplies the "event" logic for reacting to the generated event.
-
EventGenerator
public EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, java.lang.String name)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events. The default maximum number of events to generate is infinite (Long.MAX_VALUE) Default time between next is infinity. The default time of the first event is 0.0- Parameters:
parent- the parent model elementlistener- This listener supplies the "event" logic for reacting to the generated event.name- The name of the generator.
-
EventGenerator
public EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events. The default maximum number of events to generate is infinite (Long.MAX_VALUE) Default time between next is infinity.- Parameters:
parent- the parent model elementlistener- This listener supplies the "event" logic for reacting to the generated event.timeUntilFirst- A DistributionIfc object that supplies the time until the first event
-
EventGenerator
public EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst, RandomIfc timeUntilNext)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events. The default maximum number of events to generate is infinite (Long.MAX_VALUE)- Parameters:
parent- the parent model elementlistener- This listener supplies the "event" logic for reacting to the generated event.timeUntilFirst- A RandomIfc object that supplies the time until the first event.timeUntilNext- A RandomIfc object that supplies the time between events. Must not be a RandomIfc that always returns 0.0, if the maximum number of generations is infinite (Long.MAX_VALUE)
-
EventGenerator
public EventGenerator(ModelElement parent, RandomIfc timeUntilFirst)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events. The default maximum number of events to generate is infinite (Long.MAX_VALUE) Default time between next is infinity.- Parameters:
parent- the parent model elementtimeUntilFirst- A RandomIfc object that supplies the time until the first event.
-
EventGenerator
public EventGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events. The default maximum number of events to generate is infinite (Long.MAX_VALUE)- Parameters:
parent- the parent model elementtimeUntilFirst- A RandomIfc object that supplies the time until the first event.timeUntilNext- A RandomIfc object that supplies the time between events. Must not be a RandomIfc that always returns 0.0, if the maximum number of generations is infinite (Long.MAX_VALUE)
-
EventGenerator
public EventGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, java.lang.String name)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events. The default maximum number of events to generate is infinite (Long.MAX_VALUE)- Parameters:
parent- the parent model elementtimeUntilFirst- A RandomIfc object that supplies the time until the first event.timeUntilNext- A RandomIfc object that supplies the time between events. Must not be a RandomIfc that always returns 0.0, if the maximum number of generations is infinite (Long.MAX_VALUE)name- the name of the generator
-
EventGenerator
public EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, java.lang.String name)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events. The default maximum number of events to generate is infinite (Long.MAX_VALUE)- Parameters:
parent- the parent model elementlistener- This listener supplies the "event" logic for reacting to the generated event.timeUntilFirst- A RandomIfc object that supplies the time until the first event.timeUntilNext- A RandomIfc object that supplies the time between events. Must not be a RandomIfc that always returns 0.0, if the maximum number of generations is infinite (Long.MAX_VALUE)name- the name of the generator
-
EventGenerator
public EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, long maxNum)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.- Parameters:
parent- the parent model elementlistener- This listener supplies the "event" logic for reacting to the generated event.timeUntilFirst- A RandomIfc object that supplies the time until the first event.timeUntilNext- A RandomIfc object that supplies the time between events. Must not be a RandomIfc that always returns 0.0, if the maximum number of generations is infinite (Long.MAX_VALUE)maxNum- A long that supplies the maximum number of events to generate. Each time an event is to be scheduled the maximum number of events is checked. If the maximum has been reached, then the generator is turned off. The default is Long.MAX_VALUE. This parameter cannot be Long.MAX_VALUE when the time until next always returns a value of 0.0
-
EventGenerator
public EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, long maxNum, double timeUntilLast)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.- Parameters:
parent- the parent model elementlistener- This listener supplies the "event" logic for reacting to the generated event.timeUntilFirst- A RandomIfc object that supplies the time until the first event.timeUntilNext- A RandomIfc object that supplies the time between events. Must not be a RandomIfc that always returns 0.0, if the maximum number of generations is infinite (Long.MAX_VALUE)maxNum- A long that supplies the maximum number of events to generate. Each time an event is to be scheduled the maximum number of events is checked. If the maximum has been reached, then the generator is turned off. The default is Long.MAX_VALUE. This parameter cannot be Long.MAX_VALUE when the time until next always returns a value of 0.0timeUntilLast- A double that supplies a time to stop generating events. When the generator is created, this variable is used to set the ending time of the generator. Each time an event is to be scheduled the ending time is checked. If the time of the next event is past this time, then the generator is turned off and the event won't be scheduled. The default is Double.POSITIVE_INFINITY.
-
EventGenerator
public EventGenerator(ModelElement parent, EventGeneratorActionIfc listener, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, long maxNum, double timeUntilLast, java.lang.String name)
Creates an EventGenerator that uses the supplied EventGeneratorActionIfc to react to the events.- Parameters:
parent- the parent model elementlistener- This listener supplies the "event" logic for reacting to the generated event.timeUntilFirst- A RandomIfc object that supplies the time until the first event.timeUntilNext- A RandomIfc object that supplies the time between events. Must not be a RandomIfc that always returns 0.0, if the maximum number of generations is infinite (Long.MAX_VALUE)maxNum- A long that supplies the maximum number of events to generate. Each time an event is to be scheduled the maximum number of events is checked. If the maximum has been reached, then the generator is turned off. The default is Long.MAX_VALUE. This parameter cannot be Long.MAX_VALUE when the time until next always returns a value of 0.0timeUntilLast- A double that supplies a time to stop generating events. When the generator is created, this variable is used to set the ending time of the generator. Each time an event is to be scheduled the ending time is checked. If the time of the next event is past this time, then the generator is turned off and the event won't be scheduled. The default is Double.POSITIVE_INFINITY.name- The name of the generator.
-
-
Method Detail
-
builder
public static EventGenerator.ActionStepIfc builder(ModelElement parent)
-
getEventPriority
public final int getEventPriority()
The priority of the events for the generator- Returns:
- the event priority
-
setEventPriority
public final void setEventPriority(int priority)
Lower means earlier (higher priority). Changing the priority effects only future scheduled events The changed priority is retained for all future replications- Parameters:
priority- the priority to set
-
setEventGeneratorListener
public final void setEventGeneratorListener(EventGeneratorActionIfc listener)
Sets the listener for the events to the supplied EventGeneratorActionIfc- Parameters:
listener- This listener supplies the "event" logic for reacting to the generated event.
-
getEventGeneratorListener
public final EventGeneratorActionIfc getEventGeneratorListener()
Gets the listener for the events to the supplied EventGeneratorActionIfc. This can be null. If null, the generate(JSLEvent event) method is called.- Returns:
- the event generator's action
-
getStartOnInitializeFlag
public final boolean getStartOnInitializeFlag()
Description copied from interface:EventGeneratorIfcThis flag indicates whether or not the generator will automatically start at the beginning of a replication when initialized. By default this option is true.- Specified by:
getStartOnInitializeFlagin interfaceEventGeneratorIfc- Returns:
- true if on
-
setStartOnInitializeFlag
public final void setStartOnInitializeFlag(boolean flag)
Description copied from interface:EventGeneratorIfcSets the flag that indicates whether or not the generator will automatically start at the beginning of a replication when initialized- Specified by:
setStartOnInitializeFlagin interfaceEventGeneratorIfc- Parameters:
flag- true indicates automatic start
-
turnOnGenerator
public final void turnOnGenerator(double t)
Description copied from interface:EventGeneratorIfcIf the generator was not started upon initialization at the beginning of a replication, then this method can be used to start the generator The generator will be started t time units after the call If this method is used when the generator is already started it does nothing. If this method is used after the generator is done it does nothing. If this method is used after the generator has been suspended it does nothing. Use suspend() and resume() to suspend and resume a generator that has already been started.- Specified by:
turnOnGeneratorin interfaceEventGeneratorIfc- Parameters:
t- The time until the generator should be turned on
-
turnOnGenerator
public void turnOnGenerator(RandomIfc r)
Description copied from interface:EventGeneratorIfcIf the generator was not started upon initialization at the beginning of a replication, then this method can be used to start the generator The generator will be started r.getValue() time units after the call If this method is used when the generator is already started it does nothing. If this method is used after the generator is done it does nothing. If this method is used after the generator has been suspended it does nothing. Use suspend() and resume() to suspend and resume a generator that has already been started.- Specified by:
turnOnGeneratorin interfaceEventGeneratorIfc- Parameters:
r- The time until the generator should be turned on
-
turnOnGenerator
public final void turnOnGenerator()
Description copied from interface:EventGeneratorIfcIf the generator was not started upon initialization at the beginning of a replication, then this method can be used to start the generator The generator will be started 0.0 time units after the call If this method is used when the generator is already started it does nothing. If this method is used after the generator is done it does nothing. If this method is used after the generator has been suspended it does nothing. Use suspend() and resume() to suspend and resume a generator that has already been started.- Specified by:
turnOnGeneratorin interfaceEventGeneratorIfc
-
turnOffGenerator
public final void turnOffGenerator()
Description copied from interface:EventGeneratorIfcThis method turns the generator off, the next scheduled generation event will NOT occur, i.e. this method will also cancel a previously scheduled generation event if one exists. No future events will be scheduled after turning off the generator- Specified by:
turnOffGeneratorin interfaceEventGeneratorIfc
-
isEventPending
public final boolean isEventPending()
- Specified by:
isEventPendingin interfaceEventGeneratorIfc- Returns:
- true if an event is scheduled to occur for the generator
-
suspend
public final void suspend()
Description copied from interface:EventGeneratorIfcSuspends the generation of events and cancels the next scheduled event from the generator- Specified by:
suspendin interfaceEventGeneratorIfc
-
isSuspended
public final boolean isSuspended()
Description copied from interface:EventGeneratorIfcIndicates whether or not the generator has been suspended- Specified by:
isSuspendedin interfaceEventGeneratorIfc- Returns:
- true if generator is suspended
-
resume
public final void resume()
Description copied from interface:EventGeneratorIfcResume the generation of events according to the time between event distribution.- Specified by:
resumein interfaceEventGeneratorIfc
-
isGeneratorDone
public final boolean isGeneratorDone()
Description copied from interface:EventGeneratorIfcThis method checks to see if the generator is done. In other words, if it has been turned off.- Specified by:
isGeneratorDonein interfaceEventGeneratorIfc- Returns:
- True means that it is done.
-
getMaximumNumberOfEvents
public final long getMaximumNumberOfEvents()
Description copied from interface:EventGeneratorIfcGets the maximum number of actions for the generator. This is set by the supplied maxNum upon creation of the generator. This implies that it will be the same for every simulation replication.- Specified by:
getMaximumNumberOfEventsin interfaceEventGeneratorIfc- Returns:
- A long representing the maximum number of actions for the generator.
-
getTimeBetweenEvents
public final RandomIfc getTimeBetweenEvents()
Description copied from interface:EventGeneratorIfcGets the random source controlling the time between events- Specified by:
getTimeBetweenEventsin interfaceEventGeneratorIfc- Returns:
- the random source controlling the time between events
-
setTimeBetweenEvents
public final void setTimeBetweenEvents(RandomIfc timeUntilNext)
Description copied from interface:EventGeneratorIfcSets the time between event random source. Must not always evaluate to 0.0, if the current setting of the maximum number of events is infinite (Long.MAX_VALUE)- Specified by:
setTimeBetweenEventsin interfaceEventGeneratorIfc- Parameters:
timeUntilNext- time until the next event
-
setMaximumNumberOfEvents
public final void setMaximumNumberOfEvents(long maxNum)
Description copied from interface:EventGeneratorIfcSets the maximum number of events for the generator. Must not be infinite (Long.MAX_VALUE) if the current time between events is 0.0- Specified by:
setMaximumNumberOfEventsin interfaceEventGeneratorIfc- Parameters:
maxNum- maximum number of events
-
setTimeBetweenEvents
public final void setTimeBetweenEvents(RandomIfc timeBtwEvents, long maxNumEvents)
Description copied from interface:EventGeneratorIfcSets the time between events and the maximum number of events for the generator. These two parameters are dependent. The time between events cannot always evaluate to 0.0 if the maximum number of events is infinite (Long.MAX_VALUE). This method only changes these parameters for the current replication. The changes take effect when the next event is generated. If current number of events that have been generated is greater than or equal to the supplied maximum number of events, the generator will be turned off.- Specified by:
setTimeBetweenEventsin interfaceEventGeneratorIfc- Parameters:
timeBtwEvents- the time between eventsmaxNumEvents- the maximum number of events
-
setInitialTimeBetweenEvents
public final void setInitialTimeBetweenEvents(RandomIfc timeBtwEvents)
Description copied from interface:EventGeneratorIfcSets the time between events and the maximum number of events to be used to initialize each replication. The time between events cannot evaluate to a constant value of 0.0. The maximum number of events is kept at its current value, which by default is Long.Max_Value- Specified by:
setInitialTimeBetweenEventsin interfaceEventGeneratorIfc- Parameters:
timeBtwEvents- the time between events
-
setInitialMaximumNumberOfEvents
public final void setInitialMaximumNumberOfEvents(long maxNumEvents)
Description copied from interface:EventGeneratorIfcSets the the maximum number of events to be used to initialize each replication. The time between events cannot evaluate to a constant value of 0.0 if the maximum number of events is infinite (Long.MAX_VALUE). Uses the current value for initial time between events- Specified by:
setInitialMaximumNumberOfEventsin interfaceEventGeneratorIfc- Parameters:
maxNumEvents- the the maximum number of events
-
setInitialTimeBetweenEventsAndMaxNumEvents
public final void setInitialTimeBetweenEventsAndMaxNumEvents(RandomIfc timeBtwEvents, long maxNumEvents)
Description copied from interface:EventGeneratorIfcSets the time between events and the maximum number of events to be used to initialize each replication. These parameters are dependent. The time between events cannot evaluate to a constant value of 0.0 if the maximum number of events is infinite (Long.MAX_VALUE)- Specified by:
setInitialTimeBetweenEventsAndMaxNumEventsin interfaceEventGeneratorIfc- Parameters:
timeBtwEvents- the initial time between eventsmaxNumEvents- the initial maximum number of events
-
getInitialTimeBetweenEvents
public final RandomIfc getInitialTimeBetweenEvents()
Description copied from interface:EventGeneratorIfcReturns the time between events used to initialize each replication- Specified by:
getInitialTimeBetweenEventsin interfaceEventGeneratorIfc- Returns:
- the initial time between events
-
getInitialMaximumNumberOfEvents
public final long getInitialMaximumNumberOfEvents()
Description copied from interface:EventGeneratorIfcReturns the maximum number of events that is used for initializing each replication- Specified by:
getInitialMaximumNumberOfEventsin interfaceEventGeneratorIfc- Returns:
- the initial maximum number of events
-
setInitialTimeUntilFirstEvent
public final void setInitialTimeUntilFirstEvent(RandomIfc timeUntilFirst)
Description copied from interface:EventGeneratorIfcSets the RandomIfc representing the time until the first event that is used at the beginning of each replication to generate the time until the first event. This change becomes effective at the beginning of the next replication to execute- Specified by:
setInitialTimeUntilFirstEventin interfaceEventGeneratorIfc- Parameters:
timeUntilFirst- , The supplied RandomIfc, cannot be null
-
getInitialTimeUntilFirstEvent
public final RandomIfc getInitialTimeUntilFirstEvent()
Description copied from interface:EventGeneratorIfcGets the RandomIfc that will be used at the beginning of each replication to generate the time until the first event- Specified by:
getInitialTimeUntilFirstEventin interfaceEventGeneratorIfc- Returns:
- RandomIfc that will be used at the beginning of each replication to generate the time until the first event
-
setEndingTime
public final void setEndingTime(double endingTime)
Description copied from interface:EventGeneratorIfcSets the ending time for generating events for the current replication. A new ending time will be applied to the generator. If this change results in an ending time that is less than the current time, the generator will be turned off- Specified by:
setEndingTimein interfaceEventGeneratorIfc- Parameters:
endingTime- the ending time for generating events
-
getEndingTime
public final double getEndingTime()
Description copied from interface:EventGeneratorIfcGets the currently planned ending time of the generator.- Specified by:
getEndingTimein interfaceEventGeneratorIfc- Returns:
- A double representing the ending time.
-
setInitialEndingTime
public final void setInitialEndingTime(double endingTime)
Description copied from interface:EventGeneratorIfcThis value is used to set the ending time for generating actions for each replication. Changing this variable during a replication cause the next replication to use this value for its ending time.- Specified by:
setInitialEndingTimein interfaceEventGeneratorIfc- Parameters:
endingTime- value is used to set the initial ending time for generating actions
-
getInitialEndingTime
public final double getInitialEndingTime()
Description copied from interface:EventGeneratorIfcReturns the ending time that is to be used when the generator is initialized for each replication.- Specified by:
getInitialEndingTimein interfaceEventGeneratorIfc- Returns:
- Returns the initial ending time that is to be used when the generator
-
getNumberOfEventsGenerated
public final long getNumberOfEventsGenerated()
Description copied from interface:EventGeneratorIfcGets the number of events that have been generated by the generator- Specified by:
getNumberOfEventsGeneratedin interfaceEventGeneratorIfc- Returns:
- the number of events that have been generated
-
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
-
isGeneratorStarted
public final boolean isGeneratorStarted()
- Specified by:
isGeneratorStartedin interfaceEventGeneratorIfc- Returns:
- true if the generator has been started (turned on) either automatically or manually
-
generate
protected void generate(JSLEvent event)
This method should be overridden by sub-classes that do not supply an EventGeneratorActionIfc to model the action that occur when the event happens.- Parameters:
event- the event associated with the generations
-
scheduleFirstEvent
protected final void scheduleFirstEvent(GetValueIfc r)
Schedules the first event at current time + r.getValue()- Parameters:
r- the time to the first event
-
scheduleFirstEvent
protected final void scheduleFirstEvent(double t)
Schedules the first event at current time + t- Parameters:
t- the time to the first event
-
incrementNumberOfEvents
protected final void incrementNumberOfEvents()
Increments the number of actions and checks if the number of actions is greater than the maximum number of actions. If so, the generator is told to shut down.
-
removedFromModel
protected void removedFromModel()
Description copied from class:ModelElementThis method should be overridden by subclasses that need actions performed when a model element is removed from a model- Overrides:
removedFromModelin classModelElement
-
-