Update job completion counts, and fix regression on job rescheduling.

Authored by TallFurryMan on Oct 3 2018, 12:16 PM.

Description

Update job completion counts, and fix regression on job rescheduling.

Summary:
This change connects the Scheduler to the new-image signal sent by the Capture module.
If remembering job progress, it triggers a refresh of the capture storage, and updates the time estimation of all jobs.
It also makes sure a completed job is not re-evaluated to schedule in the basic "run-to-finish" and "repeat-N-times" cases.
It also adjust the count of captures in the scheduler table to avoid displaying required counts on jobs that are looping.

When remembering job progress, the new-image event can't be a simple +1 in the count of the running job because of duplicates.
Note that ANY new-image coming from the Capture module will trigger a refresh, even if the Scheduler is not running.
This is not expected to be an issue as currently all jobs, whatever their state (even being edited), can be re-evaluated without issue.

Test Plan:
Create a scheduler job list, with or without duplicates, using sequence jobs with or without duplicates.
Test vector "repeated_jobs_no_twilight.esl" is a simple version of this test setup.
You may need to disable option "Sort jobs by Altitude and Priority" to get an ordered schedule.

Run the Scheduler, check capture counts are properly updated (beware, that can be quite difficult to follow in complex cases).
Without the change, no capture count is updating, and the running job is rescheduled incorrectly.
With the change, relevant capture counts update, as well as imaging durations, resulting in proper evaluation of imaging time left (yay!).
When the job finishes capturing, it is considered complete.

The execution path depends on the value of option "Remember Job Progress".
When that option is set, the capture storage will be refreshed on each new capture received to update the completed count.
When that option is not set, the running job will get its completed count increased by one, independently of other jobs.

Also observe as, with the change, the looping last job has only a count of completed captures, instead of a completed/required count.

Notes:
There's an issue that raises from this test, but not exactly a real issue, more a consequence of the implementation.

Because the Capture module has options to add a Filter and a Duration suffix (and that those options are effectively optional),
and because the Scheduler is recognizing capture files from the beginning of the file *name*, captures without suffix *and* captures with
suffix will be counted for a scheduler job using a sequence *without* suffix. On the opposite, a scheduler job using a sequence *with*
suffix will not count capture files *without* suffix.

If we really want to fix that issue all the way through, we need to look into the FITS header to match the capture file with the sequence
properties.

Another important point is the fact that once jobs get their completed count increased, the only way to reset that value is to delete and
re-create the scheduler job, or to load a new scheduler file, which essentially does the same.

Reviewers: mutlaqja, wreissenberger

Reviewed By: mutlaqja, wreissenberger

Subscribers: kde-edu

Tags: KDE Edu

Differential Revision: https://phabricator.kde.org/D14942