Fix auto-run simulation NA values
This commit is contained in:
parent
46b974cae7
commit
b7dc313ee8
@ -259,7 +259,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
||||
private boolean handleEvents() throws SimulationException {
|
||||
boolean ret = true;
|
||||
FlightEvent event;
|
||||
|
||||
|
||||
log.trace("HandleEvents: current branch = " + currentStatus.getFlightData().getBranchName());
|
||||
for (event = nextEvent(); event != null; event = nextEvent()) {
|
||||
log.trace("Obtained event from queue: " + event.toString());
|
||||
@ -300,7 +300,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
||||
// Ignore events for components that are no longer attached to the rocket
|
||||
if (event.getSource() != null && event.getSource().getParent() != null &&
|
||||
!currentStatus.getConfiguration().isComponentActive(event.getSource())) {
|
||||
log.trace("Ignoring event from unattached componenent");
|
||||
log.trace("Ignoring event from unattached component");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -332,6 +332,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
||||
|
||||
|
||||
// Check for recovery device deployment, add events to queue
|
||||
// TODO: LOW: check if deprecated function getActiveComponents needs to be replaced
|
||||
for (RocketComponent c : currentStatus.getConfiguration().getActiveComponents()) {
|
||||
if (!(c instanceof RecoveryDevice))
|
||||
continue;
|
||||
|
@ -220,7 +220,7 @@ public class FlightData {
|
||||
timeToApogee = Double.NaN;
|
||||
|
||||
|
||||
// Launch rod velocity
|
||||
// Launch rod velocity + deployment velocity + ground hit velocity
|
||||
for (FlightEvent event : branch.getEvents()) {
|
||||
if (event.getType() == FlightEvent.Type.LAUNCHROD) {
|
||||
double t = event.getTime();
|
||||
|
@ -0,0 +1,29 @@
|
||||
package net.sf.openrocket.simulation.listeners.system;
|
||||
|
||||
import net.sf.openrocket.simulation.FlightEvent;
|
||||
import net.sf.openrocket.simulation.SimulationStatus;
|
||||
import net.sf.openrocket.simulation.listeners.AbstractSimulationListener;
|
||||
|
||||
|
||||
/**
|
||||
* A simulation listeners that ends the simulation when the ground is hit.
|
||||
*
|
||||
* @author Sibo Van Gool <sibo.vangool@hotmail.com>
|
||||
*/
|
||||
public class GroundHitListener extends AbstractSimulationListener {
|
||||
|
||||
public static final GroundHitListener INSTANCE = new GroundHitListener();
|
||||
|
||||
@Override
|
||||
public boolean handleFlightEvent(SimulationStatus status, FlightEvent event) {
|
||||
if (event.getType() == FlightEvent.Type.GROUND_HIT) {
|
||||
status.getEventQueue().add(new FlightEvent(FlightEvent.Type.SIMULATION_END, status.getSimulationTime()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSystemListener() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -66,7 +66,7 @@ import net.sf.openrocket.simulation.FlightData;
|
||||
import net.sf.openrocket.simulation.customexpression.CustomExpression;
|
||||
import net.sf.openrocket.simulation.customexpression.CustomExpressionSimulationListener;
|
||||
import net.sf.openrocket.simulation.listeners.SimulationListener;
|
||||
import net.sf.openrocket.simulation.listeners.system.ApogeeEndListener;
|
||||
import net.sf.openrocket.simulation.listeners.system.GroundHitListener;
|
||||
import net.sf.openrocket.simulation.listeners.system.InterruptListener;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.unit.UnitGroup;
|
||||
@ -770,7 +770,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
protected SimulationListener[] getExtraListeners() {
|
||||
return new SimulationListener[] {
|
||||
InterruptListener.INSTANCE,
|
||||
ApogeeEndListener.INSTANCE,
|
||||
GroundHitListener.INSTANCE,
|
||||
exprListener };
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user