1 package net.sf.openrocket.utils;
3 import java.io.FileInputStream;
4 import java.io.IOException;
5 import java.io.InputStream;
8 import net.sf.openrocket.file.motor.GeneralMotorLoader;
9 import net.sf.openrocket.file.motor.MotorLoader;
10 import net.sf.openrocket.motor.Manufacturer;
11 import net.sf.openrocket.motor.Motor;
12 import net.sf.openrocket.motor.ThrustCurveMotor;
14 public class MotorCheck {
16 // Warn if less that this many points
17 public static final int WARN_POINTS = 6;
20 public static void main(String[] args) {
21 MotorLoader loader = new GeneralMotorLoader();
24 for (String file : args) {
25 System.out.print("Checking " + file + "... ");
30 List<Motor> motors = null;
32 InputStream stream = new FileInputStream(file);
33 motors = loader.load(stream, file);
35 } catch (IOException e) {
36 System.out.println("ERROR: " + e.getMessage());
37 e.printStackTrace(System.out);
41 String base = file.split("_")[0];
42 Manufacturer mfg = Manufacturer.getManufacturer(base);
45 if (motors.size() == 0) {
46 System.out.println("ERROR: File contained no motors");
49 for (Motor motor : motors) {
50 ThrustCurveMotor m = (ThrustCurveMotor) motor;
52 sum += m.getAverageThrustEstimate();
53 sum += m.getBurnTimeEstimate();
54 sum += m.getTotalImpulseEstimate();
55 // sum += m.getTotalTime();
56 sum += m.getDiameter();
58 sum += m.getEmptyCG().weight;
59 sum += m.getEmptyCG().x;
60 sum += m.getLaunchCG().weight;
61 sum += m.getLaunchCG().x;
62 sum += m.getMaxThrustEstimate();
63 if (Double.isInfinite(sum) || Double.isNaN(sum)) {
64 System.out.println("ERROR: Invalid motor values");
68 if (m.getManufacturer() != mfg) {
69 System.out.println("ERROR: Inconsistent manufacturer " +
70 m.getManufacturer() + " (file name indicates " + mfg
75 int points = ((ThrustCurveMotor) m).getTimePoints().length;
76 if (points < WARN_POINTS) {
77 System.out.println("WARNING: Only " + points + " data points");
85 System.out.println("OK");