Implementing a Time-Controlled Maneuver with SMA detection

Hello, I am attempting to create a maneuver with the following conditions:

  1. The maneuver begins when the spacecraft reaches a minimum altitude.
  2. There is a set maximum duration for the maneuver. If the spacecraft reaches a maximum altitude before this duration, the maneuver should cease.
  3. If the maximum altitude is not achieved within the maximum duration, the thrust must be halted. After a specified waiting period, the thrust should be reactivated.
  4. This cycle of thrusting, waiting, and reactivation should repeat until the maximum altitude is attained.

Currently, a code implementing only minimum and maximum altitude is as follows:

// The maneuver is triggered when the mean SMA is lower than min_altitude and stops when it reaches max_altitude
MeanSemiMajorAxisDetector minSmaDetector = new MeanSemiMajorAxisDetector(Constants.WGS84_EARTH_EQUATORIAL_RADIUS+stationKeepingParameters[0]);
MeanSemiMajorAxisDetector maxSmaDetector = new MeanSemiMajorAxisDetector(Constants.WGS84_EARTH_EQUATORIAL_RADIUS+stationKeepingParameters[1]);

// Negate minSmaDetector since the start and stop firing events are triggered only on increasing event
EventBasedManeuverTriggers trigger = new EventBasedManeuverTriggers(new NegateDetector(minSmaDetector),maxSmaDetector);

// Constant thrust direction in TNW
ThrustDirectionAndAttitudeProvider thrustDirProvider = ThrustDirectionAndAttitudeProvider.buildFromFixedDirectionInSatelliteFrame(Vector3D.PLUS_I);
ConfigurableLowThrustManeuver maneuver = new ConfigurableLowThrustManeuver(thrustDirProvider,trigger,stationKeepingParameters[2],stationKeepingParameters[3]);
propagator.addForceModel(maneuver);

I am considering adding a DateDetector to control the thrust after a certain time, but I am unsure how to integrate it with the other triggers. Could you provide suggestions on how to modify my code to implement this maneuver? Your ideas would be greatly appreciated. Thank you!

You should probably set up first an empty date detector, and register it to both the propagator (as all other detectors), but also store a reference to it in the event handler that triggers maneuver start. When the maneuver is triggered, the handler knows the start date, then it can compute a maximum end date using state.getDate().shiftedBy(maxDuration), it would then register this new date to the date detector.
Date detectors have been designed precisely for this: being able to manage new dates that are provided on the fly by other detectors.
In your case, you still have to check if the maneuver is still ongoing or if it was already shut down by the other conditions on altitude.