1 package net.sf.openrocket.simulation;
3 import net.sf.openrocket.rocketcomponent.RocketComponent;
7 * A class that defines an event during the flight of a rocket.
9 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
11 public class FlightEvent implements Comparable<FlightEvent> {
14 * The type of the flight event.
16 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
24 * When the motor has lifted off the ground.
28 * Launch rod has been cleared.
32 * Ignition of a motor. Source is the motor mount the motor of which has ignited.
36 * Burnout of a motor. Source is the motor mount the motor of which has burnt out.
40 * Ejection charge of a motor fired. Source is the motor mount the motor of
41 * which has exploded its ejection charge.
45 * Opening of a recovery device. Source is the RecoveryComponent which has opened.
47 RECOVERY_DEVICE_DEPLOYMENT,
49 * Separation of a stage. Source is the stage which has separated all lower stages.
53 * Apogee has been reached.
57 * Ground has been hit after flight.
62 * End of simulation. Placing this to the queue will end the simulation.
67 * A change in altitude has occurred. Data is a <code>Pair<Double,Double></code>
68 * which contains the old and new altitudes.
73 private final Type type;
74 private final double time;
75 private final RocketComponent source;
76 private final Object data;
79 public FlightEvent(Type type, double time) {
80 this(type, time, null);
83 public FlightEvent(Type type, double time, RocketComponent source) {
84 this(type,time,source,null);
87 public FlightEvent(Type type, double time, RocketComponent source, Object data) {
96 public Type getType() {
100 public double getTime() {
104 public RocketComponent getSource() {
108 public Object getData() {
113 public FlightEvent resetSource() {
114 return new FlightEvent(type, time, null, data);
118 * Compares this event to another event depending on the event time. Secondary
119 * sorting is performed based on the event type ordinal.
122 public int compareTo(FlightEvent o) {
123 if (this.time < o.time)
125 if (this.time > o.time)
128 return this.type.ordinal() - o.type.ordinal();
132 public String toString() {
133 return "FlightEvent[type="+type.toString()+",time="+time+",source="+source+"]";