Class DefaultController
java.lang.Object
repast.simphony.engine.controller.DefaultController
- All Implemented Interfaces:
Controller
,IAction
A default implementation of a Controller. This performs all the functionality
specified in the
Controller
interface.- Author:
- Jerry Vos
-
Constructor Summary
ConstructorDescriptionDefaultController
(RunEnvironmentBuilder runEnvironmentBuilder) TODO: fill this inDefaultController
(RunEnvironmentBuilder runEnvironmentBuilder, int runNumber) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Calls the batchCleanup method of this class with all the contexts in the controller registry in the order they are returned by that registry.void
batchCleanup
(RunState runState, Object contextId) Calls the batchCleanup method on all the actions this registry contains, with runState as an argument.void
Calls the runInitialize method of this class with all the contexts in the controller registry in the order they are returned by that registry.void
cleanup()
Invalidates the currentRunState
.void
execute()
Executes the current RunState of the controller.void
Executes the specified RunState with the ScheduleRunner.Retrieves the registry ofControllerAction
s that the controller will run.Retrieves the current RunState the controller is using.int
Gets the next batch number.int
Gets the next run number.Gets the ScheduleRunner that will be used to execute the model's schedule found through the RunState.protected void
protected boolean
prepare()
If the RunState object is invalidated (null) this will create a new RunState object, using the next*Number fields and the model name of this class.protected void
void
Calls the runCleanup method of this class with all the contexts in the controller registry in the order they are returned by that registry.void
runCleanup
(RunState runState, Object contextId) Calls the runCleanup method on all the actions this registry contains, with runState as an argument.runInitialize
(Parameters params) Calls the runInitialize method of this class with all the contexts in the controller registry in the order they are returned by that registry.runParameterSetters
(Parameters params) Initializes the parameters for the current run.void
setControllerRegistry
(ControllerRegistry controllerRegistry) Sets the registry ofControllerAction
s that the controller will run.void
setScheduleRunner
(Runner scheduleRunner) Sets the ScheduleRunner that will be used to execute the model's schedule found through the RunState.void
setup()
-
Constructor Details
-
DefaultController
TODO: fill this in- Parameters:
runEnvironmentBuilder
-
-
DefaultController
-
-
Method Details
-
setControllerRegistry
Sets the registry ofControllerAction
s that the controller will run.- Specified by:
setControllerRegistry
in interfaceController
- Parameters:
controllerRegistry
- a registry used to find actions to run
-
getControllerRegistry
Retrieves the registry ofControllerAction
s that the controller will run.- Specified by:
getControllerRegistry
in interfaceController
- Returns:
- a registry used to find actions to run
-
setScheduleRunner
Sets the ScheduleRunner that will be used to execute the model's schedule found through the RunState. This is used in the execute() phase of the controller.- Specified by:
setScheduleRunner
in interfaceController
- Parameters:
scheduleRunner
- the ScheduleRunner that will execute the model's schedule
-
getScheduleRunner
Description copied from interface:Controller
Gets the ScheduleRunner that will be used to execute the model's schedule found through the RunState. This is used in the execute() phase of the controller.- Specified by:
getScheduleRunner
in interfaceController
- Returns:
- the ScheduleRunner that will be used to execute the model's schedule.
-
batchCleanup
Calls the batchCleanup method on all the actions this registry contains, with runState as an argument.- Parameters:
runState
- the state to pass to the actions
-
runCleanup
Calls the runCleanup method on all the actions this registry contains, with runState as an argument.- Parameters:
runState
- the state to pass to the actions
-
execute
Executes the specified RunState with the ScheduleRunner.- Parameters:
toExecuteOn
- the RunState to execute- See Also:
-
execute
public void execute()Executes the current RunState of the controller. The current RunState is created when thebatchInitialize()
orrunInitialize(repast.simphony.parameter.Parameters)
methods are called. -
batchInitialize
public void batchInitialize()Calls the runInitialize method of this class with all the contexts in the controller registry in the order they are returned by that registry. This will prepare the controller, creating a new run state object for the next set of runs (batch or not) if the RunState has been invalidated. Calling thebatchCleanup()
orcleanup()
method is required to invalidate the RunState in prepartion for another set of runs.- Specified by:
batchInitialize
in interfaceController
-
runInitialize
Calls the runInitialize method of this class with all the contexts in the controller registry in the order they are returned by that registry. This will prepare the controller, creating a new run state object for the next set of runs (batch or not) if the RunState has been invalidated. Calling therunCleanup()
orcleanup()
method is required to invalidate the RunState in prepartion for another set of runs.- Specified by:
runInitialize
in interfaceController
- Returns:
- the current initialized RunState.
-
loadRandomLoader
protected void loadRandomLoader() -
runParameterSetters
Description copied from interface:Controller
Initializes the parameters for the current run.- Specified by:
runParameterSetters
in interfaceController
- Parameters:
params
- an optional parameters object that will have the parameters loaded into it- Returns:
- the parameters object that the parameters were loaded into
-
runCleanup
public void runCleanup()Calls the runCleanup method of this class with all the contexts in the controller registry in the order they are returned by that registry. If the RunState object of this controller was created by the runInitialize method, this method will then invalidate the RunState object.- Specified by:
runCleanup
in interfaceController
-
batchCleanup
public void batchCleanup()Calls the batchCleanup method of this class with all the contexts in the controller registry in the order they are returned by that registry. This method will invalidate the RunState object.- Specified by:
batchCleanup
in interfaceController
-
prepare
protected boolean prepare()If the RunState object is invalidated (null) this will create a new RunState object, using the next*Number fields and the model name of this class. If the RunState is still valid (non-null) this will just return false.- Returns:
- true if a new RunState object was created.
-
prepareForNextRun
protected void prepareForNextRun() -
cleanup
public void cleanup()Invalidates the currentRunState
. -
getNextRunNumber
public int getNextRunNumber()Gets the next run number. The next run number is the number assigned to the next run when runInitialize is called.- Specified by:
getNextRunNumber
in interfaceController
- Returns:
- the next run number. The next run number is the number assigned to the next run when runInitialize is called.
-
getNextBatchNumber
public int getNextBatchNumber()Gets the next batch number. The next batch number is the number assigned to the next batch when batchInitialize is called.- Specified by:
getNextBatchNumber
in interfaceController
- Returns:
- the next batch number. The next batch number is the number assigned to the next batch when batchInitialize is called.
-
getCurrentRunState
Retrieves the current RunState the controller is using.- Specified by:
getCurrentRunState
in interfaceController
- Returns:
- the RunState the controller is currently using
-
setup
public void setup()- Specified by:
setup
in interfaceController
-