|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.sim.engine.BaseController
public abstract class BaseController
Abstract base class implementing IController. This provides methods for controlling the execution of a SimModel, firing SimEvents and minimal parameter handling abilities. Child classes are expected to add more sophisticated parameter handling.
| Field Summary | |
|---|---|
protected boolean |
done
when true the simulation has stopped |
protected boolean |
doStep
when true the simulation should execute all actions for the next tick and then pause. |
protected boolean |
executeBegin
Tracks whether model.begin() has been called and so whether startSim should call model.begin(). |
protected boolean |
exitOnExit
Flag for whether the simulation should exit the JVM on exiting the simulation. |
protected boolean |
go
when true the simulation runs, when false it stops |
protected boolean |
isGui
true if this is a gui controller - i.e. toolbar is displayed |
protected java.util.ArrayList |
listenerList
List of listeners listening for SimEvents broadcast by this BaseController. |
protected SimModel |
model
the model (simulation) to run with this BaseController |
protected java.lang.Object |
monitor
Monitor object used in guarded suspension pause check. |
protected ParameterSetter |
params
Default model parameters read from a parameter file |
protected boolean |
pauseActionsExecuted
true if the actions scheduled to be run when the simulation is paused have been run, false if not |
protected int |
pauseAt
|
protected BasicAction |
pauseAtAction
|
protected boolean |
pauseSim
when true the sim pauses, when false it runs |
protected java.util.Hashtable |
persistentObj
Persistent objects store. |
protected boolean |
runFinished
when true a a single run of simulation has finished. |
protected java.lang.Thread |
runThread
The actual run thread that runs the Runnable simRun |
protected Schedule |
schedule
The master schedule |
protected java.lang.Runnable |
simRun
The runnable that encapsulates the schedule and allows for threaded execution of the schedule |
protected int |
sleepValue
The amount to pause while simRun is running, allowing other processing to occur. |
protected double |
time
the tick count |
| Constructor Summary | |
|---|---|
BaseController()
Constructs a BaseController. |
|
| Method Summary | |
|---|---|
void |
addSimEventListener(SimEventListener l)
Adds a SimEventListener to listen for SimEvents broadcast from this BaseController. |
protected void |
beginModel()
|
void |
fireSimEvent(SimEvent evt)
Fires a SimEvent to the registered listeners. |
int |
getCellDepth()
Gets the display cell depth. |
int |
getCellHeight()
Gets the display cell height. |
int |
getCellWidth()
Gets the display cell width. |
double |
getCurrentTime()
Gets the current simulation time (tick count) - the current number of execution cycles completed by main schedule. |
java.util.Hashtable |
getDefaultModelParameters()
Gets a Hashtable of the default model parameters. |
boolean |
getExitOnExit()
Gets whether the simulation application should exit with a System.exit(0) call on exit (pressing the exit button), or dispose of all windows, release the model without killing this instance of the virtual machine. |
SimModel |
getModel()
Returns the SimModel currently associated with this BaseController. |
java.util.Hashtable |
getModelParameters()
Deprecated. replaced by ParameterUtilities.#getModelProperties(SimModel) |
int |
getPauseAt()
|
java.lang.Object |
getPersistentObj(java.lang.Object key)
Gets a stored persistent (over the life of many runs) object. |
long |
getRandomSeed()
Gets the current random seed for the current model |
Schedule |
getSchedule()
Returns the Schedule associated with BaseController |
boolean |
isBatch()
Is this a BatchController. |
protected void |
notifyMonitor()
Notifies object monitor that controlls pausing. |
protected abstract void |
onTickCountUpdate()
Called whenever the tick count is incremented. |
void |
pauseSim()
Pauses the simulation |
void |
putPersistentObj(java.lang.Object key,
java.lang.Object val)
Allows for the storage of objects to persist beyond the life of a single run by objects that do not so persist. |
void |
removeSimEventListener(SimEventListener l)
Removes a SimEventListener from the list of listeners listening for SimEvents broadcast from this BaseController. |
void |
setCellDepth(int cellSize)
Sets the display cell depth. |
void |
setCellHeight(int cellSize)
Sets the display cell height. |
void |
setCellWidth(int cellSize)
Sets the display cell width. |
void |
setExitOnExit(boolean val)
Sets whether the simulation application should exit with a System.exit(0) call on exit (pressing the exit button), or dispose of all windows, release the model without killing this instance of the virtual machine. |
void |
setModel(SimModel model)
Sets the model associated with this controller. |
void |
setPauseAt(int val)
|
void |
setRandomSeed(long seed)
Sets the random seed for the current model. |
void |
setSchedule(Schedule schedule)
Sets the schedule to be run by the controller. |
protected void |
setupSchedule()
Sets up the schedule thread. |
void |
startSim()
Starts the simulation. |
void |
stopSim()
Stops the simulation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface uchicago.src.sim.engine.SimEventListener |
|---|
simEventPerformed |
| Methods inherited from interface uchicago.src.sim.engine.IController |
|---|
exitSim, getRunCount, isGUI |
| Field Detail |
|---|
protected Schedule schedule
protected java.lang.Runnable simRun
protected double time
protected volatile java.lang.Thread runThread
protected volatile boolean go
protected volatile boolean pauseSim
protected boolean done
protected volatile boolean doStep
protected volatile boolean runFinished
BatchController
protected int sleepValue
protected SimModel model
BaseController
protected boolean pauseActionsExecuted
protected boolean isGui
protected java.util.Hashtable persistentObj
protected ParameterSetter params
protected int pauseAt
protected boolean executeBegin
protected java.lang.Object monitor
protected java.util.ArrayList listenerList
protected boolean exitOnExit
protected BasicAction pauseAtAction
| Constructor Detail |
|---|
public BaseController()
| Method Detail |
|---|
public void setModel(SimModel model)
setModel in interface IControllermodel - the model associated with this BaseControllerpublic SimModel getModel()
getModel in interface IControllerpublic int getCellWidth()
public void setCellWidth(int cellSize)
cellSize - the new display cell sizegetCellWidth()public int getCellHeight()
public void setCellHeight(int cellSize)
cellSize - the new display cell sizegetCellHeight()public int getCellDepth()
public void setCellDepth(int cellSize)
cellSize - the new display cell sizegetCellDepth()public void setSchedule(Schedule schedule)
setSchedule in interface IControllerschedule - the schedule to be run by this BaseController.Schedulepublic Schedule getSchedule()
getSchedule in interface IControllerpublic double getCurrentTime()
getCurrentTime in interface IControllergetCurrentTime in interface TickCounterprotected abstract void onTickCountUpdate()
public void setRandomSeed(long seed)
seed - the new random seedSimModelImpl.setRngSeed(long)public long getRandomSeed()
protected void beginModel()
public void startSim()
startSim in interface IControllerprotected void notifyMonitor()
protected void setupSchedule()
public java.util.Hashtable getModelParameters()
public java.util.Hashtable getDefaultModelParameters()
Hashtable if no model
has been loaded. Note that this creates no distinction between
batch parameters that are dynamic and those that are constant.If any default values have been loaded from a file this will return those values. To get the current parameter values, use getModelParameters();
public void pauseSim()
pauseSim in interface IControllerpublic void stopSim()
stopSim in interface IControllerpublic boolean isBatch()
isBatch in interface IControllerpublic void addSimEventListener(SimEventListener l)
addSimEventListener in interface IControllerl - the SimEventListener to addSimEventListenerpublic void removeSimEventListener(SimEventListener l)
removeSimEventListener in interface IControllerl - the SimEventListener to remove.SimEventListenerpublic void fireSimEvent(SimEvent evt)
evt - the SimEvent to fire
public void putPersistentObj(java.lang.Object key,
java.lang.Object val)
putPersistentObj in interface IControllerkey - a unique identifier for the object to storeval - the actual object to storepublic java.lang.Object getPersistentObj(java.lang.Object key)
getPersistentObj in interface IControllerkey - the unique identifier for the persistent objectpublic void setPauseAt(int val)
public int getPauseAt()
public void setExitOnExit(boolean val)
setExitOnExit in interface IControllerpublic boolean getExitOnExit()
getExitOnExit in interface IController
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||