summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-11-08 21:27:43 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-11-08 21:27:43 (GMT)
commit341b6e77742a4912a0af412ba65378088719d8c8 (patch)
tree570f36cd9d30d28571e21f02d6587262291ab0e8
parent64a2d1ed533ece24e6d85dfe6f960a9c56acb7c0 (diff)
Improve handling of sync and slew failure in align module
-rw-r--r--kstars/ekos/align/align.cpp143
-rw-r--r--kstars/ekos/align/align.h5
-rw-r--r--kstars/ekos/ekos.h4
3 files changed, 120 insertions, 32 deletions
diff --git a/kstars/ekos/align/align.cpp b/kstars/ekos/align/align.cpp
index 2186bde..4b51075 100644
--- a/kstars/ekos/align/align.cpp
+++ b/kstars/ekos/align/align.cpp
@@ -108,16 +108,16 @@ Align::Align()
connect(correctAzB, SIGNAL(clicked()), this, SLOT(correctAzError()));
connect(loadSlewB, SIGNAL(clicked()), this, SLOT(loadAndSlew()));
+ gotoModeButtonGroup->setId(syncR, GOTO_SYNC);
+ gotoModeButtonGroup->setId(slewR, GOTO_SLEW);
+ gotoModeButtonGroup->setId(nothingR, GOTO_NOTHING);
+
connect(gotoModeButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, [=](int id){ this->currentGotoMode = static_cast<GotoMode>(id); });
// TODO make this configurable, 3 minutes timeout
alignTimer.setInterval(180*1000);
connect(&alignTimer, SIGNAL(timeout()), this, SLOT(checkAlignmentTimeout()));
- int i=0;
- foreach(QAbstractButton *button, gotoModeButtonGroup->buttons())
- gotoModeButtonGroup->setId(button, i++);
-
currentGotoMode = static_cast<GotoMode>(Options::solverGotoOption());
gotoModeButtonGroup->button(currentGotoMode)->setChecked(true);
@@ -911,6 +911,7 @@ void Align::solverFinished(double orientation, double ra, double dec, double pix
{
case GOTO_SYNC:
executeGOTO();
+ return;
break;
case GOTO_SLEW:
@@ -1057,28 +1058,42 @@ void Align::processTelescopeNumber(INumberVectorProperty *coord)
ScopeRAOut->setText(ra_dms);
ScopeDecOut->setText(dec_dms);
- if (Options::alignmentLogging())
- qDebug() << "Alignment: State is " << Ekos::getAlignStatusString(state) << " isSlewing? " << currentTelescope->isSlewing() << " slew Dirty? " << slew_dirty
- << " Current GOTO Mode? " << currentGotoMode << " LoadSlewState? " << pstateStr(loadSlewState);
-
- if (currentTelescope->isSlewing() && slew_dirty == false)
+ switch (coord->s)
{
- slew_dirty = true;
- if (Options::alignmentLogging())
- qDebug() << "Alignment: slew dirty is true.";
- }
- else if (currentTelescope->isSlewing() == false && slew_dirty)
+ case IPS_OK:
{
- slew_dirty = false;
-
- if (Options::alignmentLogging())
- qDebug() << "Alignment: slew dirty is false.";
-
- if (Options::solverUpdateCoords())
+ // Update the boxes as the mount just finished slewing
+ if (slew_dirty && Options::solverUpdateCoords())
copyCoordsToBoxes();
- if (state >= ALIGN_PROGRESS)
+ switch (state)
{
+ case ALIGN_PROGRESS:
+ break;
+
+ case ALIGN_SYNCING:
+ {
+ slew_dirty = false;
+ if (currentGotoMode == GOTO_SLEW)
+ {
+ Slew();
+ return;
+ }
+ else
+ {
+ appendLogText(i18n("Mount is synced to solution coordinates. Astrometric solver is successful."));
+ KNotification::event( QLatin1String( "AlignSuccessful"), i18n("Astrometry alignment completed successfully") );
+ state = ALIGN_COMPLETE;
+ emit newStatus(state);
+ }
+ }
+ break;
+
+ case ALIGN_SLEWING:
+ if (slew_dirty == false)
+ break;
+
+ slew_dirty == false;
if (loadSlewState == IPS_BUSY)
{
loadSlewState = IPS_IDLE;
@@ -1092,7 +1107,7 @@ void Align::processTelescopeNumber(INumberVectorProperty *coord)
QTimer::singleShot(delaySpin->value(), this, SLOT(captureAndSolve()));
return;
}
- else if (currentGotoMode == GOTO_SLEW && state == ALIGN_SLEWING)
+ else if(currentGotoMode == GOTO_SLEW)
{
appendLogText(i18n("Target accuracy is not met, running solver again..."));
@@ -1102,8 +1117,59 @@ void Align::processTelescopeNumber(INumberVectorProperty *coord)
QTimer::singleShot(delaySpin->value(), this, SLOT(captureAndSolve()));
return;
}
+ break;
+
+ default:
+ {
+ slew_dirty = false;
+ }
+ break;
}
}
+ break;
+
+ case IPS_BUSY:
+ {
+ slew_dirty = true;
+
+ }
+ break;
+
+ case IPS_ALERT:
+ {
+ if (state == ALIGN_SYNCING || state == ALIGN_SLEWING)
+ {
+ if (state == ALIGN_SYNCING)
+ appendLogText(i18n("Syncing failed!"));
+ else
+ appendLogText(i18n("Slewing failed!"));
+
+ if (++retries == 3)
+ {
+ abort();
+ return;
+ }
+ else
+ {
+ if (currentGotoMode == GOTO_SLEW)
+ Slew();
+ else
+ Sync();
+ }
+ }
+
+ return;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+
+ if (Options::alignmentLogging())
+ qDebug() << "Alignment: State is " << Ekos::getAlignStatusString(state) << " isSlewing? " << currentTelescope->isSlewing() << " slew Dirty? " << slew_dirty
+ << " Current GOTO Mode? " << currentGotoMode << " LoadSlewState? " << pstateStr(loadSlewState);
switch (azStage)
{
@@ -1185,24 +1251,40 @@ void Align::executeGOTO()
void Align::Sync()
{
- if (currentTelescope->Sync(&alignCoord))
- appendLogText(i18n("Syncing to RA (%1) DEC (%2) is successful.", alignCoord.ra().toHMSString(), alignCoord.dec().toDMSString()));
+ state = ALIGN_SYNCING;
+
+ if (currentTelescope->Sync(&alignCoord))
+ {
+ emit newStatus(state);
+ appendLogText(i18n("Syncing to RA (%1) DEC (%2)", alignCoord.ra().toHMSString(), alignCoord.dec().toDMSString()));
+ }
else
+ {
+ state = ALIGN_IDLE;
+ emit newStatus(state);
appendLogText(i18n("Syncing failed."));
-
+ }
}
-void Align::SlewToTarget()
+void Align::Slew()
{
- if (canSync && loadSlewState == IPS_IDLE)
- Sync();
-
state = ALIGN_SLEWING;
emit newStatus(state);
currentTelescope->Slew(&targetCoord);
- appendLogText(i18n("Slewing to target coordinates: RA (%1) DEC (%2).", targetCoord.ra().toHMSString(), targetCoord.dec().toDMSString()));
+ appendLogText(i18n("Slewing to target coordinates: RA (%1) DEC (%2).", targetCoord.ra().toHMSString(), targetCoord.dec().toDMSString()));
+}
+
+void Align::SlewToTarget()
+{
+ if (canSync && loadSlewState == IPS_IDLE)
+ {
+ Sync();
+ return;
+ }
+
+ Slew();
}
void Align::executePolarAlign()
@@ -1671,6 +1753,7 @@ void Align::loadAndSlew(QString fileURL)
loadSlewState=IPS_BUSY;
slewR->setChecked(true);
+ currentGotoMode = GOTO_SLEW;
solveB->setEnabled(false);
stopB->setEnabled(true);
diff --git a/kstars/ekos/align/align.h b/kstars/ekos/align/align.h
index 082a85e..efda62d 100644
--- a/kstars/ekos/align/align.h
+++ b/kstars/ekos/align/align.h
@@ -332,6 +332,11 @@ private:
void Sync();
/**
+ * @brief Slew the telescope to the solved alignment coordinate.
+ */
+ void Slew();
+
+ /**
* @brief Sync the telescope to the solved alignment coordinate, and then slew to the target coordinate.
*/
void SlewToTarget();
diff --git a/kstars/ekos/ekos.h b/kstars/ekos/ekos.h
index c1a6266..6c5947d 100644
--- a/kstars/ekos/ekos.h
+++ b/kstars/ekos/ekos.h
@@ -36,9 +36,9 @@ namespace Ekos
const QString &getFocusStatusString(FocusState state);
// Align States
- static const QStringList alignStates = { I18N_NOOP("Idle"), I18N_NOOP("Complete"), I18N_NOOP("Failed"), I18N_NOOP("Aborted"), I18N_NOOP("In Progress"), I18N_NOOP("Slewing")};
+ static const QStringList alignStates = { I18N_NOOP("Idle"), I18N_NOOP("Complete"), I18N_NOOP("Failed"), I18N_NOOP("Aborted"), I18N_NOOP("In Progress"), I18N_NOOP("Syncing"), I18N_NOOP("Slewing")};
- typedef enum { ALIGN_IDLE, ALIGN_COMPLETE, ALIGN_FAILED, ALIGN_ABORTED, ALIGN_PROGRESS, ALIGN_SLEWING} AlignState;
+ typedef enum { ALIGN_IDLE, ALIGN_COMPLETE, ALIGN_FAILED, ALIGN_ABORTED, ALIGN_PROGRESS, ALIGN_SYNCING, ALIGN_SLEWING} AlignState;
const QString &getAlignStatusString(AlignState state);
}