It's confusing to have types FlightData and FlightDataBranch, with many variables of type FlightDataBranch named flightData. This commit changes these to be named flightDataBranch (and also changes a few other similarly named variables, so for instance data becomes dataBranch).

Also, FlightDataBranch.getBranchName() is renamed FlightDataBranch.getName(). I suspect the reason for the old method name was to clarify code in the presence of the confusion described above.
This commit is contained in:
JoePfeiffer 2024-04-20 07:47:54 -06:00
parent 36afea51f2
commit 872de38b8d
17 changed files with 209 additions and 203 deletions

View File

@ -483,7 +483,7 @@ public class OpenRocketSaver extends RocketSaver {
// Build the <databranch> tag // Build the <databranch> tag
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<databranch name=\""); sb.append("<databranch name=\"");
sb.append(TextUtil.escapeXML(branch.getBranchName())); sb.append(TextUtil.escapeXML(branch.getName()));
sb.append("\" "); sb.append("\" ");
// Kevins version where typekeys are used // Kevins version where typekeys are used

View File

@ -169,69 +169,69 @@ public abstract class AbstractEulerStepper extends AbstractSimulationStepper {
status.setRocketWorldPosition(w); status.setRocketWorldPosition(w);
// Store data // Store data
final FlightDataBranch data = status.getFlightData(); final FlightDataBranch dataBranch = status.getFlightDataBranch();
// Values looked up or calculated at start of time step // Values looked up or calculated at start of time step
data.setValue(FlightDataType.TYPE_REFERENCE_LENGTH, status.getConfiguration().getReferenceLength()); dataBranch.setValue(FlightDataType.TYPE_REFERENCE_LENGTH, status.getConfiguration().getReferenceLength());
data.setValue(FlightDataType.TYPE_REFERENCE_AREA, status.getConfiguration().getReferenceArea()); dataBranch.setValue(FlightDataType.TYPE_REFERENCE_AREA, status.getConfiguration().getReferenceArea());
data.setValue(FlightDataType.TYPE_WIND_VELOCITY, windSpeed.length()); dataBranch.setValue(FlightDataType.TYPE_WIND_VELOCITY, windSpeed.length());
data.setValue(FlightDataType.TYPE_AIR_TEMPERATURE, atmosphere.getTemperature()); dataBranch.setValue(FlightDataType.TYPE_AIR_TEMPERATURE, atmosphere.getTemperature());
data.setValue(FlightDataType.TYPE_AIR_PRESSURE, atmosphere.getPressure()); dataBranch.setValue(FlightDataType.TYPE_AIR_PRESSURE, atmosphere.getPressure());
data.setValue(FlightDataType.TYPE_SPEED_OF_SOUND, atmosphere.getMachSpeed()); dataBranch.setValue(FlightDataType.TYPE_SPEED_OF_SOUND, atmosphere.getMachSpeed());
data.setValue(FlightDataType.TYPE_MACH_NUMBER, mach); dataBranch.setValue(FlightDataType.TYPE_MACH_NUMBER, mach);
if (status.getSimulationConditions().getGeodeticComputation() != GeodeticComputationStrategy.FLAT) { if (status.getSimulationConditions().getGeodeticComputation() != GeodeticComputationStrategy.FLAT) {
data.setValue(FlightDataType.TYPE_CORIOLIS_ACCELERATION, coriolisAcceleration.length()); dataBranch.setValue(FlightDataType.TYPE_CORIOLIS_ACCELERATION, coriolisAcceleration.length());
} }
data.setValue(FlightDataType.TYPE_GRAVITY, gravity); dataBranch.setValue(FlightDataType.TYPE_GRAVITY, gravity);
data.setValue(FlightDataType.TYPE_DRAG_COEFF, getCD()); dataBranch.setValue(FlightDataType.TYPE_DRAG_COEFF, getCD());
data.setValue(FlightDataType.TYPE_PRESSURE_DRAG_COEFF, getCD()); dataBranch.setValue(FlightDataType.TYPE_PRESSURE_DRAG_COEFF, getCD());
data.setValue(FlightDataType.TYPE_FRICTION_DRAG_COEFF, 0); dataBranch.setValue(FlightDataType.TYPE_FRICTION_DRAG_COEFF, 0);
data.setValue(FlightDataType.TYPE_BASE_DRAG_COEFF, 0); dataBranch.setValue(FlightDataType.TYPE_BASE_DRAG_COEFF, 0);
data.setValue(FlightDataType.TYPE_AXIAL_DRAG_COEFF, getCD()); dataBranch.setValue(FlightDataType.TYPE_AXIAL_DRAG_COEFF, getCD());
data.setValue(FlightDataType.TYPE_THRUST_FORCE, 0); dataBranch.setValue(FlightDataType.TYPE_THRUST_FORCE, 0);
data.setValue(FlightDataType.TYPE_DRAG_FORCE, dragForce); dataBranch.setValue(FlightDataType.TYPE_DRAG_FORCE, dragForce);
data.setValue(FlightDataType.TYPE_MASS, mass); dataBranch.setValue(FlightDataType.TYPE_MASS, mass);
data.setValue(FlightDataType.TYPE_MOTOR_MASS, motorMass); dataBranch.setValue(FlightDataType.TYPE_MOTOR_MASS, motorMass);
data.setValue(FlightDataType.TYPE_THRUST_WEIGHT_RATIO, 0); dataBranch.setValue(FlightDataType.TYPE_THRUST_WEIGHT_RATIO, 0);
data.setValue(FlightDataType.TYPE_ACCELERATION_XY, dataBranch.setValue(FlightDataType.TYPE_ACCELERATION_XY,
MathUtil.hypot(linearAcceleration.x, linearAcceleration.y)); MathUtil.hypot(linearAcceleration.x, linearAcceleration.y));
data.setValue(FlightDataType.TYPE_ACCELERATION_Z, linearAcceleration.z); dataBranch.setValue(FlightDataType.TYPE_ACCELERATION_Z, linearAcceleration.z);
data.setValue(FlightDataType.TYPE_ACCELERATION_TOTAL, linearAcceleration.length()); dataBranch.setValue(FlightDataType.TYPE_ACCELERATION_TOTAL, linearAcceleration.length());
data.setValue(FlightDataType.TYPE_TIME_STEP, timeStep); dataBranch.setValue(FlightDataType.TYPE_TIME_STEP, timeStep);
// Values calculated on this step // Values calculated on this step
data.addPoint(); dataBranch.addPoint();
data.setValue(FlightDataType.TYPE_TIME, status.getSimulationTime()); dataBranch.setValue(FlightDataType.TYPE_TIME, status.getSimulationTime());
data.setValue(FlightDataType.TYPE_ALTITUDE, status.getRocketPosition().z); dataBranch.setValue(FlightDataType.TYPE_ALTITUDE, status.getRocketPosition().z);
data.setValue(FlightDataType.TYPE_POSITION_X, status.getRocketPosition().x); dataBranch.setValue(FlightDataType.TYPE_POSITION_X, status.getRocketPosition().x);
data.setValue(FlightDataType.TYPE_POSITION_Y, status.getRocketPosition().y); dataBranch.setValue(FlightDataType.TYPE_POSITION_Y, status.getRocketPosition().y);
data.setValue(FlightDataType.TYPE_POSITION_XY, dataBranch.setValue(FlightDataType.TYPE_POSITION_XY,
MathUtil.hypot(status.getRocketPosition().x, status.getRocketPosition().y)); MathUtil.hypot(status.getRocketPosition().x, status.getRocketPosition().y));
data.setValue(FlightDataType.TYPE_POSITION_DIRECTION, dataBranch.setValue(FlightDataType.TYPE_POSITION_DIRECTION,
Math.atan2(status.getRocketPosition().y, status.getRocketPosition().x)); Math.atan2(status.getRocketPosition().y, status.getRocketPosition().x));
data.setValue(FlightDataType.TYPE_LATITUDE, status.getRocketWorldPosition().getLatitudeRad()); dataBranch.setValue(FlightDataType.TYPE_LATITUDE, status.getRocketWorldPosition().getLatitudeRad());
data.setValue(FlightDataType.TYPE_LONGITUDE, status.getRocketWorldPosition().getLongitudeRad()); dataBranch.setValue(FlightDataType.TYPE_LONGITUDE, status.getRocketWorldPosition().getLongitudeRad());
data.setValue(FlightDataType.TYPE_VELOCITY_XY, dataBranch.setValue(FlightDataType.TYPE_VELOCITY_XY,
MathUtil.hypot(status.getRocketVelocity().x, status.getRocketVelocity().y)); MathUtil.hypot(status.getRocketVelocity().x, status.getRocketVelocity().y));
data.setValue(FlightDataType.TYPE_VELOCITY_Z, status.getRocketVelocity().z); dataBranch.setValue(FlightDataType.TYPE_VELOCITY_Z, status.getRocketVelocity().z);
data.setValue(FlightDataType.TYPE_VELOCITY_TOTAL, airSpeed.length()); dataBranch.setValue(FlightDataType.TYPE_VELOCITY_TOTAL, airSpeed.length());
airSpeed = status.getRocketVelocity().add(windSpeed); airSpeed = status.getRocketVelocity().add(windSpeed);
final double Re = airSpeed.length() * final double Re = airSpeed.length() *
status.getConfiguration().getLengthAerodynamic() / status.getConfiguration().getLengthAerodynamic() /
atmosphere.getKinematicViscosity(); atmosphere.getKinematicViscosity();
data.setValue(FlightDataType.TYPE_REYNOLDS_NUMBER, Re); dataBranch.setValue(FlightDataType.TYPE_REYNOLDS_NUMBER, Re);
data.setValue(FlightDataType.TYPE_COMPUTATION_TIME, dataBranch.setValue(FlightDataType.TYPE_COMPUTATION_TIME,
(System.nanoTime() - status.getSimulationStartWallTime()) / 1000000000.0); (System.nanoTime() - status.getSimulationStartWallTime()) / 1000000000.0);
log.trace("time " + data.getLast(FlightDataType.TYPE_TIME) + ", altitude " + data.getLast(FlightDataType.TYPE_ALTITUDE) + ", velocity " + data.getLast(FlightDataType.TYPE_VELOCITY_Z)); log.trace("time " + dataBranch.getLast(FlightDataType.TYPE_TIME) + ", altitude " + dataBranch.getLast(FlightDataType.TYPE_ALTITUDE) + ", velocity " + dataBranch.getLast(FlightDataType.TYPE_VELOCITY_Z));
} }
private static class EulerValues { private static class EulerValues {

View File

@ -88,7 +88,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
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.setFlightData(initialBranch); currentStatus.setFlightDataBranch(initialBranch);
// Sanity checks on design and configuration // Sanity checks on design and configuration
@ -121,21 +121,21 @@ public class BasicEventSimulationEngine implements SimulationEngine {
break; break;
} }
currentStatus = toSimulate.pop(); currentStatus = toSimulate.pop();
log.info(">>Starting simulation of branch: " + currentStatus.getFlightData().getBranchName()); log.info(">>Starting simulation of branch: " + currentStatus.getFlightDataBranch().getName());
FlightDataBranch dataBranch = simulateLoop(); FlightDataBranch dataBranch = simulateLoop();
flightData.addBranch(dataBranch); flightData.addBranch(dataBranch);
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",
dataBranch.getBranchName(), dataBranch.getName(),
currentStatus.getSimulationTime(), currentStatus.getSimulationTime(),
dataBranch.getLast(FlightDataType.TYPE_TIME))); dataBranch.getLast(FlightDataType.TYPE_TIME)));
// Did the branch generate any data? // Did the branch generate any data?
if (dataBranch.getLength() == 0) { if (dataBranch.getLength() == 0) {
flightData.getWarningSet().add(Warning.EMPTY_BRANCH, dataBranch.getBranchName()); flightData.getWarningSet().add(Warning.EMPTY_BRANCH, dataBranch.getName());
} }
} while (!toSimulate.isEmpty()); } while (!toSimulate.isEmpty());
@ -264,9 +264,9 @@ public class BasicEventSimulationEngine implements SimulationEngine {
// and aoa > AOA_TUMBLE_CONDITION threshold // and aoa > AOA_TUMBLE_CONDITION threshold
if (!currentStatus.isTumbling()) { if (!currentStatus.isTumbling()) {
final double cp = currentStatus.getFlightData().getLast(FlightDataType.TYPE_CP_LOCATION); final double cp = currentStatus.getFlightDataBranch().getLast(FlightDataType.TYPE_CP_LOCATION);
final double cg = currentStatus.getFlightData().getLast(FlightDataType.TYPE_CG_LOCATION); final double cg = currentStatus.getFlightDataBranch().getLast(FlightDataType.TYPE_CG_LOCATION);
final double aoa = currentStatus.getFlightData().getLast(FlightDataType.TYPE_AOA); final double aoa = currentStatus.getFlightDataBranch().getLast(FlightDataType.TYPE_AOA);
if (cg > cp && aoa > AOA_TUMBLE_CONDITION) { if (cg > cp && aoa > AOA_TUMBLE_CONDITION) {
currentStatus.addEvent(new FlightEvent(FlightEvent.Type.TUMBLE, currentStatus.getSimulationTime())); currentStatus.addEvent(new FlightEvent(FlightEvent.Type.TUMBLE, currentStatus.getSimulationTime()));
@ -284,18 +284,18 @@ public class BasicEventSimulationEngine implements SimulationEngine {
SimulationListenerHelper.fireEndSimulation(currentStatus, e); SimulationListenerHelper.fireEndSimulation(currentStatus, e);
// Add FlightEvent for exception. // Add FlightEvent for exception.
currentStatus.getFlightData().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.getFlightData()); flightData.addBranch(currentStatus.getFlightDataBranch());
flightData.getWarningSet().addAll(currentStatus.getWarnings()); flightData.getWarningSet().addAll(currentStatus.getWarnings());
e.setFlightData(flightData); e.setFlightData(flightData);
e.setFlightDataBranch(currentStatus.getFlightData()); e.setFlightDataBranch(currentStatus.getFlightDataBranch());
throw e; throw e;
} }
return currentStatus.getFlightData(); return currentStatus.getFlightDataBranch();
} }
/** /**
@ -307,7 +307,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
boolean ret = true; boolean ret = true;
FlightEvent event; FlightEvent event;
log.trace("HandleEvents: current branch = " + currentStatus.getFlightData().getBranchName()); log.trace("HandleEvents: current branch = " + currentStatus.getFlightDataBranch().getName());
for (event = nextEvent(); event != null; event = nextEvent()) { for (event = nextEvent(); event != null; event = nextEvent()) {
log.trace("Obtained event from queue: " + event.toString()); log.trace("Obtained event from queue: " + event.toString());
log.trace("Remaining EventQueue = " + currentStatus.getEventQueue().toString()); log.trace("Remaining EventQueue = " + currentStatus.getEventQueue().toString());
@ -390,7 +390,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
switch (event.getType()) { switch (event.getType()) {
case LAUNCH: { case LAUNCH: {
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
break; break;
} }
@ -412,7 +412,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
// Ignite the motor // Ignite the motor
currentStatus.setMotorIgnited(true); currentStatus.setMotorIgnited(true);
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
// ... ignite ...uhh, again? // ... ignite ...uhh, again?
// TBH, I'm not sure what this call is for. It seems to be mostly a bunch of // TBH, I'm not sure what this call is for. It seems to be mostly a bunch of
@ -442,14 +442,14 @@ public class BasicEventSimulationEngine implements SimulationEngine {
case LIFTOFF: { case LIFTOFF: {
// Mark lift-off as occurred // Mark lift-off as occurred
currentStatus.setLiftoff(true); currentStatus.setLiftoff(true);
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
break; break;
} }
case LAUNCHROD: { case LAUNCHROD: {
// Mark launch rod as cleared // Mark launch rod as cleared
currentStatus.setLaunchRodCleared(true); currentStatus.setLaunchRodCleared(true);
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
break; break;
} }
@ -472,14 +472,14 @@ public class BasicEventSimulationEngine implements SimulationEngine {
currentStatus.addEvent(new FlightEvent(FlightEvent.Type.EJECTION_CHARGE, currentStatus.getSimulationTime() + delay, currentStatus.addEvent(new FlightEvent(FlightEvent.Type.EJECTION_CHARGE, currentStatus.getSimulationTime() + delay,
stage, event.getData())); stage, event.getData()));
} }
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
break; break;
} }
case EJECTION_CHARGE: { case EJECTION_CHARGE: {
MotorClusterState motorState = (MotorClusterState) event.getData(); MotorClusterState motorState = (MotorClusterState) event.getData();
motorState.expend( event.getTime() ); motorState.expend( event.getTime() );
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
break; break;
} }
@ -490,7 +490,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
if (currentStatus.getConfiguration().isStageActive(stageNumber - 1)) { if (currentStatus.getConfiguration().isStageActive(stageNumber - 1)) {
// Record the event. // Record the event.
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
// If I've got something other than one active stage below the separation point, // If I've got something other than one active stage below the separation point,
// flag a warning // flag a warning
@ -513,8 +513,8 @@ public class BasicEventSimulationEngine implements SimulationEngine {
SimulationStatus boosterStatus = new SimulationStatus(currentStatus); SimulationStatus boosterStatus = new SimulationStatus(currentStatus);
// Prepare the new simulation branch // Prepare the new simulation branch
boosterStatus.setFlightData(new FlightDataBranch(boosterStage.getName(), boosterStage, currentStatus.getFlightData())); boosterStatus.setFlightDataBranch(new FlightDataBranch(boosterStage.getName(), boosterStage, currentStatus.getFlightDataBranch()));
boosterStatus.getFlightData().addEvent(event); boosterStatus.getFlightDataBranch().addEvent(event);
// Mark the current status as having dropped the current stage and all stages // Mark the current status as having dropped the current stage and all stages
// below it // below it
@ -530,7 +530,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
log.info(String.format("==>> @ %g; from Branch: %s ---- Branching: %s ---- \n", log.info(String.format("==>> @ %g; from Branch: %s ---- Branching: %s ---- \n",
currentStatus.getSimulationTime(), currentStatus.getSimulationTime(),
currentStatus.getFlightData().getBranchName(), boosterStatus.getFlightData().getBranchName())); currentStatus.getFlightDataBranch().getName(), boosterStatus.getFlightDataBranch().getName()));
} else { } else {
log.debug("upper stage is not active; not performing separation"); log.debug("upper stage is not active; not performing separation");
} }
@ -541,11 +541,11 @@ public class BasicEventSimulationEngine implements SimulationEngine {
case APOGEE: case APOGEE:
// Mark apogee as reached // Mark apogee as reached
currentStatus.setApogeeReached(true); currentStatus.setApogeeReached(true);
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
// This apogee event might be the optimum if recovery has not already happened. // This apogee event might be the optimum if recovery has not already happened.
if (currentStatus.getDeployedRecoveryDevices().size() == 0) { if (currentStatus.getDeployedRecoveryDevices().size() == 0) {
currentStatus.getFlightData().setOptimumAltitude(currentStatus.getMaxAlt()); currentStatus.getFlightDataBranch().setOptimumAltitude(currentStatus.getMaxAlt());
currentStatus.getFlightData().setTimeToOptimumAltitude(currentStatus.getMaxAltTime()); currentStatus.getFlightDataBranch().setTimeToOptimumAltitude(currentStatus.getMaxAltTime());
} }
break; break;
@ -582,8 +582,8 @@ public class BasicEventSimulationEngine implements SimulationEngine {
if (!currentStatus.isApogeeReached()) { if (!currentStatus.isApogeeReached()) {
FlightData coastStatus = computeCoastTime(); FlightData coastStatus = computeCoastTime();
currentStatus.getFlightData().setOptimumAltitude(coastStatus.getMaxAltitude()); currentStatus.getFlightDataBranch().setOptimumAltitude(coastStatus.getMaxAltitude());
currentStatus.getFlightData().setTimeToOptimumAltitude(coastStatus.getTimeToApogee()); currentStatus.getFlightDataBranch().setTimeToOptimumAltitude(coastStatus.getTimeToApogee());
} }
// switch to landing stepper (unless we're already on the ground) // switch to landing stepper (unless we're already on the ground)
@ -592,7 +592,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
currentStatus = currentStepper.initialize(currentStatus); currentStatus = currentStepper.initialize(currentStatus);
} }
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
} }
log.debug("deployed recovery devices: " + currentStatus.getDeployedRecoveryDevices().size() ); log.debug("deployed recovery devices: " + currentStatus.getDeployedRecoveryDevices().size() );
break; break;
@ -603,17 +603,17 @@ public class BasicEventSimulationEngine implements SimulationEngine {
currentStepper = groundStepper; currentStepper = groundStepper;
currentStatus = currentStepper.initialize(currentStatus); currentStatus = currentStepper.initialize(currentStatus);
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
break; break;
case SIM_ABORT: case SIM_ABORT:
ret = false; ret = false;
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
break; break;
case SIMULATION_END: case SIMULATION_END:
ret = false; ret = false;
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
break; break;
case ALTITUDE: case ALTITUDE:
@ -628,13 +628,13 @@ public class BasicEventSimulationEngine implements SimulationEngine {
currentStepper = tumbleStepper; currentStepper = tumbleStepper;
currentStatus = currentStepper.initialize(currentStatus); currentStatus = currentStepper.initialize(currentStatus);
final boolean tooMuchThrust = currentStatus.getFlightData().getLast(FlightDataType.TYPE_THRUST_FORCE) > THRUST_TUMBLE_CONDITION; final boolean tooMuchThrust = currentStatus.getFlightDataBranch().getLast(FlightDataType.TYPE_THRUST_FORCE) > THRUST_TUMBLE_CONDITION;
if (tooMuchThrust) { if (tooMuchThrust) {
currentStatus.abortSimulation(SimulationAbort.Cause.TUMBLE_UNDER_THRUST); currentStatus.abortSimulation(SimulationAbort.Cause.TUMBLE_UNDER_THRUST);
} }
currentStatus.setTumbling(true); currentStatus.setTumbling(true);
currentStatus.getFlightData().addEvent(event); currentStatus.getFlightDataBranch().addEvent(event);
break; break;
} }
@ -645,7 +645,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
if (1200 < currentStatus.getSimulationTime()) { if (1200 < currentStatus.getSimulationTime()) {
ret = false; ret = false;
log.error("Simulation hit max time (1200s): aborting."); log.error("Simulation hit max time (1200s): aborting.");
currentStatus.getFlightData() currentStatus.getFlightDataBranch()
.addEvent(new FlightEvent(FlightEvent.Type.SIMULATION_END, currentStatus.getSimulationTime())); .addEvent(new FlightEvent(FlightEvent.Type.SIMULATION_END, currentStatus.getSimulationTime()));
} }

View File

@ -31,7 +31,7 @@ import info.openrocket.core.util.Mutable;
public class FlightDataBranch implements Monitorable { public class FlightDataBranch implements Monitorable {
/** The name of this flight data branch. */ /** The name of this flight data branch. */
private final String branchName; private final String name;
private final Map<FlightDataType, ArrayList<Double>> values = new LinkedHashMap<>(); private final Map<FlightDataType, ArrayList<Double>> values = new LinkedHashMap<>();
@ -64,7 +64,7 @@ public class FlightDataBranch implements Monitorable {
throw new IllegalArgumentException("Must specify at least one data type."); throw new IllegalArgumentException("Must specify at least one data type.");
} }
this.branchName = name; this.name = name;
for (FlightDataType t : types) { for (FlightDataType t : types) {
if (values.containsKey(t)) { if (values.containsKey(t)) {
@ -83,12 +83,12 @@ public class FlightDataBranch implements Monitorable {
* when creating a new branch upon stage separation, so the data at separation is present * when creating a new branch upon stage separation, so the data at separation is present
* in both branches (and if the new branch has an immediate exception, it can be plotted) * in both branches (and if the new branch has an immediate exception, it can be plotted)
* *
* @param branchName the name of the new branch. * @param name the name of the new branch.
* @param srcComponent the component that is the source of the new branch. * @param srcComponent the component that is the source of the new branch.
* @param parent the parent branch to copy data from. * @param parent the parent branch to copy data from.
*/ */
public FlightDataBranch(String branchName, RocketComponent srcComponent, FlightDataBranch parent) { public FlightDataBranch(String name, RocketComponent srcComponent, FlightDataBranch parent) {
this.branchName = branchName; this.name = name;
// Copy all the values from the parent // Copy all the values from the parent
copyValuesFromBranch(parent, srcComponent); copyValuesFromBranch(parent, srcComponent);
@ -98,7 +98,7 @@ public class FlightDataBranch implements Monitorable {
* Makes an 'empty' flight data branch which has no data but all built in data types are defined. * Makes an 'empty' flight data branch which has no data but all built in data types are defined.
*/ */
public FlightDataBranch() { public FlightDataBranch() {
branchName = "Empty branch"; name = "Empty branch";
for (FlightDataType type : FlightDataType.ALL_TYPES) { for (FlightDataType type : FlightDataType.ALL_TYPES) {
this.setValue(type, Double.NaN); this.setValue(type, Double.NaN);
} }
@ -230,8 +230,8 @@ public class FlightDataBranch implements Monitorable {
/** /**
* Return the branch name. * Return the branch name.
*/ */
public String getBranchName() { public String getName() {
return branchName; return name;
} }
/** /**
@ -447,7 +447,7 @@ public class FlightDataBranch implements Monitorable {
public FlightDataBranch clone() { public FlightDataBranch clone() {
FlightDataType[] types = getTypes(); FlightDataType[] types = getTypes();
FlightDataBranch clone = new FlightDataBranch(branchName, types); FlightDataBranch clone = new FlightDataBranch(name, types);
for (FlightDataType type : values.keySet()) { for (FlightDataType type : values.keySet()) {
clone.values.put(type, values.get(type).clone()); clone.values.put(type, values.get(type).clone());
} }

View File

@ -526,117 +526,117 @@ public class RK4SimulationStepper extends AbstractSimulationStepper {
private void storeData(RK4SimulationStatus status, DataStore store) { private void storeData(RK4SimulationStatus status, DataStore store) {
FlightDataBranch data = status.getFlightData(); FlightDataBranch dataBranch = status.getFlightDataBranch();
data.addPoint(); dataBranch.addPoint();
data.setValue(FlightDataType.TYPE_TIME, status.getSimulationTime()); dataBranch.setValue(FlightDataType.TYPE_TIME, status.getSimulationTime());
data.setValue(FlightDataType.TYPE_ALTITUDE, status.getRocketPosition().z); dataBranch.setValue(FlightDataType.TYPE_ALTITUDE, status.getRocketPosition().z);
data.setValue(FlightDataType.TYPE_POSITION_X, status.getRocketPosition().x); dataBranch.setValue(FlightDataType.TYPE_POSITION_X, status.getRocketPosition().x);
data.setValue(FlightDataType.TYPE_POSITION_Y, status.getRocketPosition().y); dataBranch.setValue(FlightDataType.TYPE_POSITION_Y, status.getRocketPosition().y);
data.setValue(FlightDataType.TYPE_LATITUDE, status.getRocketWorldPosition().getLatitudeRad()); dataBranch.setValue(FlightDataType.TYPE_LATITUDE, status.getRocketWorldPosition().getLatitudeRad());
data.setValue(FlightDataType.TYPE_LONGITUDE, status.getRocketWorldPosition().getLongitudeRad()); dataBranch.setValue(FlightDataType.TYPE_LONGITUDE, status.getRocketWorldPosition().getLongitudeRad());
if (status.getSimulationConditions().getGeodeticComputation() != GeodeticComputationStrategy.FLAT) { if (status.getSimulationConditions().getGeodeticComputation() != GeodeticComputationStrategy.FLAT) {
data.setValue(FlightDataType.TYPE_CORIOLIS_ACCELERATION, store.coriolisAcceleration.length()); dataBranch.setValue(FlightDataType.TYPE_CORIOLIS_ACCELERATION, store.coriolisAcceleration.length());
} }
data.setValue(FlightDataType.TYPE_POSITION_XY, dataBranch.setValue(FlightDataType.TYPE_POSITION_XY,
MathUtil.hypot(status.getRocketPosition().x, status.getRocketPosition().y)); MathUtil.hypot(status.getRocketPosition().x, status.getRocketPosition().y));
data.setValue(FlightDataType.TYPE_POSITION_DIRECTION, dataBranch.setValue(FlightDataType.TYPE_POSITION_DIRECTION,
Math.atan2(status.getRocketPosition().y, status.getRocketPosition().x)); Math.atan2(status.getRocketPosition().y, status.getRocketPosition().x));
data.setValue(FlightDataType.TYPE_VELOCITY_XY, dataBranch.setValue(FlightDataType.TYPE_VELOCITY_XY,
MathUtil.hypot(status.getRocketVelocity().x, status.getRocketVelocity().y)); MathUtil.hypot(status.getRocketVelocity().x, status.getRocketVelocity().y));
if (store.linearAcceleration != null) { if (store.linearAcceleration != null) {
data.setValue(FlightDataType.TYPE_ACCELERATION_XY, dataBranch.setValue(FlightDataType.TYPE_ACCELERATION_XY,
MathUtil.hypot(store.linearAcceleration.x, store.linearAcceleration.y)); MathUtil.hypot(store.linearAcceleration.x, store.linearAcceleration.y));
data.setValue(FlightDataType.TYPE_ACCELERATION_TOTAL, store.linearAcceleration.length()); dataBranch.setValue(FlightDataType.TYPE_ACCELERATION_TOTAL, store.linearAcceleration.length());
} }
if (store.flightConditions != null) { if (store.flightConditions != null) {
double Re = (store.flightConditions.getVelocity() * double Re = (store.flightConditions.getVelocity() *
status.getConfiguration().getLengthAerodynamic() / status.getConfiguration().getLengthAerodynamic() /
store.flightConditions.getAtmosphericConditions().getKinematicViscosity()); store.flightConditions.getAtmosphericConditions().getKinematicViscosity());
data.setValue(FlightDataType.TYPE_REYNOLDS_NUMBER, Re); dataBranch.setValue(FlightDataType.TYPE_REYNOLDS_NUMBER, Re);
} }
data.setValue(FlightDataType.TYPE_VELOCITY_Z, status.getRocketVelocity().z); dataBranch.setValue(FlightDataType.TYPE_VELOCITY_Z, status.getRocketVelocity().z);
if (store.linearAcceleration != null) { if (store.linearAcceleration != null) {
data.setValue(FlightDataType.TYPE_ACCELERATION_Z, store.linearAcceleration.z); dataBranch.setValue(FlightDataType.TYPE_ACCELERATION_Z, store.linearAcceleration.z);
} }
if (store.flightConditions != null) { if (store.flightConditions != null) {
data.setValue(FlightDataType.TYPE_VELOCITY_TOTAL, status.getRocketVelocity().length()); dataBranch.setValue(FlightDataType.TYPE_VELOCITY_TOTAL, status.getRocketVelocity().length());
data.setValue(FlightDataType.TYPE_MACH_NUMBER, store.flightConditions.getMach()); dataBranch.setValue(FlightDataType.TYPE_MACH_NUMBER, store.flightConditions.getMach());
} }
if (store.rocketMass != null) { if (store.rocketMass != null) {
data.setValue(FlightDataType.TYPE_CG_LOCATION, store.rocketMass.getCM().x); dataBranch.setValue(FlightDataType.TYPE_CG_LOCATION, store.rocketMass.getCM().x);
} }
if (status.isLaunchRodCleared()) { if (status.isLaunchRodCleared()) {
// Don't include CP and stability with huge launch AOA // Don't include CP and stability with huge launch AOA
if (store.forces != null) { if (store.forces != null) {
data.setValue(FlightDataType.TYPE_CP_LOCATION, store.forces.getCP().x); dataBranch.setValue(FlightDataType.TYPE_CP_LOCATION, store.forces.getCP().x);
} }
if (store.forces != null && store.flightConditions != null && store.rocketMass != null) { if (store.forces != null && store.flightConditions != null && store.rocketMass != null) {
data.setValue(FlightDataType.TYPE_STABILITY, dataBranch.setValue(FlightDataType.TYPE_STABILITY,
(store.forces.getCP().x - store.rocketMass.getCM().x) / store.flightConditions.getRefLength()); (store.forces.getCP().x - store.rocketMass.getCM().x) / store.flightConditions.getRefLength());
} }
} }
if (null != store.motorMass) { if (null != store.motorMass) {
data.setValue(FlightDataType.TYPE_MOTOR_MASS, store.motorMass.getMass()); dataBranch.setValue(FlightDataType.TYPE_MOTOR_MASS, store.motorMass.getMass());
//data.setValue(FlightDataType.TYPE_MOTOR_LONGITUDINAL_INERTIA, store.motorMassData.getLongitudinalInertia()); //dataBranch.setValue(FlightDataType.TYPE_MOTOR_LONGITUDINAL_INERTIA, store.motorMassData.getLongitudinalInertia());
//data.setValue(FlightDataType.TYPE_MOTOR_ROTATIONAL_INERTIA, store.motorMassData.getRotationalInertia()); //dataBranch.setValue(FlightDataType.TYPE_MOTOR_ROTATIONAL_INERTIA, store.motorMassData.getRotationalInertia());
} }
if (store.rocketMass != null) { if (store.rocketMass != null) {
// N.B.: These refer to total mass // N.B.: These refer to total mass
data.setValue(FlightDataType.TYPE_MASS, store.rocketMass.getMass()); dataBranch.setValue(FlightDataType.TYPE_MASS, store.rocketMass.getMass());
data.setValue(FlightDataType.TYPE_LONGITUDINAL_INERTIA, store.rocketMass.getLongitudinalInertia()); dataBranch.setValue(FlightDataType.TYPE_LONGITUDINAL_INERTIA, store.rocketMass.getLongitudinalInertia());
data.setValue(FlightDataType.TYPE_ROTATIONAL_INERTIA, store.rocketMass.getRotationalInertia()); dataBranch.setValue(FlightDataType.TYPE_ROTATIONAL_INERTIA, store.rocketMass.getRotationalInertia());
} }
data.setValue(FlightDataType.TYPE_THRUST_FORCE, store.thrustForce); dataBranch.setValue(FlightDataType.TYPE_THRUST_FORCE, store.thrustForce);
double weight = store.rocketMass.getMass() * store.gravity; double weight = store.rocketMass.getMass() * store.gravity;
data.setValue(FlightDataType.TYPE_THRUST_WEIGHT_RATIO, store.thrustForce / weight); dataBranch.setValue(FlightDataType.TYPE_THRUST_WEIGHT_RATIO, store.thrustForce / weight);
data.setValue(FlightDataType.TYPE_DRAG_FORCE, store.dragForce); dataBranch.setValue(FlightDataType.TYPE_DRAG_FORCE, store.dragForce);
data.setValue(FlightDataType.TYPE_GRAVITY, store.gravity); dataBranch.setValue(FlightDataType.TYPE_GRAVITY, store.gravity);
if (status.isLaunchRodCleared() && store.forces != null) { if (status.isLaunchRodCleared() && store.forces != null) {
if (store.rocketMass != null && store.flightConditions != null) { if (store.rocketMass != null && store.flightConditions != null) {
data.setValue(FlightDataType.TYPE_PITCH_MOMENT_COEFF, dataBranch.setValue(FlightDataType.TYPE_PITCH_MOMENT_COEFF,
store.forces.getCm() - store.forces.getCN() * store.rocketMass.getCM().x / store.flightConditions.getRefLength()); store.forces.getCm() - store.forces.getCN() * store.rocketMass.getCM().x / store.flightConditions.getRefLength());
data.setValue(FlightDataType.TYPE_YAW_MOMENT_COEFF, dataBranch.setValue(FlightDataType.TYPE_YAW_MOMENT_COEFF,
store.forces.getCyaw() - store.forces.getCside() * store.rocketMass.getCM().x / store.flightConditions.getRefLength()); store.forces.getCyaw() - store.forces.getCside() * store.rocketMass.getCM().x / store.flightConditions.getRefLength());
} }
data.setValue(FlightDataType.TYPE_NORMAL_FORCE_COEFF, store.forces.getCN()); dataBranch.setValue(FlightDataType.TYPE_NORMAL_FORCE_COEFF, store.forces.getCN());
data.setValue(FlightDataType.TYPE_SIDE_FORCE_COEFF, store.forces.getCside()); dataBranch.setValue(FlightDataType.TYPE_SIDE_FORCE_COEFF, store.forces.getCside());
data.setValue(FlightDataType.TYPE_ROLL_MOMENT_COEFF, store.forces.getCroll()); dataBranch.setValue(FlightDataType.TYPE_ROLL_MOMENT_COEFF, store.forces.getCroll());
data.setValue(FlightDataType.TYPE_ROLL_FORCING_COEFF, store.forces.getCrollForce()); dataBranch.setValue(FlightDataType.TYPE_ROLL_FORCING_COEFF, store.forces.getCrollForce());
data.setValue(FlightDataType.TYPE_ROLL_DAMPING_COEFF, store.forces.getCrollDamp()); dataBranch.setValue(FlightDataType.TYPE_ROLL_DAMPING_COEFF, store.forces.getCrollDamp());
data.setValue(FlightDataType.TYPE_PITCH_DAMPING_MOMENT_COEFF, dataBranch.setValue(FlightDataType.TYPE_PITCH_DAMPING_MOMENT_COEFF,
store.forces.getPitchDampingMoment()); store.forces.getPitchDampingMoment());
} }
if (store.forces != null) { if (store.forces != null) {
data.setValue(FlightDataType.TYPE_DRAG_COEFF, store.forces.getCD()); dataBranch.setValue(FlightDataType.TYPE_DRAG_COEFF, store.forces.getCD());
data.setValue(FlightDataType.TYPE_AXIAL_DRAG_COEFF, store.forces.getCDaxial()); dataBranch.setValue(FlightDataType.TYPE_AXIAL_DRAG_COEFF, store.forces.getCDaxial());
data.setValue(FlightDataType.TYPE_FRICTION_DRAG_COEFF, store.forces.getFrictionCD()); dataBranch.setValue(FlightDataType.TYPE_FRICTION_DRAG_COEFF, store.forces.getFrictionCD());
data.setValue(FlightDataType.TYPE_PRESSURE_DRAG_COEFF, store.forces.getPressureCD()); dataBranch.setValue(FlightDataType.TYPE_PRESSURE_DRAG_COEFF, store.forces.getPressureCD());
data.setValue(FlightDataType.TYPE_BASE_DRAG_COEFF, store.forces.getBaseCD()); dataBranch.setValue(FlightDataType.TYPE_BASE_DRAG_COEFF, store.forces.getBaseCD());
} }
if (store.flightConditions != null) { if (store.flightConditions != null) {
data.setValue(FlightDataType.TYPE_REFERENCE_LENGTH, store.flightConditions.getRefLength()); dataBranch.setValue(FlightDataType.TYPE_REFERENCE_LENGTH, store.flightConditions.getRefLength());
data.setValue(FlightDataType.TYPE_REFERENCE_AREA, store.flightConditions.getRefArea()); dataBranch.setValue(FlightDataType.TYPE_REFERENCE_AREA, store.flightConditions.getRefArea());
data.setValue(FlightDataType.TYPE_PITCH_RATE, store.flightConditions.getPitchRate()); dataBranch.setValue(FlightDataType.TYPE_PITCH_RATE, store.flightConditions.getPitchRate());
data.setValue(FlightDataType.TYPE_YAW_RATE, store.flightConditions.getYawRate()); dataBranch.setValue(FlightDataType.TYPE_YAW_RATE, store.flightConditions.getYawRate());
data.setValue(FlightDataType.TYPE_ROLL_RATE, store.flightConditions.getRollRate()); dataBranch.setValue(FlightDataType.TYPE_ROLL_RATE, store.flightConditions.getRollRate());
data.setValue(FlightDataType.TYPE_AOA, store.flightConditions.getAOA()); dataBranch.setValue(FlightDataType.TYPE_AOA, store.flightConditions.getAOA());
} }
Coordinate c = status.getRocketOrientationQuaternion().rotateZ(); Coordinate c = status.getRocketOrientationQuaternion().rotateZ();
@ -644,23 +644,23 @@ public class RK4SimulationStepper extends AbstractSimulationStepper {
double phi = Math.atan2(c.y, c.x); double phi = Math.atan2(c.y, c.x);
if (phi < -(Math.PI - 0.0001)) if (phi < -(Math.PI - 0.0001))
phi = Math.PI; phi = Math.PI;
data.setValue(FlightDataType.TYPE_ORIENTATION_THETA, theta); dataBranch.setValue(FlightDataType.TYPE_ORIENTATION_THETA, theta);
data.setValue(FlightDataType.TYPE_ORIENTATION_PHI, phi); dataBranch.setValue(FlightDataType.TYPE_ORIENTATION_PHI, phi);
data.setValue(FlightDataType.TYPE_WIND_VELOCITY, store.windSpeed); dataBranch.setValue(FlightDataType.TYPE_WIND_VELOCITY, store.windSpeed);
if (store.flightConditions != null) { if (store.flightConditions != null) {
data.setValue(FlightDataType.TYPE_AIR_TEMPERATURE, dataBranch.setValue(FlightDataType.TYPE_AIR_TEMPERATURE,
store.flightConditions.getAtmosphericConditions().getTemperature()); store.flightConditions.getAtmosphericConditions().getTemperature());
data.setValue(FlightDataType.TYPE_AIR_PRESSURE, dataBranch.setValue(FlightDataType.TYPE_AIR_PRESSURE,
store.flightConditions.getAtmosphericConditions().getPressure()); store.flightConditions.getAtmosphericConditions().getPressure());
data.setValue(FlightDataType.TYPE_SPEED_OF_SOUND, dataBranch.setValue(FlightDataType.TYPE_SPEED_OF_SOUND,
store.flightConditions.getAtmosphericConditions().getMachSpeed()); store.flightConditions.getAtmosphericConditions().getMachSpeed());
} }
data.setValue(FlightDataType.TYPE_TIME_STEP, store.timestep); dataBranch.setValue(FlightDataType.TYPE_TIME_STEP, store.timestep);
data.setValue(FlightDataType.TYPE_COMPUTATION_TIME, dataBranch.setValue(FlightDataType.TYPE_COMPUTATION_TIME,
(System.nanoTime() - status.getSimulationStartWallTime()) / 1000000000.0); (System.nanoTime() - status.getSimulationStartWallTime()) / 1000000000.0);
} }

View File

@ -39,7 +39,7 @@ public class SimulationStatus implements Monitorable {
private SimulationConditions simulationConditions; private SimulationConditions simulationConditions;
private FlightConfiguration configuration; private FlightConfiguration configuration;
private FlightDataBranch flightData; private FlightDataBranch flightDataBranch;
private double time; private double time;
@ -169,8 +169,8 @@ public class SimulationStatus implements Monitorable {
public SimulationStatus(SimulationStatus orig) { public SimulationStatus(SimulationStatus orig) {
this.simulationConditions = orig.simulationConditions.clone(); this.simulationConditions = orig.simulationConditions.clone();
this.configuration = orig.configuration.clone(); this.configuration = orig.configuration.clone();
// FlightData is not cloned. // FlightDataBranch is not cloned.
this.flightData = orig.flightData; this.flightDataBranch = orig.flightDataBranch;
this.time = orig.time; this.time = orig.time;
this.position = orig.position; this.position = orig.position;
this.acceleration = orig.acceleration; this.acceleration = orig.acceleration;
@ -247,15 +247,15 @@ public class SimulationStatus implements Monitorable {
return configuration; return configuration;
} }
public void setFlightData(FlightDataBranch flightData) { public void setFlightDataBranch(FlightDataBranch flightDataBranch) {
if (this.flightData != null) if (this.flightDataBranch != null)
this.modIDadd += this.flightData.getModID(); this.modIDadd += this.flightDataBranch.getModID();
this.modID++; this.modID++;
this.flightData = flightData; this.flightDataBranch = flightDataBranch;
} }
public FlightDataBranch getFlightData() { public FlightDataBranch getFlightDataBranch() {
return flightData; return flightDataBranch;
} }
public void setRocketPosition(Coordinate position) { public void setRocketPosition(Coordinate position) {
@ -481,7 +481,7 @@ public class SimulationStatus implements Monitorable {
@Override @Override
public int getModID() { public int getModID() {
return (modID + modIDadd + simulationConditions.getModID() + configuration.getModID() + return (modID + modIDadd + simulationConditions.getModID() + configuration.getModID() +
flightData.getModID() + deployedRecoveryDevices.getModID() + flightDataBranch.getModID() + deployedRecoveryDevices.getModID() +
eventQueue.getModID() + warnings.getModID()); eventQueue.getModID() + warnings.getModID());
} }

View File

@ -6,6 +6,7 @@ import java.util.regex.Pattern;
import info.openrocket.core.document.OpenRocketDocument; import info.openrocket.core.document.OpenRocketDocument;
import info.openrocket.core.logging.Markers; import info.openrocket.core.logging.Markers;
import info.openrocket.core.simulation.FlightDataBranch;
import info.openrocket.core.simulation.FlightDataType; import info.openrocket.core.simulation.FlightDataType;
import info.openrocket.core.simulation.SimulationStatus; import info.openrocket.core.simulation.SimulationStatus;
import info.openrocket.core.unit.FixedUnitGroup; import info.openrocket.core.unit.FixedUnitGroup;
@ -431,8 +432,9 @@ public class CustomExpression implements Cloneable {
// Set all the built-in variables. Strictly we surely won't need all of them // Set all the built-in variables. Strictly we surely won't need all of them
// Going through and checking them to include only the ones used *might* give a // Going through and checking them to include only the ones used *might* give a
// speedup // speedup
for (FlightDataType type : status.getFlightData().getTypes()) { FlightDataBranch dataBranch = status.getFlightDataBranch();
double value = status.getFlightData().getLast(type); for (FlightDataType type : dataBranch.getTypes()) {
double value = dataBranch.getLast(type);
calc.setVariable(new Variable(type.getSymbol(), value)); calc.setVariable(new Variable(type.getSymbol(), value));
} }

View File

@ -26,12 +26,12 @@ public class CustomExpressionSimulationListener extends AbstractSimulationListen
return; return;
} }
// Calculate values for custom expressions // Calculate values for custom expressions
FlightDataBranch data = status.getFlightData(); FlightDataBranch dataBranch = status.getFlightDataBranch();
for (CustomExpression expression : expressions) { for (CustomExpression expression : expressions) {
double value = expression.evaluateDouble(status); double value = expression.evaluateDouble(status);
// log.debug("Setting value of custom expression "+expression.toString()+" = // log.debug("Setting value of custom expression "+expression.toString()+" =
// "+value); // "+value);
data.setValue(expression.getType(), value); dataBranch.setValue(expression.getType(), value);
} }
} }

View File

@ -10,6 +10,7 @@ import de.congrace.exp4j.Variable;
import info.openrocket.core.document.OpenRocketDocument; import info.openrocket.core.document.OpenRocketDocument;
import info.openrocket.core.logging.Markers; import info.openrocket.core.logging.Markers;
import info.openrocket.core.simulation.customexpression.CustomExpression; import info.openrocket.core.simulation.customexpression.CustomExpression;
import info.openrocket.core.simulation.FlightDataBranch;
import info.openrocket.core.simulation.FlightDataType; import info.openrocket.core.simulation.FlightDataType;
import info.openrocket.core.simulation.SimulationStatus; import info.openrocket.core.simulation.SimulationStatus;
import info.openrocket.core.util.LinearInterpolator; import info.openrocket.core.util.LinearInterpolator;
@ -41,13 +42,14 @@ public class IndexExpression extends CustomExpression {
// Otherwise there will be a type conflict when we get the new data. // Otherwise there will be a type conflict when we get the new data.
FlightDataType myType = FlightDataType.getType(null, getSymbol(), null); FlightDataType myType = FlightDataType.getType(null, getSymbol(), null);
List<Double> data = status.getFlightData().get(myType); FlightDataBranch dataBranch = status.getFlightDataBranch();
List<Double> time = status.getFlightData().get(FlightDataType.TYPE_TIME); List<Double> data = dataBranch.get(myType);
List<Double> time = dataBranch.get(FlightDataType.TYPE_TIME);
LinearInterpolator interp = new LinearInterpolator(time, data); LinearInterpolator interp = new LinearInterpolator(time, data);
// Set the variables in the expression to evaluate // Set the variables in the expression to evaluate
for (FlightDataType etype : status.getFlightData().getTypes()) { for (FlightDataType etype : dataBranch.getTypes()) {
double value = status.getFlightData().getLast(etype); double value = dataBranch.getLast(etype);
calc.setVariable(new Variable(etype.getSymbol(), value)); calc.setVariable(new Variable(etype.getSymbol(), value));
} }

View File

@ -14,6 +14,7 @@ import de.congrace.exp4j.ExpressionBuilder;
import de.congrace.exp4j.Variable; import de.congrace.exp4j.Variable;
import info.openrocket.core.document.OpenRocketDocument; import info.openrocket.core.document.OpenRocketDocument;
import info.openrocket.core.logging.Markers; import info.openrocket.core.logging.Markers;
import info.openrocket.core.simulation.FlightDataBranch;
import info.openrocket.core.simulation.FlightDataType; import info.openrocket.core.simulation.FlightDataType;
import info.openrocket.core.simulation.SimulationStatus; import info.openrocket.core.simulation.SimulationStatus;
import info.openrocket.core.util.ArrayUtils; import info.openrocket.core.util.ArrayUtils;
@ -66,9 +67,10 @@ public class RangeExpression extends CustomExpression {
return new Variable("Unknown"); return new Variable("Unknown");
} }
FlightDataBranch dataBranch = status.getFlightDataBranch();
// Set the variables in the start and end calculators // Set the variables in the start and end calculators
for (FlightDataType type : status.getFlightData().getTypes()) { for (FlightDataType type : dataBranch.getTypes()) {
double value = status.getFlightData().getLast(type); double value = dataBranch.getLast(type);
startCalc.setVariable(new Variable(type.getSymbol(), value)); startCalc.setVariable(new Variable(type.getSymbol(), value));
endCalc.setVariable(new Variable(type.getSymbol(), value)); endCalc.setVariable(new Variable(type.getSymbol(), value));
} }
@ -80,8 +82,8 @@ public class RangeExpression extends CustomExpression {
// Otherwise there will be a type conflict when we get the new data. // Otherwise there will be a type conflict when we get the new data.
FlightDataType type = FlightDataType.getType(null, getSymbol(), null); FlightDataType type = FlightDataType.getType(null, getSymbol(), null);
List<Double> data = status.getFlightData().get(type); List<Double> data = dataBranch.get(type);
List<Double> time = status.getFlightData().get(FlightDataType.TYPE_TIME); List<Double> time = dataBranch.get(FlightDataType.TYPE_TIME);
LinearInterpolator interp = new LinearInterpolator(time, data); LinearInterpolator interp = new LinearInterpolator(time, data);
// Evaluate the expression to get the start and end of the range // Evaluate the expression to get the start and end of the range

View File

@ -63,122 +63,122 @@ public class CSVSave extends AbstractSimulationExtension {
THETA { THETA {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_ORIENTATION_THETA); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_ORIENTATION_THETA);
} }
}, },
PHI { PHI {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_ORIENTATION_PHI); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_ORIENTATION_PHI);
} }
}, },
AOA { AOA {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_AOA); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_AOA);
} }
}, },
ROLLRATE { ROLLRATE {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_ROLL_RATE); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_ROLL_RATE);
} }
}, },
PITCHRATE { PITCHRATE {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_PITCH_RATE); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_PITCH_RATE);
} }
}, },
PITCHMOMENT { PITCHMOMENT {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_PITCH_MOMENT_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_PITCH_MOMENT_COEFF);
} }
}, },
YAWMOMENT { YAWMOMENT {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_YAW_MOMENT_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_YAW_MOMENT_COEFF);
} }
}, },
ROLLMOMENT { ROLLMOMENT {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_ROLL_MOMENT_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_ROLL_MOMENT_COEFF);
} }
}, },
NORMALFORCE { NORMALFORCE {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_NORMAL_FORCE_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_NORMAL_FORCE_COEFF);
} }
}, },
SIDEFORCE { SIDEFORCE {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_SIDE_FORCE_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_SIDE_FORCE_COEFF);
} }
}, },
AXIALFORCE { AXIALFORCE {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_DRAG_FORCE); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_DRAG_FORCE);
} }
}, },
WINDSPEED { WINDSPEED {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_WIND_VELOCITY); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_WIND_VELOCITY);
} }
}, },
PITCHDAMPING { PITCHDAMPING {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_PITCH_DAMPING_MOMENT_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_PITCH_DAMPING_MOMENT_COEFF);
} }
}, },
CA { CA {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_AXIAL_DRAG_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_AXIAL_DRAG_COEFF);
} }
}, },
CD { CD {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_DRAG_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_DRAG_COEFF);
} }
}, },
CDpressure { CDpressure {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_PRESSURE_DRAG_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_PRESSURE_DRAG_COEFF);
} }
}, },
CDfriction { CDfriction {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_FRICTION_DRAG_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_FRICTION_DRAG_COEFF);
} }
}, },
CDbase { CDbase {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_BASE_DRAG_COEFF); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_BASE_DRAG_COEFF);
} }
}, },
MACH { MACH {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_MACH_NUMBER); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_MACH_NUMBER);
} }
}, },
RE { RE {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_REYNOLDS_NUMBER); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_REYNOLDS_NUMBER);
} }
}, },
@ -204,7 +204,7 @@ public class CSVSave extends AbstractSimulationExtension {
MASS { MASS {
@Override @Override
public double getValue(SimulationStatus status) { public double getValue(SimulationStatus status) {
return status.getFlightData().getLast(FlightDataType.TYPE_MASS); return status.getFlightDataBranch().getLast(FlightDataType.TYPE_MASS);
} }
} }

View File

@ -61,8 +61,8 @@ public class DampingMoment extends AbstractSimulationExtension {
public FlightConditions postFlightConditions(SimulationStatus status, FlightConditions flightConditions) public FlightConditions postFlightConditions(SimulationStatus status, FlightConditions flightConditions)
throws SimulationException { throws SimulationException {
// status.getFlightData().setValue(cdm, aerodynamicPart + propulsivePart); // status.getFlightDataBranch().setValue(cdm, aerodynamicPart + propulsivePart);
status.getFlightData().setValue(cdm, calculate(status, flightConditions)); status.getFlightDataBranch().setValue(cdm, calculate(status, flightConditions));
return flightConditions; return flightConditions;
} }
@ -72,10 +72,10 @@ public class DampingMoment extends AbstractSimulationExtension {
// Work out the propulsive/jet damping part of the moment. // Work out the propulsive/jet damping part of the moment.
// dm/dt = (thrust - ma)/v // dm/dt = (thrust - ma)/v
FlightDataBranch data = status.getFlightData(); FlightDataBranch dataBranch = status.getFlightDataBranch();
List<Double> mpAll = data.get(FlightDataType.TYPE_MOTOR_MASS); List<Double> mpAll = dataBranch.get(FlightDataType.TYPE_MOTOR_MASS);
List<Double> time = data.get(FlightDataType.TYPE_TIME); List<Double> time = dataBranch.get(FlightDataType.TYPE_TIME);
if (mpAll == null || time == null) { if (mpAll == null || time == null) {
return Double.NaN; return Double.NaN;
} }
@ -98,7 +98,7 @@ public class DampingMoment extends AbstractSimulationExtension {
mdot = (mpAll.get(len - 1) - mpAll.get(len - 2)) / (time.get(len - 1) - time.get(len - 2)); mdot = (mpAll.get(len - 1) - mpAll.get(len - 2)) / (time.get(len - 1) - time.get(len - 2));
} }
double cg = data.getLast(FlightDataType.TYPE_CG_LOCATION); double cg = dataBranch.getLast(FlightDataType.TYPE_CG_LOCATION);
// find the maximum distance from nose to nozzle. // find the maximum distance from nose to nozzle.
double nozzleDistance = 0; double nozzleDistance = 0;

View File

@ -37,17 +37,17 @@ public class PrintSimulation extends AbstractSimulationExtension {
@Override @Override
public void postStep(SimulationStatus status) throws SimulationException { public void postStep(SimulationStatus status) throws SimulationException {
FlightDataBranch data = status.getFlightData(); FlightDataBranch dataBranch = status.getFlightDataBranch();
System.out.printf("*** stepTaken *** time=%.3f position=" + status.getRocketPosition() + System.out.printf("*** stepTaken *** time=%.3f position=" + status.getRocketPosition() +
" velocity=" + status.getRocketVelocity() + "=%.3f\n", status.getSimulationTime(), " velocity=" + status.getRocketVelocity() + "=%.3f\n", status.getSimulationTime(),
status.getRocketVelocity().length()); status.getRocketVelocity().length());
System.out.printf(" thrust=%.3fN drag==%.3fN mass=%.3fkg " + System.out.printf(" thrust=%.3fN drag==%.3fN mass=%.3fkg " +
"accZ=%.3fm/s2 acc=%.3fm/s2\n", "accZ=%.3fm/s2 acc=%.3fm/s2\n",
data.getLast(FlightDataType.TYPE_THRUST_FORCE), dataBranch.getLast(FlightDataType.TYPE_THRUST_FORCE),
data.getLast(FlightDataType.TYPE_DRAG_FORCE), dataBranch.getLast(FlightDataType.TYPE_DRAG_FORCE),
data.getLast(FlightDataType.TYPE_MASS), dataBranch.getLast(FlightDataType.TYPE_MASS),
data.getLast(FlightDataType.TYPE_ACCELERATION_Z), dataBranch.getLast(FlightDataType.TYPE_ACCELERATION_Z),
data.getLast(FlightDataType.TYPE_ACCELERATION_TOTAL)); dataBranch.getLast(FlightDataType.TYPE_ACCELERATION_TOTAL));
} }
} }

View File

@ -198,7 +198,7 @@ public class RollControl extends AbstractSimulationExtension {
// Set the control fin cant and store the data // Set the control fin cant and store the data
finset.setCantAngle(finPosition); finset.setCantAngle(finPosition);
status.getFlightData().setValue(FIN_CANT_TYPE, finPosition); status.getFlightDataBranch().setValue(FIN_CANT_TYPE, finPosition);
} }
@Override @Override

View File

@ -216,13 +216,13 @@ public class SimulationPlot {
if (thisBranch.getLength() == 0) { if (thisBranch.getLength() == 0) {
// Add an empty series to keep the series count consistent // Add an empty series to keep the series count consistent
XYSeries series = new XYSeries(seriesCount++, false, true); XYSeries series = new XYSeries(seriesCount++, false, true);
series.setDescription(thisBranch.getBranchName() + ": " + name); series.setDescription(thisBranch.getName() + ": " + name);
data[axis].addSeries(series); data[axis].addSeries(series);
continue; continue;
} }
XYSeries series = new XYSeries(seriesCount++, false, true); XYSeries series = new XYSeries(seriesCount++, false, true);
series.setDescription(thisBranch.getBranchName() + ": " + name); series.setDescription(thisBranch.getName() + ": " + name);
// Copy all the data from the secondary branch // Copy all the data from the secondary branch
List<Double> plotx = thisBranch.get(domainType); List<Double> plotx = thisBranch.get(domainType);
@ -848,7 +848,7 @@ public class SimulationPlot {
abortString = new StringBuilder(trans.get("simulationplot.abort.title")); abortString = new StringBuilder(trans.get("simulationplot.abort.title"));
} }
abortString.append("\n") abortString.append("\n")
.append(trans.get("simulationplot.abort.stage")).append(": ").append(branch.getBranchName()).append("; ") .append(trans.get("simulationplot.abort.stage")).append(": ").append(branch.getName()).append("; ")
.append(trans.get("simulationplot.abort.time")).append(": ").append(abortEvent.getTime()).append(" s; ") .append(trans.get("simulationplot.abort.time")).append(": ").append(abortEvent.getTime()).append(" s; ")
.append(trans.get("simulationplot.abort.cause")).append(": ").append(((SimulationAbort) abortEvent.getData()).getMessageDescription()); .append(trans.get("simulationplot.abort.cause")).append(": ").append(((SimulationAbort) abortEvent.getData()).getMessageDescription());
} }

View File

@ -28,7 +28,7 @@ public abstract class Util {
// on the stage name there is no guarantee they are unique. In order to address this, we first assume // on the stage name there is no guarantee they are unique. In order to address this, we first assume
// all the names are unique, then go through them looking for duplicates. // all the names are unique, then go through them looking for duplicates.
for (int i = 0; i < simulation.getSimulatedData().getBranchCount(); i++) { for (int i = 0; i < simulation.getSimulatedData().getBranchCount(); i++) {
stages.add(simulation.getSimulatedData().getBranch(i).getBranchName()); stages.add(simulation.getSimulatedData().getBranch(i).getName());
} }
// check for duplicates: // check for duplicates:
for( int i = 0; i< stages.size(); i++ ) { for( int i = 0; i< stages.size(); i++ ) {

View File

@ -430,7 +430,7 @@ public class SimulationRunDialog extends JDialog {
String message; String message;
if (dataBranch != null) { if (dataBranch != null) {
message = trans.get("SimuRunDlg.msg.branchErrorOccurred") + "\"" + dataBranch.getBranchName() + "\""; message = trans.get("SimuRunDlg.msg.branchErrorOccurred") + "\"" + dataBranch.getName() + "\"";
} else { } else {
message = trans.get("SimuRunDlg.msg.errorOccurred"); message = trans.get("SimuRunDlg.msg.errorOccurred");
} }