Change simulation file loader so it always marks a simulation as LOADED if it has data, and NOT_SIMULATED if it doesn't. This is more reliable than the status attributed, as that gets saved as notsimulated when only summary data is saved.
Also clean up logic in Simulation constructor a bit,
This commit is contained in:
parent
297ab11fe2
commit
f0621e5790
@ -146,42 +146,24 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
if (options == null)
|
if (options == null)
|
||||||
throw new IllegalArgumentException("options cannot be null");
|
throw new IllegalArgumentException("options cannot be null");
|
||||||
|
|
||||||
this.document = document;
|
|
||||||
this.rocket = rocket;
|
this.rocket = rocket;
|
||||||
|
|
||||||
if (status == Status.UPTODATE) {
|
|
||||||
this.status = Status.LOADED;
|
|
||||||
} else if (data == null) {
|
|
||||||
this.status = Status.NOT_SIMULATED;
|
|
||||||
} else {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.status = status;
|
||||||
|
this.simulatedConditions = options.clone();
|
||||||
|
this.simulatedData = data;
|
||||||
|
this.document = document;
|
||||||
|
addChangeListener(this.document);
|
||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
this.options.addChangeListener(new ConditionListener());
|
||||||
|
|
||||||
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
||||||
this.setFlightConfigurationId(config.getFlightConfigurationID());
|
this.setFlightConfigurationId(config.getFlightConfigurationID());
|
||||||
|
this.simulatedConfigurationID = config.getModID();
|
||||||
|
|
||||||
options.addChangeListener(new ConditionListener());
|
|
||||||
addChangeListener(document);
|
|
||||||
|
|
||||||
if (extensions != null) {
|
|
||||||
this.simulationExtensions.addAll(extensions);
|
this.simulationExtensions.addAll(extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (data != null && this.status != Status.NOT_SIMULATED) {
|
|
||||||
simulatedData = data;
|
|
||||||
if (this.status == Status.LOADED) {
|
|
||||||
simulatedConditions = options.clone();
|
|
||||||
simulatedConfigurationID = config.getModID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public FlightConfiguration getActiveConfiguration() {
|
public FlightConfiguration getActiveConfiguration() {
|
||||||
mutex.verify();
|
mutex.verify();
|
||||||
return rocket.getFlightConfiguration(this.configId);
|
return rocket.getFlightConfiguration(this.configId);
|
||||||
|
@ -109,13 +109,6 @@ class SingleSimulationHandler extends AbstractElementHandler {
|
|||||||
public void endHandler(String element, HashMap<String, String> attributes,
|
public void endHandler(String element, HashMap<String, String> attributes,
|
||||||
String content, WarningSet warnings) {
|
String content, WarningSet warnings) {
|
||||||
|
|
||||||
String s = attributes.get("status");
|
|
||||||
Simulation.Status status = (Status) DocumentConfig.findEnum(s, Simulation.Status.class);
|
|
||||||
if (status == null) {
|
|
||||||
warnings.add("Simulation status unknown, assuming outdated.");
|
|
||||||
status = Simulation.Status.OUTDATED;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimulationOptions options;
|
SimulationOptions options;
|
||||||
FlightConfigurationId idToSet= FlightConfigurationId.ERROR_FCID;
|
FlightConfigurationId idToSet= FlightConfigurationId.ERROR_FCID;
|
||||||
if (conditionHandler != null) {
|
if (conditionHandler != null) {
|
||||||
@ -129,13 +122,20 @@ class SingleSimulationHandler extends AbstractElementHandler {
|
|||||||
if (name == null)
|
if (name == null)
|
||||||
name = "Simulation";
|
name = "Simulation";
|
||||||
|
|
||||||
|
// If the simulation was saved with flight data (which may just be a summary)
|
||||||
|
// mark it as loaded from the file else as not simulated. We're ignoring the
|
||||||
|
// simulation status attribute, since (1) it really isn't relevant now, and (2)
|
||||||
|
// sim summaries are getting marked as not simulated when they're saved
|
||||||
FlightData data;
|
FlightData data;
|
||||||
if (dataHandler == null)
|
if (dataHandler == null)
|
||||||
data = null;
|
data = null;
|
||||||
else
|
else
|
||||||
data = dataHandler.getFlightData();
|
data = dataHandler.getFlightData();
|
||||||
|
|
||||||
if (data == null) {
|
Simulation.Status status;
|
||||||
|
if (data != null) {
|
||||||
|
status = Status.LOADED;
|
||||||
|
} else {
|
||||||
status = Status.NOT_SIMULATED;
|
status = Status.NOT_SIMULATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user