summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-10-25 10:22:35 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-10-25 10:22:35 (GMT)
commit6dfa89afc8171d045af5374e1513fd1ccceabe01 (patch)
tree5f68b980b7eb0f0334bec024ffeafa28e18b444f
parent931a353b98211a0f253ff396b7441f99d4b7b5a2 (diff)
Add parity detection to astrometry modules and it is reused on next captures unless a solver fails then it gets reset to both. Adding alignment solver timer as well to watch for timeout
-rw-r--r--kstars/ekos/align/align.cpp17
-rw-r--r--kstars/ekos/align/align.h6
-rw-r--r--kstars/ekos/align/offlineastrometryparser.cpp15
-rw-r--r--kstars/ekos/align/offlineastrometryparser.h1
-rw-r--r--kstars/ekos/align/onlineastrometryparser.cpp17
-rw-r--r--kstars/ekos/align/onlineastrometryparser.h3
6 files changed, 54 insertions, 5 deletions
diff --git a/kstars/ekos/align/align.cpp b/kstars/ekos/align/align.cpp
index b6ce078..e93c285 100644
--- a/kstars/ekos/align/align.cpp
+++ b/kstars/ekos/align/align.cpp
@@ -110,6 +110,10 @@ Align::Align()
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++);
@@ -202,6 +206,14 @@ bool Align::isParserOK()
return rc;
}
+void Align::checkAlignmentTimeout()
+{
+ if (loadSlewState != IPS_IDLE || ++solverIterations == MAXIMUM_SOLVER_ITERATIONS)
+ abort();
+ else if (loadSlewState == IPS_IDLE)
+ captureAndSolve();
+}
+
void Align::setSolverType(int type)
{
switch(type)
@@ -758,6 +770,8 @@ void Align::startSolving(const QString &filename, bool isGenerated)
solverTimer.start();
+ alignTimer.start();
+
if (isGenerated)
solverArgs = solverOptions->text().split(" ");
else if (filename.endsWith("fits") || filename.endsWith("fit"))
@@ -787,6 +801,8 @@ void Align::solverFinished(double orientation, double ra, double dec, double pix
sRA = ra;
sDEC = dec;
+ alignTimer.stop();
+
int binx, biny;
ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
targetChip->getBinning(&binx, &biny);
@@ -951,6 +967,7 @@ void Align::abort()
//m_slewToTargetSelected=false;
solverIterations=0;
retries=0;
+ alignTimer.stop();
//currentCCD->disconnect(this);
disconnect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
diff --git a/kstars/ekos/align/align.h b/kstars/ekos/align/align.h
index 6b9bce0..f4b455f 100644
--- a/kstars/ekos/align/align.h
+++ b/kstars/ekos/align/align.h
@@ -297,6 +297,9 @@ private slots:
void saveSettleTime();
+ // Solver timeout
+ void checkAlignmentTimeout();
+
signals:
void newLog();
void solverComplete(bool);
@@ -449,6 +452,9 @@ private:
GotoMode currentGotoMode;
QString dirPath;
+
+ // Timer
+ QTimer alignTimer;
};
}
diff --git a/kstars/ekos/align/offlineastrometryparser.cpp b/kstars/ekos/align/offlineastrometryparser.cpp
index c7a369b..34ba849 100644
--- a/kstars/ekos/align/offlineastrometryparser.cpp
+++ b/kstars/ekos/align/offlineastrometryparser.cpp
@@ -48,6 +48,10 @@ OfflineAstrometryParser::OfflineAstrometryParser() : AstrometryParser()
connect(&solver, SIGNAL(finished(int)), this, SLOT(solverComplete(int)));
connect(&solver, SIGNAL(readyReadStandardOutput()), this, SLOT(logSolver()));
+
+ // Reset parity on solver failure
+ connect(this, &OfflineAstrometryParser::solverFailed, this, [&]() { parity = QString();});
+
connect(&solver, &QProcess::errorOccurred, this, [&]()
{
align->appendLogText(i18n("Error starting solver: %1", solver.errorString()));
@@ -191,11 +195,16 @@ bool OfflineAstrometryParser::startSovler(const QString &filename, const QStrin
#endif
QStringList solverArgs = args;
+ // Add parity option if none is give and we already know parity before
+ if (parity.isEmpty() == false && args.contains("parity") == false)
+ solverArgs << "--parity" << parity;
QString solutionFile = QDir::tempPath() + "/solution.wcs";
solverArgs << "-W" << solutionFile << filename;
fitsFile = filename;
+ solver.kill();
+
solverTimer.start();
solver.start(Options::astrometrySolver(), solverArgs);
@@ -258,7 +267,7 @@ void OfflineAstrometryParser::wcsinfoComplete(int exist_status)
QStringList key_value;
- double ra=0, dec=0, orientation=0, pixscale=0;
+ double ra=0, dec=0, orientation=0, pixscale=0;
foreach(QString key, wcskeys)
{
@@ -274,9 +283,9 @@ void OfflineAstrometryParser::wcsinfoComplete(int exist_status)
orientation = key_value[1].toDouble();
else if (key_value[0] == "pixscale")
pixscale = key_value[1].toDouble();
-
+ else if (key_value[0] == "parity")
+ parity = (key_value[1].toInt() > 0) ? "pos" : "neg";
}
-
}
int elapsed = (int) round(solverTimer.elapsed()/1000.0);
diff --git a/kstars/ekos/align/offlineastrometryparser.h b/kstars/ekos/align/offlineastrometryparser.h
index 4a2368f..8f22b24 100644
--- a/kstars/ekos/align/offlineastrometryparser.h
+++ b/kstars/ekos/align/offlineastrometryparser.h
@@ -52,6 +52,7 @@ private:
bool getAstrometryDataDir(QString &dataDir);
QMap<float, QString> astrometryIndex;
+ QString parity;
QProcess solver;
QProcess wcsinfo;
QTime solverTimer;
diff --git a/kstars/ekos/align/onlineastrometryparser.cpp b/kstars/ekos/align/onlineastrometryparser.cpp
index e0efe89..c03d15e 100644
--- a/kstars/ekos/align/onlineastrometryparser.cpp
+++ b/kstars/ekos/align/onlineastrometryparser.cpp
@@ -47,6 +47,9 @@ OnlineAstrometryParser::OnlineAstrometryParser() : AstrometryParser()
connect(this, SIGNAL(jobIDFinished()), this, SLOT(checkJobs()));
connect(this, SIGNAL(jobFinished()), this, SLOT(checkJobCalibration()));
+ // Reset parity on solver failure
+ connect(this, &OnlineAstrometryParser::solverFailed, this, [&]() { parity = -1;});
+
connect(this, SIGNAL(solverFailed()), this, SLOT(resetSolver()));
connect(this, SIGNAL(solverFinished(double,double,double, double)), this, SLOT(resetSolver()));
@@ -172,6 +175,16 @@ bool OnlineAstrometryParser::startSovler(const QString &in_filename, const QStri
radius = args[i+1].toDouble(&ok);
else if (args[i] == "--downsample")
downsample_factor = args[i+1].toInt(&ok);
+ else if (args[i] == "--parity")
+ {
+ QString arg = args[i+1];
+ if (arg == "both")
+ parity = 2;
+ else if (arg == "pos")
+ parity = 0;
+ else
+ parity = 1;
+ }
}
connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onResult(QNetworkReply*)));
@@ -260,6 +273,8 @@ void OnlineAstrometryParser::uploadFile()
uploadReq.insert("radius", radius);
if (downsample_factor != 0)
uploadReq.insert("downsample_factor", downsample_factor);
+ if (parity != -1)
+ uploadReq.insert("parity", parity);
QJsonObject json = QJsonObject::fromVariantMap(uploadReq);
QJsonDocument json_doc(json);
@@ -469,7 +484,7 @@ void OnlineAstrometryParser::onResult(QNetworkReply* reply)
break;
case JOB_CALIBRATION_STAGE:
- parity = result["parity"].toDouble(&ok);
+ parity = result["parity"].toInt(&ok);
if (ok == false)
{
align->appendLogText(i18n("Error parsing parity."));
diff --git a/kstars/ekos/align/onlineastrometryparser.h b/kstars/ekos/align/onlineastrometryparser.h
index 7f57729..cba059b 100644
--- a/kstars/ekos/align/onlineastrometryparser.h
+++ b/kstars/ekos/align/onlineastrometryparser.h
@@ -71,7 +71,8 @@ private:
QTime solverTimer;
QString filename;
double lowerScale, upperScale, center_ra, center_dec, radius, pixscale;
- double parity,ra,dec,orientation;
+ int parity = -1;
+ double ra,dec,orientation;
int downsample_factor;
bool isGenerated;
Align *align;