Commit d0408276 authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

+ Separating AutoGuide trigger from Dither trigger.

+ Saving last used guide exposure time.
+ Aborting capture process if autoguiding process is stopped while it was running before.
+ Restarting capture exposure in scheduler in case of guide failure.
parent 17395b00
......@@ -1708,10 +1708,16 @@ void Capture::setGuideDither(bool enable)
guideDither = enable;
}
void Capture::setAutoguiding(bool enable, bool isDithering)
void Capture::setAutoguiding(bool enable)
{
// If Autoguiding was started before and now stopped, let's abort.
if (enable == false && isAutoGuiding && activeJob && activeJob->getStatus() == SequenceJob::JOB_BUSY)
{
appendLogText(i18n("Autoguiding stopped. Aborting..."));
abort();
}
isAutoGuiding = enable;
guideDither = isDithering;
}
void Capture::updateFocusStatus(bool status)
......
......@@ -333,7 +333,7 @@ public slots:
* @param enable True if autoguiding is enabled and running, false otherwise.
* @param isDithering true if dithering is enabled.
*/
void setAutoguiding(bool enable, bool isDithering);
void setAutoguiding(bool enable);
/**
* @brief resumeCapture Resume capture after dither and/or focusing processes are complete.
......
......@@ -2725,7 +2725,7 @@ void EkosManager::initGuide()
connect(guideProcess, SIGNAL(newAxisDelta(double,double)), captureProcess, SLOT(setGuideDeviation(double,double)));
// Dithering
connect(guideProcess, SIGNAL(autoGuidingToggled(bool,bool)), captureProcess, SLOT(setAutoguiding(bool,bool)));
connect(guideProcess, SIGNAL(autoGuidingToggled(bool)), captureProcess, SLOT(setAutoguiding(bool)));
connect(guideProcess, SIGNAL(ditherComplete()), captureProcess, SLOT(resumeCapture()));
connect(guideProcess, SIGNAL(ditherFailed()), captureProcess, SLOT(abort()));
connect(guideProcess, SIGNAL(ditherToggled(bool)), captureProcess, SLOT(setGuideDither(bool)));
......
......@@ -63,6 +63,9 @@ Guide::Guide() : QWidget()
tabLayout->addWidget(tabWidget);
exposureIN->setValue(Options::guideExposure());
connect(exposureIN, SIGNAL(editingFinished()), this, SLOT(saveDefaultGuideExposure()));
pmath = new cgmath();
connect(pmath, SIGNAL(newAxisDelta(double,double)), this, SIGNAL(newAxisDelta(double,double)));
......@@ -73,7 +76,7 @@ Guide::Guide() : QWidget()
guider = new rguider(pmath, this);
connect(guider, SIGNAL(ditherToggled(bool)), this, SIGNAL(ditherToggled(bool)));
connect(guider, SIGNAL(autoGuidingToggled(bool,bool)), this, SIGNAL(autoGuidingToggled(bool,bool)));
connect(guider, SIGNAL(autoGuidingToggled(bool)), this, SIGNAL(autoGuidingToggled(bool)));
connect(guider, SIGNAL(ditherComplete()), this, SIGNAL(ditherComplete()));
tabWidget->addTab(calibration, calibration->windowTitle());
......@@ -91,8 +94,8 @@ Guide::Guide() : QWidget()
connect(phd2, SIGNAL(newLog(QString)), this, SLOT(appendLogText(QString)));
connect(phd2, SIGNAL(newAxisDelta(double,double)), this, SIGNAL(newAxisDelta(double,double)));
connect(phd2, SIGNAL(guideReady()), this, SIGNAL(guideReady()));
connect(phd2, SIGNAL(autoGuidingToggled(bool,bool)), this, SIGNAL(autoGuidingToggled(bool,bool)));
connect(phd2, SIGNAL(autoGuidingToggled(bool,bool)), guider, SLOT(setGuideState(bool,bool)));
connect(phd2, SIGNAL(autoGuidingToggled(bool)), this, SIGNAL(autoGuidingToggled(bool)));
connect(phd2, SIGNAL(autoGuidingToggled(bool)), guider, SLOT(setGuideState(bool)));
connect(guider, SIGNAL(ditherToggled(bool)), phd2, SLOT(setDitherEnabled(bool)));
connect(phd2, SIGNAL(ditherComplete()), this, SIGNAL(ditherComplete()));
......@@ -847,11 +850,14 @@ bool Guide::isGuiding()
}
bool Guide::startGuiding()
{
if (Options::useEkosGuider())
{
// This will handle both internal and external guiders
return guider->start();
/*if (Options::useEkosGuider())
return guider->start();
else
return phd2->startGuiding();
return phd2->startGuiding();*/
}
bool Guide::stopGuiding()
......@@ -1059,6 +1065,11 @@ void Guide::setUseDarkFrame(bool enable)
" You can capture dark frames with auto mode off and they shall be saved in the dark library for use when ever needed."));
}
void Guide::saveDefaultGuideExposure()
{
Options::setGuideExposure(exposureIN->value());
}
}
......@@ -268,11 +268,13 @@ protected slots:
*/
void processCCDNumber(INumberVectorProperty *nvp);
void saveDefaultGuideExposure();
signals:
void newLog();
void guideReady();
void newAxisDelta(double delta_ra, double delta_dec);
void autoGuidingToggled(bool, bool);
void autoGuidingToggled(bool);
void ditherComplete();
void ditherFailed();
void ditherToggled(bool);
......
......@@ -388,6 +388,9 @@ bool rguider::start()
if (guideFrame)
disconnect(guideFrame, SIGNAL(guideStarSelected(int,int)), 0, 0);
// Let everyone know about dither option status
emit ditherToggled(ui.ditherCheck->isChecked());
if (phd2)
{
phd2->startGuiding();
......@@ -422,7 +425,7 @@ bool rguider::start()
if (m_useRapidGuide)
pmain_wnd->startRapidGuide();
emit autoGuidingToggled(true, ui.ditherCheck->isChecked());
emit autoGuidingToggled(true);
pmain_wnd->setSuspended(false);
......@@ -443,7 +446,7 @@ bool rguider::stop()
if (phd2)
{
ui.pushButton_StartStop->setText( i18n("Start Autoguide") );
emit autoGuidingToggled(false, ui.ditherCheck->isChecked());
emit autoGuidingToggled(false);
m_isDithering = false;
m_isStarted = false;
......@@ -465,7 +468,7 @@ bool rguider::stop()
if (m_useRapidGuide)
pmain_wnd->stopRapidGuide();
emit autoGuidingToggled(false, ui.ditherCheck->isChecked());
emit autoGuidingToggled(false);
m_isDithering = false;
m_isStarted = false;
......@@ -473,12 +476,11 @@ bool rguider::stop()
return true;
}
void rguider::setGuideState(bool guiding, bool ditherChecked)
void rguider::setGuideState(bool guiding)
{
if (phd2 == NULL)
return;
ui.ditherCheck->setChecked(ditherChecked);
// If not started already
if (m_isStarted == false && guiding)
{
......
......@@ -49,6 +49,7 @@ public:
void setGuideOptions(int boxSize, const QString & algorithm, bool useSubFrame, bool useRapidGuide);
// Dither
bool isDitherChecked() { return ui.ditherCheck->isChecked(); }
bool dither();
bool isDithering() { return m_isDithering; }
void setDither(bool enable, double value);
......@@ -67,7 +68,7 @@ public slots:
void setPHD2Connected();
void setPHD2Disconnected();
// Only called by PHD2
void setGuideState(bool guiding, bool ditherChecked);
void setGuideState(bool guiding);
protected slots:
void onXscaleChanged( int i );
......@@ -87,7 +88,7 @@ protected slots:
signals:
void ditherComplete();
void ditherToggled(bool);
void autoGuidingToggled(bool, bool);
void autoGuidingToggled(bool);
private:
cgmath *pmath;
......
......@@ -42,8 +42,6 @@ PHD2::PHD2()
connection = DISCONNECTED;
event = Alert;
ditherEnabled = Options::useDither();
events["Version"] = Version;
events["LockPositionSet"] = LockPositionSet;
events["CalibrationComplete"] = CalibrationComplete;
......@@ -266,7 +264,7 @@ void PHD2::processPHD2Event(const QJsonObject &jsonEvent)
emit connected();
}
emit newLog(i18n("PHD2: Guiding Started."));
emit autoGuidingToggled(true, ditherEnabled);
emit autoGuidingToggled(true);
break;
case Paused:
......@@ -345,7 +343,7 @@ void PHD2::processPHD2Event(const QJsonObject &jsonEvent)
case GuidingStopped:
emit newLog(i18n("PHD2: Guiding Stopped."));
emit autoGuidingToggled(false, ditherEnabled);
emit autoGuidingToggled(false);
break;
case Resumed:
......
......@@ -63,7 +63,6 @@ public:
private slots:
void setDitherEnabled(bool enable) { ditherEnabled = enable; }
void readPHD2();
void displayError(QAbstractSocket::SocketError socketError);
......@@ -76,7 +75,7 @@ signals:
void ditherComplete();
void ditherFailed();
void newAxisDelta(double delta_ra, double delta_dec);
void autoGuidingToggled(bool, bool);
void autoGuidingToggled(bool);
void guideReady();
private:
......@@ -97,8 +96,6 @@ private:
PHD2Connection connection;
PHD2Event event;
bool ditherEnabled;
double ccd_pixel_width, ccd_pixel_height, focal;
};
......
......@@ -97,6 +97,7 @@ Scheduler::Scheduler()
focusFailureCount=0;
guideFailureCount=0;
alignFailureCount=0;
captureFailureCount=0;
noWeatherCounter=0;
......@@ -809,6 +810,7 @@ void Scheduler::stop()
focusFailureCount=0;
guideFailureCount=0;
alignFailureCount=0;
captureFailureCount=0;
jobEvaluationOnly=false;
loadAndSlewProgress=false;
autofocusCompleted=false;
......@@ -2626,7 +2628,7 @@ void Scheduler::checkJobStage()
QDBusReply<bool> guideReply = guideInterface->call(QDBus::AutoDetect,"isCalibrationComplete");
if (Options::verboseLogging())
qDebug() << "Scheduler: Calibration stage...";
qDebug() << "Scheduler: Calibration & Guide stage...";
if (guideReply.error().type() == QDBusError::UnknownObject)
{
......@@ -2697,6 +2699,21 @@ void Scheduler::checkJobStage()
if(captureReply.value().toStdString()=="Aborted" || captureReply.value().toStdString()=="Error")
{
appendLogText(i18n("%1 capture failed!", currentJob->getName()));
// If capture failed due to guiding error, let's try to restart that
if ( (currentJob->getStepPipeline() & SchedulerJob::USE_GUIDE) && captureFailureCount++ < MAX_FAILURE_ATTEMPTS)
{
// Check if it is guiding related.
QDBusReply<bool> guideReply = guideInterface->call(QDBus::AutoDetect,"isGuiding");
// If guiding failed, let's restart it
if(guideReply.value() == false)
{
appendLogText(i18n("Restarting %1 guiding procedure...", currentJob->getName()));
currentJob->setStage(SchedulerJob::STAGE_CALIBRATING);
return;
}
}
currentJob->setState(SchedulerJob::JOB_ERROR);
findNextJob();
......
......@@ -528,6 +528,7 @@ private:
uint8_t focusFailureCount; // Keep track of Ekos focus module failures
uint8_t guideFailureCount; // Keep track of Ekos guide module failures
uint8_t alignFailureCount; // Keep track of Ekos align module failures
uint8_t captureFailureCount; // Keep track of Ekos capture module failures
QTimer weatherTimer; // Call checkWeather when weatherTimer time expires. It is equal to the UpdatePeriod time in INDI::Weather device.
QTimer sleepTimer; // Timer to put the scheduler into sleep mode until a job is ready
......
......@@ -1504,6 +1504,10 @@
</entry>
</group>
<group name="Guide">
<entry name="GuideExposure" type="Double">
<label>Guider exposure duration in seconds.</label>
<default>1.0</default>
</entry>
<entry name="UseEkosGuider" type="Bool">
<label>Use Ekos Internal Guider Module for guiding</label>
<default>true</default>
......
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