org.mars_sim.msp.core.vehicle
Class Vehicle

java.lang.Object
  extended by org.mars_sim.msp.core.Unit
      extended by org.mars_sim.msp.core.vehicle.Vehicle
All Implemented Interfaces:
Serializable, Comparable<Unit>, LocalBoundedObject, Malfunctionable, Salvagable
Direct Known Subclasses:
GroundVehicle

public abstract class Vehicle
extends Unit
implements Serializable, Malfunctionable, Salvagable, LocalBoundedObject

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 String EMERGENCY_BEACON_EVENT
           
static String MAINTENANCE
           
static String MALFUNCTION
           
protected  MalfunctionManager malfunctionManager
           
static String MOVING
           
static String OPERATOR_EVENT
           
static String PARKED
           
static double RANGE_ERROR_MARGIN
           
static String RESERVED_EVENT
           
static String SPEED_EVENT
           
static String STATUS_EVENT
           
static String TOWED
           
 
Fields inherited from class org.mars_sim.msp.core.Unit
CONTAINER_UNIT_EVENT, DESCRIPTION_EVENT, LOCATION_EVENT, MASS_EVENT, NAME_EVENT
 
Constructor Summary
protected Vehicle(String name, 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
 void destroy()
          Prepare object for garbage collection.
abstract  void determinedSettlementParkedLocationAndFacing()
          Set initial parked location and facing at settlement.
 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 getFacing()
          Gets the object's facing.
 double getFuelEfficiency()
          Gets the fuel efficiency of the vehicle.
abstract  AmountResource getFuelType()
          Gets the resource type that this vehicle uses for fuel.
 double getLength()
          Gets the object's length.
 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
 SalvageInfo getSalvageInfo()
          Gets the salvage info.
 Settlement getSettlement()
          Returns the current settlement vehicle is parked at.
 double getSpeed()
          Gets the speed of vehicle
 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.
 Collection<Coordinates> getTrail()
          Gets the vehicle's trail as a collection of coordinate locations.
 double getWidth()
          Gets the object's width.
 double getXLocation()
          Gets the X location of the object from the local area's center point.
 double getYLocation()
          Gets the Y location of the object from the local area's center point.
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.
 boolean isSalvaged()
          Checks if the item is salvaged.
 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 setParkedLocation(double xLocation, double yLocation, double facing)
          Sets the location and facing of the vehicle when parked at a settlement.
 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 startSalvage(SalvageProcessInfo info, Settlement settlement)
          Indicate the start of a salvage process on the item.
 void timePassing(double time)
          Time passing for vehicle.
 
Methods inherited from class org.mars_sim.msp.core.Unit
addUnitListener, compareTo, fireUnitUpdate, fireUnitUpdate, getBaseMass, getContainerUnit, getCoordinates, getDescription, getInventory, getMass, getName, getTopContainerUnit, getUnitManager, hasUnitListener, 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.core.malfunction.Malfunctionable
getInventory, getName
 

Field Detail

STATUS_EVENT

public static final String STATUS_EVENT
See Also:
Constant Field Values

SPEED_EVENT

public static final String SPEED_EVENT
See Also:
Constant Field Values

OPERATOR_EVENT

public static final String OPERATOR_EVENT
See Also:
Constant Field Values

EMERGENCY_BEACON_EVENT

public static final String EMERGENCY_BEACON_EVENT
See Also:
Constant Field Values

RESERVED_EVENT

public static final String RESERVED_EVENT
See Also:
Constant Field Values

PARKED

public static final String PARKED
See Also:
Constant Field Values

MOVING

public static final String MOVING
See Also:
Constant Field Values

MALFUNCTION

public static final String MALFUNCTION
See Also:
Constant Field Values

MAINTENANCE

public static final String MAINTENANCE
See Also:
Constant Field Values

TOWED

public static final 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(String name,
                  String description,
                  Settlement settlement,
                  double baseSpeed,
                  double baseMass,
                  double fuelEfficiency)
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:
Exception - if error constructing vehicle
Method Detail

getWidth

public double getWidth()
Description copied from interface: LocalBoundedObject
Gets the object's width.

Specified by:
getWidth in interface LocalBoundedObject
Returns:
width (meters).

getLength

public double getLength()
Description copied from interface: LocalBoundedObject
Gets the object's length.

Specified by:
getLength in interface LocalBoundedObject
Returns:
length (meters).

getXLocation

public double getXLocation()
Description copied from interface: LocalBoundedObject
Gets the X location of the object from the local area's center point.

Specified by:
getXLocation in interface LocalBoundedObject
Returns:
X location (meters from local center point - West: positive, East: negative).

getYLocation

public double getYLocation()
Description copied from interface: LocalBoundedObject
Gets the Y location of the object from the local area's center point.

Specified by:
getYLocation in interface LocalBoundedObject
Returns:
Y location (meters from local center point - North: positive, South: negative).

getFacing

public double getFacing()
Description copied from interface: LocalBoundedObject
Gets the object's facing.

Specified by:
getFacing in interface LocalBoundedObject
Returns:
facing (degrees from North clockwise).

setParkedLocation

public void setParkedLocation(double xLocation,
                              double yLocation,
                              double facing)
Sets the location and facing of the vehicle when parked at a settlement.

Parameters:
xLocation - the x location (meters from settlement center - West: positive, East: negative).
yLocation - the y location (meters from settlement center - North: positive, South: negative).
facing - (degrees from North clockwise).

getStatus

public 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()
Gets the range of the vehicle

Returns:
the range of the vehicle (in km)
Throws:
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)
Time passing for vehicle.

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

getAffectedPeople

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

Specified by:
getAffectedPeople in interface Malfunctionable
Returns:
person collection

getTrail

public 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.

isSalvaged

public boolean isSalvaged()
Checks if the item is salvaged.

Specified by:
isSalvaged in interface Salvagable
Returns:
true if salvaged.

startSalvage

public void startSalvage(SalvageProcessInfo info,
                         Settlement settlement)
Indicate the start of a salvage process on the item.

Specified by:
startSalvage in interface Salvagable
Parameters:
info - the salvage process info.
settlement - the settlement where the salvage is taking place.

getSalvageInfo

public SalvageInfo getSalvageInfo()
Gets the salvage info.

Specified by:
getSalvageInfo in interface Salvagable
Returns:
salvage info or null if item not salvaged.

determinedSettlementParkedLocationAndFacing

public abstract void determinedSettlementParkedLocationAndFacing()
Set initial parked location and facing at settlement.


destroy

public void destroy()
Description copied from class: Unit
Prepare object for garbage collection.

Overrides:
destroy in class Unit


Copyright © 2009-2013. All Rights Reserved.