I18 changes
[debian/openrocket] / src / net / sf / openrocket / rocketcomponent / MotorMount.java
1 package net.sf.openrocket.rocketcomponent;
2
3 import net.sf.openrocket.motor.Motor;
4 import net.sf.openrocket.simulation.FlightEvent;
5 import net.sf.openrocket.util.ChangeSource;
6 import net.sf.openrocket.util.Coordinate;
7
8 public interface MotorMount extends ChangeSource {
9         
10         public static enum IgnitionEvent {
11                 AUTOMATIC("Automatic (launch or ejection charge)") {
12                         @Override
13                         public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
14                                 int count = source.getRocket().getStageCount();
15                                 int stage = source.getStageNumber();
16                                 
17                                 if (stage == count-1) {
18                                         return LAUNCH.isActivationEvent(e, source);
19                                 } else {
20                                         return EJECTION_CHARGE.isActivationEvent(e, source);
21                                 }
22                         }
23                 },
24                 LAUNCH("Launch") {
25                         @Override
26                         public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
27                                 return (e.getType() == FlightEvent.Type.LAUNCH);
28                         }
29                 },
30                 EJECTION_CHARGE("First ejection charge of previous stage") {
31                         @Override
32                         public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
33                                 if (e.getType() != FlightEvent.Type.EJECTION_CHARGE)
34                                         return false;
35
36                                 int charge = e.getSource().getStageNumber();
37                                 int mount = source.getStageNumber();
38                                 return (mount+1 == charge);
39                         }
40                 },
41                 BURNOUT("First burnout of previous stage") {
42                         @Override
43                         public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
44                                 if (e.getType() != FlightEvent.Type.BURNOUT)
45                                         return false;
46
47                                 int charge = e.getSource().getStageNumber();
48                                 int mount = source.getStageNumber();
49                                 return (mount+1 == charge);
50                         }
51                 },
52                 NEVER("Never") {
53                         @Override
54                         public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
55                                 return false;
56                         }
57                 },
58                 ;
59                 
60                 
61                 private final String description;
62                 
63                 IgnitionEvent(String description) {
64                         this.description = description;
65                 }
66                 
67                 public abstract boolean isActivationEvent(FlightEvent e, RocketComponent source);
68                 
69                 @Override
70                 public String toString() {
71                         return description;
72                 }
73         };
74         
75         
76         /**
77          * Is the component currently a motor mount.
78          * 
79          * @return  whether the component holds a motor.
80          */
81         public boolean isMotorMount();
82         
83         /**
84          * Set whether the component is currently a motor mount.
85          */
86         public void setMotorMount(boolean mount);
87         
88         
89         /**
90          * Return the motor for the motor configuration.  May return <code>null</code>
91          * if no motor has been set.  This method must return <code>null</code> if ID
92          * is <code>null</code> or if the ID is not valid for the current rocket
93          * (or if the component is not part of any rocket).
94          * 
95          * @param id    the motor configuration ID
96          * @return      the motor, or <code>null</code> if not set.
97          */
98         public Motor getMotor(String id);
99         
100         /**
101          * Set the motor for the motor configuration.  May be set to <code>null</code>
102          * to remove the motor.
103          * 
104          * @param id     the motor configuration ID
105          * @param motor  the motor, or <code>null</code>.
106          */
107         public void setMotor(String id, Motor motor);
108
109         /**
110          * Get the number of similar motors clustered.
111          * 
112          * TODO: HIGH: This should not be used, since the components themselves can be clustered
113          * 
114          * @return  the number of motors.
115          */
116         @Deprecated
117         public int getMotorCount();
118         
119         
120         
121         /**
122          * Return the ejection charge delay of given motor configuration.
123          * A "plugged" motor without an ejection charge is given by
124          * {@link Motor#PLUGGED} (<code>Double.POSITIVE_INFINITY</code>).
125          * 
126          * @param id    the motor configuration ID
127          * @return      the ejection charge delay.
128          */
129         public double getMotorDelay(String id);
130         
131         /**
132          * Set the ejection change delay of the given motor configuration.  
133          * The ejection charge is disable (a "plugged" motor) is set by
134          * {@link Motor#PLUGGED} (<code>Double.POSITIVE_INFINITY</code>).
135          * 
136          * @param id     the motor configuration ID
137          * @param delay  the ejection charge delay.
138          */
139         public void setMotorDelay(String id, double delay);
140         
141         
142         /**
143          * Return the event that ignites this motor.
144          * 
145          * @return   the {@link IgnitionEvent} that ignites this motor.
146          */
147         public IgnitionEvent getIgnitionEvent();
148         
149         /**
150          * Sets the event that ignites this motor.
151          * 
152          * @param event   the {@link IgnitionEvent} that ignites this motor.
153          */
154         public void setIgnitionEvent(IgnitionEvent event);
155         
156         
157         /**
158          * Returns the ignition delay of this motor.
159          * 
160          * @return  the ignition delay
161          */
162         public double getIgnitionDelay();
163         
164         /**
165          * Sets the ignition delay of this motor.
166          * 
167          * @param delay   the ignition delay.
168          */
169         public void setIgnitionDelay(double delay);
170         
171         
172         /**
173          * Return the distance that the motors hang outside this motor mount.
174          * 
175          * @return  the overhang length.
176          */
177         public double getMotorOverhang();
178         
179         /**
180          * Sets the distance that the motors hang outside this motor mount.
181          * 
182          * @param overhang   the overhang length.
183          */
184         public void setMotorOverhang(double overhang);
185         
186         
187         
188         /**
189          * Return the inner diameter of the motor mount.
190          * 
191          * @return  the inner diameter of the motor mount.
192          */
193         public double getMotorMountDiameter();
194         
195         
196         /**
197          * Return the position of the motor relative to this component.  The coordinate
198          * is that of the front cap of the motor.
199          * 
200          * @return      the position of the motor relative to this component.
201          * @throws  IllegalArgumentException if a motor with the specified ID does not exist.
202          */
203         public Coordinate getMotorPosition(String id);
204         
205 }