1 package net.sf.openrocket.utils;
3 import java.io.FileInputStream;
4 import java.io.IOException;
5 import java.io.InputStream;
6 import java.util.Arrays;
9 import net.sf.openrocket.file.motor.GeneralMotorLoader;
10 import net.sf.openrocket.file.motor.MotorLoader;
11 import net.sf.openrocket.motor.Motor;
12 import net.sf.openrocket.motor.MotorDigest;
13 import net.sf.openrocket.motor.ThrustCurveMotor;
15 public class MotorPrinter {
17 public static void main(String[] args) throws IOException {
19 MotorLoader loader = new GeneralMotorLoader();
22 for (String arg : args) {
23 InputStream stream = new FileInputStream(arg);
25 List<Motor> motors = loader.load(stream, arg);
27 System.out.println("*** " + arg + " ***");
29 for (Motor motor : motors) {
30 ThrustCurveMotor m = (ThrustCurveMotor) motor;
31 System.out.println(" Manufacturer: " + m.getManufacturer());
32 System.out.println(" Designation: " + m.getDesignation());
33 System.out.println(" Delays: " +
34 Arrays.toString(m.getStandardDelays()));
35 System.out.printf(" Nominal time: %.2f s\n", m.getBurnTimeEstimate());
36 // System.out.printf(" Total time: %.2f s\n", m.getTotalTime());
37 System.out.printf(" Avg. thrust: %.2f N\n", m.getAverageThrustEstimate());
38 System.out.printf(" Max. thrust: %.2f N\n", m.getMaxThrustEstimate());
39 System.out.printf(" Total impulse: %.2f Ns\n", m.getTotalImpulseEstimate());
40 System.out.println(" Diameter: " + m.getDiameter() * 1000 + " mm");
41 System.out.println(" Length: " + m.getLength() * 1000 + " mm");
42 System.out.println(" Digest: " + MotorDigest.digestMotor(m));
44 if (m instanceof ThrustCurveMotor) {
45 ThrustCurveMotor tc = (ThrustCurveMotor) m;
46 System.out.println(" Data points: " + tc.getTimePoints().length);
47 for (int i = 0; i < m.getTimePoints().length; i++) {
48 double time = m.getTimePoints()[i];
49 double thrust = m.getThrustPoints()[i];
50 System.out.printf(" t=%.3f F=%.3f\n", time, thrust);
54 System.out.println(" Comment:");
55 System.out.println(m.getDescription());