org.mars_sim.msp.simulation.person.ai.mission
Class TravelMission

java.lang.Object
  extended by org.mars_sim.msp.simulation.person.ai.mission.Mission
      extended by org.mars_sim.msp.simulation.person.ai.mission.TravelMission
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
VehicleMission

public abstract class TravelMission
extends Mission

A mission that involves traveling along a series of navpoints.

See Also:
Serialized Form

Field Summary
static java.lang.String AT_NAVPOINT
           
static java.lang.String DISTANCE_EVENT
           
static java.lang.String NAVPOINTS_EVENT
           
static java.lang.String TRAVEL_STATUS_EVENT
           
static java.lang.String TRAVEL_TO_NAVPOINT
           
 
Fields inherited from class org.mars_sim.msp.simulation.person.ai.mission.Mission
ADD_MEMBER_EVENT, ASSOCIATED_SETTLEMENT_EVENT, CAPACITY_EVENT, DESCRIPTION_EVENT, END_MISSION_EVENT, MIN_PEOPLE_EVENT, NAME_EVENT, PHASE_DESCRIPTION_EVENT, PHASE_EVENT, REMOVE_MEMBER_EVENT
 
Constructor Summary
protected TravelMission(java.lang.String name, Person startingPerson, int minPeople)
          Constructor (note: The constructor handles setting the initial nav point.)
 
Method Summary
 void addNavpoint(NavPoint navPoint)
          Adds a navpoint to the mission.
 void clearRemainingNavpoints()
          Clears out any unreached nav points.
 double getCurrentLegDistance()
          Gets the distance of the current leg of the mission, or 0 if not in the travelling phase.
 double getCurrentLegRemainingDistance()
          Gets the remaining distance for the current leg of the mission.
protected  MarsClock getCurrentLegStartingTime()
          Gets the starting time of the current leg of the mission.
 NavPoint getCurrentNavpoint()
          Gets the current navpoint the mission is stopped at.
 int getCurrentNavpointIndex()
          Gets the index of the current navpoint the mission is stopped at.
abstract  double getEstimatedRemainingMissionTime(boolean useBuffer)
          Gets the estimated time remaining for the mission.
abstract  double getEstimatedTripTime(boolean useBuffer, double distance)
          Gets the estimated time for a trip.
abstract  MarsClock getLegETA()
          Gets the estimated time of arrival (ETA) for the current leg of the mission.
 NavPoint getNavpoint(int index)
          Gets the navpoint at an index value.
 int getNavpointIndex(NavPoint navpoint)
          Gets the index of a navpoint.
 NavPoint getNextNavpoint()
          Gets the mission's next navpoint.
 int getNextNavpointIndex()
          Gets the mission's next navpoint index.
 int getNumberOfNavpoints()
          Gets the number of navpoints on the trip.
 NavPoint getPreviousNavpoint()
          Gets the last navpoint reached.
 double getTotalDistance()
          Gets the total distance of the trip.
abstract  double getTotalDistanceTravelled()
          Gets the total distance travelled during the mission so far.
 double getTotalRemainingDistance()
          Gets the total remaining distance to travel in the mission.
 java.lang.String getTravelStatus()
          Get the travel mission's current status.
protected abstract  void performTravelPhase(Person person)
          Performs the travel phase of the mission.
protected  void reachedNextNode()
          The mission has reached the next navpoint.
protected  void setNavpoint(int index, NavPoint navPoint)
          Sets a nav point for the mission.
 void setNextNavpointIndex(int newNavIndex)
          Set the next navpoint index.
protected  void startTravelToNextNode()
          Starts travel to the next navpoint in the mission.
abstract  void updateTravelDestination()
          Update mission to the next navpoint destination.
 
Methods inherited from class org.mars_sim.msp.simulation.person.ai.mission.Mission
addMissionListener, addPerson, addPhase, assignTask, associateAllMembersWithSettlement, determineNewPhase, endMission, fireMissionUpdate, fireMissionUpdate, getAssociatedSettlement, getCurrentMissionLocation, getDescription, getEquipmentNeededForRemainingMission, getMinPeople, getMissionCapacity, getMissionQualification, getName, getNewMissionProbability, getPeople, getPeopleNumber, getPhase, getPhaseDescription, getPhaseEnded, getResourcesNeededForRemainingMission, hasDangerousMedicalProblems, hasDangerousMedicalProblemsAllCrew, hasEmergency, hasEmergencyAllCrew, hasPerson, isCapableOfMission, isDone, performMission, performPhase, recruitPeopleForMission, removeMissionListener, removePerson, setDescription, setMinPeople, setMissionCapacity, setName, setPhase, setPhaseDescription, setPhaseEnded, timePassing, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRAVEL_STATUS_EVENT

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

NAVPOINTS_EVENT

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

DISTANCE_EVENT

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

AT_NAVPOINT

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

TRAVEL_TO_NAVPOINT

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

TravelMission

protected TravelMission(java.lang.String name,
                        Person startingPerson,
                        int minPeople)
                 throws MissionException
Constructor (note: The constructor handles setting the initial nav point.)

