|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectetomica.action.Activity
etomica.action.activity.ActivityGroupSeries
etomica.action.activity.Controller
public class Controller
Organizer and executor of actions performed by the simulation. The Controller holds a series of Actions which it performs in series, using a thread that it launches when start() is invoked. A simple Action will run on the Controller's thread. An Activity is a subclass of Action that runs on its own thread, and can be paused or terminated (halted) before it completes naturally.
The Controller thread will idle while an Activity is running. While idling, the Controller will respond to "urgent actions" that another thread (typically a gui) will ask it to perform. In response, the Controller will pause the current Activity (or complete the Action if not an Activity), perform the urgent action, and continue where it left off. This capability is needed for a user to interact with a simulation that is in progress, without colliding with an integrator running on this Controller.
The queue for pending Actions may be altered (given additions or deletions) while Actions are being executed. As Actions are completed they are moved into a list of completed Actions. When all Actions are done, the Controller exits, but it may be restarted if Actions are added and start() is invoked again.
Each Simulation holds a single, final instance of a Controller.
Action,
Activity,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
Controller.ActionStatus
Enumerated type describing the status of an action. |
protected static class |
Controller.UrgentWaitObject
|
protected static class |
Controller.WaitObject
|
| Field Summary | |
|---|---|
protected HashMap<IAction,Throwable> |
actionExceptionMap
|
protected HashMap<IAction,Controller.ActionStatus> |
actionStatusMap
|
protected Controller.UrgentWaitObject |
urgentWaitObject
|
protected Controller.WaitObject |
waitObject
|
| Fields inherited from class etomica.action.activity.ActivityGroupSeries |
|---|
completedActions, currentAction, numActions, pauseAfterEachAction, pendingActions |
| Fields inherited from class etomica.action.Activity |
|---|
haltRequested, isActive, pauseRequested |
| Constructor Summary | |
|---|---|
Controller()
|
|
| Method Summary | |
|---|---|
void |
addAction(IAction newAction)
Adds the given action to the list of actions. |
void |
doActionNow(IAction action)
Pauses current activity, executes given action, then resumes current activity. |
Controller.ActionStatus |
getActionStatus(IAction action)
Returns the status of an action held by the controller. |
IEventManager |
getEventManager()
Returns the event manager used by the controller to notify listeners of individual actions events as well as events related to the controller itself. |
Throwable |
getException(IAction action)
Returns the exception thrown by an action held by the controller. |
boolean |
isRepeatCurrentAction()
Returns value of repeatCurrentAction flag. |
boolean |
removeAction(IAction oldAction)
Removes the given action from the list of actions performed by this controller. |
void |
reset()
Marks all actions as pending. |
protected void |
run()
Causes uncompleted actions added to this group to be run in sequence. |
void |
setRepeatCurrentAction(boolean repeatCurrentAction)
Flag indicating whether the current action should be repeated indefinitely before moving on to the next action. |
String |
toString()
|
| Methods inherited from class etomica.action.activity.ActivityGroupSeries |
|---|
getAllActions, getCompletedActions, getCurrentActions, getPendingActions, halt, isPauseAfterEachAction, isPaused, pause, setPauseAfterEachAction, unPause |
| Methods inherited from class etomica.action.Activity |
|---|
actionPerformed, doContinue, doWait, isActive |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface etomica.action.activity.ActivityGroup |
|---|
getCompletedActions, getCurrentActions, getPendingActions |
| Methods inherited from interface etomica.action.ActionGroup |
|---|
getAllActions |
| Methods inherited from interface etomica.action.IAction |
|---|
actionPerformed |
| Field Detail |
|---|
protected final Controller.UrgentWaitObject urgentWaitObject
protected final Controller.WaitObject waitObject
protected final HashMap<IAction,Controller.ActionStatus> actionStatusMap
protected final HashMap<IAction,Throwable> actionExceptionMap
| Constructor Detail |
|---|
public Controller()
| Method Detail |
|---|
public void addAction(IAction newAction)
ActivityGroupSeries
addAction in interface ActionGroupaddAction in class ActivityGroupSeriespublic boolean removeAction(IAction oldAction)
ActivityGroupSeries
removeAction in interface ActionGroupremoveAction in class ActivityGroupSeriespublic void reset()
ActivityGroupSeries
reset in interface IControllerreset in class ActivityGroupSeriespublic Controller.ActionStatus getActionStatus(IAction action)
getActionStatus in interface IControllerpublic Throwable getException(IAction action)
getException in interface IControllerprotected void run()
run in class ActivityGroupSeriespublic void doActionNow(IAction action)
doActionNow in interface IControlleraction - Action to be performed right away; cannot be an Activity.public void setRepeatCurrentAction(boolean repeatCurrentAction)
Default is false.
public boolean isRepeatCurrentAction()
public String toString()
toString in class Objectpublic IEventManager getEventManager()
IController
getEventManager in interface IControllerControllerEvent
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||