diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java b/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java index 0a6882d5c..dfc0e4cbf 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java @@ -1026,6 +1026,9 @@ class MotorMountHandler extends AbstractElementHandler { Motor motor = motorHandler.getMotor(warnings); mount.setMotor(id, motor); mount.setMotorDelay(id, motorHandler.getDelay(warnings)); + MotorConfiguration motorConfig = mount.getFlightConfiguration(id); + motorConfig.setIgnitionEvent( motorHandler.getIgnitionEvent()); + motorConfig.setIgnitionDelay( motorHandler.getIgnitionDelay()); return; } @@ -1148,6 +1151,9 @@ class MotorHandler extends AbstractElementHandler { private double length = Double.NaN; private double delay = Double.NaN; + private Double ignitionDelay = null; + private MotorConfiguration.IgnitionEvent ignitionEvent = null; + public MotorHandler(DocumentLoadingContext context) { this.context = context; } @@ -1178,7 +1184,14 @@ class MotorHandler extends AbstractElementHandler { return delay; } - + public Double getIgnitionDelay() { + return ignitionDelay; + } + + public MotorConfiguration.IgnitionEvent getIgnitionEvent() { + return ignitionEvent; + } + @Override public void closeElement(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { @@ -1260,6 +1273,24 @@ class MotorHandler extends AbstractElementHandler { } + } else if ( element.equals("ignitionevent")) { + + for (MotorConfiguration.IgnitionEvent e : MotorConfiguration.IgnitionEvent.values()) { + if (e.name().toLowerCase(Locale.ENGLISH).replaceAll("_", "").equals(content)) { + ignitionEvent = e; + break; + } + } + if (ignitionEvent == null) { + warnings.add(Warning.fromString("Unknown ignition event type '" + content + "', ignoring.")); + } + + } else if ( element.equals("ignitiondelay")) { + try { + ignitionDelay = Double.parseDouble(content); + } catch (NumberFormatException nfe) { + warnings.add(Warning.fromString("Illegal ignition delay specified, ignoring.")); + } } else { super.closeElement(element, attributes, content, warnings); } diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java index 591e3ff89..c1dbbedc8 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java @@ -12,6 +12,7 @@ import net.sf.openrocket.motor.Motor; import net.sf.openrocket.motor.ThrustCurveMotor; import net.sf.openrocket.preset.ComponentPreset; import net.sf.openrocket.rocketcomponent.ComponentAssembly; +import net.sf.openrocket.rocketcomponent.MotorConfiguration; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; @@ -127,8 +128,11 @@ public class RocketComponentSaver { elements.add(""); for (String id : motorConfigIDs) { - Motor motor = mount.getMotor(id); - + MotorConfiguration motorConfig = mount.getFlightConfiguration(id); + if ( motorConfig == null ) { + continue; + } + Motor motor = motorConfig.getMotor(); // Nothing is stored if no motor loaded if (motor == null) continue; @@ -148,10 +152,17 @@ public class RocketComponentSaver { elements.add(" " + motor.getLength() + ""); // Motor delay - if (mount.getMotorDelay(id) == Motor.PLUGGED) { + if (motorConfig.getEjectionDelay() == Motor.PLUGGED) { elements.add(" none"); } else { - elements.add(" " + mount.getMotorDelay(id) + ""); + elements.add(" " + motorConfig.getEjectionDelay() + ""); + } + + if ( motorConfig.getIgnitionEvent() != null ) { + elements.add(" " + motorConfig.getIgnitionEvent().name().toLowerCase(Locale.ENGLISH).replace("_", "") + ""); + } + if ( motorConfig.getIgnitionDelay() != null ) { + elements.add(" " + motorConfig.getIgnitionDelay() + ""); } elements.add(" ");