package net.sf.openrocket.android.thrustcurve;\r
\r
-import java.util.Vector;\r
+import java.io.IOException;\r
+import java.io.StringReader;\r
+import java.util.List;\r
+\r
+import net.sf.openrocket.file.motor.RASPMotorLoader;\r
+import net.sf.openrocket.file.motor.RockSimMotorLoader;\r
+import net.sf.openrocket.motor.Motor;\r
+import net.sf.openrocket.motor.ThrustCurveMotor;\r
\r
public class MotorBurnFile {\r
\r
- private Integer motor_id;\r
+ private Integer motorId;\r
private String filetype;\r
- private Float length;\r
- private String delays;\r
- private Double propWeightG;\r
- private Double totWeightG;\r
- private Vector<Double> datapoints = new Vector<Double>();\r
- \r
+ private ThrustCurveMotor thrustCurveMotor;\r
+\r
public void init() {\r
- this.motor_id = null;\r
+ this.motorId = null;\r
this.filetype = null;\r
- this.length = null;\r
- this.delays = null;\r
- this.propWeightG = null;\r
- this.totWeightG = null;\r
- this.datapoints = new Vector<Double>();\r
+ this.thrustCurveMotor = null;\r
}\r
- \r
+\r
@Override\r
public MotorBurnFile clone() {\r
MotorBurnFile clone = new MotorBurnFile();\r
- clone.motor_id = this.motor_id;\r
+ clone.motorId = this.motorId;\r
clone.filetype = this.filetype;\r
- clone.length = this.length;\r
- clone.delays = this.delays;\r
- clone.propWeightG = this.propWeightG;\r
- clone.totWeightG = this.totWeightG;\r
- clone.datapoints = this.datapoints;\r
+ clone.thrustCurveMotor = this.thrustCurveMotor;\r
return clone;\r
}\r
\r
- public void decodeFile(String data){\r
- if (SupportedFileTypes.RASP_FORMAT.equals(filetype)) {\r
- RaspBurnFile.parse(this,data);\r
- } else if (SupportedFileTypes.ROCKSIM_FORMAT.equals(filetype) ){\r
- RSEBurnFile.parse(this,data);\r
+ public void decodeFile(String data) {\r
+ try {\r
+ if (SupportedFileTypes.RASP_FORMAT.equals(filetype)) {\r
+ RASPMotorLoader loader = new RASPMotorLoader();\r
+ List<Motor> motors = loader.load( new StringReader(data), "download");\r
+ this.thrustCurveMotor = (ThrustCurveMotor) motors.get(0);\r
+ } else if (SupportedFileTypes.ROCKSIM_FORMAT.equals(filetype) ){\r
+ RockSimMotorLoader loader = new RockSimMotorLoader();\r
+ List<Motor> motors = loader.load( new StringReader(data), "download");\r
+ this.thrustCurveMotor = (ThrustCurveMotor) motors.get(0);\r
+ }\r
+ } catch ( IOException ex ) {\r
+ this.thrustCurveMotor = null;\r
}\r
}\r
- \r
+\r
+ /**\r
+ * @return the motor_id\r
+ */\r
public Integer getMotorId() {\r
- return motor_id;\r
- }\r
- public String getFileType() {\r
- return filetype;\r
- }\r
- public Float getLength() {\r
- return length;\r
- }\r
- public String getDelays() {\r
- return delays;\r
- }\r
- public Double getPropWeightG() {\r
- return propWeightG;\r
- }\r
- public Double getTotWeightG() {\r
- return totWeightG;\r
+ return motorId;\r
}\r
- public Vector<Double> getDatapoints() {\r
- return datapoints;\r
+\r
+ /**\r
+ * @param motor_id the motor_id to set\r
+ */\r
+ public void setMotorId(Integer motorId) {\r
+ this.motorId = motorId;\r
}\r
\r
- void setMotor_id(Integer motor_id) {\r
- this.motor_id = motor_id;\r
+ /**\r
+ * @return the filetype\r
+ */\r
+ public String getFiletype() {\r
+ return filetype;\r
}\r
- void setFiletype(String filetype ) {\r
+\r
+ /**\r
+ * @param filetype the filetype to set\r
+ */\r
+ public void setFiletype(String filetype) {\r
this.filetype = filetype;\r
}\r
- void setLength(Float length) {\r
- this.length = length;\r
- }\r
- void setDelays(String delays) {\r
- this.delays = delays;\r
- }\r
- void setPropWeightG(Double propWeightG) {\r
- this.propWeightG = propWeightG;\r
- }\r
- void setTotWeightG(Double totWeightG) {\r
- this.totWeightG = totWeightG;\r
- }\r
- void setDatapoints(Vector<Double> datapoints) {\r
- this.datapoints = datapoints;\r
+\r
+ /**\r
+ * @return the thrustCurveMotor\r
+ */\r
+ public ThrustCurveMotor getThrustCurveMotor() {\r
+ return thrustCurveMotor;\r
}\r
+\r
}\r