import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.TubeCoupler;
-import net.sf.openrocket.simulation.CustomExpression;
import net.sf.openrocket.simulation.FlightData;
import net.sf.openrocket.simulation.FlightDataBranch;
import net.sf.openrocket.simulation.FlightDataType;
import net.sf.openrocket.simulation.FlightEvent;
import net.sf.openrocket.simulation.SimulationOptions;
+import net.sf.openrocket.simulation.customexpression.CustomExpression;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BugException;
import net.sf.openrocket.util.BuildProperties;
writeln("");
+ // Save custom expressions;
+ saveCustomDatatypes(document);
+
// Save all simulations
writeln("<simulations>");
indent++;
}
}
+ /*
+ * Save all the custom expressions
+ */
+ private void saveCustomDatatypes(OpenRocketDocument doc) throws IOException {
+
+ if (doc.getCustomExpressions().isEmpty())
+ return;
+
+ writeln("<datatypes>");
+ indent++;
+
+ for (CustomExpression exp : doc.getCustomExpressions()) {
+ saveCustomExpressionDatatype(exp);
+ }
+
+ indent--;
+ writeln("</datatypes>");
+ writeln("");
+ }
+ /*
+ * Save one custom expression datatype
+ */
+ private void saveCustomExpressionDatatype(CustomExpression exp) throws IOException {
+ // Write out custom expression
+
+ writeln("<type source=\"customexpression\">");
+ indent++;
+ writeln("<name>" + exp.getName() + "</name>");
+ writeln("<symbol>" + exp.getSymbol() + "</symbol>");
+ writeln("<unit unittype=\"auto\">" + exp.getUnit() + "</unit>"); // auto unit type means it will be determined from string
+ writeln("<expression>" + exp.getExpressionString() + "</expression>");
+ indent--;
+ writeln("</type>");
+ }
@Override
public long estimateFileSize(OpenRocketDocument doc, StorageOptions options) {
* File version 1.5 is requires for:
* - saving designs using ComponentPrests
* - recovery device deployment on lower stage separation
+ * - custom expressions
*
* File version 1.4 is required for:
* - saving simulation data
}
}
+ // Check for custom expressions
+ if (!document.getCustomExpressions().isEmpty()) {
+ return FILE_VERSION_DIVISOR + 5;
+ }
+
// Check if design has simulations defined (version 1.4)
if (document.getSimulationCount() > 0) {
return FILE_VERSION_DIVISOR + 4;
writeln("<simulator>RK4Simulator</simulator>");
writeln("<calculator>BarrowmanCalculator</calculator>");
- // Write out custom expressions
- if (!simulation.getCustomExpressions().isEmpty()){
- writeln("<customexpressions>"); indent++;
- for (CustomExpression expression : simulation.getCustomExpressions()){
- writeln("<expression>"); indent++;
- writeElement("name", expression.getName());
- writeElement("symbol", expression.getSymbol());
- writeElement("unit", expression.getUnit());
- writeElement("expressionstring", expression.getExpressionString());
- indent--; writeln("</expression>");
- }
- indent--; writeln("</customexpressions>");
- }
-
- writeln("<conditions>"); indent++;
+ writeln("<conditions>");
+ indent++;
writeElement("configid", cond.getMotorConfigurationID());
writeElement("launchrodlength", cond.getLaunchRodLength());
sb.append("<databranch name=\"");
sb.append(escapeXML(branch.getBranchName()));
-
+ // Kevins version where typekeys are used
+ /*
sb.append("\" typekeys=\"");
for (int i = 0; i < types.length; i++) {
if (i > 0)
sb.append(",");
sb.append(escapeXML(types[i].getKey()));
}
+ */
+
sb.append("\" types=\"");
for (int i = 0; i < types.length; i++) {
if (i > 0)