diff --git a/src/modules/navigator/navigator.cpp b/src/modules/navigator/navigator.cpp index eb76e52..b6ca02e 100644 --- a/src/modules/navigator/navigator.cpp +++ b/src/modules/navigator/navigator.cpp @@ -186,15 +186,15 @@ void Navigator::OnNewImage() folders.append("/usr/share/astrometry/"); stellarSolver.setIndexFolderPaths(folders); stellarSolver.setProperty("UseScale", true); - stellarSolver.setSearchScale(ech * 0.9, ech * 1.1, ScaleUnits::ARCSEC_PER_PIX); + stellarSolver.setSearchScale(ech * 0.8, ech * 1.2, ScaleUnits::ARCSEC_PER_PIX); stellarSolver.setProperty("UsePosition", true); stellarSolver.setSearchPositionInDegrees(wra, wde); stellarSolver.setParameters(StellarSolver::getBuiltInProfiles()[SSolver::Parameters::DEFAULT]); stellarSolver.setProperty("ProcessType", SOLVE); stellarSolver.setProperty("ExtractorType", EXTRACTOR_INTERNAL); stellarSolver.setProperty("SolverType", SOLVER_STELLARSOLVER); - stellarSolver.setLogLevel(LOG_ALL); - stellarSolver.setSSLogLevel(LOG_VERBOSE); + stellarSolver.setLogLevel(LOG_MSG); + stellarSolver.setSSLogLevel(LOG_NORMAL); stellarSolver.setProperty("LogToFile", true); stellarSolver.setProperty("LogFileName", getWebroot() + "/navigator_solver.log"); stellarSolver.start(); @@ -216,6 +216,16 @@ void Navigator::updateProperty(INDI::Property property) sendWarning("cameraAlert"); emit cameraAlert(); } + if ( + (property.getDeviceName() == getString("devices", "mount")) + && (property.getName() == std::string("EQUATORIAL_EOD_COORD")) + ) + { + // Update mount position + INDI::PropertyNumber prop = property; + getEltFloat("mountposition", "RA")->setValue(prop.findWidgetByName("RA")->value, false); + getEltFloat("mountposition", "DEC")->setValue(prop.findWidgetByName("DEC")->value, true); + } if ( (property.getDeviceName() == getString("devices", "mount")) && (property.getName() == std::string("EQUATORIAL_EOD_COORD")) @@ -266,7 +276,7 @@ void Navigator::OnSucessSolve() { if (stellarSolver.failed()) { - sendError("Image NOT solved - centering aborted"); + sendError("Image NOT solved - Centering aborted"); stellarSolver.abort(); getProperty("actions")->setState(OST::Error); mState = "idle"; @@ -293,6 +303,7 @@ void Navigator::OnSucessSolve() sendMessage(QString("Centering successful after %1 iteration(s) - within tolerance") .arg(mCurrentIteration)); getProperty("actions")->setState(OST::Ok); + syncMountIfNeeded(solvedRA, solvedDEC); mState = "idle"; mCurrentIteration = 0; return; @@ -458,8 +469,6 @@ void Navigator::correctOffset(double solvedRA, double solvedDEC) .arg(newDEC, 0, 'f', 2)); // Send corrected position to mount - qDebug() << prop.findWidgetByName("RA")->value << "->" << newRA; - qDebug() << prop.findWidgetByName("DEC")->value << "->" << newDEC; prop.findWidgetByName("RA")->value = newRA; prop.findWidgetByName("DEC")->value = newDEC; mWaitingSlew = true; @@ -468,3 +477,40 @@ void Navigator::correctOffset(double solvedRA, double solvedDEC) // Mount will trigger updateProperty when slew is complete // which will call Shoot() again for next iteration } +void Navigator::syncMountIfNeeded(double solvedRA, double solvedDEC) +{ + + // Get mount device + QString mount = getString("devices", "mount"); + INDI::BaseDevice dp = getDevice(mount.toStdString().c_str()); + if (!(dp.getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE)) + { + sendError( "Device " + mount + " has no telescope interface"); + return; + } + + if (!sendModNewSwitch(mount, "ON_COORD_SET", "SYNC", ISS_ON)) return; + + INDI::PropertyNumber prop = dp.getProperty("EQUATORIAL_EOD_COORD"); + if (!prop.isValid()) + { + sendError("Error - unable to find " + mount + " / EQUATORIAL_EOD_COORD property. Aborting."); + return; + } + double jd = ln_get_julian_from_sys(); + INDI::IEquatorialCoordinates j2000pos; + INDI::IEquatorialCoordinates observed; + observed.rightascension = solvedRA; + observed.declination = solvedDEC; + INDI::ObservedToJ2000(&observed, jd, &j2000pos); + + prop.findWidgetByName("RA")->value = j2000pos.declination; + prop.findWidgetByName("DEC")->value = j2000pos.rightascension; + sendNewNumber(prop); + + //restore slew + if (!sendModNewSwitch(mount, "ON_COORD_SET", "SLEW", ISS_ON)) return; + + sendMessage("Mount successfully synchronized with solved field"); + +} diff --git a/src/modules/navigator/navigator.h b/src/modules/navigator/navigator.h index d50de3b..e4fb997 100644 --- a/src/modules/navigator/navigator.h +++ b/src/modules/navigator/navigator.h @@ -47,6 +47,7 @@ class MODULE_INIT Navigator : public IndiModule void convertSelection(void); void correctOffset(double solvedRA, double solvedDEC); bool checkCentering(double solvedRA, double solvedDEC, double targetRA, double targetDEC); + void syncMountIfNeeded(double solvedRA, double solvedDEC); QString mState = "idle"; diff --git a/src/modules/navigator/navigator.json b/src/modules/navigator/navigator.json index 2dc1556..8995476 100644 --- a/src/modules/navigator/navigator.json +++ b/src/modules/navigator/navigator.json @@ -6,7 +6,7 @@ "group": "", "permission": 2, "hasprofile":true, - "rule":0, + "rule":2, "label": "Centering parameters", "elements": { "maxiterations": { @@ -35,7 +35,17 @@ "slider":2, "format":"%.1f", "hint":"Centering tolerance in arcseconds" + }, + "syncafter": { + "autoupdate":true, + "directedit":true, + "type": "bool", + "label": "Sync mount after sucess", + "order": "3", + "value":false, + "hint":"Synchronise mount coordinates after centering" } + } }, "search": { @@ -198,6 +208,28 @@ ] } } + }, + "mountposition": { + "devcat": "Control", + "order": "Control0000", + "group": "", + "permission": 0, + "rule":0, + "label": "Mount position", + "elements": { + "RA": { + "type": "float", + "label": "RA", + "order": "10", + "value": 0.0 + }, + "DEC": { + "type": "float", + "label": "DEC", + "order": "20", + "value": 0.0 + } + } } } }