commit
						7934f0beec
					
				@ -1,27 +0,0 @@
 | 
			
		||||
package net.sf.openrocket.file;
 | 
			
		||||
 | 
			
		||||
import net.sf.openrocket.aerodynamics.WarningSet;
 | 
			
		||||
import net.sf.openrocket.motor.Motor;
 | 
			
		||||
import net.sf.openrocket.motor.Motor.Type;
 | 
			
		||||
import net.sf.openrocket.motor.ThrustCurveMotorPlaceholder;
 | 
			
		||||
 | 
			
		||||
public class DatabaseMotorFinderWithMissingMotors extends DatabaseMotorFinder
 | 
			
		||||
implements MotorFinder {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * This implementation returns a ThrustCurveMotorPlaceholder.
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	protected Motor handleMissingMotor(Type type, String manufacturer, String designation, double diameter, double length, String digest, WarningSet warnings) {
 | 
			
		||||
		Motor motor = new ThrustCurveMotorPlaceholder(type,
 | 
			
		||||
				manufacturer,
 | 
			
		||||
				designation,
 | 
			
		||||
				diameter,
 | 
			
		||||
				length,
 | 
			
		||||
				digest,
 | 
			
		||||
				/* delay */ Double.NaN,
 | 
			
		||||
				/*launchMass*/ Double.NaN,
 | 
			
		||||
				/*emptyMass*/ Double.NaN);
 | 
			
		||||
		return motor;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -60,16 +60,6 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor>, Se
 | 
			
		||||
		
 | 
			
		||||
		ThrustCurveMotor motor = new ThrustCurveMotor();
 | 
			
		||||
		
 | 
			
		||||
		public Builder setAverageThrustEstimate(double v) {
 | 
			
		||||
			motor.averageThrust = v;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public Builder setBurnTimeEstimate(double v) {
 | 
			
		||||
			motor.burnTimeEstimate = v;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public Builder setCaseInfo(String v) {
 | 
			
		||||
			motor.caseInfo = v;
 | 
			
		||||
			return this;
 | 
			
		||||
@ -115,11 +105,6 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor>, Se
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public Builder setMaxThrustEstimate(double v) {
 | 
			
		||||
			motor.maxThrust = v;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public Builder setMotorType(Motor.Type t) {
 | 
			
		||||
			motor.type = t;
 | 
			
		||||
			return this;
 | 
			
		||||
@ -145,11 +130,6 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor>, Se
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public Builder setTotalThrustEstimate(double v) {
 | 
			
		||||
			motor.totalImpulse = v;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public Builder setAvailablity(boolean avail) {
 | 
			
		||||
			motor.available = avail;
 | 
			
		||||
			return this;
 | 
			
		||||
 | 
			
		||||
@ -1,239 +0,0 @@
 | 
			
		||||
package net.sf.openrocket.motor;
 | 
			
		||||
 | 
			
		||||
import net.sf.openrocket.util.BugException;
 | 
			
		||||
 | 
			
		||||
public class ThrustCurveMotorPlaceholder implements Motor {
 | 
			
		||||
	
 | 
			
		||||
	private final Motor.Type type;
 | 
			
		||||
	private final String manufacturer;
 | 
			
		||||
	private final String designation;
 | 
			
		||||
	private final double diameter;
 | 
			
		||||
	private final double length;
 | 
			
		||||
	private final String digest;
 | 
			
		||||
	private final double delay;
 | 
			
		||||
	private final double launchMass;
 | 
			
		||||
	private final double emptyMass;
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	public ThrustCurveMotorPlaceholder(Type type, String manufacturer, String designation, double diameter, double length,
 | 
			
		||||
			String digest, double delay, double launchMass, double emptyMass) {
 | 
			
		||||
		this.type = type;
 | 
			
		||||
		this.manufacturer = manufacturer;
 | 
			
		||||
		this.designation = designation;
 | 
			
		||||
		this.diameter = diameter;
 | 
			
		||||
		this.length = length;
 | 
			
		||||
		this.digest = digest;
 | 
			
		||||
		this.delay = delay;
 | 
			
		||||
		this.launchMass = launchMass;
 | 
			
		||||
		this.emptyMass = emptyMass;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Type getMotorType() {
 | 
			
		||||
		return type;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public String getManufacturer() {
 | 
			
		||||
		return manufacturer;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getDesignation() {
 | 
			
		||||
		return designation;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getDesignation(double designationDelay) {
 | 
			
		||||
		return designation + "-" + ThrustCurveMotor.getDelayString(designationDelay);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getDescription() {
 | 
			
		||||
		return "";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getDiameter() {
 | 
			
		||||
		return diameter;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getLength() {
 | 
			
		||||
		return length;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getDigest() {
 | 
			
		||||
		return digest;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public double getDelay() {
 | 
			
		||||
		return delay;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Motor clone() {
 | 
			
		||||
		throw new BugException("Called getInstance on PlaceholderMotor");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getBurnTimeEstimate() {
 | 
			
		||||
		return Double.NaN;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getAverageThrustEstimate() {
 | 
			
		||||
		return Double.NaN;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getMaxThrustEstimate() {
 | 
			
		||||
		return Double.NaN;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getTotalImpulseEstimate() {
 | 
			
		||||
		return Double.NaN;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public int hashCode() {
 | 
			
		||||
		final int prime = 31;
 | 
			
		||||
		int result = 1;
 | 
			
		||||
		long temp;
 | 
			
		||||
		temp = Double.doubleToLongBits(delay);
 | 
			
		||||
		result = prime * result + (int) (temp ^ (temp >>> 32));
 | 
			
		||||
		result = prime * result
 | 
			
		||||
				+ ((designation == null) ? 0 : designation.hashCode());
 | 
			
		||||
		temp = Double.doubleToLongBits(diameter);
 | 
			
		||||
		result = prime * result + (int) (temp ^ (temp >>> 32));
 | 
			
		||||
		result = prime * result + ((digest == null) ? 0 : digest.hashCode());
 | 
			
		||||
		temp = Double.doubleToLongBits(emptyMass);
 | 
			
		||||
		result = prime * result + (int) (temp ^ (temp >>> 32));
 | 
			
		||||
		temp = Double.doubleToLongBits(launchMass);
 | 
			
		||||
		result = prime * result + (int) (temp ^ (temp >>> 32));
 | 
			
		||||
		temp = Double.doubleToLongBits(length);
 | 
			
		||||
		result = prime * result + (int) (temp ^ (temp >>> 32));
 | 
			
		||||
		result = prime * result
 | 
			
		||||
				+ ((manufacturer == null) ? 0 : manufacturer.hashCode());
 | 
			
		||||
		result = prime * result + ((type == null) ? 0 : type.hashCode());
 | 
			
		||||
		return result;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean equals(Object obj) {
 | 
			
		||||
		if (this == obj)
 | 
			
		||||
			return true;
 | 
			
		||||
		if (obj == null)
 | 
			
		||||
			return false;
 | 
			
		||||
		if (getClass() != obj.getClass())
 | 
			
		||||
			return false;
 | 
			
		||||
		ThrustCurveMotorPlaceholder other = (ThrustCurveMotorPlaceholder) obj;
 | 
			
		||||
		if (Double.doubleToLongBits(delay) != Double
 | 
			
		||||
				.doubleToLongBits(other.delay))
 | 
			
		||||
			return false;
 | 
			
		||||
		if (designation == null) {
 | 
			
		||||
			if (other.designation != null)
 | 
			
		||||
				return false;
 | 
			
		||||
		} else if (!designation.equals(other.designation))
 | 
			
		||||
			return false;
 | 
			
		||||
		if (Double.doubleToLongBits(diameter) != Double
 | 
			
		||||
				.doubleToLongBits(other.diameter))
 | 
			
		||||
			return false;
 | 
			
		||||
		if (digest == null) {
 | 
			
		||||
			if (other.digest != null)
 | 
			
		||||
				return false;
 | 
			
		||||
		} else if (!digest.equals(other.digest))
 | 
			
		||||
			return false;
 | 
			
		||||
		if (Double.doubleToLongBits(emptyMass) != Double
 | 
			
		||||
				.doubleToLongBits(other.emptyMass))
 | 
			
		||||
			return false;
 | 
			
		||||
		if (Double.doubleToLongBits(launchMass) != Double
 | 
			
		||||
				.doubleToLongBits(other.launchMass))
 | 
			
		||||
			return false;
 | 
			
		||||
		if (Double.doubleToLongBits(length) != Double
 | 
			
		||||
				.doubleToLongBits(other.length))
 | 
			
		||||
			return false;
 | 
			
		||||
		if (manufacturer == null) {
 | 
			
		||||
			if (other.manufacturer != null)
 | 
			
		||||
				return false;
 | 
			
		||||
		} else if (!manufacturer.equals(other.manufacturer))
 | 
			
		||||
			return false;
 | 
			
		||||
		if (type != other.type)
 | 
			
		||||
			return false;
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String toString() {
 | 
			
		||||
		return "ThrustCurveMotorPlaceholder [manufacturer=" + manufacturer
 | 
			
		||||
				+ ", designation=" + designation + "]";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getLaunchCGx() {
 | 
			
		||||
		return length / 2;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getBurnoutCGx() {
 | 
			
		||||
		return length / 2;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getLaunchMass() {
 | 
			
		||||
		return launchMass;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getBurnoutMass() {
 | 
			
		||||
		return emptyMass;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getThrust(double pseudoIndex) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getAverageThrust(double startTime, double endTime) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getTotalMass(final double motorTime) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getPropellantMass( final Double motorTime){
 | 
			
		||||
		return 0.;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getCMx(double pseudoIndex) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getBurnTime() { 
 | 
			
		||||
		return 0; 
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getUnitIxx() {
 | 
			
		||||
		return 0.; 
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getUnitIyy() {
 | 
			
		||||
		return 0.;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public double getUnitIzz(){
 | 
			
		||||
		return 0.;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -177,8 +177,6 @@ public class MotorRowFilterTest {
 | 
			
		||||
		// create a motor with all fields explicitly defined
 | 
			
		||||
		// This is the Aerotech H123 from thrustcurve.org, motor ID 917
 | 
			
		||||
		final ThrustCurveMotor fullMotor = new ThrustCurveMotor.Builder()
 | 
			
		||||
			.setAverageThrustEstimate(83.5)
 | 
			
		||||
			.setBurnTimeEstimate(2.5)
 | 
			
		||||
			.setCaseInfo("Aerotech 38/240")
 | 
			
		||||
			.setCGPoints(new Coordinate[] {new Coordinate(0.077, 0, 0, 125.0),
 | 
			
		||||
										   new Coordinate(0.077, 0, 0, 109.93),
 | 
			
		||||
@ -199,13 +197,11 @@ public class MotorRowFilterTest {
 | 
			
		||||
			.setInitialMass(293.3)
 | 
			
		||||
			.setLength(0.152)
 | 
			
		||||
			.setManufacturer(Manufacturer.getManufacturer("AeroTech"))
 | 
			
		||||
			.setMaxThrustEstimate(174.2)
 | 
			
		||||
			.setMotorType(Motor.Type.RELOAD)
 | 
			
		||||
			.setPropellantInfo("White Lightning")
 | 
			
		||||
			.setStandardDelays(new double[] {6, 10, 14})
 | 
			
		||||
			.setThrustPoints(new double[] {138.42, 116.45, 116.45, 112.18, 107.82, 86.29, 81.93, 64.72, 47.46, 43.15, 30.2, 0.0})
 | 
			
		||||
			.setTimePoints(new double[] {0.0, 0.2, 0.6, 0.7, 0.8, 1.3, 1.5, 1.8, 2.1, 2.2, 2.3, 2.6})
 | 
			
		||||
			.setTotalThrustEstimate(211.4)
 | 
			
		||||
			.build();
 | 
			
		||||
		
 | 
			
		||||
		// two search terms, both present, one only a substring of a column
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user