Remove unused methods from SimulationListener

This commit is contained in:
Sampo Niskanen 2014-12-27 10:41:09 +02:00
parent e6b5248a0c
commit 807450b407
5 changed files with 32 additions and 96 deletions

View File

@ -8,7 +8,6 @@ import net.sf.openrocket.motor.MotorInstance;
import net.sf.openrocket.rocketcomponent.MotorMount;
import net.sf.openrocket.rocketcomponent.RecoveryDevice;
import net.sf.openrocket.simulation.AccelerationData;
import net.sf.openrocket.simulation.FlightDataType;
import net.sf.openrocket.simulation.FlightEvent;
import net.sf.openrocket.simulation.MassData;
import net.sf.openrocket.simulation.SimulationStatus;
@ -28,16 +27,6 @@ public class AbstractSimulationListener implements SimulationListener, Simulatio
//// SimulationListener ////
@Override
public String getName() {
return this.getClass().getSimpleName();
}
@Override
public String[] getMenuPosition() {
return new String[0];
}
@Override
public void startSimulation(SimulationStatus status) throws SimulationException {
// No-op
@ -68,14 +57,6 @@ public class AbstractSimulationListener implements SimulationListener, Simulatio
return false;
}
/**
* Return an array of any flight data types this listener creates.
*/
@Override
public FlightDataType[] getFlightDataTypes() {
return new FlightDataType[] {};
}
//// SimulationEventListener ////

View File

@ -4,7 +4,6 @@ import net.sf.openrocket.aerodynamics.AerodynamicForces;
import net.sf.openrocket.aerodynamics.FlightConditions;
import net.sf.openrocket.models.atmosphere.AtmosphericConditions;
import net.sf.openrocket.simulation.AccelerationData;
import net.sf.openrocket.simulation.FlightDataType;
import net.sf.openrocket.simulation.MassData;
import net.sf.openrocket.simulation.SimulationStatus;
import net.sf.openrocket.simulation.exception.SimulationException;
@ -65,6 +64,4 @@ public interface SimulationComputationListener extends SimulationListener {
public double postSimpleThrustCalculation(SimulationStatus status, double thrust) throws SimulationException;
@Override
public FlightDataType[] getFlightDataTypes();
}

View File

@ -4,7 +4,6 @@ import net.sf.openrocket.motor.MotorId;
import net.sf.openrocket.motor.MotorInstance;
import net.sf.openrocket.rocketcomponent.MotorMount;
import net.sf.openrocket.rocketcomponent.RecoveryDevice;
import net.sf.openrocket.simulation.FlightDataType;
import net.sf.openrocket.simulation.FlightEvent;
import net.sf.openrocket.simulation.SimulationStatus;
import net.sf.openrocket.simulation.exception.SimulationException;
@ -59,8 +58,4 @@ public interface SimulationEventListener {
throws SimulationException;
public FlightDataType[] getFlightDataTypes();
}

View File

@ -1,6 +1,5 @@
package net.sf.openrocket.simulation.listeners;
import net.sf.openrocket.simulation.FlightDataType;
import net.sf.openrocket.simulation.SimulationStatus;
import net.sf.openrocket.simulation.exception.SimulationException;
@ -12,25 +11,6 @@ import net.sf.openrocket.simulation.exception.SimulationException;
*/
public interface SimulationListener extends Cloneable {
/**
* Get the name of this simulation listener. Ideally this should be localized, as
* it can be displayed in the UI.
*
* @return the name of this simulation listener.
*/
public String getName();
/**
* Get the menu position of this simulation listener. This should be an array
* of localized submenu names in descending order, or an empty array for positioning
* in the base menu.
*
* @return the menu position of this simulation listener.
*/
public String[] getMenuPosition();
/**
* Called when starting a simulation.
*
@ -82,10 +62,5 @@ public interface SimulationListener extends Cloneable {
public boolean isSystemListener();
/**
* Return a list of any flight data types this listener creates.
*/
public FlightDataType[] getFlightDataTypes();
public SimulationListener clone() throws CloneNotSupportedException;
}

