Change handling of Motor Digests. The computed digest value is now stored as a membe...
[debian/openrocket] / core / src / net / sf / openrocket / motor / Motor.java
1 package net.sf.openrocket.motor;
2
3 import net.sf.openrocket.util.Coordinate;
4
5 public interface Motor {
6
7         /**
8          * Enum of rocket motor types.
9          * 
10          * @author Sampo Niskanen <sampo.niskanen@iki.fi>
11          */
12         public enum Type {
13                 SINGLE("Single-use", "Single-use solid propellant motor"), 
14                 RELOAD("Reloadable", "Reloadable solid propellant motor"), 
15                 HYBRID("Hybrid", "Hybrid rocket motor engine"), 
16                 UNKNOWN("Unknown", "Unknown motor type");
17                 
18                 private final String name;
19                 private final String description;
20                 
21                 Type(String name, String description) {
22                         this.name = name;
23                         this.description = description;
24                 }
25                 
26                 public static Type fromName( String name ) {
27                         if ( name == null ) {
28                                 return UNKNOWN;
29                         }
30                         if ("single-use".equalsIgnoreCase(name)) {
31                                 return SINGLE;
32                         } else if ("hybrid".equalsIgnoreCase(name)) {
33                                 return HYBRID;
34                         } else if ("reloadable".equalsIgnoreCase(name)) {
35                                 return RELOAD;
36                         } else {
37                                 return UNKNOWN;
38                         }
39                 }
40
41                 /**
42                  * Return a short name of this motor type.
43                  * @return  a short name of the motor type.
44                  */
45                 public String getName() {
46                         return name;
47                 }
48                 
49                 /**
50                  * Return a long description of this motor type.
51                  * @return  a description of the motor type.
52                  */
53                 public String getDescription() {
54                         return description;
55                 }
56                 
57                 @Override
58                 public String toString() {
59                         return name;
60                 }
61         }
62         
63         
64         /**
65          * Ejection charge delay value signifying a "plugged" motor with no ejection charge.
66          * The value is that of <code>Double.POSITIVE_INFINITY</code>.
67          */
68         public static final double PLUGGED = Double.POSITIVE_INFINITY;
69         
70         
71         /**
72          * Below what portion of maximum thrust is the motor chosen to be off when
73          * calculating average thrust and burn time.  NFPA 1125 defines the "official"
74          * burn time to be the time which the motor produces over 5% of its maximum thrust.
75          */
76         public static final double MARGINAL_THRUST = 0.05;
77         
78
79
80         /**
81          * Return the motor type.
82          * 
83          * @return  the motorType
84          */
85         public Type getMotorType();
86
87
88         /**
89          * Return the designation of the motor.
90          * 
91          * @return the designation
92          */
93         public String getDesignation();
94         
95         /**
96          * Return the designation of the motor, including a delay.
97          * 
98          * @param delay  the delay of the motor.
99          * @return               designation with delay.
100          */
101         public String getDesignation(double delay);
102         
103
104         /**
105          * Return extra description for the motor.  This may include for example 
106          * comments on the source of the thrust curve.  The returned <code>String</code>
107          * may include new-lines.
108          * 
109          * @return the description
110          */
111         public String getDescription();
112         
113         
114         /**
115          * Return the maximum diameter of the motor.
116          * 
117          * @return the diameter
118          */
119         public double getDiameter();
120
121         /**
122          * Return the length of the motor.  This should be a "characteristic" length,
123          * and the exact definition may depend on the motor type.  Typically this should
124          * be the length from the bottom of the motor to the end of the maximum diameter
125          * portion, ignoring any smaller ejection charge compartments.
126          * 
127          * @return the length
128          */
129         public double getLength();
130         
131         public String getDigest();
132
133         public MotorInstance getInstance();
134         
135         
136         public Coordinate getLaunchCG();
137         public Coordinate getEmptyCG();
138         
139         
140         public double getBurnTimeEstimate();
141         public double getAverageThrustEstimate();
142         public double getMaxThrustEstimate();
143         public double getTotalImpulseEstimate();
144         
145         public double[] getTimePoints();
146         public double[] getThrustPoints();
147         public Coordinate[] getCGPoints();
148         
149 }