1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.simulation.FlightEvent;
4 import net.sf.openrocket.util.ChangeSource;
6 public interface MotorMount extends ChangeSource {
8 public static enum IgnitionEvent {
9 AUTOMATIC("Automatic (launch or ejection charge)") {
11 public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
12 int count = source.getRocket().getStageCount();
13 int stage = source.getStageNumber();
15 if (stage == count-1) {
16 return LAUNCH.isActivationEvent(e, source);
18 return EJECTION_CHARGE.isActivationEvent(e, source);
24 public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
25 return (e.getType() == FlightEvent.Type.LAUNCH);
28 EJECTION_CHARGE("First ejection charge of previous stage") {
30 public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
31 if (e.getType() != FlightEvent.Type.EJECTION_CHARGE)
34 int charge = e.getSource().getStageNumber();
35 int mount = source.getStageNumber();
36 return (mount+1 == charge);
39 BURNOUT("First burnout of previous stage") {
41 public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
42 if (e.getType() != FlightEvent.Type.BURNOUT)
45 int charge = e.getSource().getStageNumber();
46 int mount = source.getStageNumber();
47 return (mount+1 == charge);
52 public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
59 private final String description;
61 IgnitionEvent(String description) {
62 this.description = description;
65 public abstract boolean isActivationEvent(FlightEvent e, RocketComponent source);
68 public String toString() {
75 * Is the component currently a motor mount.
77 * @return whether the component holds a motor.
79 public boolean isMotorMount();
82 * Set whether the component is currently a motor mount.
84 public void setMotorMount(boolean mount);
88 * Return the motor for the motor configuration. May return <code>null</code>
89 * if no motor has been set. This method must return <code>null</code> if ID
90 * is <code>null</code>.
92 * @param id the motor configuration ID
93 * @return the motor, or <code>null</code> if not set.
95 public Motor getMotor(String id);
98 * Set the motor for the motor configuration. May be set to <code>null</code>
99 * to remove the motor.
101 * @param id the motor configuration ID
102 * @param motor the motor, or <code>null</code>.
104 public void setMotor(String id, Motor motor);
107 * Get the number of similar motors clustered.
109 * @return the number of motors.
111 public int getMotorCount();
116 * Return the ejection charge delay of given motor configuration.
117 * A "plugged" motor without an ejection charge is given by
118 * {@link Motor#PLUGGED} (<code>Double.POSITIVE_INFINITY</code>).
120 * @param id the motor configuration ID
121 * @return the ejection charge delay.
123 public double getMotorDelay(String id);
126 * Set the ejection change delay of the given motor configuration.
127 * The ejection charge is disable (a "plugged" motor) is set by
128 * {@link Motor#PLUGGED} (<code>Double.POSITIVE_INFINITY</code>).
130 * @param id the motor configuration ID
131 * @param delay the ejection charge delay.
133 public void setMotorDelay(String id, double delay);
137 * Return the event that ignites this motor.
139 * @return the {@link IgnitionEvent} that ignites this motor.
141 public IgnitionEvent getIgnitionEvent();
144 * Sets the event that ignites this motor.
146 * @param event the {@link IgnitionEvent} that ignites this motor.
148 public void setIgnitionEvent(IgnitionEvent event);
152 * Returns the ignition delay of this motor.
154 * @return the ignition delay
156 public double getIgnitionDelay();
159 * Sets the ignition delay of this motor.
161 * @param delay the ignition delay.
163 public void setIgnitionDelay(double delay);
167 * Return the distance that the motors hang outside this motor mount.
169 * @return the overhang length.
171 public double getMotorOverhang();
174 * Sets the distance that the motors hang outside this motor mount.
176 * @param overhang the overhang length.
178 public void setMotorOverhang(double overhang);
183 * Return the inner diameter of the motor mount.
185 * @return the inner diameter of the motor mount.
187 public double getMotorMountDiameter();