diff --git a/kstars/ekos/capture/capture.h b/kstars/ekos/capture/capture.h --- a/kstars/ekos/capture/capture.h +++ b/kstars/ekos/capture/capture.h @@ -590,6 +590,15 @@ // Guide void setGuideStatus(Ekos::GuideState state); + // short cut for all guiding states that indicate guiding is active + bool isGuidingActive() {return (guideState == GUIDE_GUIDING || + guideState == GUIDE_CALIBRATING || + guideState == GUIDE_CALIBRATION_SUCESS || + guideState == GUIDE_REACQUIRE || + guideState == GUIDE_DITHERING || + guideState == GUIDE_DITHERING_SUCCESS || + guideState == GUIDE_DITHERING_ERROR || + guideState == GUIDE_DITHERING_SETTLE);}; // Align void setAlignStatus(Ekos::AlignState state); void setAlignResults(double orientation, double ra, double de, double pixscale); diff --git a/kstars/ekos/capture/capture.cpp b/kstars/ekos/capture/capture.cpp --- a/kstars/ekos/capture/capture.cpp +++ b/kstars/ekos/capture/capture.cpp @@ -1807,12 +1807,9 @@ bool Capture::startFocusIfRequired() { - if (activeJob->getFrameType() != FRAME_LIGHT) + if (activeJob == nullptr || activeJob->getFrameType() != FRAME_LIGHT) return false; - // if (autoFocusReady == false) - // return false; - // check if time for forced refocus if (refocusEveryNCheck->isChecked()) { @@ -3451,7 +3448,7 @@ else { // If we are autoguiding, we should resume autoguiding after flip - resumeGuidingAfterFlip = (guideState == GUIDE_GUIDING); + resumeGuidingAfterFlip = isGuidingActive(); if (m_State == CAPTURE_IDLE || m_State == CAPTURE_ABORTED || m_State == CAPTURE_COMPLETE || m_State == CAPTURE_PAUSED) { @@ -4529,7 +4526,6 @@ if (aborted > 0) { - //if (guideState >= GUIDE_GUIDING && deviationDetected) if (m_State == CAPTURE_SUSPENDED) return "Suspended"; else @@ -4743,12 +4739,16 @@ void Capture::setGuideStatus(GuideState state) { + if (state != guideState) + qCDebug(KSTARS_EKOS_CAPTURE) << "Guiding state changed from" << getGuideStatusString(guideState) + << "to" << getGuideStatusString(state); + switch (state) { case GUIDE_IDLE: case GUIDE_ABORTED: // If Autoguiding was started before and now stopped, let's abort (unless we're doing a meridian flip) - if (guideState == GUIDE_GUIDING && meridianFlipStage == MF_NONE && + if (isGuidingActive() && meridianFlipStage == MF_NONE && ((activeJob && activeJob->getStatus() == SequenceJob::JOB_BUSY) || this->m_State == CAPTURE_SUSPENDED || this->m_State == CAPTURE_PAUSED)) { @@ -4790,7 +4790,10 @@ else { appendLogText(i18n("Dither complete.")); - resumeCapture(); + qCInfo(KSTARS_EKOS_CAPTURE) << "Dither complete, capture state" << getCaptureStatusString(m_State); + // resume only if nothing happened during dithering + if (m_State == CAPTURE_DITHERING) + resumeCapture(); } break; @@ -5942,124 +5945,6 @@ } } -// FIXME Migrate to Filter Manager -#if 0 -void Capture::loadFilterOffsets() -{ - // Get all OAL equipment filter list - KStarsData::Instance()->userdb()->GetAllFilters(m_filterList); - filterFocusOffsets.clear(); - - for (int i = 0; i < FilterPosCombo->count(); i++) - { - FocusOffset * oneOffset = new FocusOffset; - oneOffset->filter = FilterPosCombo->itemText(i); - oneOffset->offset = 0; - - // Find matching filter if any and loads its offset - foreach (OAL::Filter * o, m_filterList) - { - if (o->vendor() == FilterCaptureCombo->currentText() && o->color() == oneOffset->filter) - { - oneOffset->offset = o->offset().toInt(); - break; - } - } - - filterFocusOffsets.append(oneOffset); - } -} - -void Capture::showFilterOffsetDialog() -{ - loadFilterOffsets(); - - QDialog filterOffsetDialog; - - filterOffsetDialog.setWindowTitle(i18n("Filter Focus Offsets")); - - QDialogButtonBox * buttonBox = - new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &filterOffsetDialog); - - connect(buttonBox, SIGNAL(accepted()), &filterOffsetDialog, &Ekos::Capture::accept())); - connect(buttonBox, SIGNAL(rejected()), &filterOffsetDialog, &Ekos::Capture::reject())); - - QVBoxLayout * mainLayout = new QVBoxLayout(&filterOffsetDialog); - QGridLayout * grid = new QGridLayout(&filterOffsetDialog); - QHBoxLayout * tipLayout = new QHBoxLayout(&filterOffsetDialog); - - QLabel * tipIcon = new QLabel(&filterOffsetDialog); - QLabel * tipText = new QLabel(&filterOffsetDialog); - - tipIcon->setPixmap( - QIcon::fromTheme("kstars_flag").pixmap(QSize(32, 32))); - tipIcon->setFixedSize(32, 32); - - tipText->setText(i18n("Set relative filter focus offset in steps.")); - - tipLayout->addWidget(tipIcon); - tipLayout->addWidget(tipText); - - mainLayout->addLayout(grid); - mainLayout->addLayout(tipLayout); - mainLayout->addWidget(buttonBox); - - //filterOffsetDialog.setLayout(mainLayout); - - for (int i = 0; i < filterFocusOffsets.count(); i++) -{ - FocusOffset * oneOffset = filterFocusOffsets.at(i); - - QLabel * label = new QLabel(oneOffset->filter, &filterOffsetDialog); - QSpinBox * spin = new QSpinBox(&filterOffsetDialog); - spin->setMinimum(-10000); - spin->setMaximum(10000); - spin->setSingleStep(100); - spin->setValue(oneOffset->offset); - - grid->addWidget(label, i, 0); - grid->addWidget(spin, i, 1); - } - - if (filterOffsetDialog.exec() == QDialog::Accepted) -{ - for (int i = 0; i < filterFocusOffsets.count(); i++) - { - FocusOffset * oneOffset = filterFocusOffsets.at(i); - oneOffset->offset = static_cast(grid->itemAtPosition(i, 1)->widget())->value(); - - // Find matching filter if any and save its offset - OAL::Filter * matchedFilter = nullptr; - - foreach (OAL::Filter * o, m_filterList) - { - if (o->vendor() == FilterCaptureCombo->currentText() && o->color() == oneOffset->filter) - { - o->setOffset(QString::number(oneOffset->offset)); - matchedFilter = o; - break; - } - } - -#if 0 - // If no filter exists, let's create one - if (matchedFilter == nullptr) - { - KStarsData::Instance()->userdb()->AddFilter(FilterCaptureCombo->currentText(), "", "", - QString::number(oneOffset->offset), oneOffset->filter, "1"); - } - // Or update Existing one - else - { - KStarsData::Instance()->userdb()->AddFilter(FilterCaptureCombo->currentText(), "", "", - QString::number(oneOffset->offset), oneOffset->filter, - matchedFilter->exposure(), matchedFilter->id()); - } -#endif - } - } -} -#endif void Capture::toggleVideo(bool enabled) { diff --git a/kstars/ekos/guide/guide.cpp b/kstars/ekos/guide/guide.cpp --- a/kstars/ekos/guide/guide.cpp +++ b/kstars/ekos/guide/guide.cpp @@ -753,31 +753,6 @@ connect(currentCCD, &ISD::CCD::numberUpdated, this, &Ekos::Guide::processCCDNumber, Qt::UniqueConnection); connect(currentCCD, &ISD::CCD::newExposureValue, this, &Ekos::Guide::checkExposureValue, Qt::UniqueConnection); - // If guider is external and already connected and remote images option was disabled AND it was already - // disabled, then let's go ahead and disable it. -#if 0 - if (guiderType != GUIDE_INTERNAL && Options::guideRemoteImagesEnabled() == false && guider->isConnected()) - { - for (int i = 0; i < CCDs.count(); i++) - { - ISD::CCD * oneCCD = CCDs[i]; - if (i == ccdNum && oneCCD->getDriverInfo()->getClientManager()->getBLOBMode(oneCCD->getDeviceName(), "CCD1") != B_NEVER) - { - appendLogText(i18n("Disabling remote image reception from %1", oneCCD->getDeviceName())); - oneCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_NEVER, oneCCD->getDeviceName(), "CCD1"); - oneCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_NEVER, oneCCD->getDeviceName(), "CCD2"); - } - // If it was already disabled, enable it back - else if (i != ccdNum && oneCCD->getDriverInfo()->getClientManager()->getBLOBMode(oneCCD->getDeviceName(), "CCD1") == B_NEVER) - { - appendLogText(i18n("Enabling remote image reception from %1", oneCCD->getDeviceName())); - oneCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_ALSO, oneCCD->getDeviceName(), "CCD1"); - oneCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_ALSO, oneCCD->getDeviceName(), "CCD2"); - } - } - } -#endif - targetChip->setImageView(guideView, FITS_GUIDE); syncCCDInfo(); @@ -1091,21 +1066,6 @@ settings["h"].toInt()); } -#if 0 - switch (state) - { - case GUIDE_GUIDING: - if (Options::rapidGuideEnabled() == false) - connect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, &Ekos::Guide::newFITS(IBLOB *)), Qt::UniqueConnection); - targetChip->capture(seqExpose); - return true; - break; - - default: - break; - } -#endif - currentCCD->setTransformFormat(ISD::CCD::FORMAT_FITS); connect(currentCCD, &ISD::CCD::BLOBUpdated, this, &Ekos::Guide::newFITS, Qt::UniqueConnection); @@ -1405,90 +1365,6 @@ return devices; } -#if 0 -void Guide::processRapidStarData(ISD::CCDChip * targetChip, double dx, double dy, double fit) -{ - // Check if guide star is lost - if (dx == -1 && dy == -1 && fit == -1) - { - KSNotification::error(i18n("Lost track of the guide star. Rapid guide aborted.")); - guider->abort(); - return; - } - - FITSView * targetImage = targetChip->getImage(FITS_GUIDE); - - if (targetImage == nullptr) - { - pmath->setImageView(nullptr); - guider->setImageView(nullptr); - calibration->setImageView(nullptr); - } - - if (rapidGuideReticleSet == false) - { - // Let's set reticle parameter on first capture to those of the star, then we check if there - // is any set - double x, y, angle; - pmath->getReticleParameters(&x, &y, &angle); - pmath->setReticleParameters(dx, dy, angle); - rapidGuideReticleSet = true; - } - - pmath->setRapidStarData(dx, dy); - - if (guider->isDithering()) - { - pmath->performProcessing(); - if (guider->dither() == false) - { - appendLogText(i18n("Dithering failed. Autoguiding aborted.")); - emit newStatus(GUIDE_DITHERING_ERROR); - guider->abort(); - //emit ditherFailed(); - } - } - else - { - guider->guide(); - capture(); - } - -} - -void Guide::startRapidGuide() -{ - ISD::CCDChip * targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD); - - if (currentCCD->setRapidGuide(targetChip, true) == false) - { - appendLogText(i18n("The CCD does not support Rapid Guiding. Aborting...")); - guider->abort(); - return; - } - - rapidGuideReticleSet = false; - - pmath->setRapidGuide(true); - currentCCD->configureRapidGuide(targetChip, true); - connect(currentCCD, SIGNAL(newGuideStarData(ISD::CCDChip*, double, double, double)), this, &Ekos::Guide::processRapidStarData(ISD::CCDChip *, double, double, double))); -} - -void Guide::stopRapidGuide() -{ - ISD::CCDChip * targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD); - - pmath->setRapidGuide(false); - - rapidGuideReticleSet = false; - - currentCCD->disconnect(SIGNAL(newGuideStarData(ISD::CCDChip*, double, double, double))); - - currentCCD->configureRapidGuide(targetChip, false, false, false); - - currentCCD->setRapidGuide(targetChip, false); -} -#endif bool Guide::calibrate() { @@ -1766,46 +1642,13 @@ setExternalGuiderBLOBEnabled(!enable); } -#if 0 -void Guide::setGuideRapidEnabled(bool enable) -{ - //guider->setGuideOptions(guider->getAlgorithm(), guider->useSubFrame() , enable); -} -#endif void Guide::setDitherSettings(bool enable, double value) { Options::setDitherEnabled(enable); Options::setDitherPixels(value); } -#if 0 -void Guide::startAutoCalibrateGuide() -{ - // A must for auto stuff - Options::setGuideAutoStarEnabled(true); - - if (Options::resetGuideCalibration()) - clearCalibration(); - - guide(); - -#if 0 - if (guiderType == GUIDE_INTERNAL) - { - calibrationComplete = false; - autoCalibrateGuide = true; - calibrate(); - } - else - { - calibrationComplete = true; - autoCalibrateGuide = true; - guide(); - } -#endif -} -#endif void Guide::clearCalibration() { @@ -2468,25 +2311,6 @@ connect(southControlCheck, &QCheckBox::toggled, this, &Ekos::Guide::onControlDirectionChanged); } -#if 0 -void Guide::onRapidGuideChanged(bool enable) -{ - if (m_isStarted) - { - guideModule->appendLogText(i18n("You must stop auto guiding before changing this setting.")); - return; - } - - m_useRapidGuide = enable; - - if (m_useRapidGuide) - { - guideModule->appendLogText(i18n("Rapid Guiding is enabled. Guide star will be determined automatically by the CCD driver. No frames are sent to Ekos unless explicitly enabled by the user in the CCD driver settings.")); - } - else - guideModule->appendLogText(i18n("Rapid Guiding is disabled.")); -} -#endif void Guide::loadSettings() {