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 * Ignition of a motor. Source is the motor mount the motor of which has ignited.
26 IGNITION("Motor ignition"),
28 * When the motor has lifted off the ground.
32 * Launch rod has been cleared.
34 LAUNCHROD("Launch rod clearance"),
36 * Burnout of a motor. Source is the motor mount the motor of which has burnt out.
38 BURNOUT("Motor burnout"),
40 * Ejection charge of a motor fired. Source is the motor mount the motor of
41 * which has exploded its ejection charge.
43 EJECTION_CHARGE("Ejection charge"),
45 * Separation of a stage. Source is the stage which has separated all lower stages.
47 STAGE_SEPARATION("Stage separation"),
49 * Apogee has been reached.
53 * Opening of a recovery device. Source is the RecoveryComponent which has opened.
55 RECOVERY_DEVICE_DEPLOYMENT("Recovery device deployment"),
57 * Ground has been hit after flight.
59 GROUND_HIT("Ground hit"),
62 * End of simulation. Placing this to the queue will end the simulation.
64 SIMULATION_END("Simulation end"),
67 * A change in altitude has occurred. Data is a <code>Pair<Double,Double></code>
68 * which contains the old and new altitudes.
70 ALTITUDE("Altitude change");
72 private final String name;
73 private Type(String name) {
77 public String toString() {
82 private final Type type;
83 private final double time;
84 private final RocketComponent source;
85 private final Object data;
88 public FlightEvent(Type type, double time) {
89 this(type, time, null);
92 public FlightEvent(Type type, double time, RocketComponent source) {
93 this(type,time,source,null);
96 public FlightEvent(Type type, double time, RocketComponent source, Object data) {
105 public Type getType() {
109 public double getTime() {
113 public RocketComponent getSource() {
117 public Object getData() {
122 public FlightEvent resetSource() {
123 return new FlightEvent(type, time, null, data);
127 * Compares this event to another event depending on the event time. Secondary
128 * sorting is performed based on the event type ordinal.
131 public int compareTo(FlightEvent o) {
132 if (this.time < o.time)
134 if (this.time > o.time)
137 return this.type.ordinal() - o.type.ordinal();
141 public String toString() {
142 return "FlightEvent[type="+type.name()+",time="+time+",source="+source+"]";