Parameters:
name - the name of the mission.
startingPerson - the person starting the mission.
minPeople - the minimum number of people required for mission.
Throws:
MissionException - if error constructing mission.
Method Detail

addNavpoint

public final void addNavpoint(NavPoint navPoint)
Adds a navpoint to the mission.

Parameters:
navPoint - the new nav point location to be added.
Throws:
java.lang.IllegalArgumentException - if location is null.

setNavpoint

protected final void setNavpoint(int index,
                                 NavPoint navPoint)
Sets a nav point for the mission.

Parameters:
index - the index in the list of nav points.
navPoint - the new navpoint
Throws:
java.lang.IllegalArgumentException - if location is null or index < 0.

clearRemainingNavpoints

public final void clearRemainingNavpoints()
Clears out any unreached nav points.


getPreviousNavpoint

public final NavPoint getPreviousNavpoint()
Gets the last navpoint reached.

Returns:
navpoint

getNextNavpoint

public final NavPoint getNextNavpoint()
Gets the mission's next navpoint.

Returns:
navpoint or null if no more navpoints.

getNextNavpointIndex

public final int getNextNavpointIndex()
Gets the mission's next navpoint index.

Returns:
navpoint index or -1 if none.

setNextNavpointIndex

public final void setNextNavpointIndex(int newNavIndex)
                                throws MissionException
Set the next navpoint index.

Parameters:
newNavIndex - the next navpoint index.
Throws:
MissionException - if the new navpoint is out of range.

getNavpoint

public final NavPoint getNavpoint(int index)
Gets the navpoint at an index value.

Parameters:
index - the index value
Returns:
navpoint
Throws:
IllegaArgumentException - if no navpoint at that index.

getNavpointIndex

public final int getNavpointIndex(NavPoint navpoint)
Gets the index of a navpoint.

Parameters:
navpoint - the navpoint
Returns:
index or -1 if navpoint isn't in the trip.

getNumberOfNavpoints

public final int getNumberOfNavpoints()
Gets the number of navpoints on the trip.

Returns:
number of navpoints

getCurrentNavpoint

public final NavPoint getCurrentNavpoint()
Gets the current navpoint the mission is stopped at.

Returns:
navpoint or null if mission is not stopped at a navpoint.

getCurrentNavpointIndex

public final int getCurrentNavpointIndex()
Gets the index of the current navpoint the mission is stopped at.

Returns:
index of current navpoint or -1 if mission is not stopped at a navpoint.

getTravelStatus

public final java.lang.String getTravelStatus()
Get the travel mission's current status.

Returns:
travel status as a String.

startTravelToNextNode

protected final void startTravelToNextNode()
                                    throws MissionException
Starts travel to the next navpoint in the mission.

Throws:
MissionException - if no more navpoints.

reachedNextNode

protected final void reachedNextNode()
                              throws MissionException
The mission has reached the next navpoint.

Throws:
MisisonException - if error determining mission location.
MissionException

performTravelPhase

protected abstract void performTravelPhase(Person person)
                                    throws MissionException
Performs the travel phase of the mission.

Parameters:
person - the person currently performing the mission.
Throws:
MissionException - if error performing travel phase.

getCurrentLegStartingTime

protected final MarsClock getCurrentLegStartingTime()
Gets the starting time of the current leg of the mission.

Returns:
starting time

getCurrentLegDistance

public final double getCurrentLegDistance()
Gets the distance of the current leg of the mission, or 0 if not in the travelling phase.

Returns:
distance (km)

getCurrentLegRemainingDistance

public final double getCurrentLegRemainingDistance()
                                            throws MissionException
Gets the remaining distance for the current leg of the mission.

Returns:
distance (km) or 0 if not in the travelling phase.
Throws:
MissionException - if error determining distance.

getTotalDistance

public final double getTotalDistance()
Gets the total distance of the trip.

Returns:
total distance (km)

getTotalRemainingDistance

public final double getTotalRemainingDistance()
                                       throws MissionException
Gets the total remaining distance to travel in the mission.

Returns:
distance (km).
Throws:
MissionException - if error determining distance.

getTotalDistanceTravelled

public abstract double getTotalDistanceTravelled()
Gets the total distance travelled during the mission so far.

Returns:
distance (km)

getLegETA

public abstract MarsClock getLegETA()
Gets the estimated time of arrival (ETA) for the current leg of the mission.

Returns:
time (MarsClock) or null if not applicable.

getEstimatedRemainingMissionTime

public abstract double getEstimatedRemainingMissionTime(boolean useBuffer)
                                                 throws MissionException
Gets the estimated time remaining for the mission.

Parameters:
useBuffer - use a time buffer in estimation if true.
Returns:
time (millisols)
Throws:
MissionException

getEstimatedTripTime

public abstract double getEstimatedTripTime(boolean useBuffer,
                                            double distance)
                                     throws MissionException
Gets the estimated time for a trip.

Parameters:
useBuffer - use time buffers in estimation if true.
distance - the distance of the trip.
Returns:
time (millisols)
Throws:
MissionException

updateTravelDestination

public abstract void updateTravelDestination()
Update mission to the next navpoint destination.