cad.simcad.worldsimulator.objects.units
Class Ambulance

java.lang.Object
  |
  +--cad.simcad.worldsimulator.objects.SimulatedObject
        |
        +--cad.simcad.worldsimulator.objects.units.MyUnit
              |
              +--cad.simcad.worldsimulator.objects.units.Ambulance
All Implemented Interfaces:
Drawable2DObject, PathUser, java.io.Serializable, SimAmbulance, SimObject

public class Ambulance
extends MyUnit
implements SimAmbulance

Implementation of SimAmbulance

Version:
1.0
Author:
Charles-Philip Bentley
See Also:
Serialized Form

Field Summary
protected  boolean _autoProcess
           
protected  Incident _currentIncident
           
protected  EmergencyVehicule _ev
           
protected  GPSPosition _gp
           
protected  GPSSim _gps
           
protected  MDTSim _mdt
           
protected  boolean _nextToMyIncident
           
static int ARRIVED
           
static int FREE
           
static int IN_MISSION
           
static int UNAVAILABLE
           
 
Fields inherited from class cad.simcad.worldsimulator.objects.units.MyUnit
_baseTurnIncrement, _boundingRadius, _pp, _previousOne, _recomputing, _savedMovPoints, _state, _uc, _um, _velocity, IncrementWaypoint, ReachedGoal, WaitingForPath
 
Fields inherited from class cad.simcad.worldsimulator.objects.SimulatedObject
_am, _className, _height, _id, _name, _om, _owner, _serial, _sime, _stateId, _width
 
Constructor Summary
Ambulance(SimEnvironment sime, PathPlace mp, UnitMediator um, Owner owner)
          Creates new Ambulance
 
