Refine simulation loading: if the data saved with a simulation is out of date, mark it out of date when loading

This commit is contained in:
JoePfeiffer 2023-03-03 18:40:31 -07:00
parent b6c6a47811
commit e8be376a69

View File

@ -109,6 +109,13 @@ 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) {
@ -123,20 +130,19 @@ class SingleSimulationHandler extends AbstractElementHandler {
name = "Simulation"; name = "Simulation";
// If the simulation was saved with flight data (which may just be a summary) // 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 // mark it as loaded from the file else as not simulated. If outdated data was saved,
// simulation status attribute, since (1) it really isn't relevant now, and (2) // it'll be marked as outdated (creating a new status for "loaded but outdated" seems
// sim summaries are getting marked as not simulated when they're saved // excessive, and the fact that it's outdated is the more important)
FlightData data; FlightData data;
if (dataHandler == null) if (dataHandler == null)
data = null; data = null;
else else
data = dataHandler.getFlightData(); data = dataHandler.getFlightData();
Simulation.Status status; if (data == null) {
if (data != null) {
status = Status.LOADED;
} else {
status = Status.NOT_SIMULATED; status = Status.NOT_SIMULATED;
} else if (status != Status.OUTDATED) {
status = Status.LOADED;
} }
Simulation simulation = new Simulation(doc, doc.getRocket(), status, name, Simulation simulation = new Simulation(doc, doc.getRocket(), status, name,