Create default sim if no sims present
This commit is contained in:
parent
d0102fde0e
commit
215080e0c9
@ -120,14 +120,16 @@ public class SimulationDTO {
|
||||
*/
|
||||
public SimulationDTO(Rocket rocket, Simulation simulation, Map<AxialStage, MotorMount> mounts, List<ThrustCurveMotor> motors,
|
||||
WarningSet warnings, ErrorSet errors) {
|
||||
FlightConfigurationId fcid = simulation.getFlightConfigurationId();
|
||||
if (fcid == null) {
|
||||
warnings.add(String.format("Empty simulation '%s', ignoring.", simulation.getName()));
|
||||
String simulationName = simulation != null ? simulation.getName() : "DEFAULT";
|
||||
FlightConfigurationId fcid = simulation != null ? simulation.getFlightConfigurationId() : null;
|
||||
|
||||
if (simulation != null && fcid == null) {
|
||||
warnings.add(String.format("Empty simulation '%s', ignoring.", simulationName));
|
||||
return;
|
||||
}
|
||||
|
||||
if (mounts.isEmpty()) {
|
||||
warnings.add(String.format("No motors found in simulation '%s', ignoring.", simulation.getName()));
|
||||
warnings.add(String.format("No motors found in simulation '%s', ignoring.", simulationName));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -242,7 +244,7 @@ public class SimulationDTO {
|
||||
// Invalid
|
||||
default:
|
||||
errors.add(String.format("Invalid stage number '%d' for simulation '%s'",
|
||||
stageNr, simulation.getName()));
|
||||
stageNr, simulationName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,10 +78,16 @@ public class SimulationListDTO {
|
||||
// Load all RASAero motors
|
||||
List<ThrustCurveMotor> motors = RASAeroMotorsLoader.loadAllRASAeroMotors(warnings);
|
||||
|
||||
// Add all the simulations
|
||||
for (Simulation simulation : document.getSimulations()) {
|
||||
addSimulation(new SimulationDTO(rocket, simulation, mounts, motors, warnings, errors));
|
||||
}
|
||||
|
||||
// If there are no simulations, add a default simulation (to have the mass/CG export)
|
||||
if (document.getSimulations().size() == 0) {
|
||||
addSimulation(new SimulationDTO(rocket, null, mounts, motors, warnings, errors));
|
||||
}
|
||||
|
||||
motors.clear();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user