org.mars_sim.msp.simulation.person.ai.task
Class TaskManager

java.lang.Object
  extended by org.mars_sim.msp.simulation.person.ai.task.TaskManager
All Implemented Interfaces:
java.io.Serializable

public class TaskManager
extends java.lang.Object
implements java.io.Serializable

The TaskManager class keeps track of a person's current task and can randomly assign a new task to a person based on a list of possible tasks and that person's current situation. There is one instance of TaskManager per person.

See Also:
Serialized Form

Field Summary
static java.lang.String TASK_EVENT
           
 
Constructor Summary
TaskManager(Mind mind)
          Constructor
 
Method Summary
 void addTask(Task newTask)
          Adds a task to the stack of tasks.
 void clearTask()
          Sets the current task to null.
 Task getNewTask()
          Gets a new task for the person based on tasks available.
 java.lang.String getPhase()
          Returns the name of current task phase if there is one.
 Task getTask()
          Returns the current task.
 java.lang.String getTaskDescription()
          Returns a description of current task for UI purposes.
 java.lang.String getTaskName()
          Returns the name of the current task for UI purposes.
 double getTotalTaskProbability()
          Determines the total probability weight for available tasks.
 boolean hasActiveTask()
          Returns true if person has an active task.
 boolean hasTask()
          Returns true if perosn has a task (may be inactive).
 void performTask(double time, double efficiency)
          Perform the current task for a given amount of time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TASK_EVENT

public static final java.lang.String TASK_EVENT
See Also:
Constant Field Values
Constructor Detail

TaskManager

public TaskManager(Mind mind)
Constructor

Parameters:
mind - the mind that uses this task manager.
Method Detail

hasActiveTask

public boolean hasActiveTask()
Returns true if person has an active task.

Returns:
true if person has an active task

hasTask

public boolean hasTask()
Returns true if perosn has a task (may be inactive).

Returns:
true if person has a task

getTaskName

public java.lang.String getTaskName()
Returns the name of the current task for UI purposes. Returns a blank string if there is no current task.

Returns:
name of the current task

getTaskDescription

public java.lang.String getTaskDescription()
Returns a description of current task for UI purposes. Returns a blank string if there is no current task.

Returns:
a description of the current task

getPhase

public java.lang.String getPhase()
Returns the name of current task phase if there is one. Returns blank string if current task has no phase. Returns blank string if there is no current task.

Returns:
the name of the current task phase

getTask

public Task getTask()
Returns the current task. Return null if there is no current task.

Returns:
the current task

clearTask

public void clearTask()
Sets the current task to null.


addTask

public void addTask(Task newTask)
Adds a task to the stack of tasks.

Parameters:
newTask - the task to be added

performTask

public void performTask(double time,
                        double efficiency)
                 throws java.lang.Exception
Perform the current task for a given amount of time.

Parameters:
time - amount of time to perform the action
efficiency - The performance rating of person performance task.
Throws:
java.lang.Exception - if error in performing task.

getNewTask

public Task getNewTask()
                throws java.lang.Exception
Gets a new task for the person based on tasks available.

Returns:
new task
Throws:
java.lang.Exception - if new task could not be found.

getTotalTaskProbability

public double getTotalTaskProbability()
Determines the total probability weight for available tasks.

Returns:
total probability weight