diff --git a/Tests/capture/2x10x20s_refocus1min.esq b/Tests/capture/2x10x20s_refocus1min.esq
new file mode 100644
--- /dev/null
+++ b/Tests/capture/2x10x20s_refocus1min.esq
@@ -0,0 +1,88 @@
+
+
+Eric TallFurryMan
+CCD Simulator
+CCD Simulator
+2
+0
+1
+0
+
+20
+
+1
+1
+
+
+0
+0
+1280
+1024
+
+0
+Red
+Light
+
+
+1
+1
+1
+
+5
+0
+/var/tmp/kstars_tests
+0
+0
+
+
+
+
+Manual
+
+
+Manual
+
+False
+False
+
+
+
+20
+
+1
+1
+
+
+0
+0
+1280
+1024
+
+0
+Blue
+Light
+
+
+1
+1
+1
+
+5
+0
+/var/tmp/kstars_tests
+0
+0
+
+
+
+
+Manual
+
+
+Manual
+
+False
+False
+
+
+
diff --git a/Tests/capture/jobs_using_refocus.esl b/Tests/capture/jobs_using_refocus.esl
new file mode 100644
--- /dev/null
+++ b/Tests/capture/jobs_using_refocus.esl
@@ -0,0 +1,72 @@
+
+
+Default
+
+Kocab-1
+10
+
+14.845
+74.1553
+
+/var/tmp/kstars_tests/2x10x20s_refocus1min.esq
+
+ASAP
+
+
+MinimumAltitude
+
+
+Sequence
+
+
+Track
+Focus
+
+
+
+Kocab-2
+10
+
+14.845
+74.1553
+
+/var/tmp/kstars_tests/2x10x20s_refocus1min.esq
+
+ASAP
+
+
+MinimumAltitude
+
+
+Sequence
+
+
+Track
+
+
+
+Kocab-3
+10
+
+14.845
+74.1553
+
+/var/tmp/kstars_tests/2x10x20s_refocus1min.esq
+
+ASAP
+
+
+MinimumAltitude
+
+
+Sequence
+
+
+Track
+
+
+
+
+
+
+
diff --git a/kstars/ekos/capture/capture.h b/kstars/ekos/capture/capture.h
--- a/kstars/ekos/capture/capture.h
+++ b/kstars/ekos/capture/capture.h
@@ -519,8 +519,8 @@
// Auto Focus
// Timed refocus
- void startRefocusEveryNTimer();
- void restartRefocusEveryNTimer();
+ void startRefocusEveryNTimer() { startRefocusTimer(false); }
+ void restartRefocusEveryNTimer() { startRefocusTimer(true); }
int getRefocusEveryNTimerElapsedSec();
// Flat field
@@ -594,6 +594,9 @@
void resetFrameToZero();
+ /* Refocus */
+ void startRefocusTimer(bool forced = false);
+
/* Capture */
double seqExpose { 0 };
int seqTotalCount { 0 };
diff --git a/kstars/ekos/capture/capture.cpp b/kstars/ekos/capture/capture.cpp
--- a/kstars/ekos/capture/capture.cpp
+++ b/kstars/ekos/capture/capture.cpp
@@ -407,7 +407,6 @@
<< "DE:" << initialMountCoords.dec().toDMSString();
}
-
// start timer to measure time until next forced refocus
startRefocusEveryNTimer();
}
@@ -1353,10 +1352,7 @@
if (autoFocusReady && refocusEveryNCheck->isChecked())
{
qCDebug(KSTARS_EKOS_CAPTURE) << "NFocus Elapsed Time (secs): " << getRefocusEveryNTimerElapsedSec() << " Requested Interval (secs): " << refocusEveryN->value()*60;
- if (getRefocusEveryNTimerElapsedSec() >= refocusEveryN->value()*60)
- isRefocus = true;
- else
- isRefocus = false;
+ isRefocus = getRefocusEveryNTimerElapsedSec() >= refocusEveryN->value()*60;
}
// If we suspended guiding due to primary chip download, resume guide chip guiding now
@@ -1393,7 +1389,7 @@
}
else if (isRefocus && activeJob->getFrameType() == FRAME_LIGHT)
{
- appendLogText(i18n("Scheduled refocus started..."));
+ appendLogText(i18n("Scheduled refocus starting after %1 seconds...",getRefocusEveryNTimerElapsedSec()));
secondsLabel->setText(i18n("Focusing..."));
@@ -1642,6 +1638,13 @@
return false;
}
+ /* Refresh isRefocus when resuming */
+ if (autoFocusReady && refocusEveryNCheck->isChecked())
+ {
+ qCDebug(KSTARS_EKOS_CAPTURE) << "NFocus Elapsed Time (secs): " << getRefocusEveryNTimerElapsedSec() << " Requested Interval (secs): " << refocusEveryN->value()*60;
+ isRefocus = getRefocusEveryNTimerElapsedSec() >= refocusEveryN->value()*60;
+ }
+
// FIXME ought to be able to combine these - only different is value passed
// to checkFocus()
// 2018-08-23 Jasem: For now in-sequence-focusing takes precedense.
@@ -2331,6 +2334,7 @@
calibrationStage = CAL_NONE;
}
+ /* FIXME: this locks up the scheduler when it starts without any prior focus procedure done */
// If we haven't performed a single autofocus yet, we stop
//if (!job->isPreview() && Options::enforceRefocusEveryN() && autoFocusReady && isInSequenceFocus == false && firstAutoFocus == true)
if (!job->isPreview() && Options::enforceRefocusEveryN() && autoFocusReady == false && isInSequenceFocus == false)
@@ -5012,19 +5016,31 @@
}
-void Capture::startRefocusEveryNTimer()
+void Capture::startRefocusTimer(bool forced)
{
- refocusEveryNTimer.restart();
-}
-
-void Capture::restartRefocusEveryNTimer()
-{
- refocusEveryNTimer.restart();
+ /* If refocus is requested, only restart timer if not already running in order to keep current elapsed time since last refocus */
+ if (refocusEveryNCheck->isChecked())
+ {
+ if (!refocusEveryNTimer.isValid() || forced)
+ {
+ appendLogText(i18n("Ekos will refocus in %1 seconds.", refocusEveryN->value()*60));
+ refocusEveryNTimer.restart();
+ }
+ else if (refocusEveryNTimer.elapsed()/1000 < refocusEveryN->value()*60)
+ {
+ appendLogText(i18n("Ekos will refocus in %1 seconds, last procedure was %2 seconds ago.", refocusEveryNTimer.elapsed()/1000-refocusEveryNTimer.elapsed()*60, refocusEveryNTimer.elapsed()/1000));
+ }
+ else
+ {
+ appendLogText(i18n("Ekos will refocus as soon as possible, last procedure was %1 seconds ago.", refocusEveryNTimer.elapsed()/1000));
+ }
+ }
}
int Capture::getRefocusEveryNTimerElapsedSec()
{
- return refocusEveryNTimer.elapsed()/1000;
+ /* If timer isn't valid, consider there is no focus to be done, that is, that focus was just done */
+ return refocusEveryNTimer.isValid() ? refocusEveryNTimer.elapsed()/1000 : 0;
}
void Capture::setAlignResults(double orientation, double ra, double de, double pixscale)