Method Summary
 void autoProcessIndicentArrival()
           
 boolean getAutoProcess()
          Returns true if Ambulance process incidents automatically
 double getDeformFactor()
          Returns the deform factor of the Path user.
 EmergencyVehicule getEmergencyVehicule()
          Returns the EmergencyVehicule for this Ambulance
 GPSSim getGPSSim()
          Returns the simulated GPS of this ambulance
 double getMaxSteepNessRatio()
          Return the maximum slope ratio the PathUser can walk on.
 MDTSim getMDTSim()
          Returns the simulated MDT of this ambulance
 void manualProcessIncidentArrival()
           
 void move()
          Top of movement state loop: { If we're in IncrementWaypoint state: Increment our waypoint.
 void processIndicent(Incident p)
          Ask the SimAmbulance to process an Incident
 void processIndicentPlace()
          Ambulance moves to the Place of the Incident if it has one in cache
 void processIndicentPlace(Place p)
           
 void setAutoProcess(boolean b)
          Ask the SimAmbulance to process an Incident automatically or not
 void setGPSSim(GPSSim gps)
          Set the simulated GPS of this ambulance
 void setMDTSim(MDTSim mdt)
          Set the simulated MDT of this ambulance
 java.lang.String toString()
           
 
Methods inherited from class cad.simcad.worldsimulator.objects.units.MyUnit
debug, firePathComputed, getBoundingCircleRadius, getCurrentPathPlace, getHeight, getMiniMapColor, getObjectType, getOwner, getUnitControler, getVelocity, getWidth, getX, getY, isCollision, resolveNewMove, setState, setVelocity, stopObject, stopUnit, takeTurn, updateStateId
 
Methods inherited from class cad.simcad.worldsimulator.objects.SimulatedObject
getClassName, getId, getName, getSerialNumber, getStateId, setStateId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface cad.simcad.objectserver.spec.sim.SimAmbulance
getVelocity, setVelocity
 
Methods inherited from interface cad.simcad.objectserver.spec.sim.SimObject
getBoundingCircleRadius, getClassName, getCurrentPathPlace, getHeight, getId, getName, getObjectType, getSerialNumber, getStateId, getWidth, setStateId, stopObject, takeTurn
 
Methods inherited from interface cad.simcad.objectserver.spec.pathfinding.PathUser
getId, getName
 

Field Detail

IN_MISSION

public static int IN_MISSION

FREE

public static int FREE

UNAVAILABLE

public static int UNAVAILABLE

ARRIVED

public static int ARRIVED

_mdt

protected MDTSim _mdt

_gps

protected GPSSim _gps

_ev

protected EmergencyVehicule _ev

_gp

protected GPSPosition _gp

_autoProcess

protected boolean _autoProcess

_currentIncident

protected Incident _currentIncident

_nextToMyIncident

protected boolean _nextToMyIncident
Constructor Detail

Ambulance

public Ambulance(SimEnvironment sime,
                 PathPlace mp,
                 UnitMediator um,
                 Owner owner)
Creates new Ambulance

Method Detail

getMaxSteepNessRatio

public double getMaxSteepNessRatio()
Description copied from interface: PathUser
Return the maximum slope ratio the PathUser can walk on.

Specified by:
getMaxSteepNessRatio in interface PathUser
Returns:
double value

getDeformFactor

public double getDeformFactor()
Returns the deform factor of the Path user. The Deform factor is a ratio. 0 means the PathUser shrink completely 1 means the PathUser is enabled to shrink 0.5 means the PathUser can shrink to half its size

Specified by:
getDeformFactor in interface PathUser
Returns:
double value

getGPSSim

public GPSSim getGPSSim()
Returns the simulated GPS of this ambulance

Specified by:
getGPSSim in interface SimAmbulance
Pre:
-
Returns:
a MDTSim object
Post:
-

getMDTSim

public MDTSim getMDTSim()
Returns the simulated MDT of this ambulance

Specified by:
getMDTSim in interface SimAmbulance
Pre:
-
Returns:
a MDTSim object
Post:
-

getEmergencyVehicule

public EmergencyVehicule getEmergencyVehicule()
Description copied from interface: SimAmbulance
Returns the EmergencyVehicule for this Ambulance

Specified by:
getEmergencyVehicule in interface SimAmbulance

move

public void move()
Description copied from class: MyUnit
Top of movement state loop: { If we're in IncrementWaypoint state: Increment our waypoint. If we're on a patrol Grab the next waypoint as defined by the patrol direction. Set state to WaitingForPath. Else If we're out of waypoints Set state to ReachedGoal. Else Set state to WaitingForPath. If we're in ReachedGoal state: Make the appropriate notifications (if any). We're done. Stop the walking animation. Exit function. If we're in WaitingForPath state: Find a path and save it. If we could not find one We've failed. Exit function. Calculate the direction we need to head in to get to our desired waypoint. Modify that direction by any limitations such as turn radius. Using that new direction, calculate where we'll end up after this move. If that new position causes a collision Set state to WaitingForPath. Jump back to the top of the loop. Using the current and future position: If we're closer to the waypoint before moving Set state to IncrementWaypoint Go back to top of loop. If we're going to jump over the waypoint during this move Set state to IncrementWaypoint. Break out of loop. } Set the accelerations accordingly. Do the actual move. Set or update any animation hooks that we might have. Update our predicted positions

Overrides:
move in class MyUnit

autoProcessIndicentArrival

public void autoProcessIndicentArrival()
Post:
the Ambulance has no more incident in its lis

manualProcessIncidentArrival

public void manualProcessIncidentArrival()

setGPSSim

public void setGPSSim(GPSSim gps)
Set the simulated GPS of this ambulance

Specified by:
setGPSSim in interface SimAmbulance
Pre:
-
Post:
-

setMDTSim

public void setMDTSim(MDTSim mdt)
Set the simulated MDT of this ambulance

Specified by:
setMDTSim in interface SimAmbulance
Pre:
-
Post:
-

setAutoProcess

public void setAutoProcess(boolean b)
Description copied from interface: SimAmbulance
Ask the SimAmbulance to process an Incident automatically or not

Specified by:
setAutoProcess in interface SimAmbulance

getAutoProcess

public boolean getAutoProcess()
Description copied from interface: SimAmbulance
Returns true if Ambulance process incidents automatically

Specified by:
getAutoProcess in interface SimAmbulance
Returns:
boolean value

processIndicent

public void processIndicent(Incident p)
Description copied from interface: SimAmbulance
Ask the SimAmbulance to process an Incident

Specified by:
processIndicent in interface SimAmbulance

processIndicentPlace

public void processIndicentPlace(Place p)

processIndicentPlace

public void processIndicentPlace()
Description copied from interface: SimAmbulance
Ambulance moves to the Place of the Incident if it has one in cache

Specified by:
processIndicentPlace in interface SimAmbulance
Returns:
boolean value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Logo

With the help of www.sourceforge.net and www.info.ucl.ac.be