Merge pull request #1832 from JoePfeiffer/fix-1611
When a simulation fails badly enough to be aborted, don't turn the exception into a warning
This commit is contained in:
commit
38b66be2a4
@ -554,6 +554,7 @@ SimuRunDlg.msg.errorOccurred = An error occurred during the simulation:
|
|||||||
|
|
||||||
BasicEventSimulationEngine.error.noMotorsDefined = No motors defined in the simulation.
|
BasicEventSimulationEngine.error.noMotorsDefined = No motors defined in the simulation.
|
||||||
BasicEventSimulationEngine.error.earlyMotorBurnout = Motor burnout without liftoff.
|
BasicEventSimulationEngine.error.earlyMotorBurnout = Motor burnout without liftoff.
|
||||||
|
BasicEventSimulationEngine.error.noConfiguredIgnition = No motors configured to ignite at liftoff
|
||||||
BasicEventSimulationEngine.error.noIgnition = No motors ignited.
|
BasicEventSimulationEngine.error.noIgnition = No motors ignited.
|
||||||
BasicEventSimulationEngine.error.NaNResult = Simulation resulted in not-a-number (NaN) value, please report a bug.
|
BasicEventSimulationEngine.error.NaNResult = Simulation resulted in not-a-number (NaN) value, please report a bug.
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.sf.openrocket.simulation;
|
package net.sf.openrocket.simulation;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -8,6 +9,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import net.sf.openrocket.aerodynamics.Warning;
|
import net.sf.openrocket.aerodynamics.Warning;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
|
import net.sf.openrocket.motor.IgnitionEvent;
|
||||||
import net.sf.openrocket.motor.MotorConfiguration;
|
import net.sf.openrocket.motor.MotorConfiguration;
|
||||||
import net.sf.openrocket.motor.MotorConfigurationId;
|
import net.sf.openrocket.motor.MotorConfigurationId;
|
||||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
@ -68,11 +70,25 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
FlightConfiguration origConfig = simulationConditions.getRocket().getFlightConfiguration(this.fcid);
|
FlightConfiguration origConfig = simulationConditions.getRocket().getFlightConfiguration(this.fcid);
|
||||||
FlightConfiguration simulationConfig = origConfig.clone();
|
FlightConfiguration simulationConfig = origConfig.clone();
|
||||||
simulationConfig.copyStages(origConfig); // Clone the stage activation configuration
|
simulationConfig.copyStages(origConfig); // Clone the stage activation configuration
|
||||||
if ( ! simulationConfig.hasMotors() ) {
|
|
||||||
|
currentStatus = new SimulationStatus(simulationConfig, simulationConditions);
|
||||||
|
|
||||||
|
// Sanity checks on design and configuration
|
||||||
|
|
||||||
|
// Problems that keep us from simulating at all
|
||||||
|
|
||||||
|
// No motors in configuration
|
||||||
|
if (!simulationConfig.hasMotors() ) {
|
||||||
throw new MotorIgnitionException(trans.get("BasicEventSimulationEngine.error.noMotorsDefined"));
|
throw new MotorIgnitionException(trans.get("BasicEventSimulationEngine.error.noMotorsDefined"));
|
||||||
}
|
}
|
||||||
|
|
||||||
currentStatus = new SimulationStatus(simulationConfig, simulationConditions);
|
// Problems that let us simulate, but result is likely bad
|
||||||
|
|
||||||
|
// No recovery device
|
||||||
|
if (!simulationConfig.hasRecoveryDevice()) {
|
||||||
|
currentStatus.getWarnings().add(Warning.NO_RECOVERY_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
currentStatus.getEventQueue().add(new FlightEvent(FlightEvent.Type.LAUNCH, 0, simulationConditions.getRocket()));
|
currentStatus.getEventQueue().add(new FlightEvent(FlightEvent.Type.LAUNCH, 0, simulationConditions.getRocket()));
|
||||||
{
|
{
|
||||||
// main simulation branch
|
// main simulation branch
|
||||||
@ -114,7 +130,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
return flightData;
|
return flightData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlightDataBranch simulateLoop() {
|
private FlightDataBranch simulateLoop() throws SimulationException {
|
||||||
|
|
||||||
// Initialize the simulation. We'll use the flight stepper unless we're already on the ground
|
// Initialize the simulation. We'll use the flight stepper unless we're already on the ground
|
||||||
if (currentStatus.isLanded())
|
if (currentStatus.isLanded())
|
||||||
@ -246,9 +262,11 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
|
|
||||||
} catch (SimulationException e) {
|
} catch (SimulationException e) {
|
||||||
SimulationListenerHelper.fireEndSimulation(currentStatus, e);
|
SimulationListenerHelper.fireEndSimulation(currentStatus, e);
|
||||||
|
|
||||||
// Add FlightEvent for Abort.
|
// Add FlightEvent for Abort.
|
||||||
currentStatus.getFlightData().addEvent(new FlightEvent(FlightEvent.Type.EXCEPTION, currentStatus.getSimulationTime(), currentStatus.getConfiguration().getRocket(), e.getLocalizedMessage()));
|
currentStatus.getFlightData().addEvent(new FlightEvent(FlightEvent.Type.EXCEPTION, currentStatus.getSimulationTime(), currentStatus.getConfiguration().getRocket(), e.getLocalizedMessage()));
|
||||||
currentStatus.getWarnings().add(e.getLocalizedMessage());
|
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentStatus.getFlightData();
|
return currentStatus.getFlightData();
|
||||||
@ -348,11 +366,6 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a warning if there is no recovery device defined.
|
|
||||||
if (!currentStatus.getConfiguration().hasRecoveryDevice()) {
|
|
||||||
currentStatus.getWarnings().add(Warning.NO_RECOVERY_DEVICE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle event
|
// Handle event
|
||||||
log.trace("Handling event " + event);
|
log.trace("Handling event " + event);
|
||||||
switch (event.getType()) {
|
switch (event.getType()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user