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>.
93 * @param id the motor configuration ID
94 * @return the motor, or <code>null</code> if not set.
96 public Motor getMotor(String id);
99 * Set the motor for the motor configuration. May be set to <code>null</code>
100 * to remove the motor.
102 * @param id the motor configuration ID
103 * @param motor the motor, or <code>null</code>.
105 public void setMotor(String id, Motor motor);
108 * Get the number of similar motors clustered.
110 * @return the number of motors.
112 public int getMotorCount();
117 * Return the ejection charge delay of given motor configuration.
118 * A "plugged" motor without an ejection charge is given by
119 * {@link Motor#PLUGGED} (<code>Double.POSITIVE_INFINITY</code>).
121 * @param id the motor configuration ID
122 * @return the ejection charge delay.
124 public double getMotorDelay(String id);
127 * Set the ejection change delay of the given motor configuration.
128 * The ejection charge is disable (a "plugged" motor) is set by
129 * {@link Motor#PLUGGED} (<code>Double.POSITIVE_INFINITY</code>).
131 * @param id the motor configuration ID
132 * @param delay the ejection charge delay.
134 public void setMotorDelay(String id, double delay);
138 * Return the event that ignites this motor.
140 * @return the {@link IgnitionEvent} that ignites this motor.
142 public IgnitionEvent getIgnitionEvent();
145 * Sets the event that ignites this motor.
147 * @param event the {@link IgnitionEvent} that ignites this motor.
149 public void setIgnitionEvent(IgnitionEvent event);
153 * Returns the ignition delay of this motor.
155 * @return the ignition delay
157 public double getIgnitionDelay();
160 * Sets the ignition delay of this motor.
162 * @param delay the ignition delay.
164 public void setIgnitionDelay(double delay);
168 * Return the distance that the motors hang outside this motor mount.
170 * @return the overhang length.
172 public double getMotorOverhang();
175 * Sets the distance that the motors hang outside this motor mount.
177 * @param overhang the overhang length.
179 public void setMotorOverhang(double overhang);
184 * Return the inner diameter of the motor mount.
186 * @return the inner diameter of the motor mount.
188 public double getMotorMountDiameter();