Add explicit test and abort for "no stages defined" running simulation
This commit is contained in:
parent
6273c7a7be
commit
f5755cc4af
@ -655,8 +655,11 @@ BasicEventSimulationEngine.error.noConfiguredIgnition = No motors configured to
|
||||
BasicEventSimulationEngine.error.noIgnition = No motors ignited.
|
||||
BasicEventSimulationEngine.error.NaNResult = Simulation resulted in not-a-number (NaN) value, please report a bug.
|
||||
|
||||
BasicEventSimlationEngine.nullBranchName = (null)
|
||||
|
||||
RK4SimulationStepper.error.valuesTooLarge = Simulation values exceeded limits. Try selecting a shorter time step.
|
||||
|
||||
SimulationAbort.noActiveStages = No active stages
|
||||
SimulationAbort.noMotorsDefined = No motors defined in the simulation
|
||||
SimulationAbort.noConfiguredIgnition = No motors configured to ignite at liftoff
|
||||
SimulationAbort.noIgnition = No motors ignited
|
||||
|
@ -24,6 +24,9 @@ public class SimulationAbort extends Message {
|
||||
* Possible causes of sim aborts
|
||||
*/
|
||||
public enum Cause {
|
||||
// No active stages in simulation
|
||||
NO_ACTIVE_STAGES(trans.get("SimulationAbort.noActiveStages")),
|
||||
|
||||
// No motors are defined in the sim configuration
|
||||
NOMOTORSDEFINED(trans.get("SimulationAbort.noMotorsDefined")),
|
||||
|
||||
|
@ -75,8 +75,14 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
||||
simulationConfig.copyStages(origConfig); // Clone the stage activation configuration
|
||||
|
||||
currentStatus = new SimulationStatus(simulationConfig, simulationConditions);
|
||||
// main simulation branch
|
||||
final String branchName = simulationConfig.getRocket().getTopmostStage(currentStatus.getConfiguration()).getName();
|
||||
// main simulation branch. Need to watch for pathological case with no stages defined
|
||||
final AxialStage topStage = simulationConfig.getRocket().getTopmostStage(currentStatus.getConfiguration());
|
||||
final String branchName;
|
||||
if (topStage != null) {
|
||||
branchName = topStage.getName();
|
||||
} else {
|
||||
branchName = trans.get("BasicEventSimulationEngine.nullBranchName");
|
||||
}
|
||||
FlightDataBranch initialBranch = new FlightDataBranch( branchName, FlightDataType.TYPE_TIME);
|
||||
|
||||
// put a point on it so we can plot if we get an early abort event
|
||||
@ -90,6 +96,11 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
||||
|
||||
// Problems that keep us from simulating at all
|
||||
|
||||
// No active stages
|
||||
if (topStage == null) {
|
||||
currentStatus.abortSimulation(SimulationAbort.Cause.NO_ACTIVE_STAGES);
|
||||
}
|
||||
|
||||
// No motors in configuration
|
||||
if (!simulationConfig.hasMotors() ) {
|
||||
currentStatus.abortSimulation(SimulationAbort.Cause.NOMOTORSDEFINED);
|
||||
|
Loading…
x
Reference in New Issue
Block a user