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

java.lang.Object
  extended by org.mars_sim.msp.simulation.person.ai.task.Task
      extended by org.mars_sim.msp.simulation.person.ai.task.LoadVehicle
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class LoadVehicle
extends Task
implements java.io.Serializable

The LoadVehicle class is a task for loading a vehicle with fuel and supplies.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.mars_sim.msp.simulation.person.ai.task.Task
effortDriven, hasDuration, person, phaseTimeCompleted, phaseTimeRequired, stressModifier, subTask, TASK_DESC_EVENT, TASK_ENDED_EVENT, TASK_NAME_EVENT, TASK_PHASE_EVENT, TASK_SUBTASK_EVENT
 
Constructor Summary
LoadVehicle(Person person)
          Constructor
LoadVehicle(Person person, Vehicle vehicle, java.util.Map<Resource,java.lang.Number> resources, java.util.Map<java.lang.Class,java.lang.Integer> equipment)
          Constructor
 
Method Summary
protected  void addExperience(double time)
          Adds experience to the person's skills used in this task.
static boolean enoughCapacityForSupplies(java.util.Map<Resource,java.lang.Number> resources, java.util.Map<java.lang.Class,java.lang.Integer> equipment, Vehicle vehicle, Settlement settlement)
          Checks if a vehicle has enough storage capacity for the supplies needed on the trip.
 java.util.List<java.lang.String> getAssociatedSkills()
          Gets a list of the skills associated with this task.
 int getEffectiveSkillLevel()
          Gets the effective skill level a person has at this task.
static double getProbability(Person person)
          Returns the weighted probability that a person might perform this task.
static boolean hasEnoughSupplies(Settlement settlement, Vehicle vehicle, java.util.Map<Resource,java.lang.Number> resources, java.util.Map<java.lang.Class,java.lang.Integer> equipment, int vehicleCrewNum, double tripTime)
          Checks if there are enough supplies in the settlement's stores to supply trip.
static boolean isFullyLoaded(java.util.Map<Resource,java.lang.Number> resources, java.util.Map<java.lang.Class,java.lang.Integer> equipment, Vehicle vehicle)
          Checks if the vehicle is fully loaded with supplies.
protected  double performMappedPhase(double time)
          Performs the method mapped to the task's current phase.
 
Methods inherited from class org.mars_sim.msp.simulation.person.ai.task.Task
addPhase, compareTo, endTask, getCreateEvents, getCrowdingProbabilityModifier, getDescription, getDuration, getName, getPhase, getRelationshipModifier, getSubTask, getTeacher, getTeachingExperienceModifier, getTimeCompleted, getTopPhase, hasTeacher, isDone, isEffortDriven, setCreateEvents, setDescription, setDuration, setName, setPhase, setStressModifier, setTeacher, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LoadVehicle

public LoadVehicle(Person person)
            throws java.lang.Exception
Constructor

Parameters:
person - the person performing the task.
Throws:
java.lang.Exception - if error creating task.

LoadVehicle

public LoadVehicle(Person person,
                   Vehicle vehicle,
                   java.util.Map<Resource,java.lang.Number> resources,
                   java.util.Map<java.lang.Class,java.lang.Integer> equipment)
            throws java.lang.Exception
Constructor

Parameters:
person - the person performing the task.
vehicle - the vehicle to be loaded.
resources - a map of resources to be loaded.
equipment - a map of equipment to be loaded.
Throws:
java.lang.Exception - if error creating task.
Method Detail

getProbability

public static double getProbability(Person person)
Returns the weighted probability that a person might perform this task. It should return a 0 if there is no chance to perform this task given the person and his/her situation.

Parameters:
person - the person to perform the task
Returns:
the weighted probability that a person might perform this task

performMappedPhase

protected double performMappedPhase(double time)
                             throws java.lang.Exception
Performs the method mapped to the task's current phase.

Specified by:
performMappedPhase in class Task
Parameters:
time - the amount of time (millisol) the phase is to be performed.
Returns:
the remaining time (millisol) after the phase has been performed.
Throws:
java.lang.Exception - if error in performing phase or if phase cannot be found.

addExperience

protected void addExperience(double time)
Adds experience to the person's skills used in this task.

Specified by:
addExperience in class Task
Parameters:
time - the amount of time (ms) the person performed this task.

hasEnoughSupplies

public static boolean hasEnoughSupplies(Settlement settlement,
                                        Vehicle vehicle,
                                        java.util.Map<Resource,java.lang.Number> resources,
                                        java.util.Map<java.lang.Class,java.lang.Integer> equipment,
                                        int vehicleCrewNum,
                                        double tripTime)
                                 throws java.lang.Exception
Checks if there are enough supplies in the settlement's stores to supply trip.

Parameters:
settlement - the settlement the vehicle is at.
resources - a map of resources required for the trip.
equipment - a map of equipment required for the trip.
vehicleCrewNum - the number of people in the vehicle crew.
tripTime - the estimated time for the trip (millisols).
Returns:
true if enough supplies
Throws:
java.lang.Exception - if error checking supplies.

enoughCapacityForSupplies

public static boolean enoughCapacityForSupplies(java.util.Map<Resource,java.lang.Number> resources,
                                                java.util.Map<java.lang.Class,java.lang.Integer> equipment,
                                                Vehicle vehicle,
                                                Settlement settlement)
                                         throws java.lang.Exception
Checks if a vehicle has enough storage capacity for the supplies needed on the trip.

Parameters:
resources - a map of the resources required.
equipment - a map of the equipment types and numbers needed.
vehicle - the vehicle to check.
settlement - the settlement to disembark from.
Returns:
true if vehicle can carry supplies.
Throws:
java.lang.Exception - if error

isFullyLoaded

public static final boolean isFullyLoaded(java.util.Map<Resource,java.lang.Number> resources,
                                          java.util.Map<java.lang.Class,java.lang.Integer> equipment,
                                          Vehicle vehicle)
                                   throws java.lang.Exception
Checks if the vehicle is fully loaded with supplies.

Returns:
true if vehicle is fully loaded.
Throws:
java.lang.Exception - if error checking supplies.

getEffectiveSkillLevel

public int getEffectiveSkillLevel()
Gets the effective skill level a person has at this task.

Specified by:
getEffectiveSkillLevel in class Task
Returns:
effective skill level

getAssociatedSkills

public java.util.List<java.lang.String> getAssociatedSkills()
Gets a list of the skills associated with this task. May be empty list if no associated skills.

Specified by:
getAssociatedSkills in class Task
Returns:
list of skills as strings