javax.realtime.test.airplane
Class Airplane

java.lang.Object
  extended byjavax.realtime.test.airplane.Airplane

public class Airplane
extends java.lang.Object

Class modeling the airplane -- a central part of the embedding code for this example

Author:
gary

Field Summary
protected  Normal gearChangeDelay
          Pseudo random normal number generator, used for landing gear change delays.
 AbsoluteTime lastSpeedChange
          Time at which speed was last set.
 boolean localizerAlive
          True iff the localizer alive event has happened.
 boolean onGround
          True iff the airplane is on the ground.
 boolean spoilersArmed
          True iff spoilers are armed.
 
Constructor Summary
Airplane(int altitude)
          Constructor
 
Method Summary
 void changeFlaps(int newDegrees, AsyncEvent lightIndicator)
          Change the current flaps setting.
 void changeGear(AsyncEvent gearIndicator)
          Invert state of landing gear, i.e., from up to down, or vice-versa.
 int feetCovered(RelativeTime interval)
          Feet covered at current speed for given time interval
 java.lang.String gearString(boolean invert)
          Create a string conveying the status of the landing gear.
 int getFlapsDegrees()
          Return the current flaps setting in degrees
 boolean getGearDown()
          Return the state of the landing gear; true iff gear is down.
 long millisToCoverFeetAtCurrentSpeed(int feet)
          Calculate the time to cover a specified distance at the current speed.
 void printTimeDistanceAndAltitude()
          Prints prefix to log lines, including simulated time, distance to runway, and current altitude.
 int readAltitude()
          Read the airplane's current altitude.
 int readFeetToRunway()
          Make a dynamic calculation of the current feet to the runway.
 void setAltitude(int altitude)
          Set the airplane's current altitude, at level flight.
 void setAltitudePlan(int plannedAltitude, AbsoluteTime plannedAltitudeTime)
          Set the airplane's current altitude plan, i.e., to ascend or descend
 void setFeetToRunway(int feet)
          Sets the current feet to runway.
 void setFlaps(int degrees)
          Set flaps degrees directly, without simulating delay.
 void setGearDown(boolean gearDown)
          Set the state of the landing gear, without simulating delay.
 void setSpeed(int feetPerSecond)
          Set the current ground speed of the airplane.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastSpeedChange

public AbsoluteTime lastSpeedChange
Time at which speed was last set. If speed has never been set, equals null.


gearChangeDelay

protected Normal gearChangeDelay
Pseudo random normal number generator, used for landing gear change delays.


spoilersArmed

public boolean spoilersArmed
True iff spoilers are armed.


localizerAlive

public boolean localizerAlive
True iff the localizer alive event has happened.


onGround

public boolean onGround
True iff the airplane is on the ground. Initially false.

Constructor Detail

Airplane

public Airplane(int altitude)
Constructor

Parameters:
altitude - current altitude of the airplane
Method Detail

setAltitudePlan

public void setAltitudePlan(int plannedAltitude,
                            AbsoluteTime plannedAltitudeTime)
Set the airplane's current altitude plan, i.e., to ascend or descend

Parameters:
plannedAltitude - the target altitude
plannedAltitudeTime - the time at which the target altitude will be reached

setAltitude

public void setAltitude(int altitude)
Set the airplane's current altitude, at level flight.

Parameters:
altitude - the current altitude

readAltitude

public int readAltitude()
Read the airplane's current altitude. Note that if there is an altitude plan in effect, this will require extrapolation of last altitude known explicitly.

Returns:
the current altitude

getFlapsDegrees

public int getFlapsDegrees()
Return the current flaps setting in degrees

Returns:
the current flaps setting in degrees

changeFlaps

public void changeFlaps(int newDegrees,
                        AsyncEvent lightIndicator)
                 throws java.lang.InterruptedException
Change the current flaps setting. Note that this will require a delay of the invoking RealtimeThread, because actuation is not instantaneous.

Parameters:
newDegrees - the desired new flaps setting
lightIndicator - an event to fire when the flaps attain the desired setting; if null, simply return after the delay
Throws:
java.lang.InterruptedException

changeGear

public void changeGear(AsyncEvent gearIndicator)
                throws java.lang.InterruptedException
Invert state of landing gear, i.e., from up to down, or vice-versa. Action includes retraction of gear doors.

Note this will require a delay, which figures significantly in the accident scenario.

Parameters:
gearIndicator - an event to fire when gear change and door retraction are completed; if null, simply return after the delay.
Throws:
java.lang.InterruptedException

setFlaps

public void setFlaps(int degrees)
Set flaps degrees directly, without simulating delay. Can be used for initialization.

Parameters:
degrees - the current flaps degrees

getGearDown

public boolean getGearDown()
Return the state of the landing gear; true iff gear is down.

Returns:
true iff the landing gear is down

setGearDown

public void setGearDown(boolean gearDown)
Set the state of the landing gear, without simulating delay. Can be used for initialization.

Parameters:
gearDown -

gearString

public java.lang.String gearString(boolean invert)
Create a string conveying the status of the landing gear.

Parameters:
invert - if true, invert the state for reporting. This is handy for printing state requested before it is attained.
Returns:
up or down

printTimeDistanceAndAltitude

public void printTimeDistanceAndAltitude()
Prints prefix to log lines, including simulated time, distance to runway, and current altitude.


setFeetToRunway

public void setFeetToRunway(int feet)
Sets the current feet to runway. Used during initialization. Also record the current time, so that the distance to the runway can be extrapolated using the current airplane speed after some time has passed.

Parameters:
feet - the current feet to the runway.

readFeetToRunway

public int readFeetToRunway()
Make a dynamic calculation of the current feet to the runway. The distance and time of the last speed change are not updated; this will not be done until the next speed change.

Returns:
the feet to the runway.

setSpeed

public void setSpeed(int feetPerSecond)
Set the current ground speed of the airplane. Because the speed is changing, the prior extrapolation must be closed out by updating the feet to the runway and recording explicitly the current distance to the runway.

Parameters:
feetPerSecond - the new speed in feet per second

millisToCoverFeetAtCurrentSpeed

public long millisToCoverFeetAtCurrentSpeed(int feet)
Calculate the time to cover a specified distance at the current speed.

Parameters:
feet - the specified distance in feet
Returns:
the time required, in milliseconds

feetCovered

public int feetCovered(RelativeTime interval)
Feet covered at current speed for given time interval

Parameters:
interval - the time interval
Returns:
the feet covered during the interval