View File

@ -20,20 +20,7 @@ import net.sf.openrocket.util.Coordinate;
public class DampingMoment extends AbstractSimulationListener {
private static final FlightDataType type = FlightDataType.getType("Damping moment coefficient", "Cdm", UnitGroup.UNITS_COEFFICIENT);
private static final FlightDataType[] typeList = {type};
@Override
public String getName(){
return "Damping moment listener";
}
/**
* Return a list of any flight data types this listener creates.
*/
@Override
public FlightDataType[] getFlightDataTypes(){
return typeList;
}
private static final FlightDataType[] typeList = { type };
@Override
public FlightConditions postFlightConditions(SimulationStatus status, FlightConditions flightConditions) throws SimulationException {
@ -46,7 +33,7 @@ public class DampingMoment extends AbstractSimulationListener {
return flightConditions;
}
private double calculate(SimulationStatus status, FlightConditions flightConditions){
private double calculate(SimulationStatus status, FlightConditions flightConditions) {
// Work out the propulsive/jet damping part of the moment.
@ -55,15 +42,15 @@ public class DampingMoment extends AbstractSimulationListener {
List<Double> mpAll = data.get(FlightDataType.TYPE_PROPELLANT_MASS);
List<Double> time = data.get(FlightDataType.TYPE_TIME);
if (mpAll == null || time == null){
if (mpAll == null || time == null) {
return Double.NaN;
}
int len = mpAll.size();
// This isn't as accurate as I would like
double mdot=Double.NaN;
if (len > 2){
double mdot = Double.NaN;
if (len > 2) {
// Using polynomial interpolator for derivative. Doesn't help much
//double[] x = { time.get(len-5), time.get(len-4), time.get(len-3), time.get(len-2), time.get(len-1) };
//double[] y = { mpAll.get(len-5), mpAll.get(len-4), mpAll.get(len-3), mpAll.get(len-2), mpAll.get(len-1) };
@ -72,19 +59,19 @@ public class DampingMoment extends AbstractSimulationListener {
//double dt = .01;
//mdot = (interp.eval(x[4], coeff) - interp.eval(x[4]-dt, coeff))/dt;
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);
// find the maximum distance from nose to nozzle.
double nozzleDistance = 0;
for (MotorId id: status.getMotorConfiguration().getMotorIDs()){
for (MotorId id : status.getMotorConfiguration().getMotorIDs()) {
MotorInstanceConfiguration config = status.getMotorConfiguration();
Coordinate position = config.getMotorPosition(id);
double x = position.x + config.getMotorInstance(id).getParentMotor().getLength();
if (x > nozzleDistance){
if (x > nozzleDistance) {
nozzleDistance = x;
}
}
@ -99,11 +86,12 @@ public class DampingMoment extends AbstractSimulationListener {
// Must go through each component ...
Map<RocketComponent, AerodynamicForces> forces = aerocalc.getForceAnalysis(status.getConfiguration(), flightConditions, null);
for (Map.Entry<RocketComponent, AerodynamicForces> entry : forces.entrySet()){
for (Map.Entry<RocketComponent, AerodynamicForces> entry : forces.entrySet()) {
RocketComponent comp = entry.getKey();
if (!comp.isAerodynamic()) continue;
if (!comp.isAerodynamic())
continue;
//System.out.println(comp.toString());
@ -111,7 +99,7 @@ public class DampingMoment extends AbstractSimulationListener {
double Cp = entry.getValue().getCP().length();
double z = comp.getPositionValue(); //?
aerodynamicPart += CNa*Math.pow(z-Cp, 2);
aerodynamicPart += CNa * Math.pow(z - Cp, 2);
}
double v = flightConditions.getVelocity();