Move CSV listener example to extension
This commit is contained in:
parent
ba630ab37e
commit
c3d2d5fc16
@ -1,4 +1,4 @@
|
||||
package net.sf.openrocket.simulation.listeners.example;
|
||||
package net.sf.openrocket.simulation.extension.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -9,12 +9,14 @@ import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.simulation.FlightDataType;
|
||||
import net.sf.openrocket.simulation.FlightEvent;
|
||||
import net.sf.openrocket.simulation.SimulationConditions;
|
||||
import net.sf.openrocket.simulation.SimulationStatus;
|
||||
import net.sf.openrocket.simulation.exception.SimulationException;
|
||||
import net.sf.openrocket.simulation.extension.AbstractSimulationExtension;
|
||||
import net.sf.openrocket.simulation.listeners.AbstractSimulationListener;
|
||||
|
||||
|
||||
public class CSVSaveListener extends AbstractSimulationListener {
|
||||
public class CSVSave extends AbstractSimulationExtension {
|
||||
|
||||
private static enum Types {
|
||||
TIME {
|
||||
@ -219,6 +221,17 @@ public class CSVSaveListener extends AbstractSimulationListener {
|
||||
private File file;
|
||||
private PrintStream output = null;
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "dump a CSV file with a predetermined set of flight variables to a CSV file while running";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(SimulationConditions conditions) throws SimulationException {
|
||||
conditions.getSimulationListenerList().add(new CSVSaveListener());
|
||||
}
|
||||
|
||||
private class CSVSaveListener extends AbstractSimulationListener {
|
||||
|
||||
@Override
|
||||
public boolean handleFlightEvent(SimulationStatus status, FlightEvent event) throws SimulationException {
|
||||
@ -290,6 +303,6 @@ public class CSVSaveListener extends AbstractSimulationListener {
|
||||
System.err.println("WARNING: stepTaken called with no open file " +
|
||||
"(t=" + status.getSimulationTime() + ")");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package net.sf.openrocket.simulation.extension.impl;
|
||||
|
||||
import net.sf.openrocket.plugin.Plugin;
|
||||
import net.sf.openrocket.simulation.extension.AbstractSimulationExtensionProvider;
|
||||
|
||||
@Plugin
|
||||
public class CSVSaveProvider extends AbstractSimulationExtensionProvider {
|
||||
|
||||
public CSVSaveProvider() {
|
||||
super(CSVSave.class, "Reports", "CSV Save");
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user