Package jsl.simulation
Class Executive
- java.lang.Object
-
- jsl.simulation.Executive
-
- All Implemented Interfaces:
ObservableIfc
,IterativeProcessIfc
,GetNameIfc
,IdentityIfc
public class Executive extends java.lang.Object implements IdentityIfc, ObservableIfc, IterativeProcessIfc
The Executive controls the execution of events, permits the scheduling of events, updates the current time, and manages conditional actions. The Executive uses an instance of a class that extends IterativeProcess to control its execution. The Executive uses an instance of a class that implements the CalendarIfc interface to manage the time ordered execution of events. The Executive uses an instance of a ConditionalActionProcessor to manage the execution of ConditionalActions. The event calendar and attached conditional actions are cleared after the initialize() method is called The Executive can be pre-loaded with events and conditional actions prior to invoking the run() method if and only if the initialize() method had already been called. If the run() method is called without calling initialize() the calendar and conditional actions are cleared. If an ending event is not scheduled using the scheduleEndEvent() method and no real clock time execution limit has been set, then a default message will be sent to JSL.LOGGER.warning(). This message can be turned off by calling setTerminationWarningMessageOption(false)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Executive.EventExecutionProcess
-
Field Summary
Fields Modifier and Type Field Description static int
AFTER_EVENT
Used to indicate to observers that an event will be executedstatic int
AFTER_EXECUTION
Used when observers are notified after all events are executedstatic int
BEFORE_EVENT
Used to indicate to observers that an event will be executedstatic int
INITIALIZED
Used when observers are notified of initializationprotected Executive.EventExecutionProcess
myEventExecutionProcess
Controls the execution of events over timeprotected ObservableComponent
myObservableComponent
Allows the object to be observed
-
Constructor Summary
Constructors Constructor Description Executive()
Executive(java.lang.String name, CalendarIfc c)
Executive(CalendarIfc c)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObserver(ObserverIfc observer)
Allows the adding (attaching) of an observer to the observableprotected void
afterExecution()
This method is called after executing all events when ending the iterative process.boolean
allStepsCompleted()
The iterative process may end by a variety of means, this method checks if the iterative process ended because it ran all of its stepsprotected void
beforeExecutingAnyEvents()
This method is called before any events are executed and after initializing the iterative process.void
cancel(JSLEvent e)
Tells the event calendar to cancel the provided event.void
changePriority(ConditionalAction action, int priority)
boolean
contains(ObserverIfc observer)
Returns true if the observer is already attachedint
countObservers()
Returns how many observers are currently observing the observablevoid
deleteObserver(ObserverIfc observer)
Allows the deletion (removing) of an observer from the observablevoid
deleteObservers()
Deletes all the observers from the observablevoid
end()
The iterative process will continue until there are no more steps or its maximum execution time has been reached, whichever comes first.void
end(java.lang.String msg)
The iterative process will continue until there are no more steps or its maximum execution time has been reached, whichever comes first.protected void
execute(JSLEvent event)
Executes the provided eventvoid
executeAllEvents()
void
executeNextEvent()
Causes the next event to be executed if it existsboolean
executionTimeExceeded()
The iterative process may end by a variety of means, this method checks if the iterative process ended because it timed outdouble
getActualEndingTime()
The simulated time that the Executive actually endedlong
getBeginExecutionTime()
Returns system time in milliseconds that the iterative process startedjava.util.Optional<ExecutiveTraceReport>
getDefaultExecutiveTraceReport()
Returns the default event trace report or null if it has not yet been turned on.long
getElapsedExecutionTime()
Gets the clock time in milliseconds since the iterative process was initializedJSLEvent
getEndEvent()
Returns the Executive's end event if scheduledlong
getEndExecutionTime()
Returns system time in milliseconds that the iterative process endedint
getId()
Returns the id for this objectJSLEvent
getLastExecutedEvent()
Returns a reference to the last executed event or null if no events have been executed or no more eventsIPLogReport
getLogReport()
Returns a reference to the current log report.long
getMaximumAllowedExecutionTime()
Returns maximum (real) clock time allocated for the iterative processboolean
getMaxScanFlag()
int
getMaxScans()
java.lang.String
getName()
Gets the name.double
getNumberEventsScheduled()
Gets the number of events currently scheduleddouble
getNumberEventsScheduledDuringExecution()
Gets the number of events that were scheduled during the executionlong
getNumberStepsCompleted()
Returns the number of steps completed since the iterative process was last initializedint
getObserverState()
Can be used by observers to check what occurreddouble
getScheduledEndTime()
Returns the time the execution was scheduled to endboolean
getStoppingFlag()
Returns the stopping flagjava.lang.String
getStoppingMessage()
A string message for why stop() was called.boolean
getTerminationWarningMessageOption()
double
getTime()
Returns the current simulated time as a doubledouble
getTotalNumberEventsExecuted()
Gets the total number of events executedboolean
hasNextEvent()
Checks to see if the event calendar has another eventvoid
initialize()
Initialize the executive, making it ready to run events This clears any events in the calendar and prepares for executionprotected void
initializeCalendar()
Tells the event calendar to clear all the events.boolean
isCompleted()
boolean
isCreated()
Checks if the iterative process is in the created state.boolean
isDone()
A flag to indicate whether the iterative process is done A iterative process can be done if: 1) it ran all of its steps 2) it was ended by a client prior to completing all of its steps 3) it ended because it exceeded its maximum allowable execution time before completing all of its steps.boolean
isEmpty()
Allows a check of the event calendar to see if it is empty, i.e.boolean
isEndConditionMet()
boolean
isEnded()
Checks if the iterative process is in the ended state After the iterative process has been ended this method will return trueboolean
isEndEventScheduled()
Returns true if an event has been scheduled to stop execution at getTimeHorizon()boolean
isExecutionTimeExceeded()
Returns if the elapsed execution time exceeds the maximum time allowed.boolean
isInitialized()
Checks if the iterative process is in the initialized state After the iterative process has been initialized this method will return trueboolean
isRunning()
An iterative process is running if it is been told to run (i.e.boolean
isRunningStep()
Indicates that the iterative process is currently running an individual stepboolean
isStepCompleted()
Checks if the iterative process is in the completed step state After the iterative process has successfully completed a step this method will return trueboolean
isTimedOut()
boolean
isUnfinished()
The iterative process may end by a variety of means, this method checks if the iterative process ended but was unfinished, not all steps completedboolean
noStepsExecuted()
Indicates that the iterative process ended because of no stepsprotected void
notifyObservers(JSLEvent e)
JSLEvent
peekNextEvent()
Returns a reference to the next event or null if no event exists.protected void
performCPhase()
void
register(ConditionalAction action)
void
register(ConditionalAction action, int priority)
<T> void
reschedule(JSLEvent<T> event, double time)
This method allows a previously *executed* event to be reused The event must have already been removed from the calendar through the natural execute event mechanism and have been executed.void
run()
Runs all of the steps of the iterative process.void
runNext()
Runs the next step in the iterative processprotected void
schedule(JSLEvent e)
JSLEvent
scheduleEndEvent(double time, ModelElement theElement)
Schedules the ending of the executive at the provided time<T> JSLEvent<T>
scheduleEvent(EventActionIfc<T> listener, double time, int priority, T message, java.lang.String name, ModelElement theElementScheduling)
Creates an event and schedules it onto the event calendarprotected void
setConditionalActionProcessor(ConditionalActionProcessor p)
void
setMaximumExecutionTime(long milliseconds)
Set the maximum allotted (suggested) execution (real) clock for the entire iterative process.void
setMaxScanFlag(boolean flag)
void
setMaxScans(int max)
void
setName(java.lang.String str)
Sets the nameprotected void
setSimulation(Simulation simulation)
Used internally by Simulation to assign itself to the Executivevoid
setTerminationWarningMessageOption(boolean flag)
False turns off the messagevoid
stop()
This sets a flag to indicate to the process that is should stop after the next step is completed.void
stop(java.lang.String msg)
This sets a flag to indicate to the process that is should stop after the next step is completed.boolean
stoppedByCondition()
The iterative process may end by a variety of means, this method checks if the iterative process ended because it was stoppedjava.lang.String
toString()
void
turnOffDefaultEventTraceReport()
Removes the default ExecutiveTraceReport as an observer of the Executive and sets it to null.void
turnOffLogReport()
Turns off log reporting.void
turnOnDefaultEventTraceReport()
This method creates an instance of the default ExecutiveTraceReport and tells it to observe the scheduler.void
turnOnDefaultEventTraceReport(java.lang.String name)
This method creates an instance of the default ExecutiveTraceReport and tells it to observe the scheduler.void
turnOnLogReport(java.nio.file.Path pathToFile)
Turns on the log report.void
turnOnTimer(long milliseconds)
This method will cause the a timer to start allowing a TimerTask to be scheduled.void
unregister(ConditionalAction action)
void
unregisterAllActions()
boolean
willTerminate()
If the Executive has an end event or maximum allowed execution time, then return true
-
-
-
Field Detail
-
AFTER_EXECUTION
public static final int AFTER_EXECUTION
Used when observers are notified after all events are executed
-
INITIALIZED
public static final int INITIALIZED
Used when observers are notified of initialization
-
BEFORE_EVENT
public static final int BEFORE_EVENT
Used to indicate to observers that an event will be executed
-
AFTER_EVENT
public static final int AFTER_EVENT
Used to indicate to observers that an event will be executed
-
myObservableComponent
protected ObservableComponent myObservableComponent
Allows the object to be observed
-
myEventExecutionProcess
protected Executive.EventExecutionProcess myEventExecutionProcess
Controls the execution of events over time
-
-
Constructor Detail
-
Executive
public Executive()
-
Executive
public Executive(CalendarIfc c)
-
Executive
public Executive(java.lang.String name, CalendarIfc c)
-
-
Method Detail
-
setSimulation
protected final void setSimulation(Simulation simulation)
Used internally by Simulation to assign itself to the Executive- Parameters:
simulation
- the simulation to set
-
getName
public final java.lang.String getName()
Gets the name.- Specified by:
getName
in interfaceGetNameIfc
- Returns:
- The name of object.
-
getId
public final int getId()
Returns the id for this object- Specified by:
getId
in interfaceIdentityIfc
- Returns:
- the id
-
setName
public final void setName(java.lang.String str)
Sets the name- Parameters:
str
- The name as a string.
-
getTerminationWarningMessageOption
public final boolean getTerminationWarningMessageOption()
- Returns:
- true if the flag permits the message to be printed
-
setTerminationWarningMessageOption
public final void setTerminationWarningMessageOption(boolean flag)
False turns off the message- Parameters:
flag
- true means off
-
getObserverState
public final int getObserverState()
Can be used by observers to check what occurred- Returns:
- an integer representation of the observer state
-
deleteObservers
public final void deleteObservers()
Description copied from interface:ObservableIfc
Deletes all the observers from the observable- Specified by:
deleteObservers
in interfaceObservableIfc
-
deleteObserver
public final void deleteObserver(ObserverIfc observer)
Description copied from interface:ObservableIfc
Allows the deletion (removing) of an observer from the observable- Specified by:
deleteObserver
in interfaceObservableIfc
- Parameters:
observer
- the observer to delete
-
countObservers
public final int countObservers()
Description copied from interface:ObservableIfc
Returns how many observers are currently observing the observable- Specified by:
countObservers
in interfaceObservableIfc
- Returns:
- number of observers
-
addObserver
public final void addObserver(ObserverIfc observer)
Description copied from interface:ObservableIfc
Allows the adding (attaching) of an observer to the observable- Specified by:
addObserver
in interfaceObservableIfc
- Parameters:
observer
- the observer to attach
-
contains
public boolean contains(ObserverIfc observer)
Description copied from interface:ObservableIfc
Returns true if the observer is already attached- Specified by:
contains
in interfaceObservableIfc
- Parameters:
observer
- the observer to check- Returns:
- true if attached
-
turnOnLogReport
public void turnOnLogReport(java.nio.file.Path pathToFile)
Description copied from interface:IterativeProcessIfc
Turns on the log report. This report yields a text file of the state changes for the iterative process- Specified by:
turnOnLogReport
in interfaceIterativeProcessIfc
- Parameters:
pathToFile
- specifies a prefix name for the report
-
turnOffLogReport
public void turnOffLogReport()
Description copied from interface:IterativeProcessIfc
Turns off log reporting.- Specified by:
turnOffLogReport
in interfaceIterativeProcessIfc
-
notifyObservers
protected final void notifyObservers(JSLEvent e)
-
getScheduledEndTime
public final double getScheduledEndTime()
Returns the time the execution was scheduled to end- Returns:
- the scheduled end time or Double.POSITIVE_INFINITY
-
reschedule
public final <T> void reschedule(JSLEvent<T> event, double time)
This method allows a previously *executed* event to be reused The event must have already been removed from the calendar through the natural execute event mechanism and have been executed. NOTE: If an event is canceled it remains in the scheduler until its originally scheduled event time. Then and only then does it become unscheduled at which time the event can be rescheduled. If a client needs to reschedule a canceled event prior to the originally scheduled event time, then just use scheduleEvent() to make a new event.- Type Parameters:
T
- the type of the event message- Parameters:
event
- The event that needs rescheduling, cannot be null and cannot already be scheduledtime
- represents the inter-event time, i.e. the interval from the current time to when the event will need to occur. Cannot be negative
-
scheduleEvent
public final <T> JSLEvent<T> scheduleEvent(EventActionIfc<T> listener, double time, int priority, T message, java.lang.String name, ModelElement theElementScheduling)
Creates an event and schedules it onto the event calendar- Type Parameters:
T
- the type of the event message- Parameters:
listener
- represents an ActionListener that will handle the change of state logic, cannot be nulltime
- represents the inter-event time, i.e. the interval from the current time to when the event will need to occur, Cannot be negativepriority
- is used to influence the ordering of eventsmessage
- is a generic Object that may represent data to be transmitted with the event, may be nullname
- the name of the event, can be nulltheElementScheduling
- the element doing the scheduling, cannot be null- Returns:
- a valid JSLEvent
-
cancel
public final void cancel(JSLEvent e)
Tells the event calendar to cancel the provided event. The event must have been scheduled otherwise an IllegalArgumentException is thrown.- Parameters:
e
- A reference to the event to be canceled.
-
isEmpty
public final boolean isEmpty()
Allows a check of the event calendar to see if it is empty, i.e. it does not have any more events. Note: Depending on how the event calendar handles canceled events, canceled events may or may not be removed. In the default, canceled events are not removed from the calendar, until after their event time has occurred.- Returns:
- True is empty, False is not empty
-
getTime
public final double getTime()
Returns the current simulated time as a double- Returns:
- Simulated time as a double
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representing the Executive.
-
getNumberEventsScheduled
public final double getNumberEventsScheduled()
Gets the number of events currently scheduled- Returns:
- number currently scheduled
-
getNumberEventsScheduledDuringExecution
public final double getNumberEventsScheduledDuringExecution()
Gets the number of events that were scheduled during the execution- Returns:
- number during the execution
-
getTotalNumberEventsExecuted
public final double getTotalNumberEventsExecuted()
Gets the total number of events executed- Returns:
- the total number of events executed
-
getActualEndingTime
public double getActualEndingTime()
The simulated time that the Executive actually ended- Returns:
- the simulated time that the Executive actually ended
-
isEndEventScheduled
public final boolean isEndEventScheduled()
Returns true if an event has been scheduled to stop execution at getTimeHorizon()- Returns:
- true if scheduled
-
hasNextEvent
public final boolean hasNextEvent()
Checks to see if the event calendar has another event- Returns:
- true if it has another event
-
peekNextEvent
public final JSLEvent peekNextEvent()
Returns a reference to the next event or null if no event exists. Does not remove or execute the event. The event remains at the "top" of the calendar.- Returns:
- a reference to the next event
-
getLastExecutedEvent
public final JSLEvent getLastExecutedEvent()
Returns a reference to the last executed event or null if no events have been executed or no more events- Returns:
- the last event executed
-
initialize
public final void initialize()
Initialize the executive, making it ready to run events This clears any events in the calendar and prepares for execution- Specified by:
initialize
in interfaceIterativeProcessIfc
-
executeNextEvent
public final void executeNextEvent()
Causes the next event to be executed if it exists
-
executeAllEvents
public final void executeAllEvents()
-
end
public final void end()
Description copied from interface:IterativeProcessIfc
The iterative process will continue until there are no more steps or its maximum execution time has been reached, whichever comes first. If this method is called the iterative process will stop processing (terminate) before the next step and not process the next step in the process. The current step will be completed. This method can be used to stop the process at an arbitrary step. Once stopped, the process must be restarted.- Specified by:
end
in interfaceIterativeProcessIfc
-
end
public final void end(java.lang.String msg)
Description copied from interface:IterativeProcessIfc
The iterative process will continue until there are no more steps or its maximum execution time has been reached, whichever comes first. If this method is called the iterative process will stop processing (terminate) before the next step and not process the next step in the process. The current step will be completed. This method can be used to stop the process at an arbitrary step. Once stopped, the process must be restarted.- Specified by:
end
in interfaceIterativeProcessIfc
- Parameters:
msg
- an option message to indicate the reason for stopping
-
isUnfinished
public final boolean isUnfinished()
Description copied from interface:IterativeProcessIfc
The iterative process may end by a variety of means, this method checks if the iterative process ended but was unfinished, not all steps completed- Specified by:
isUnfinished
in interfaceIterativeProcessIfc
- Returns:
- true if the process is not finished
-
isTimedOut
public final boolean isTimedOut()
-
isStepCompleted
public final boolean isStepCompleted()
Description copied from interface:IterativeProcessIfc
Checks if the iterative process is in the completed step state After the iterative process has successfully completed a step this method will return true- Specified by:
isStepCompleted
in interfaceIterativeProcessIfc
- Returns:
- true if the iterative process completed the step
-
isRunning
public final boolean isRunning()
Description copied from interface:IterativeProcessIfc
An iterative process is running if it is been told to run (i.e. runNext()) but has not yet been told to end().- Specified by:
isRunning
in interfaceIterativeProcessIfc
- Returns:
- true if running
-
isInitialized
public final boolean isInitialized()
Description copied from interface:IterativeProcessIfc
Checks if the iterative process is in the initialized state After the iterative process has been initialized this method will return true- Specified by:
isInitialized
in interfaceIterativeProcessIfc
- Returns:
- true if initialized
-
isCreated
public final boolean isCreated()
Description copied from interface:IterativeProcessIfc
Checks if the iterative process is in the created state. If the iterative process is in the created state this method will return true- Specified by:
isCreated
in interfaceIterativeProcessIfc
- Returns:
- true if in the created state
-
isEnded
public final boolean isEnded()
Description copied from interface:IterativeProcessIfc
Checks if the iterative process is in the ended state After the iterative process has been ended this method will return true- Specified by:
isEnded
in interfaceIterativeProcessIfc
- Returns:
- true if ended
-
isEndConditionMet
public final boolean isEndConditionMet()
-
isDone
public final boolean isDone()
Description copied from interface:IterativeProcessIfc
A flag to indicate whether the iterative process is done A iterative process can be done if: 1) it ran all of its steps 2) it was ended by a client prior to completing all of its steps 3) it ended because it exceeded its maximum allowable execution time before completing all of its steps. 4) its end condition was satisfied- Specified by:
isDone
in interfaceIterativeProcessIfc
- Returns:
- true if done
-
isCompleted
public final boolean isCompleted()
-
getMaximumAllowedExecutionTime
public final long getMaximumAllowedExecutionTime()
Description copied from interface:IterativeProcessIfc
Returns maximum (real) clock time allocated for the iterative process- Specified by:
getMaximumAllowedExecutionTime
in interfaceIterativeProcessIfc
- Returns:
- the number as long representing milliseconds
-
setMaximumExecutionTime
public final void setMaximumExecutionTime(long milliseconds)
Description copied from interface:IterativeProcessIfc
Set the maximum allotted (suggested) execution (real) clock for the entire iterative process. This is a suggested time because the execution time requirement is only checked after the completion of an individual step After it is discovered that cumulative time for executing the step has exceeded the maximum time, then the iterative process will be ended (perhaps) not completing other steps.- Specified by:
setMaximumExecutionTime
in interfaceIterativeProcessIfc
- Parameters:
milliseconds
- the time
-
getEndExecutionTime
public final long getEndExecutionTime()
Description copied from interface:IterativeProcessIfc
Returns system time in milliseconds that the iterative process ended- Specified by:
getEndExecutionTime
in interfaceIterativeProcessIfc
- Returns:
- the number as a long
-
getElapsedExecutionTime
public final long getElapsedExecutionTime()
Description copied from interface:IterativeProcessIfc
Gets the clock time in milliseconds since the iterative process was initialized- Specified by:
getElapsedExecutionTime
in interfaceIterativeProcessIfc
- Returns:
- a long representing the elapsed time
-
getBeginExecutionTime
public final long getBeginExecutionTime()
Description copied from interface:IterativeProcessIfc
Returns system time in milliseconds that the iterative process started- Specified by:
getBeginExecutionTime
in interfaceIterativeProcessIfc
- Returns:
- the number as a long
-
getStoppingMessage
public final java.lang.String getStoppingMessage()
Description copied from interface:IterativeProcessIfc
A string message for why stop() was called.- Specified by:
getStoppingMessage
in interfaceIterativeProcessIfc
- Returns:
- the message
-
turnOnDefaultEventTraceReport
public final void turnOnDefaultEventTraceReport()
This method creates an instance of the default ExecutiveTraceReport and tells it to observe the scheduler.
-
turnOnDefaultEventTraceReport
public final void turnOnDefaultEventTraceReport(java.lang.String name)
This method creates an instance of the default ExecutiveTraceReport and tells it to observe the scheduler.- Parameters:
name
- specifies a prefix name for the report
-
turnOffDefaultEventTraceReport
public final void turnOffDefaultEventTraceReport()
Removes the default ExecutiveTraceReport as an observer of the Executive and sets it to null.
-
getDefaultExecutiveTraceReport
public final java.util.Optional<ExecutiveTraceReport> getDefaultExecutiveTraceReport()
Returns the default event trace report or null if it has not yet been turned on.- Returns:
- the ExecutiveTraceReport
-
unregisterAllActions
public final void unregisterAllActions()
-
unregister
public void unregister(ConditionalAction action)
-
setMaxScans
public final void setMaxScans(int max)
-
setMaxScanFlag
public final void setMaxScanFlag(boolean flag)
-
register
public final void register(ConditionalAction action, int priority)
-
register
public final void register(ConditionalAction action)
-
getMaxScans
public final int getMaxScans()
-
getMaxScanFlag
public final boolean getMaxScanFlag()
-
changePriority
public final void changePriority(ConditionalAction action, int priority)
-
stop
public final void stop()
Description copied from interface:IterativeProcessIfc
This sets a flag to indicate to the process that is should stop after the next step is completed. This is different than end(). Calling end() immediately places the process in the End state. The process needs to be in a valid state before end() can be used. Calling stop tells the process to eventually get into the end state. stop() can be used to arbitrarily stop the process based on some user defined condition.- Specified by:
stop
in interfaceIterativeProcessIfc
-
stop
public final void stop(java.lang.String msg)
Description copied from interface:IterativeProcessIfc
This sets a flag to indicate to the process that is should stop after the next step is completed. This is different than end(). Calling end() immediately places the process in the End state. The process needs to be in a valid state before end() can be used. Calling stop tells the process to eventually get into the end state. stop() can be used to arbitrarily stop the process based on some user defined condition.- Specified by:
stop
in interfaceIterativeProcessIfc
- Parameters:
msg
- A string to represent the reason for the stopping
-
execute
protected void execute(JSLEvent event)
Executes the provided event- Parameters:
event
- represents the next event to execute or null
-
performCPhase
protected void performCPhase()
-
setConditionalActionProcessor
protected void setConditionalActionProcessor(ConditionalActionProcessor p)
-
schedule
protected void schedule(JSLEvent e)
-
scheduleEndEvent
public final JSLEvent scheduleEndEvent(double time, ModelElement theElement)
Schedules the ending of the executive at the provided time- Parameters:
time
- the time of the ending event, must be > 0theElement
- the associated model element- Returns:
- the scheduled event
-
getEndEvent
public final JSLEvent getEndEvent()
Returns the Executive's end event if scheduled- Returns:
- The Executive's end event if scheduled, or null if not
-
isExecutionTimeExceeded
public boolean isExecutionTimeExceeded()
Description copied from interface:IterativeProcessIfc
Returns if the elapsed execution time exceeds the maximum time allowed. Only true if the maximum was set and elapsed time is greater than or equal to getMaximumAllowedExecutionTime()- Specified by:
isExecutionTimeExceeded
in interfaceIterativeProcessIfc
- Returns:
- true if the execution time exceeds getMaximumAllowedExecutionTime()
-
getNumberStepsCompleted
public long getNumberStepsCompleted()
Description copied from interface:IterativeProcessIfc
Returns the number of steps completed since the iterative process was last initialized- Specified by:
getNumberStepsCompleted
in interfaceIterativeProcessIfc
- Returns:
- the number of steps completed
-
getLogReport
public IPLogReport getLogReport()
Description copied from interface:IterativeProcessIfc
Returns a reference to the current log report.- Specified by:
getLogReport
in interfaceIterativeProcessIfc
- Returns:
- The log report
-
turnOnTimer
public void turnOnTimer(long milliseconds)
Description copied from interface:IterativeProcessIfc
This method will cause the a timer to start allowing a TimerTask to be scheduled. This method causes a print to console task to be run which prints the elapsed time since initializing the iterative process.- Specified by:
turnOnTimer
in interfaceIterativeProcessIfc
- Parameters:
milliseconds
- the time for the timer
-
allStepsCompleted
public boolean allStepsCompleted()
Description copied from interface:IterativeProcessIfc
The iterative process may end by a variety of means, this method checks if the iterative process ended because it ran all of its steps- Specified by:
allStepsCompleted
in interfaceIterativeProcessIfc
- Returns:
- true if all completed
-
executionTimeExceeded
public boolean executionTimeExceeded()
Description copied from interface:IterativeProcessIfc
The iterative process may end by a variety of means, this method checks if the iterative process ended because it timed out- Specified by:
executionTimeExceeded
in interfaceIterativeProcessIfc
- Returns:
- true if exceeded
-
stoppedByCondition
public boolean stoppedByCondition()
Description copied from interface:IterativeProcessIfc
The iterative process may end by a variety of means, this method checks if the iterative process ended because it was stopped- Specified by:
stoppedByCondition
in interfaceIterativeProcessIfc
- Returns:
- true if it was stopped via stop()
-
runNext
public void runNext()
Description copied from interface:IterativeProcessIfc
Runs the next step in the iterative process- Specified by:
runNext
in interfaceIterativeProcessIfc
-
run
public void run()
Description copied from interface:IterativeProcessIfc
Runs all of the steps of the iterative process. If the iterative process has not been initialized, then it will automatically be initialized. After attempting to run the steps, the process will be in the end() state. The process may or may not complete all of its steps.- Specified by:
run
in interfaceIterativeProcessIfc
-
getStoppingFlag
public boolean getStoppingFlag()
Description copied from interface:IterativeProcessIfc
Returns the stopping flag- Specified by:
getStoppingFlag
in interfaceIterativeProcessIfc
- Returns:
- true if the process has been told to stop via stop()
-
isRunningStep
public boolean isRunningStep()
Description copied from interface:IterativeProcessIfc
Indicates that the iterative process is currently running an individual step- Specified by:
isRunningStep
in interfaceIterativeProcessIfc
- Returns:
- true if the step is in progress
-
noStepsExecuted
public boolean noStepsExecuted()
Description copied from interface:IterativeProcessIfc
Indicates that the iterative process ended because of no steps- Specified by:
noStepsExecuted
in interfaceIterativeProcessIfc
- Returns:
- True if no steps are executed
-
beforeExecutingAnyEvents
protected void beforeExecutingAnyEvents()
This method is called before any events are executed and after initializing the iterative process. It can be used to insert behavior after initializing
-
afterExecution
protected void afterExecution()
This method is called after executing all events when ending the iterative process. It can be used to insert behavior after the executive ends
-
initializeCalendar
protected void initializeCalendar()
Tells the event calendar to clear all the events. Resets the simulation time to 0.0. Resets the event identification counter. Unregisters all actions Notifies observers of initialization
-
willTerminate
public final boolean willTerminate()
If the Executive has an end event or maximum allowed execution time, then return true- Returns:
- true if the executive has an end event or max allowed execution time
-
-