public class Schedule
extends java.lang.Object
EventListImpl
as well as a static
interface to a singleton default instance of EventListImpl
.
Schedule maintains the various EventListImpl
instances and
provides a universally available way to interact with a single default
instance of an EventList
.
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.Integer,BasicEventList> |
allEventLists |
private static BasicEventList |
defaultEventList |
private static java.text.DecimalFormat |
form |
private static int |
nextEventListID |
Constructor and Description |
---|
Schedule()
Only subclass Schedule by augmenting the simkit package.
|
Modifier and Type | Method and Description |
---|---|
static void |
addAndSetDefaultEventList(java.lang.Class<BasicEventList> clazz)
Create a new Event List of the given type and set it to be the default.
|
static void |
addIgnoreOnDump(java.lang.String ignoredEventName)
When dumping event list, ignore this event.
|
static int |
addNewEventList()
Instantiate a new Event list and return its id.
|
static int |
addNewEventList(java.lang.Class<?> clazz)
Instantiates a new EventList subclass.
|
static void |
addRerun(ReRunnable se)
Adds the entity to the list of entities with "Run" events.
|
static void |
clearRerun()
Clears the list of SimEntities with Run events.
|
static void |
coldReset()
defaultEventList is now completely pristine.
|
static SimEvent |
getCurrentEvent()
Returns currently executing event; null if simulation is not currently
running.
|
static BasicEventList |
getDefaultEventList() |
static BasicEventList |
getEventList(int index)
Will return an existing EventList, if one with that id exists.
|
protected static java.lang.Integer |
getNextAvailableID()
Search event lists for an unused id.
|
static java.io.PrintStream |
getOutputStream() |
static boolean |
getPauseAfterEachEvent() |
static java.util.Set<ReRunnable> |
getReruns()
Returns a copy of the list of SimEntities with Run events.
|
static double |
getSimTime()
For default event list
|
static java.lang.String |
getSimTimeStr()
For default event list
|
static boolean |
isReallyVerbose()
It true, causes Schedule to print additional debug/trace information.
|
static boolean |
isRunning() |
static boolean |
isSingleStep()
If true, then Schedule is running in single-step mode and will pause
prior to processing each event.
|
static boolean |
isVerbose()
Causes a list of the pending events (and other information) to be dumped
to the output stream prior to processing each event when set to true.
|
static void |
pause()
Pause the simulation, which can be resumed with either resumeSimulation()
or startSimulation()
|
static boolean |
removeEventList(int id)
Removes the EventList corresponding to the given id.
|
static void |
removeIgnoreOnDump(java.lang.String ignoredEventName)
Stop ignoring this event on dump().
|
static void |
removeRerun(ReRunnable se)
Removes the SimEntity from the list of entities with Run events.
|
static void |
reset()
Clears the event list and starts time at 0.0.
|
static void |
resetToOriginalEventList()
Resets defaultEvent list to the original one.
|
static void |
setDecimalFormat(java.lang.String format) |
static void |
setDefaultEventList(BasicEventList eventList)
If not on master list, will add it with the next available id.
|
static void |
setEventSourceVerbose(boolean b)
If set to true causes the owner of the event to be included whenever the
event list is printed.
|
static void |
setOutputStream(java.io.PrintStream printStream)
The default PrintStream is System.out.
|
static void |
setPauseAfterEachEvent(boolean b)
If true, then only one event will be processed.
|
static void |
setReallyVerbose(boolean b)
It true, causes Schedule to print additional debug/trace information.
|
static void |
setSingleStep(boolean step)
Sets single step mode.
|
static void |
setUserDefinedStop()
Disables both stop at time and stop on event.
|
static void |
setVerbose(boolean v)
Causes a list of the pending events (and other information) to be dumped
to the output stream prior to processing each event when set to true.
|
static void |
startSimulation()
Starts or resumes simulation.
|
private static void |
step()
Wait for user input before continuing.
|
static void |
stopAtTime(double atTime)
Will cause the simulation to stop when it reaches the given simulation
time.
|
static void |
stopOnEvent(int numberEvents,
java.lang.String eventName,
java.lang.Class<?>... eventSignature)
Causes the simulation to stop after the given event with the given
signature has been processed the given number of times.
|
static void |
stopSimulation()
Stops the simulation and clears the event list.
|
private static int nextEventListID
private static BasicEventList defaultEventList
private static final java.util.Map<java.lang.Integer,BasicEventList> allEventLists
private static java.text.DecimalFormat form
public static void setVerbose(boolean v)
v
- Whether this instance is verbosepublic static boolean isVerbose()
public static final void setSingleStep(boolean step)
step
- true if single-step mode, false otherwise.public static boolean isSingleStep()
public static boolean isRunning()
public static void reset()
public static void startSimulation()
public static void pause()
private static void step()
's' will stop the simulation.
'g' will take the simulation out of single-step and continue.
'f' will take the simulation out of single-step, set verbose to false,
and continue.
Return will cause the simulation to step to the next event.
public static void stopAtTime(double atTime)
atTime
- Time to stop simulation runpublic static void setUserDefinedStop()
public static void stopOnEvent(int numberEvents, java.lang.String eventName, java.lang.Class<?>... eventSignature)
numberEvents
- Number of events until stoppingeventName
- Name of event to stop oneventSignature
- Signature of stopping eventpublic static void stopSimulation()
public static SimEvent getCurrentEvent()
public static double getSimTime()
public static java.lang.String getSimTimeStr()
public static void setEventSourceVerbose(boolean b)
b
- whether event sources will be in dumppublic static void addRerun(ReRunnable se)
se
- SimEntity to be added to reRun listpublic static void removeRerun(ReRunnable se)
se
- SimEntity to be removedpublic static void clearRerun()
public static java.util.Set<ReRunnable> getReruns()
public static void addIgnoreOnDump(java.lang.String ignoredEventName)
ignoredEventName
- The name of the event to be ignoredpublic static void removeIgnoreOnDump(java.lang.String ignoredEventName)
ignoredEventName
- The event that was previously ignored but now is
not.public static void setReallyVerbose(boolean b)
b
- whether reallyVerbose is to be setpublic static boolean isReallyVerbose()
public static void setDecimalFormat(java.lang.String format)
format
- DecimalFormat string for simTimespublic static int addNewEventList()
public static int addNewEventList(java.lang.Class<?> clazz)
(int)
clazz
- The class of the EventList to be addedpublic static boolean removeEventList(int id)
Removes the EventList corresponding to the given id. If no such EventList has been created, then does nothing. The removed EventList has a coldReset() invoked to clear out any lingering SimEntities.
If the requested EventList is the current defaultEventList, then it is not removed.
id
- Given EventList idpublic static void addAndSetDefaultEventList(java.lang.Class<BasicEventList> clazz)
clazz
- Class of the new Event Listprotected static java.lang.Integer getNextAvailableID()
public static BasicEventList getEventList(int index)
index
- id of desired EventList instancepublic static BasicEventList getDefaultEventList()
public static void setDefaultEventList(BasicEventList eventList)
eventList
- Desired EventList instance for defaultpublic static void resetToOriginalEventList()
public static void setPauseAfterEachEvent(boolean b)
startSimulation()
is required to get going again.b
- Whether default simulation will pause after each eventpublic static boolean getPauseAfterEachEvent()
public static void coldReset()
public static void setOutputStream(java.io.PrintStream printStream)
printStream
- the PrintStream instance for the default EventList to
dump to.public static java.io.PrintStream getOutputStream()