Remove unused methods from SimulationListener
This commit is contained in:
parent
e6b5248a0c
commit
807450b407
@ -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 ////
|
||||
|
||||
|
@ -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;
|
||||
@ -17,20 +16,20 @@ import net.sf.openrocket.util.Coordinate;
|
||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||
*/
|
||||
public interface SimulationComputationListener extends SimulationListener {
|
||||
|
||||
|
||||
|
||||
|
||||
//////// Computation/modeling related callbacks ////////
|
||||
|
||||
public AccelerationData preAccelerationCalculation(SimulationStatus status) throws SimulationException;
|
||||
|
||||
public AccelerationData postAccelerationCalculation(SimulationStatus status, AccelerationData acceleration)
|
||||
throws SimulationException;
|
||||
throws SimulationException;
|
||||
|
||||
public AtmosphericConditions preAtmosphericModel(SimulationStatus status)
|
||||
throws SimulationException;
|
||||
throws SimulationException;
|
||||
|
||||
public AtmosphericConditions postAtmosphericModel(SimulationStatus status, AtmosphericConditions atmosphericConditions)
|
||||
throws SimulationException;
|
||||
throws SimulationException;
|
||||
|
||||
|
||||
public Coordinate preWindModel(SimulationStatus status) throws SimulationException;
|
||||
@ -42,29 +41,27 @@ public interface SimulationComputationListener extends SimulationListener {
|
||||
|
||||
public double postGravityModel(SimulationStatus status, double gravity) throws SimulationException;
|
||||
|
||||
|
||||
|
||||
public FlightConditions preFlightConditions(SimulationStatus status)
|
||||
throws SimulationException;
|
||||
throws SimulationException;
|
||||
|
||||
public FlightConditions postFlightConditions(SimulationStatus status, FlightConditions flightConditions)
|
||||
throws SimulationException;
|
||||
throws SimulationException;
|
||||
|
||||
|
||||
public AerodynamicForces preAerodynamicCalculation(SimulationStatus status)
|
||||
throws SimulationException;
|
||||
throws SimulationException;
|
||||
|
||||
public AerodynamicForces postAerodynamicCalculation(SimulationStatus status, AerodynamicForces forces)
|
||||
throws SimulationException;
|
||||
throws SimulationException;
|
||||
|
||||
public MassData preMassCalculation(SimulationStatus status) throws SimulationException;
|
||||
|
||||
public MassData postMassCalculation(SimulationStatus status, MassData massData) throws SimulationException;
|
||||
|
||||
|
||||
|
||||
|
||||
public double preSimpleThrustCalculation(SimulationStatus status) throws SimulationException;
|
||||
|
||||
public double postSimpleThrustCalculation(SimulationStatus status, double thrust) throws SimulationException;
|
||||
|
||||
@Override
|
||||
public FlightDataType[] getFlightDataTypes();
|
||||
|
||||
}
|
||||
|
@ -4,14 +4,13 @@ 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;
|
||||
|
||||
public interface SimulationEventListener {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called before adding a flight event to the event queue.
|
||||
*
|
||||
@ -23,7 +22,7 @@ public interface SimulationEventListener {
|
||||
public boolean addFlightEvent(SimulationStatus status, FlightEvent event) throws SimulationException;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called before handling a flight event.
|
||||
*
|
||||
@ -57,10 +56,6 @@ public interface SimulationEventListener {
|
||||
*/
|
||||
public boolean recoveryDeviceDeployment(SimulationStatus status, RecoveryDevice recoveryDevice)
|
||||
throws SimulationException;
|
||||
|
||||
|
||||
|
||||
public FlightDataType[] getFlightDataTypes();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 {
|
||||
@ -42,11 +29,11 @@ public class DampingMoment extends AbstractSimulationListener {
|
||||
|
||||
//status.getFlightData().setValue(type, aerodynamicPart + propulsivePart);
|
||||
status.getFlightData().setValue(type, calculate(status, flightConditions));
|
||||
|
||||
|
||||
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) };
|
||||
@ -71,22 +58,22 @@ public class DampingMoment extends AbstractSimulationListener {
|
||||
//double[] coeff = interp.interpolator(y);
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now can get the propulsive part
|
||||
@ -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();
|
||||
@ -121,7 +109,7 @@ public class DampingMoment extends AbstractSimulationListener {
|
||||
aerodynamicPart = aerodynamicPart * .5 * rho * v * ar;
|
||||
|
||||
return aerodynamicPart + propulsivePart;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user