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

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

public class DriveGroundVehicle
extends OperateVehicle
implements java.io.Serializable

The Drive Ground Vehicle class is a task for driving a ground vehicle to a destination.

See Also:
Serialized Form

Field Summary
static java.lang.String AVOID_OBSTACLE
           
static java.lang.String WINCH_VEHICLE
           
 
Fields inherited from class org.mars_sim.msp.simulation.person.ai.task.OperateVehicle
backingUpDistance, BASE_ACCIDENT_CHANCE, isBackingUp, MOBILIZE
 
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
DriveGroundVehicle(Person person, GroundVehicle vehicle, Coordinates destination, MarsClock startTripTime, double startTripDistance)
          Default Constructor
DriveGroundVehicle(Person person, GroundVehicle vehicle, Coordinates destination, MarsClock startTripTime, double startTripDistance, java.lang.String startingPhase)
          Constructs with a given starting phase.
 
Method Summary
protected  void addExperience(double time)
          Adds experience to the person's skills used in this task.
protected  void checkForAccident(double time)
          Check if vehicle has had an accident.
 void endTask()
          Ends the task and performs any final actions.
 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.
protected  double getSpeed(Direction direction)
          Determine vehicle speed for a given direction.
protected  double getSpeedLightConditionModifier()
          Gets the lighting condition speed modifier.
protected  double getTerrainModifier()
          Gets the terrain speed modifier.
protected  double mobilizeVehicle(double time)
          Move the vehicle in its direction at its speed for the amount of time given.
protected  double performMappedPhase(double time)
          Performs the method mapped to the task's current phase.
protected  void updateVehicleElevationAltitude()
          Update vehicle with its current elevation or altitude.
 
Methods inherited from class org.mars_sim.msp.simulation.person.ai.task.OperateVehicle
getAverageVehicleSpeed, getDestination, getDistanceToDestination, getETA, getSpeedSkillModifier, getStartTripDistance, getStartTripTime, getVehicle, getVehicleElevation, mobilizeVehiclePhase, setDestination
 
Methods inherited from class org.mars_sim.msp.simulation.person.ai.task.Task
addPhase, compareTo, getCreateEvents, getCrowdingProbabilityModifier, getDescription, getDuration, getName, getPhase, getProbability, 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
 

Field Detail

AVOID_OBSTACLE

public static final java.lang.String AVOID_OBSTACLE
See Also:
Constant Field Values

WINCH_VEHICLE

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

DriveGroundVehicle

public DriveGroundVehicle(Person person,
                          GroundVehicle vehicle,
                          Coordinates destination,
                          MarsClock startTripTime,
                          double startTripDistance)
                   throws java.lang.Exception
Default Constructor

Parameters:
person - the person to perform the task
vehicle - the vehicle to be driven
destination - location to be driven to
startTripTime - the starting time of the trip
startTripDistance - the starting distance to destination for the trip
Throws:
java.lang.Exception - if task cannot be constructed.

DriveGroundVehicle

public DriveGroundVehicle(Person person,
                          GroundVehicle vehicle,
                          Coordinates destination,
                          MarsClock startTripTime,
                          double startTripDistance,
                          java.lang.String startingPhase)
                   throws java.lang.Exception
Constructs with a given starting phase.

Parameters:
person - the person to perform the task
vehicle - the vehicle to be driven
destination - location to be driven to
startTripTime - the starting time of the trip
startTripDistance - the starting distance to destination for the trip
startingPhase - the starting phase for the task
Throws:
java.lang.Exception - if task cannot be constructed.
Method Detail

performMappedPhase

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

Overrides:
performMappedPhase in class OperateVehicle
Parameters:
time - the amount of time the phase is to be performed.
Returns:
the remaining time after the phase has been performed.
Throws:
java.lang.Exception - if error in performing phase or if phase cannot be found.

mobilizeVehicle

protected double mobilizeVehicle(double time)
                          throws java.lang.Exception
Move the vehicle in its direction at its speed for the amount of time given. Stop if reached destination.

Overrides:
mobilizeVehicle in class OperateVehicle
Parameters:
time - the amount of time (ms) to drive.
Returns:
the amount of time (ms) left over after driving (if any)
Throws:
java.lang.Exception - of error mobilizing vehicle.

updateVehicleElevationAltitude

protected void updateVehicleElevationAltitude()
Update vehicle with its current elevation or altitude.

Specified by:
updateVehicleElevationAltitude in class OperateVehicle

getSpeed

protected double getSpeed(Direction direction)
Determine vehicle speed for a given direction.

Overrides:
getSpeed in class OperateVehicle
Parameters:
direction - the direction of travel
Returns:
speed in km/hr

getSpeedLightConditionModifier

protected double getSpeedLightConditionModifier()
Gets the lighting condition speed modifier.

Returns:
speed modifier (0D - 1D)

getTerrainModifier

protected double getTerrainModifier()
Gets the terrain speed modifier.

Returns:
speed modifier (0D - 1D)

checkForAccident

protected void checkForAccident(double time)
Check if vehicle has had an accident.

Specified by:
checkForAccident in class OperateVehicle
Parameters:
time - the amount of time vehicle is driven (millisols)

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

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.

endTask

public void endTask()
Ends the task and performs any final actions.

Overrides:
endTask in class OperateVehicle