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,
|
public SimulationDTO(Rocket rocket, Simulation simulation, Map<AxialStage, MotorMount> mounts, List<ThrustCurveMotor> motors,
|
||||||
WarningSet warnings, ErrorSet errors) {
|
WarningSet warnings, ErrorSet errors) {
|
||||||
FlightConfigurationId fcid = simulation.getFlightConfigurationId();
|
String simulationName = simulation != null ? simulation.getName() : "DEFAULT";
|
||||||
if (fcid == null) {
|
FlightConfigurationId fcid = simulation != null ? simulation.getFlightConfigurationId() : null;
|
||||||
warnings.add(String.format("Empty simulation '%s', ignoring.", simulation.getName()));
|
|
||||||
|
if (simulation != null && fcid == null) {
|
||||||
|
warnings.add(String.format("Empty simulation '%s', ignoring.", simulationName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mounts.isEmpty()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +244,7 @@ public class SimulationDTO {
|
|||||||
// Invalid
|
// Invalid
|
||||||
default:
|
default:
|
||||||
errors.add(String.format("Invalid stage number '%d' for simulation '%s'",
|
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
|
// Load all RASAero motors
|
||||||
List<ThrustCurveMotor> motors = RASAeroMotorsLoader.loadAllRASAeroMotors(warnings);
|
List<ThrustCurveMotor> motors = RASAeroMotorsLoader.loadAllRASAeroMotors(warnings);
|
||||||
|
|
||||||
|
// Add all the simulations
|
||||||
for (Simulation simulation : document.getSimulations()) {
|
for (Simulation simulation : document.getSimulations()) {
|
||||||
addSimulation(new SimulationDTO(rocket, simulation, mounts, motors, warnings, errors));
|
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();
|
motors.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user