diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties
index 6f96f8711..513996d73 100644
--- a/core/resources/l10n/messages.properties
+++ b/core/resources/l10n/messages.properties
@@ -634,7 +634,7 @@ simpanel.ttip.notSimulated = Not simulated yet
Click Run simulat
simpanel.ttip.noData = No simulation data available.
simpanel.ttip.noWarnings = No warnings.
simpanel.ttip.warnings = Warnings:
-simpanel.ttip.simAbort = Simulation Abort
+simpanel.ttip.simAbort = Simulation Abort
simpanel.msg.invalidCopySelection = Invalid copy selection
! SimulationRunDialog
diff --git a/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java b/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java
index 12e056f75..cdb3f499f 100644
--- a/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java
+++ b/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java
@@ -9,6 +9,7 @@ import java.util.*;
import net.sf.openrocket.file.openrocket.savers.PhotoStudioSaver;
import net.sf.openrocket.logging.ErrorSet;
+import net.sf.openrocket.logging.SimulationAbort;
import net.sf.openrocket.logging.WarningSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -539,6 +540,11 @@ public class OpenRocketSaver extends RocketSaver {
if (event.getSource() != null) {
eventStr += "\" source=\"" + TextUtil.escapeXML(event.getSource().getID());
}
+
+ if (event.getType() == FlightEvent.Type.SIM_ABORT) {
+ eventStr += "\" cause=\"" + enumToXMLName(((SimulationAbort)(event.getData())).getCause());
+ }
+
eventStr += "\"/>";
writeln(eventStr);
}
diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataBranchHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataBranchHandler.java
index 9641f13d6..d242c46bf 100644
--- a/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataBranchHandler.java
+++ b/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataBranchHandler.java
@@ -2,6 +2,8 @@ package net.sf.openrocket.file.openrocket.importt;
import java.util.HashMap;
+import net.sf.openrocket.logging.SimulationAbort;
+import net.sf.openrocket.logging.SimulationAbort.Cause;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.file.DocumentLoadingContext;
import net.sf.openrocket.file.simplesax.AbstractElementHandler;
@@ -128,8 +130,10 @@ class FlightDataBranchHandler extends AbstractElementHandler {
if (element.equals("event")) {
double time;
FlightEvent.Type type;
- String sourceID;
+ SimulationAbort abort = null;
+ SimulationAbort.Cause cause = null;
RocketComponent source = null;
+ String sourceID;
try {
time = DocumentConfig.stringToDouble(attributes.get("time"));
@@ -150,8 +154,14 @@ class FlightDataBranchHandler extends AbstractElementHandler {
if (sourceID != null) {
source = rocket.findComponent(sourceID);
}
+
+ // For aborts, get the cause
+ cause = (Cause) DocumentConfig.findEnum(attributes.get("cause"), SimulationAbort.Cause.class);
+ if (cause != null) {
+ abort = new SimulationAbort(cause);
+ }
- branch.addEvent(new FlightEvent(type, time, source));
+ branch.addEvent(new FlightEvent(type, time, source, abort));
return;
}
@@ -187,4 +197,4 @@ class FlightDataBranchHandler extends AbstractElementHandler {
branch.setValue(types[i], values[i]);
}
}
-}
\ No newline at end of file
+}
diff --git a/core/src/net/sf/openrocket/logging/SimulationAbort.java b/core/src/net/sf/openrocket/logging/SimulationAbort.java
index 79694b2c9..8d04fccdb 100644
--- a/core/src/net/sf/openrocket/logging/SimulationAbort.java
+++ b/core/src/net/sf/openrocket/logging/SimulationAbort.java
@@ -10,15 +10,9 @@ public class SimulationAbort extends Message {
private static final Translator trans = Application.getTranslator();
- private final String description;
-
- SimulationAbort(String _description) {
- description = _description;
- }
-
@Override
public String getMessageDescription() {
- return description;
+ return cause.toString();
}
@Override
@@ -29,29 +23,48 @@ public class SimulationAbort extends Message {
/**
* Possible causes of sim aborts
*/
+ public enum Cause {
+ // No motors are defined in the sim configuration
+ NOMOTORSDEFINED(trans.get("SimulationAbort.noMotorsDefined")),
- // No motors are defined in the sim configuration
- public static final SimulationAbort NOMOTORSDEFINED = new SimulationAbort(trans.get("SimulationAbort.noMotorsDefined"));
-
- // Motors are defined, but none are configured to fire at liftoff
- public static final SimulationAbort NOCONFIGUREDIGNITION = new SimulationAbort(trans.get("SimulationAbort.noConfiguredIgnition"));
+ // Motors are defined, but none are configured to fire at liftoff
+ NOCONFIGUREDIGNITION(trans.get("SimulationAbort.noConfiguredIgnition")),
- // No motors fired (can this really happen without getting a NoMotorsDefined?)
- public static final SimulationAbort NOMOTORSFIRED = new SimulationAbort(trans.get("SimulationAbort.noIgnition"));
+ // No motors fired (can this really happen without getting a NoMotorsDefined?)
+ NOMOTORSFIRED(trans.get("SimulationAbort.noIgnition")),
- // Motors ignited, but rocket did not lift off
- public static final SimulationAbort NOLIFTOFF = new SimulationAbort(trans.get("SimulationAbort.noLiftOff"));
+ // Motors ignited, but rocket did not lift off
+ NOLIFTOFF(trans.get("SimulationAbort.noLiftOff")),
- // It is impossible to calculate the active components' center of pressure
- public static final SimulationAbort NOCP = new SimulationAbort(trans.get("SimulationAbort.noCP"));
+ // It is impossible to calculate the active components' center of pressure
+ NOCP(trans.get("SimulationAbort.noCP")),
- // The currently active components have a total length of 0
- public static final SimulationAbort ACTIVELENGTHZERO = new SimulationAbort(trans.get("SimulationAbort.activeLengthZero"));
+ // The currently active components have a total length of 0
+ ACTIVELENGTHZERO(trans.get("SimulationAbort.activeLengthZero")),
- // The currently active components have a total mass of 0
- public static final SimulationAbort ACTIVEMASSZERO = new SimulationAbort(trans.get("SimulationAbort.activeMassZero"));
+ // The currently active components have a total mass of 0
+ ACTIVEMASSZERO(trans.get("SimulationAbort.activeMassZero"));
+
+ private final String name;
+
+ private Cause(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+ }
+
+ private final Cause cause;
+
+ public SimulationAbort(Cause cause) {
+ this.cause = cause;
+ }
+
+ public Cause getCause() {
+ return cause;
+ }
+
}
-
-
-
-
diff --git a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java
index 098c6735b..2bfd95c96 100644
--- a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java
+++ b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java
@@ -91,7 +91,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
// No motors in configuration
if (!simulationConfig.hasMotors() ) {
- currentStatus.abortSimulation(SimulationAbort.NOMOTORSDEFINED);
+ currentStatus.abortSimulation(SimulationAbort.Cause.NOMOTORSDEFINED);
}
// Problems that let us simulate, but result is likely bad
@@ -442,7 +442,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
case BURNOUT: {
// If motor burnout occurs without lift-off, abort
if (!currentStatus.isLiftoff()) {
- currentStatus.abortSimulation(SimulationAbort.NOLIFTOFF);
+ currentStatus.abortSimulation(SimulationAbort.Cause.NOLIFTOFF);
}
// Add ejection charge event
@@ -636,7 +636,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
// If no motor has ignited, abort
if (!currentStatus.isMotorIgnited()) {
// TODO MEDIUM: display this as a warning to the user (e.g. highlight the cell in the simulation panel in red and a hover: 'make sure the motor ignition is correct' or something)
- currentStatus.abortSimulation(SimulationAbort.NOMOTORSFIRED);
+ currentStatus.abortSimulation(SimulationAbort.Cause.NOMOTORSFIRED);
}
return ret;
@@ -676,7 +676,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
// Active stages have total length of 0.
if (currentStatus.getConfiguration().getLengthAerodynamic() < MathUtil.EPSILON) {
- currentStatus.abortSimulation(SimulationAbort.ACTIVELENGTHZERO);
+ currentStatus.abortSimulation(SimulationAbort.Cause.ACTIVELENGTHZERO);
}
// Can't calculate stability
@@ -684,7 +684,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
.getCP(currentStatus.getConfiguration(),
new FlightConditions(currentStatus.getConfiguration()),
new WarningSet()).weight < MathUtil.EPSILON) {
- currentStatus.abortSimulation(SimulationAbort.NOCP);
+ currentStatus.abortSimulation(SimulationAbort.Cause.NOCP);
}
}
diff --git a/core/src/net/sf/openrocket/simulation/FlightEvent.java b/core/src/net/sf/openrocket/simulation/FlightEvent.java
index 54a675201..9bda5f673 100644
--- a/core/src/net/sf/openrocket/simulation/FlightEvent.java
+++ b/core/src/net/sf/openrocket/simulation/FlightEvent.java
@@ -147,10 +147,6 @@ public class FlightEvent implements Comparable {
return data;
}
-
-
-
-
/**
* Compares this event to another event depending on the event time. Secondary
* sorting is performed on stages; lower (numerically higher) stage first. Tertiary
diff --git a/core/src/net/sf/openrocket/simulation/SimulationStatus.java b/core/src/net/sf/openrocket/simulation/SimulationStatus.java
index bb5a64a91..1d8f230e3 100644
--- a/core/src/net/sf/openrocket/simulation/SimulationStatus.java
+++ b/core/src/net/sf/openrocket/simulation/SimulationStatus.java
@@ -567,8 +567,8 @@ public class SimulationStatus implements Monitorable {
/**
* Abort the current simulation branch
*/
- public void abortSimulation(SimulationAbort cause) throws SimulationException {
- FlightEvent abortEvent = new FlightEvent(FlightEvent.Type.SIM_ABORT, getSimulationTime(), null, cause);
+ public void abortSimulation(SimulationAbort.Cause cause) throws SimulationException {
+ FlightEvent abortEvent = new FlightEvent(FlightEvent.Type.SIM_ABORT, getSimulationTime(), null, new SimulationAbort(cause));
addEvent(abortEvent);
}
diff --git a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java
index 291674ed7..0159d3cfa 100644
--- a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java
+++ b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java
@@ -52,6 +52,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.miginfocom.swing.MigLayout;
+import net.sf.openrocket.logging.SimulationAbort;
import net.sf.openrocket.logging.Warning;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.document.OpenRocketDocument;
@@ -782,8 +783,10 @@ public class SimulationPanel extends JPanel {
}
for (int b = 0; b < data.getBranchCount(); b++) {
- if (data.getBranch(b).getFirstEvent(FlightEvent.Type.SIM_ABORT) != null) {
- tip += trans.get("simpanel.ttip.simAbort");
+ FlightEvent abortEvent = data.getBranch(b).getFirstEvent(FlightEvent.Type.SIM_ABORT);
+ if ( abortEvent != null) {
+ tip += "" + trans.get("simpanel.ttip.simAbort") + ": " +
+ ((SimulationAbort)(abortEvent.getData())).toString() + "
";
}
}