Commit 0cc6acbb authored by Jasem Mutlaq's avatar Jasem Mutlaq

Add support to post filter change autofocus process

parent 150060ff
......@@ -1306,7 +1306,7 @@ void Capture::addJob(bool preview)
{
currentRow = queueTable->rowCount();
queueTable->insertRow(currentRow);
queueTable->insertRow(currentRow);
}
else
currentRow = queueTable->currentRow();
......@@ -1525,6 +1525,8 @@ void Capture::prepareJob(SequenceJob *job)
{
activeJob = job;
connect(job, SIGNAL(checkFocus()), this, SLOT(startPostFilterAutoFocus()));
// Reset calibration stage
if (calibrationStage == CAL_CAPTURING)
{
......@@ -1536,6 +1538,14 @@ void Capture::prepareJob(SequenceJob *job)
if (currentFilterPosition > 0)
{
// If we haven't performed a single autofocus yet, we stop
if (Options::autoFocusOnFilterChange() && (isAutoFocus == false && firstAutoFocus == true))
{
appendLogText(i18n("Manual focusing post filter change is not supported. Run Autofocus process before trying again."));
abort();
return;
}
activeJob->setCurrentFilter(currentFilterPosition);
if (currentFilterPosition != activeJob->getTargetFilter())
......@@ -1635,6 +1645,7 @@ void Capture::executeJob()
syncGUIToJob(activeJob);
captureImage();
}
......@@ -1748,6 +1759,24 @@ void Capture::updateAutofocusStatus(bool status, double HFR)
}
}
if (activeJob && (activeJob->getStatus() == SequenceJob::JOB_ABORTED || activeJob->getStatus() == SequenceJob::JOB_IDLE))
{
if (status)
{
HFRPixels->setValue(HFR + (HFR * 0.025));
appendLogText(i18n("Focus complete."));
}
else
{
appendLogText(i18n("Autofocus failed. Aborting exposure..."));
secondsLabel->setText("");
abort();
}
activeJob->setFilterPostFocusReady(status);
return;
}
if (isAutoFocus && activeJob && activeJob->getStatus() == SequenceJob::JOB_BUSY)
{
if (status)
......@@ -3320,4 +3349,19 @@ void Capture::setNewRemoteFile(QString file)
appendLogText(i18n("Remote image saved to %1", file));
}
void Capture::startPostFilterAutoFocus()
{
if (isFocusBusy)
return;
isFocusBusy = true;
secondsLabel->setText(i18n("Focusing..."));
appendLogText(i18n("Post filter change Autofocus..."));
// Force it to always run autofocus routine
emit checkFocus(0.1);
}
}
......@@ -359,9 +359,7 @@ private slots:
void setDirty();
void checkFrameType(int index);
void resetFrame();
void updateFocusStatus(bool status);
void updateAutofocusStatus(bool status, double HFR);
void resetFrame();
void updateCaptureProgress(ISD::CCDChip *tChip, double value, IPState state);
void checkSeqBoundary(const QString &path);
void checkSeqFile(const QString &path);
......@@ -371,19 +369,27 @@ private slots:
void setGuideChip(ISD::CCDChip* chip) { guideChip = chip; }
// Sequence Queue
void loadSequenceQueue();
void saveSequenceQueue();
void saveSequenceQueueAs();
// Jobs
void resetJobs();
void editJob(QModelIndex i);
void resetJobEdit();
void executeJob();
// Meridian Flip
void checkMeridianFlipTimeout();
void checkAlignmentSlewComplete();
void enableAlignmentFlag();
// Auto Focus
void updateFocusStatus(bool status);
void updateAutofocusStatus(bool status, double HFR);
void startPostFilterAutoFocus();
// Flat field
void openCalibrationDialog();
IPState processPreCaptureCalibrationStage();
......
......@@ -7,14 +7,14 @@
<x>0</x>
<y>0</y>
<width>502</width>
<height>419</height>
<height>444</height>
</rect>
</property>
<property name="windowTitle">
<string>TabWidget</string>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="generalTab">
<attribute name="title">
......@@ -220,6 +220,16 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="kcfg_AutoFocusOnFilterChange">
<property name="toolTip">
<string>Perform Autofocus when changing filter wheels during exposure sequence.</string>
</property>
<property name="text">
<string>Autofocus on Filter Change</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -38,7 +38,7 @@ SequenceJob::SequenceJob()
currentTemperature=targetTemperature=INVALID_TEMPERATURE;
captureFilter=FITS_NONE;
preview=false;
filterReady=temperatureReady=true;
filterReady=temperatureReady=filterPostFocusReady=true;
enforceTemperature=false;
activeChip=NULL;
activeCCD=NULL;
......@@ -121,6 +121,10 @@ void SequenceJob::prepareCapture()
else
{
filterReady = false;
// Post Focus on Filter change
filterPostFocusReady = !Options::autoFocusOnFilterChange();
activeFilter->runCommand(INDI_SET_FILTER, &targetFilter);
}
}
......@@ -260,7 +264,7 @@ void SequenceJob::setCurrentTemperature(double value)
if (enforceTemperature == false || fabs(targetTemperature - currentTemperature) <= Options::maxTemperatureDiff())
temperatureReady = true;
if (filterReady && temperatureReady && (status == JOB_IDLE || status == JOB_ABORTED))
if (filterReady && temperatureReady && filterPostFocusReady && (status == JOB_IDLE || status == JOB_ABORTED))
emit prepareComplete();
}
......@@ -363,6 +367,19 @@ void SequenceJob::setRootFITSDir(const QString &value)
rootFITSDir = value;
}
bool SequenceJob::getFilterPostFocusReady() const
{
return filterPostFocusReady;
}
void SequenceJob::setFilterPostFocusReady(bool value)
{
filterPostFocusReady = value;
if (filterPostFocusReady && filterReady && temperatureReady && (status == JOB_IDLE || status == JOB_ABORTED))
emit prepareComplete();
}
int SequenceJob::getISOIndex() const
{
return isoIndex;
......@@ -385,8 +402,10 @@ void SequenceJob::setCurrentFilter(int value)
if (currentFilter == targetFilter)
filterReady = true;
if (filterReady && temperatureReady && (status == JOB_IDLE || status == JOB_ABORTED))
if (filterReady && temperatureReady && filterPostFocusReady && (status == JOB_IDLE || status == JOB_ABORTED))
emit prepareComplete();
else if (filterReady && filterPostFocusReady == false)
emit checkFocus();
}
}
......@@ -135,8 +135,12 @@ class SequenceJob : public QObject
QString getRootFITSDir() const;
void setRootFITSDir(const QString &value);
bool getFilterPostFocusReady() const;
void setFilterPostFocusReady(bool value);
signals:
void prepareComplete();
void checkFocus();
private:
......@@ -159,7 +163,7 @@ private:
int count;
int delay;
bool preview;
bool filterReady, temperatureReady;
bool filterReady, temperatureReady, filterPostFocusReady;
bool enforceTemperature;
int isoIndex;
int captureRetires;
......
......@@ -1390,6 +1390,10 @@
<label>When starting a new capture job, check if files were previously captured and resume capture afterwards.</label>
<default>true</default>
</entry>
<entry name="AutoFocusOnFilterChange" type="Bool">
<label>Perform an autofocus operation when changing filter wheels during an exposure sequence.</label>
<default>false</default>
</entry>
</group>
<group name="Focus">
<entry name="DefaultFocusCCD" type="String">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment