org.mars_sim.msp.simulation.vehicle
Class Vehicle

java.lang.Object
  extended by org.mars_sim.msp.simulation.Unit
      extended by org.mars_sim.msp.simulation.vehicle.Vehicle
All Implemented Interfaces:
java.io.Serializable, Malfunctionable
Direct Known Subclasses:
GroundVehicle, MockVehicle

public abstract class Vehicle
extends Unit
implements java.io.Serializable, Malfunctionable

The Vehicle class represents a generic vehicle. It keeps track of generic information about the vehicle. This class needs to be subclassed to represent a specific type of vehicle.

See Also:
Serialized Form

Field Summary
static java.lang.String EMERGENCY_BEACON_EVENT
           
static java.lang.String MAINTENANCE
           
static java.lang.String MALFUNCTION
           
protected  MalfunctionManager malfunctionManager
           
static java.lang.String MOVING
           
static java.lang.String OPERATOR_EVENT
           
static java.lang.String PARKED
           
static double RANGE_ERROR_MARGIN
           
static java.lang.String RESERVED_EVENT
           
static java.lang.String SPEED_EVENT
           
static java.lang.String STATUS_EVENT
           
static java.lang.String TOWED
           
 
Fields inherited from class org.mars_sim.msp.simulation.Unit
CONTAINER_UNIT_EVENT, DESCRIPTION_EVENT, LOCATION_EVENT, MASS_EVENT, NAME_EVENT
 
Constructor Summary
protected Vehicle(java.lang.String name, java.lang.String description, Settlement settlement, double baseSpeed, double baseMass, double fuelEfficiency)
          Constructor to be used for testing.
 
Method Summary
 void addDistanceLastMaintenance(double distance)
          Adds a distance (in km.) to the vehicle's distance since last maintenance.
 void addTotalDistanceTraveled(double distance)
          Adds a distance (in km.) to the vehicle's total distance traveled
 void addToTrail(Coordinates location)
          Adds a location to the vehicle's trail if appropriate.
 void clearDistanceLastMaintenance()
          Sets vehicle's distance since last maintenance to zero
 java.util.Collection<Person> getAffectedPeople()
          Gets a collection of people affected by this entity.
 double getBaseSpeed()
          Gets the base speed of vehicle
 Direction getDirection()
          Returns direction of vehicle (0 = north, clockwise in radians)
 double getDistanceLastMaintenance()
          Returns distance traveled by vehicle since last maintenance (in km.)
 double getEstimatedTravelDistancePerSol()
          Gets the estimated distance traveled in one sol.
 double getFuelEfficiency()
          Gets the fuel efficiency of the vehicle.
abstract  AmountResource getFuelType()
          Gets the resource type that this vehicle uses for fuel.
 MalfunctionManager getMalfunctionManager()
          Gets the unit's malfunction manager.
 VehicleOperator getOperator()
          Gets the operator of the vehicle (person or AI)
 double getRange()
          Gets the range of the vehicle
 Settlement getSettlement()
          Returns the current settlement vehicle is parked at.
 double getSpeed()
          Gets the speed of vehicle
 java.lang.String getStatus()
          Returns vehicle's current status
 double getTotalDistanceTraveled()
          Returns total distance traveled by vehicle (in km.)
 Vehicle getTowingVehicle()
          Gets the vehicle that is currently towing this vehicle.
 java.util.Collection<Coordinates> getTrail()
          Gets the vehicle's trail as a collection of coordinate locations.
abstract  boolean isAppropriateOperator(VehicleOperator operator)
          Checks if a particular operator is appropriate for a vehicle.
 boolean isEmergencyBeacon()
          Checks if the vehicle's emergency beacon is turned on.
 boolean isReserved()
          Checks if the vehicle is reserved for any reason.
 boolean isReservedForMaintenance()
          Checks if the vehicle is reserved for maintenance.
 boolean isReservedForMission()
          Checks if the vehicle is reserved for a mission.
 void setBaseSpeed(double speed)
          Sets the base speed of vehicle
 void setDirection(Direction direction)
          Sets the vehicle's facing direction (0 = north, clockwise in radians)
 void setEmergencyBeacon(boolean isOn)
          Sets the vehicle's emergency beacon on or off.
 void setOperator(VehicleOperator vehicleOperator)
          Sets the operator of the vehicle
 void setReservedForMaintenance(boolean reserved)
          Sets if the vehicle is reserved for maintenance or not.
 void setReservedForMission(boolean reserved)
          Sets if the vehicle is reserved for a mission or not.
 void setSpeed(double speed)
          Sets the vehicle's current speed
 void setTowingVehicle(Vehicle towingVehicle)
          Sets the vehicle that is currently towing this vehicle.
 void timePassing(double time)
          Time passing for vehicle.
 
Methods inherited from class org.mars_sim.msp.simulation.Unit
addUnitListener, fireUnitUpdate, fireUnitUpdate, getBaseMass, getContainerUnit, getCoordinates, getDescription, getInventory, getMass, getName, getTopContainerUnit, getUnitManager, removeUnitListener, setBaseMass, setContainerUnit, setCoordinates, setDescription, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mars_sim.msp.simulation.malfunction.Malfunctionable
getInventory, getName
 

Field Detail

STATUS_EVENT

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

SPEED_EVENT

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

OPERATOR_EVENT

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

EMERGENCY_BEACON_EVENT

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

RESERVED_EVENT

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

PARKED

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

MOVING

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

MALFUNCTION

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

MAINTENANCE

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

TOWED

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

RANGE_ERROR_MARGIN

public static final double RANGE_ERROR_MARGIN
See Also:
Constant Field Values

malfunctionManager

protected MalfunctionManager malfunctionManager
Constructor Detail

Vehicle

protected Vehicle(java.lang.String name,
                  java.lang.String description,
                  Settlement settlement,
                  double baseSpeed,
                  double baseMass,
                  double fuelEfficiency)
           throws java.lang.Exception
Constructor to be used for testing.

Parameters:
name - the vehicle's name
description - the configuration description of the vehicle.
settlement - the settlement the vehicle is parked at.
baseSpeed - the base speed of the vehicle (kph)
baseMass - the base mass of the vehicle (kg)
fuelEfficiency - the fuel efficiency of the vehicle (km/kg)
Throws:
java.lang.Exception - if error constructing vehicle
Method Detail

getStatus

public java.lang.String getStatus()
Returns vehicle's current status

Returns:
the vehicle's current status

isReserved

public boolean isReserved()
Checks if the vehicle is reserved for any reason.

Returns:
true if vehicle is currently reserved

isReservedForMission

public boolean isReservedForMission()
Checks if the vehicle is reserved for a mission.

Returns:
true if vehicle is reserved for a mission.

setReservedForMission

public void setReservedForMission(boolean reserved)
Sets if the vehicle is reserved for a mission or not.

Parameters:
reserved - the vehicle's reserved for mission status

isReservedForMaintenance

public boolean isReservedForMaintenance()
Checks if the vehicle is reserved for maintenance.

Returns:
true if reserved for maintenance.

setReservedForMaintenance

public void setReservedForMaintenance(boolean reserved)
Sets if the vehicle is reserved for maintenance or not.

Parameters:
reserved - true if reserved for maintenance

setTowingVehicle

public void setTowingVehicle(Vehicle towingVehicle)
Sets the vehicle that is currently towing this vehicle.

Parameters:
towingVehicle - the vehicle

getTowingVehicle

public Vehicle getTowingVehicle()
Gets the vehicle that is currently towing this vehicle.

Returns:
towing vehicle

getSpeed

public double getSpeed()
Gets the speed of vehicle

Returns:
the vehicle's speed (in km/hr)

setSpeed

public void setSpeed(double speed)
Sets the vehicle's current speed

Parameters:
speed - the vehicle's speed (in km/hr)

getBaseSpeed

public double getBaseSpeed()
Gets the base speed of vehicle

Returns:
the vehicle's base speed (in km/hr)

setBaseSpeed

public void setBaseSpeed(double speed)
Sets the base speed of vehicle

Parameters:
speed - the vehicle's base speed (in km/hr)

getRange

public double getRange()
                throws java.lang.Exception
Gets the range of the vehicle

Returns:
the range of the vehicle (in km)
Throws:
java.lang.Exception - if error getting range.

getFuelEfficiency

public double getFuelEfficiency()
Gets the fuel efficiency of the vehicle.

Returns:
fuel efficiency (km/kg)

getTotalDistanceTraveled

public double getTotalDistanceTraveled()
Returns total distance traveled by vehicle (in km.)

Returns:
the total distanced traveled by the vehicle (in km)

addTotalDistanceTraveled

public void addTotalDistanceTraveled(double distance)
Adds a distance (in km.) to the vehicle's total distance traveled

Parameters:
distance - distance to add to total distance traveled (in km)

getDistanceLastMaintenance

public double getDistanceLastMaintenance()
Returns distance traveled by vehicle since last maintenance (in km.)

Returns:
distance traveled by vehicle since last maintenance (in km)

addDistanceLastMaintenance

public void addDistanceLastMaintenance(double distance)
Adds a distance (in km.) to the vehicle's distance since last maintenance. Set distanceMark to true if vehicle is due for maintenance.

Parameters:
distance - distance to add (in km)

clearDistanceLastMaintenance

public void clearDistanceLastMaintenance()
Sets vehicle's distance since last maintenance to zero


getDirection

public Direction getDirection()
Returns direction of vehicle (0 = north, clockwise in radians)

Returns:
the direction the vehicle is traveling (in radians)

setDirection

public void setDirection(Direction direction)
Sets the vehicle's facing direction (0 = north, clockwise in radians)

Parameters:
direction - the direction the vehicle is travleling (in radians)

getOperator

public VehicleOperator getOperator()
Gets the operator of the vehicle (person or AI)

Returns:
the vehicle operator

setOperator

public void setOperator(VehicleOperator vehicleOperator)
Sets the operator of the vehicle

Parameters:
vehicleOperator - the vehicle operator

isAppropriateOperator

public abstract boolean isAppropriateOperator(VehicleOperator operator)
Checks if a particular operator is appropriate for a vehicle.

Parameters:
operator - the operator to check
Returns:
true if appropriate operator for this vehicle.

getSettlement

public Settlement getSettlement()
Returns the current settlement vehicle is parked at. Returns null if vehicle is not currently parked at a settlement.

Returns:
the settlement the vehicle is parked at

getMalfunctionManager

public MalfunctionManager getMalfunctionManager()
Gets the unit's malfunction manager.

Specified by:
getMalfunctionManager in interface Malfunctionable
Returns:
malfunction manager

timePassing

public void timePassing(double time)
                 throws java.lang.Exception
Time passing for vehicle.

Overrides:
timePassing in class Unit
Parameters:
time - the amount of time passing (millisols)
Throws:
java.lang.Exception - if error during time.

getAffectedPeople

public java.util.Collection<Person> getAffectedPeople()
Gets a collection of people affected by this entity.

Specified by:
getAffectedPeople in interface Malfunctionable
Returns:
person collection

getTrail

public java.util.Collection<Coordinates> getTrail()
Gets the vehicle's trail as a collection of coordinate locations.

Returns:
trail collection

addToTrail

public void addToTrail(Coordinates location)
Adds a location to the vehicle's trail if appropriate.

Parameters:
location - location to be added to trail

getFuelType

public abstract AmountResource getFuelType()
Gets the resource type that this vehicle uses for fuel.

Returns:
resource type

getEstimatedTravelDistancePerSol

public double getEstimatedTravelDistancePerSol()
Gets the estimated distance traveled in one sol.

Returns:
distance traveled (km)

isEmergencyBeacon

public boolean isEmergencyBeacon()
Checks if the vehicle's emergency beacon is turned on.

Returns:
true if beacon is on.

setEmergencyBeacon

public void setEmergencyBeacon(boolean isOn)
Sets the vehicle's emergency beacon on or off.

Parameters:
isOn - true if beacon is on.