1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.motor.Motor;
4 import net.sf.openrocket.simulation.FlightEvent;
5 import net.sf.openrocket.util.ChangeSource;
7 public interface MotorMount extends ChangeSource {
9 public static enum IgnitionEvent {
10 AUTOMATIC("Automatic (launch or ejection charge)") {
12 public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
13 int count = source.getRocket().getStageCount();
14 int stage = source.getStageNumber();
16 if (stage == count-1) {
17 return LAUNCH.isActivationEvent(e, source);
19 return EJECTION_CHARGE.isActivationEvent(e, source);
25 public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
26 return (e.getType() == FlightEvent.Type.LAUNCH);
29 EJECTION_CHARGE("First ejection charge of previous stage") {
31 public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
32 if (e.getType() != FlightEvent.Type.EJECTION_CHARGE)
35 int charge = e.getSource().getStageNumber();
36 int mount = source.getStageNumber();
37 return (mount+1 == charge);
40 BURNOUT("First burnout of previous stage") {
42 public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
43 if (e.getType() != FlightEvent.Type.BURNOUT)
46 int charge = e.getSource().getStageNumber();
47 int mount = source.getStageNumber();
48 return (mount+1 == charge);
53 public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
60 private final String description;
62 IgnitionEvent(String description) {
63 this.description = description;
66 public abstract boolean isActivationEvent(FlightEvent e, RocketComponent source);
69 public String toString() {
76 * Is the component currently a motor mount.
78 * @return whether the component holds a motor.
80 public boolean isMotorMount();
83 * Set whether the component is currently a motor mount.
85 public void setMotorMount(boolean mount);
89 * Return the motor for the motor configuration. May return <code>null</code>
90 * if no motor has been set. This method must return <code>null</code> if ID
91 * is <code>null</code> or if the ID is not valid for the current rocket
92 * (or if the component is not part of any rocket).
94 * @param id the motor configuration ID
95 * @return the motor, or <code>null</code> if not set.
97 public Motor getMotor(String id);
100 * Set the motor for the motor configuration. May be set to <code>null</code>
101 * to remove the motor.
103 * @param id the motor configuration ID
104 * @param motor the motor, or <code>null</code>.
106 public void setMotor(String id, Motor motor);
109 * Get the number of similar motors clustered.
111 * TODO: HIGH: This should not be used, since the components themselves can be clustered
113 * @return the number of motors.
116 public int getMotorCount();
121 * Return the ejection charge delay of given motor configuration.
122 * A "plugged" motor without an ejection charge is given by
123 * {@link Motor#PLUGGED} (<code>Double.POSITIVE_INFINITY</code>).
125 * @param id the motor configuration ID
126 * @return the ejection charge delay.
128 public double getMotorDelay(String id);
131 * Set the ejection change delay of the given motor configuration.
132 * The ejection charge is disable (a "plugged" motor) is set by
133 * {@link Motor#PLUGGED} (<code>Double.POSITIVE_INFINITY</code>).
135 * @param id the motor configuration ID
136 * @param delay the ejection charge delay.
138 public void setMotorDelay(String id, double delay);
142 * Return the event that ignites this motor.
144 * @return the {@link IgnitionEvent} that ignites this motor.
146 public IgnitionEvent getIgnitionEvent();
149 * Sets the event that ignites this motor.
151 * @param event the {@link IgnitionEvent} that ignites this motor.
153 public void setIgnitionEvent(IgnitionEvent event);
157 * Returns the ignition delay of this motor.
159 * @return the ignition delay
161 public double getIgnitionDelay();
164 * Sets the ignition delay of this motor.
166 * @param delay the ignition delay.
168 public void setIgnitionDelay(double delay);
172 * Return the distance that the motors hang outside this motor mount.
174 * @return the overhang length.
176 public double getMotorOverhang();
179 * Sets the distance that the motors hang outside this motor mount.
181 * @param overhang the overhang length.
183 public void setMotorOverhang(double overhang);
188 * Return the inner diameter of the motor mount.
190 * @return the inner diameter of the motor mount.
192 public double getMotorMountDiameter();