1 package net.sf.openrocket.simulation.listeners.example;
3 import net.sf.openrocket.simulation.FlightDataBranch;
4 import net.sf.openrocket.simulation.FlightDataType;
5 import net.sf.openrocket.simulation.FlightEvent;
6 import net.sf.openrocket.simulation.SimulationStatus;
7 import net.sf.openrocket.simulation.exception.SimulationException;
8 import net.sf.openrocket.simulation.listeners.AbstractSimulationListener;
11 public class PrintSimulationListener extends AbstractSimulationListener {
14 public boolean handleFlightEvent(SimulationStatus status, FlightEvent event) throws SimulationException {
15 System.out.println("*** handleEvent *** " + event.toString() +
16 " position=" + status.getRocketPosition() + " velocity=" + status.getRocketVelocity());
21 public void postStep(SimulationStatus status) throws SimulationException {
22 FlightDataBranch data = status.getFlightData();
23 System.out.printf("*** stepTaken *** time=%.3f position=" + status.getRocketPosition() +
24 " velocity=" + status.getRocketVelocity() + "=%.3f\n", status.getSimulationTime(), status.getRocketVelocity().length());
25 System.out.printf(" thrust=%.3fN drag==%.3fN mass=%.3fkg " +
26 "accZ=%.3fm/s2 acc=%.3fm/s2\n",
27 data.getLast(FlightDataType.TYPE_THRUST_FORCE),
28 data.getLast(FlightDataType.TYPE_DRAG_FORCE),
29 data.getLast(FlightDataType.TYPE_MASS),
30 data.getLast(FlightDataType.TYPE_ACCELERATION_Z),
31 data.getLast(FlightDataType.TYPE_ACCELERATION_TOTAL));