Add data branch to flight data before branch is simulated, not after.
simulateLoop() no longer returns a FlightDataBranch; it just adds to the FlightDataBranch it is simulating
This commit is contained in:
parent
523fce1a4c
commit
51af956330
@ -83,13 +83,13 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
branchName = trans.get("BasicEventSimulationEngine.nullBranchName");
|
branchName = trans.get("BasicEventSimulationEngine.nullBranchName");
|
||||||
}
|
}
|
||||||
FlightDataBranch initialBranch = new FlightDataBranch( branchName, FlightDataType.TYPE_TIME);
|
FlightDataBranch initialBranch = new FlightDataBranch( branchName, FlightDataType.TYPE_TIME);
|
||||||
|
|
||||||
// put a point on it so we can plot if we get an early abort event
|
// put a point on it so we can plot if we get an early abort event
|
||||||
initialBranch.addPoint();
|
initialBranch.addPoint();
|
||||||
initialBranch.setValue(FlightDataType.TYPE_TIME, 0.0);
|
initialBranch.setValue(FlightDataType.TYPE_TIME, 0.0);
|
||||||
initialBranch.setValue(FlightDataType.TYPE_ALTITUDE, 0.0);
|
initialBranch.setValue(FlightDataType.TYPE_ALTITUDE, 0.0);
|
||||||
currentStatus.setFlightDataBranch(initialBranch);
|
|
||||||
|
|
||||||
|
currentStatus.setFlightDataBranch(initialBranch);
|
||||||
|
|
||||||
// Sanity checks on design and configuration
|
// Sanity checks on design and configuration
|
||||||
|
|
||||||
@ -121,10 +121,12 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
currentStatus = toSimulate.pop();
|
currentStatus = toSimulate.pop();
|
||||||
|
FlightDataBranch dataBranch = currentStatus.getFlightDataBranch();
|
||||||
|
flightData.addBranch(dataBranch);
|
||||||
log.info(">>Starting simulation of branch: " + currentStatus.getFlightDataBranch().getName());
|
log.info(">>Starting simulation of branch: " + currentStatus.getFlightDataBranch().getName());
|
||||||
|
|
||||||
FlightDataBranch dataBranch = simulateLoop();
|
simulateLoop();
|
||||||
flightData.addBranch(dataBranch);
|
dataBranch.immute();
|
||||||
flightData.getWarningSet().addAll(currentStatus.getWarnings());
|
flightData.getWarningSet().addAll(currentStatus.getWarnings());
|
||||||
|
|
||||||
log.info(String.format("<<Finished simulating branch: %s curTime:%s finTime:%s",
|
log.info(String.format("<<Finished simulating branch: %s curTime:%s finTime:%s",
|
||||||
@ -149,7 +151,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
return flightData;
|
return flightData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlightDataBranch simulateLoop() throws SimulationException {
|
private void simulateLoop() throws SimulationException {
|
||||||
|
|
||||||
// Initialize the simulation. We'll use the flight stepper unless we're already
|
// Initialize the simulation. We'll use the flight stepper unless we're already
|
||||||
// on the ground
|
// on the ground
|
||||||
@ -282,12 +284,12 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (SimulationException e) {
|
} catch (SimulationException e) {
|
||||||
|
|
||||||
SimulationListenerHelper.fireEndSimulation(currentStatus, e);
|
SimulationListenerHelper.fireEndSimulation(currentStatus, e);
|
||||||
|
|
||||||
// Add FlightEvent for exception.
|
// Add FlightEvent for exception.
|
||||||
currentStatus.getFlightDataBranch().addEvent(new FlightEvent(FlightEvent.Type.EXCEPTION, currentStatus.getSimulationTime(), currentStatus.getConfiguration().getRocket(), e.getLocalizedMessage()));
|
currentStatus.getFlightDataBranch().addEvent(new FlightEvent(FlightEvent.Type.EXCEPTION, currentStatus.getSimulationTime(), currentStatus.getConfiguration().getRocket(), e.getLocalizedMessage()));
|
||||||
|
|
||||||
flightData.addBranch(currentStatus.getFlightDataBranch());
|
|
||||||
flightData.getWarningSet().addAll(currentStatus.getWarnings());
|
flightData.getWarningSet().addAll(currentStatus.getWarnings());
|
||||||
|
|
||||||
e.setFlightData(flightData);
|
e.setFlightData(flightData);
|
||||||
@ -295,8 +297,6 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentStatus.getFlightDataBranch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,9 +126,7 @@ public class FlightData {
|
|||||||
public void addBranch(FlightDataBranch branch) {
|
public void addBranch(FlightDataBranch branch) {
|
||||||
mutable.check();
|
mutable.check();
|
||||||
|
|
||||||
branch.immute();
|
|
||||||
branches.add(branch);
|
branches.add(branch);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBranchCount() {
|
public int getBranchCount() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user