Commit 6dfa89af authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Add parity detection to astrometry modules and it is reused on next captures...

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
parent 931a353b
......@@ -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*)));
......
......@@ -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;
};
}
......
......@@ -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);
......
......@@ -52,6 +52,7 @@ private:
bool getAstrometryDataDir(QString &dataDir);
QMap<float, QString> astrometryIndex;
QString parity;
QProcess solver;
QProcess wcsinfo;
QTime solverTimer;
......
......@@ -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."));
......
......@@ -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;
......
Supports Markdown
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