Multi Event Visibility check

Hi everyone,
I’m working to implement a program to study visibility Check from four several ground stations (network ground stations), but I don’t understand how to manage multi events detector. If I simply add four elevation detector at the same propagator it doesn’t work. How can I resolve this problem?

Did you change the default setting for the event hendler?
By default, the ElevationDetector uses a StopOnDecreasing handler, which means the propagation will stop at the first visibility loss. You should probaly use something like:

  EventDetector ed = new ElevationDetector(...).
                     withHandler(new ContinueOnEvent<>());

Beware that as the various withXxx() methods use a combination of fluent and builder APIs, the
detector you need to register to your propagator is the one returned by the chained calls, not the initial one from the new, which is immutable.

Thank you for the answer @luc ,
I used the VisibilityHandler descripted in the tutorial “Visibility Check”, replacing STOP Action with RESET_STATE to avoid to continue the propagation. The code is:

private static class VisibilityHandler implements EventHandler {
public Action eventOccurred(final SpacecraftState s, final ElevationDetector detector,
                            final boolean increasing) {
	

    if (increasing) {
        System.out.println(" Visibility on " + detector.getTopocentricFrame().getName()
                                             + " begins at " + s.getDate());
       
        return Action.CONTINUE;
    } else {
        
    	System.out.println(" Visibility on " + detector.getTopocentricFrame().getName()
                + " ends at " + s.getDate());

return Action.RESET_STATE ;

                 }
            }

}This text will be hidden


This Handler is called in the detectors

final EventDetector sta1Visi =
new ElevationDetector(maxcheck, threshold, sta1Frame).
withConstantElevation(elevation).
withHandler(new VisibilityHandler());
    final EventDetector sta2Visi =
            new ElevationDetector(maxcheck, threshold, sta2Frame).
            withConstantElevation(elevation).
            withHandler(new VisibilityHandler());
   
    final EventDetector sta3Visi =
            new ElevationDetector(maxcheck, threshold, sta3Frame).
            withConstantElevation(elevation).
            withHandler(new VisibilityHandler());
  
    final EventDetector sta4Visi =
            new ElevationDetector(maxcheck, threshold, sta4Frame).
            withConstantElevation(elevation).
            withHandler(new VisibilityHandler());
    
 EventsLogger logger = new EventsLogger();

// Add event to be detected
prop.addEventDetector(logger.monitorDetector(sta1Visi));
prop.addEventDetector(logger.monitorDetector(sta2Visi));
prop.addEventDetector(logger.monitorDetector(sta3Visi));
prop.addEventDetector(logger.monitorDetector(sta4Visi));

	//propagate
	prop.propagate(initialDate.shiftedBy(5400.));   

It is correct? I would like also to extrapolate time duration (Date of stop visibility- date of start visibility) for each station, but I don’t know how to get the Date of beginning of visibility. It is possible?
Thank you for your support

replacing STOP Action with RESET_STATE to avoid to continue the propagation.

No, you should use Action.CONTINUE for both increasing and decreasing events here. Action.RESET is used when your want to change spacecraft state at event. A typical example would be to simulate an impulse maneuver. This is not whant you want here, you just want the propagator to continue running.

EventsLogger logger = new EventsLogger();

Here you are using both a custom VisibilityHandler and an EventLogger to monitor your events. Their is some redundancy here. If you want to just print something on the fly, a custom handler like VisibilityHandler is the way to go, and you can forget about the logger. If on the other hand you want to gather all the events as they appear and to process them all at the end of the propagation, then EventLogger is the way to go. With both methods, you could get the duration of visibility, but it is much simpler with a custom handler as follows:

If you use a custom handler, then the handler should store the date of the increasing event in a field of the hander, and compute the duration when the next decreasing event happens. Something akin to:

public class DurationHandler implements EventHandler<ElevationDetector> {
  private AbsoluteDate raisingDate = null;
  public Action eventOccurred(SpacecraftState s, ElevationDetector detector, boolean increasing) {
      if (increasing) {
         raisingDate = s.getDate();
      } else if (raisingDate != null) {
        System.out.println("visibility at " +detector.getTopocentricFrame().getName() +
                           " from " + raisingDate + " to " + s.getDate() +
                           ", duration = " + s.getDate().durationFrom(raisingDate) + " s");
      }
      return Action.CONTINUE;
}

Doing the same with the logger implies you find by yourself matching raising/setting pairs for each station, as the events will be logged only sorted by date and you may have raising on station A, then raising on station B, then setting on station A, then setting on station B. It is possible, though, just slightly more complex.

Thank you very much for the help, now I have understand the problem.