Merge pull request #2070 from JoePfeiffer/fix-2067
Properly load simulation data from saved simulations
This commit is contained in:
commit
91038c32e7
@ -555,6 +555,7 @@ simpanel.col.Timetoapogee = Time to apogee
|
|||||||
simpanel.col.Flighttime = Flight time
|
simpanel.col.Flighttime = Flight time
|
||||||
simpanel.col.Groundhitvelocity = Ground hit velocity
|
simpanel.col.Groundhitvelocity = Ground hit velocity
|
||||||
simpanel.ttip.uptodate = <i>Up to date</i>
|
simpanel.ttip.uptodate = <i>Up to date</i>
|
||||||
|
simpanel.ttip.loaded = <i>Loaded from file</i>
|
||||||
simpanel.ttip.outdated = <i><font color=\"red\">Out of date</font></i><br>Click <i><b>Run simulations</b></i> to simulate.
|
simpanel.ttip.outdated = <i><font color=\"red\">Out of date</font></i><br>Click <i><b>Run simulations</b></i> to simulate.
|
||||||
simpanel.ttip.external = <i>Imported data</i>
|
simpanel.ttip.external = <i>Imported data</i>
|
||||||
simpanel.ttip.notSimulated = <i>Not simulated yet</i><br>Click <i><b>Run simulations</b></i> to simulate.
|
simpanel.ttip.notSimulated = <i>Not simulated yet</i><br>Click <i><b>Run simulations</b></i> to simulate.
|
||||||
|
@ -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);
|
||||||
|
@ -92,12 +92,6 @@ class FlightDataHandler 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) {
|
||||||
|
|
||||||
// If no <databranch> tag in XML, then there is no sim data
|
|
||||||
if (dataHandler == null) {
|
|
||||||
data = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (branches.size() > 0) {
|
if (branches.size() > 0) {
|
||||||
data = new FlightData(branches.toArray(new FlightDataBranch[0]));
|
data = new FlightData(branches.toArray(new FlightDataBranch[0]));
|
||||||
} else {
|
} else {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,6 +710,8 @@ public class SimulationPanel extends JPanel {
|
|||||||
tip += trans.get("simpanel.ttip.noData")+"<br>";
|
tip += trans.get("simpanel.ttip.noData")+"<br>";
|
||||||
break;
|
break;
|
||||||
case LOADED:
|
case LOADED:
|
||||||
|
tip += trans.get("simpanel.ttip.loaded") + "<br>";
|
||||||
|
break;
|
||||||
case UPTODATE:
|
case UPTODATE:
|
||||||
tip += trans.get("simpanel.ttip.uptodate") + "<br>";
|
tip += trans.get("simpanel.ttip.uptodate") + "<br>";
|
||||||
break;
|
break;
|
||||||
|
@ -33,7 +33,7 @@ public class Icons {
|
|||||||
map.put(Simulation.Status.NOT_SIMULATED, loadImageIcon("pix/spheres/gray-16x16.png", "Not simulated"));
|
map.put(Simulation.Status.NOT_SIMULATED, loadImageIcon("pix/spheres/gray-16x16.png", "Not simulated"));
|
||||||
map.put(Simulation.Status.CANT_RUN, loadImageIcon("pix/spheres/yellow-16x16.png", "Can't run, no motors assigned."));
|
map.put(Simulation.Status.CANT_RUN, loadImageIcon("pix/spheres/yellow-16x16.png", "Can't run, no motors assigned."));
|
||||||
map.put(Simulation.Status.UPTODATE, loadImageIcon("pix/spheres/green-16x16.png", "Up to date"));
|
map.put(Simulation.Status.UPTODATE, loadImageIcon("pix/spheres/green-16x16.png", "Up to date"));
|
||||||
map.put(Simulation.Status.LOADED, loadImageIcon("pix/spheres/green-16x16.png", "Up to date"));
|
map.put(Simulation.Status.LOADED, loadImageIcon("pix/spheres/blue-16x16.png", "Loaded from File"));
|
||||||
map.put(Simulation.Status.OUTDATED, loadImageIcon("pix/spheres/red-16x16.png", "Out-of-date"));
|
map.put(Simulation.Status.OUTDATED, loadImageIcon("pix/spheres/red-16x16.png", "Out-of-date"));
|
||||||
map.put(Simulation.Status.EXTERNAL, loadImageIcon("pix/spheres/blue-16x16.png", "Imported data"));
|
map.put(Simulation.Status.EXTERNAL, loadImageIcon("pix/spheres/blue-16x16.png", "Imported data"));
|
||||||
SIMULATION_STATUS_ICON_MAP = Collections.unmodifiableMap(map);
|
SIMULATION_STATUS_ICON_MAP = Collections.unmodifiableMap(map);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user