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
ConstructorsConstructorDescriptionDefaultController(RunEnvironmentBuilder runEnvironmentBuilder) TODO: fill this inDefaultController(RunEnvironmentBuilder runEnvironmentBuilder, int runNumber) -
Method Summary
Modifier and TypeMethodDescriptionvoidCalls the batchCleanup method of this class with all the contexts in the controller registry in the order they are returned by that registry.voidbatchCleanup(RunState runState, Object contextId) Calls the batchCleanup method on all the actions this registry contains, with runState as an argument.voidCalls the runInitialize method of this class with all the contexts in the controller registry in the order they are returned by that registry.voidcleanup()Invalidates the currentRunState.voidexecute()Executes the current RunState of the controller.voidExecutes the specified RunState with the ScheduleRunner.Retrieves the registry ofControllerActions that the controller will run.Retrieves the current RunState the controller is using.intGets the next batch number.intGets the next run number.Gets the ScheduleRunner that will be used to execute the model's schedule found through the RunState.protected voidprotected booleanprepare()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 voidvoidCalls the runCleanup method of this class with all the contexts in the controller registry in the order they are returned by that registry.voidrunCleanup(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.voidsetControllerRegistry(ControllerRegistry controllerRegistry) Sets the registry ofControllerActions that the controller will run.voidsetScheduleRunner(Runner scheduleRunner) Sets the ScheduleRunner that will be used to execute the model's schedule found through the RunState.voidsetup()
-
Constructor Details
-
DefaultController
TODO: fill this in- Parameters:
runEnvironmentBuilder-
-
DefaultController
-
-
Method Details
-
setControllerRegistry
Sets the registry ofControllerActions that the controller will run.- Specified by:
setControllerRegistryin interfaceController- Parameters:
controllerRegistry- a registry used to find actions to run
-
getControllerRegistry
Retrieves the registry ofControllerActions that the controller will run.- Specified by:
getControllerRegistryin 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:
setScheduleRunnerin interfaceController- Parameters:
scheduleRunner- the ScheduleRunner that will execute the model's schedule
-
getScheduleRunner
Description copied from interface:ControllerGets 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:
getScheduleRunnerin 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:
batchInitializein 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:
runInitializein interfaceController- Returns:
- the current initialized RunState.
-
loadRandomLoader
protected void loadRandomLoader() -
runParameterSetters
Description copied from interface:ControllerInitializes the parameters for the current run.- Specified by:
runParameterSettersin 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:
runCleanupin 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:
batchCleanupin 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:
getNextRunNumberin 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:
getNextBatchNumberin 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:
getCurrentRunStatein interfaceController- Returns:
- the RunState the controller is currently using
-
setup
public void setup()- Specified by:
setupin interfaceController
-