1 package net.sf.openrocket.file;
5 import net.sf.openrocket.aerodynamics.Warning;
6 import net.sf.openrocket.aerodynamics.WarningSet;
7 import net.sf.openrocket.motor.Motor;
8 import net.sf.openrocket.motor.Motor.Type;
9 import net.sf.openrocket.startup.Application;
12 * A MotorFinder implementation that searches the thrust curve motor database
15 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
17 public class DatabaseMotorFinder implements MotorFinder {
20 public Motor findMotor(Type type, String manufacturer, String designation, double diameter, double length, String digest, WarningSet warnings) {
22 if (designation == null) {
23 warnings.add(Warning.fromString("No motor specified, ignoring."));
27 List<? extends Motor> motors = Application.getMotorSetDatabase().findMotors(type, manufacturer, designation, diameter, length);
30 if (motors.size() == 0) {
31 Warning.MissingMotor mmw = new Warning.MissingMotor();
32 mmw.setDesignation(designation);
33 mmw.setDigest(digest);
34 mmw.setDiameter(diameter);
35 mmw.setLength(length);
36 mmw.setManufacturer(manufacturer);
43 if (motors.size() == 1) {
44 Motor m = motors.get(0);
45 if (digest != null && !digest.equals(m.getDigest())) {
46 String str = "Motor with designation '" + designation + "'";
47 if (manufacturer != null)
48 str += " for manufacturer '" + manufacturer + "'";
49 str += " has differing thrust curve than the original.";
55 // Multiple motors, check digest for which one to use
58 // Check for motor with correct digest
59 for (Motor m : motors) {
60 if (digest.equals(m.getDigest())) {
64 String str = "Motor with designation '" + designation + "'";
65 if (manufacturer != null)
66 str += " for manufacturer '" + manufacturer + "'";
67 str += " has differing thrust curve than the original.";
72 String str = "Multiple motors with designation '" + designation + "'";
73 if (manufacturer != null)
74 str += " for manufacturer '" + manufacturer + "'";
75 str += " found, one chosen arbitrarily.";