This is pretty complex and I am not sure I understand all the implications of the new functionality. I think I will have to see it live.
I was expecting a much simpler logic, something along the lines:
- The Sequence has a start time (this would normally be the start of the darkness or whatever start time the user feels like entering) and an end time.
- Each Target has start and end altitude settings.
After the user activates the sequence, SGP first waits until actual time > sequence start time.
It then looks if the first target is higher than the start altitude. If positive, the target will be activated and the events for that target will be executed. The target is active as long as the target altitude > end altitude and only as long as the sequence end time have not been reached.
If, on the other side, the target is below the start altitude, SGP tries the next target in the sequence.
If none of the targets can be started, the loop starts again with the first target, as long as the end time for the sequence have not been reached.
After completing a target, the loop starts again from the beginning. Completed targets will be marked as complete and dropped from the loop.
This would be, for my use case, the ideal way to control the use of the available darkness.