Many thanks for your fast and constructive response, I have followed your approached and it works (see full at the end of the email).
Yes, I will create a bug report for this.
A) I have implemented the AdditionalStatesProvider not storing the event epoch, but simply changing the value that should be provided. Is this solution also valid?
private double value = -1;
@Override
public String getName() {
return "A";
}
@Override
public double[] getAdditionalState(SpacecraftState state) throws OrekitException {
return new double[] {value};
}
public void setValue(double value) {
this.value = value;
}
}
public static class MyHandler implements EventHandler<DateDetector> {
private final MyProvider myProvider;
public MyHandler(MyProvider myProvider) {
this.myProvider = myProvider;
}
@Override
public Action eventOccurred(SpacecraftState s, DateDetector detector, boolean increasing)
throws OrekitException {
myProvider.setValue(+1);
return Action.CONTINUE;
}
}
public static void main(String[] args) throws OrekitException {
// Load Orekit data
DataProvidersManager.getInstance()
.addProvider(new DirectoryCrawler(new File("OREKIT_DATA_PATH_HERE")));
// Build orbit
AbsoluteDate date0 = new AbsoluteDate(2000, 1, 1, TimeScalesFactory.getUTC());
Orbit orbit = new KeplerianOrbit(7.1E6, 0, 0, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getGCRF(), date0,
Constants.WGS84_EARTH_MU);
// Build propagator
ODEIntegrator odeIntegrator = new DormandPrince853Integrator(1E-3, 1E3, 1E-6, 1E-6);
NumericalPropagator propagator = new NumericalPropagator(odeIntegrator);
// Create initial state and add it to the propagator
SpacecraftState initialState = new SpacecraftState(orbit).addAdditionalState("A", -1);
propagator.setInitialState(initialState);
//Create provider and handler
MyProvider myProvider = new MyProvider();
EventHandler<DateDetector> myHandler = new MyHandler(myProvider);
// Create date detector and handler
DateDetector dateDetector = new DateDetector(date0.shiftedBy(3)).withHandler(myHandler);
propagator.addEventDetector(dateDetector);
propagator.addAdditionalStateProvider(myProvider);
// Set the propagator mode
propagator.setMasterMode(1, new OrekitFixedStepHandler() {
@Override
public void handleStep(SpacecraftState currentState, boolean isLast) throws OrekitException {
String line = currentState.getDate().toString();
for (Entry<String, double[]> entry : currentState.getAdditionalStates().entrySet()) {
line += " " + entry.getKey();
for (double d : entry.getValue()) {
line += " " + d;
}
}
System.out.println(line);
}
});
// Propagate
propagator.propagate(date0, date0.shiftedBy(5));
}