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.GeneralMotorLoader;
9 import net.sf.openrocket.file.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 m: motors) {
51 sum += m.getAverageThrust();
52 sum += m.getAverageTime();
53 sum += m.getTotalImpulse();
54 sum += m.getTotalTime();
55 sum += m.getDiameter();
58 sum += m.getMass(Double.POSITIVE_INFINITY);
60 sum += m.getCG(0).weight;
61 sum += m.getMaxThrust();
62 if (Double.isInfinite(sum) || Double.isNaN(sum)) {
63 System.out.println("ERROR: Invalid motor values");
67 if (m.getManufacturer() != mfg) {
68 System.out.println("ERROR: Inconsistent manufacturer " +
69 m.getManufacturer() + " (file name indicates " + mfg
74 int points = ((ThrustCurveMotor)m).getTimePoints().length;
75 if (points < WARN_POINTS) {
76 System.out.println("WARNING: Only " + points + " data points");
84 System.out.println("OK");