End of event triggered by large HFR or large image mean values

If I take images, I like to have HFR and image background below a certain value, depending of the target and the filter I use. Lets say I take images of a target and during the time the target sets or the moon raises. Now I have to plan everything in advance, regardless of the actual seeing and sky conditions. I would like to have possibility on the event settings window to set the limit of HFR and image mean (or median), for last X images. It could be something like this on the event settings window:

  • end this event if HFR of last X images in the image history is greater then value Y
  • end this event if image mean of last X images in the image history is greater then value Y

Alternatively give there a possibility to run a custom script at the end of each image download and wait for the return code from it. If it ends with ends with return code (lets say 0), continue normaly. If the script ends with return code (lets say 1), end this event and go the the next event. If it end with return code (lets say 2), end this object and go to next object. If it end with return code (lets say 3), run end of sequence options.