Git commit 29f66bff03d27e1a5b5ec958fa7cccf82ee7613c by Jasem Mutlaq. Committed on 30/09/2016 at 20:38. Pushed by mutlaqja into branch 'bleeding'. Calibration mostly works now in internal guider. Need to test all cases aft= er guiding and dithering are complete M +1 -1 kstars/ekos/guide/externalguide/phd2.h M +235 -89 kstars/ekos/guide/guide.cpp M +37 -15 kstars/ekos/guide/guide.h M +48 -29 kstars/ekos/guide/guide.ui M +5 -0 kstars/ekos/guide/guideinterface.cpp M +3 -1 kstars/ekos/guide/guideinterface.h M +16 -26 kstars/ekos/guide/internalguide/gmath.cpp M +4 -7 kstars/ekos/guide/internalguide/gmath.h M +146 -287 kstars/ekos/guide/internalguide/internalguider.cpp M +24 -11 kstars/ekos/guide/internalguide/internalguider.h M +1 -6 kstars/ekos/guide/opscalibration.cpp M +0 -1 kstars/ekos/guide/opscalibration.h M +19 -22 kstars/ekos/guide/opscalibration.ui M +1 -5 kstars/kstars.kcfg M +3 -6 kstars/org.kde.kstars.Ekos.Guide.xml http://commits.kde.org/kstars/29f66bff03d27e1a5b5ec958fa7cccf82ee7613c diff --git a/kstars/ekos/guide/externalguide/phd2.h b/kstars/ekos/guide/ext= ernalguide/phd2.h index 90b2a37..a36c100 100644 --- a/kstars/ekos/guide/externalguide/phd2.h +++ b/kstars/ekos/guide/externalguide/phd2.h @@ -47,7 +47,7 @@ public: = bool calibrate() override; bool guide() override; - bool stop() override; + bool abort() override; bool suspend() override; bool resume() override; bool dither(double pixels) override; diff --git a/kstars/ekos/guide/guide.cpp b/kstars/ekos/guide/guide.cpp index f4fb24f..ab8f8bc 100644 --- a/kstars/ekos/guide/guide.cpp +++ b/kstars/ekos/guide/guide.cpp @@ -37,6 +37,7 @@ = #include "guideadaptor.h" #include "kspaths.h" +#include "kstarsdata.h" = #define driftGraph_WIDTH 200 #define driftGraph_HEIGHT 200 @@ -63,15 +64,37 @@ Guide::Guide() : QWidget() // ST4 Driver GuideDriver=3DNULL; = + // Auto Star + autoStarCaptured =3D false; + + guideView =3D new FITSView(guideWidget); + guideView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expandin= g); + guideView->setBaseSize(guideWidget->size()); + QVBoxLayout *vlayout =3D new QVBoxLayout(); + vlayout->addWidget(guideView); + guideWidget->setLayout(vlayout); + connect(guideView, SIGNAL(trackingStarSelected(int,int)), this, SLOT(s= etTrackingStar(int,int))); + ccd_hor_pixel =3D ccd_ver_pixel =3D focal_length =3D aperture =3D -= 1; guideDeviationRA =3D guideDeviationDEC =3D 0; = useGuideHead =3D false; - rapidGuideReticleSet =3D false; + rapidGuideReticleSet =3D false; = = // Load all settings loadSettings(); = + // Set color scheme + refreshColorScheme(); + + // Image Filters + foreach(QString filter, FITSViewer::filterTypes) + filterCombo->addItem(filter); + + // Progress Indicator + pi =3D new QProgressIndicator(this); + controlLayout->addWidget(pi, 0, 1, 1, 1); + // Exposure connect(exposureIN, SIGNAL(editingFinished()), this, SLOT(saveDefaultG= uideExposure())); = @@ -96,7 +119,7 @@ Guide::Guide() : QWidget() = // Drift Graph scales connect( spinBox_XScale, SIGNAL(valueChanged(int)), this, SLOT(onXsc= aleChanged(int)) ); - connect( spinBox_YScale, SIGNAL(valueChanged(int)), this, SLOT(onYsc= aleChanged(int)) ); + connect( spinBox_YScale, SIGNAL(valueChanged(int)), this, SLOT(onYsc= aleChanged(int)) ); = = // Guiding Rate - Advisory only connect( spinBox_GuideRate, SIGNAL(valueChanged(double)), this, SLOT= (onInfoRateChanged(double)) ); @@ -134,13 +157,14 @@ Guide::Guide() : QWidget() connect( spinBox_MinPulseRA, SIGNAL(editingFinished()), this, SLOT(on= InputParamChanged()) ); connect( spinBox_MinPulseDEC, SIGNAL(editingFinished()), this, SLOT(o= nInputParamChanged()) ); = - // Image Filters - foreach(QString filter, FITSViewer::filterTypes) - filterCombo->addItem(filter); + // Capture + connect(captureB, SIGNAL(clicked()), this, SLOT(capture())); = - // Progress Indicator - pi =3D new QProgressIndicator(this); - controlLayout->addWidget(pi, 0, 1, 1, 1); + // Stop + connect(stopB, SIGNAL(clicked()), this, SLOT(abort())); + + // Calibrate + connect(calibrateB, SIGNAL(clicked()), this, SLOT(calibrate())); = // Drift Graph //driftGraph =3D new ScrollGraph( this, driftGraph_WIDTH, driftGraph_H= EIGHT ); @@ -158,15 +182,23 @@ Guide::Guide() : QWidget() case GUIDE_INTERNAL: { guider=3D new InternalGuider(); + InternalGuider *internalGuider =3D dynamic_cast(g= uider); // Options KConfigDialog* dialog =3D new KConfigDialog(this, "guidesettings",= Options::self()); - opsCalibration =3D new OpsCalibration(dynamic_cast(guider)); + opsCalibration =3D new OpsCalibration(internalGuider); dialog->addPage(opsCalibration, i18n("Calibration Settings")); - opsGuide =3D new OpsGuide(dynamic_cast(guider)); + opsGuide =3D new OpsGuide(internalGuider); dialog->addPage(opsGuide, i18n("Guide Settings")); connect(guideOptionsB, SIGNAL(clicked()), dialog, SLOT(show())); = - calibrationB->setEnabled(true); + connect(internalGuider, SIGNAL(newPulse(GuideDirection,int)), this= , SLOT(sendPulse(GuideDirection,int))); + connect(internalGuider, SIGNAL(newPulse(GuideDirection,int,GuideDi= rection,int)), this, SLOT(sendPulse(GuideDirection,int,GuideDirection,int))= ); + connect(internalGuider, SIGNAL(DESwapChanged(bool)), swapCheck, SL= OT(setChecked(bool))); + //connect(swapCheck, SIGNAL(toggled(bool)), internalGuider, SLOT(s= etDECSwap(bool))); + + internalGuider->setGuideView(guideView); + + calibrateB->setEnabled(true); captureB->setEnabled(true); } break; @@ -177,7 +209,7 @@ Guide::Guide() : QWidget() // Do NOT receive BLOBs from the driver //currentCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_N= EVER, currentCCD->getDeviceName(), useGuideHead ? "CCD2" : "CCD1"); = - calibrationB->setEnabled(false); + calibrateB->setEnabled(false); captureB->setEnabled(false); break; = @@ -187,7 +219,7 @@ Guide::Guide() : QWidget() = // Do NOT receive BLOBs from the driver //currentCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_N= EVER, currentCCD->getDeviceName(), useGuideHead ? "CCD2" : "CCD1"); - calibrationB->setEnabled(false); + calibrateB->setEnabled(false); captureB->setEnabled(false); break; } @@ -195,6 +227,8 @@ Guide::Guide() : QWidget() = state =3D GUIDE_IDLE; = + connect(guider, SIGNAL(frameCaptureRequested()), this, SLOT(capture())= ); + connect(guider, SIGNAL(newLog(QString)), this, SLOT(appendLogText(QStr= ing))); connect(guider, SIGNAL(newStatus(Ekos::GuideState)), this, SLOT(setSta= tus(Ekos::GuideState))); connect(guider, SIGNAL(newStarPosition(QVector3D,bool)), this, SLOT(se= tStarPosition(QVector3D,bool))); = @@ -305,6 +339,9 @@ void Guide::checkCCD(int ccdNum) else useGuideHead=3Dfalse; = + ISD::CCDChip *targetChip =3D currentCCD->getChip(useGuideHead ? IS= D::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD); + targetChip->setImageView(guideView, FITS_GUIDE); + syncCCDInfo(); } } @@ -522,7 +559,7 @@ void Guide::setAO(ISD::ST4 *newAO) bool Guide::capture() { if (currentCCD =3D=3D NULL) - return false; + return false; = = double seqExpose =3D exposureIN->value(); = @@ -581,12 +618,78 @@ bool Guide::capture() break; } = + guideView->setBaseSize(guideWidget->size()); + connect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IB= LOB*))); targetChip->capture(seqExpose); = + setBusy(true); + + return true; +} + +bool Guide::abort() +{ + ISD::CCDChip *targetChip =3D currentCCD->getChip(useGuideHead ? ISD::C= CDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD); + + setBusy(false); + + switch (state) + { + case GUIDE_IDLE: + case GUIDE_CONNECTED: + case GUIDE_DISCONNECTED: + if (targetChip->isCapturing()) + targetChip->abortExposure(); + break; + + case GUIDE_CALIBRATING: + case GUIDE_CALIBRATION_STAR: + case GUIDE_CALIBRATION_CAPTURE: + guider->abort(); + default: + break; + + } + + + // Maybe set this above? + if (state >=3D GUIDE_CALIBRATING) + state =3D GUIDE_ABORTED; + else + state =3D GUIDE_IDLE; + + emit newStatus(state); + return true; } = +void Guide::setBusy(bool enable) +{ + if (enable) + { + calibrateB->setEnabled(false); + guideB->setEnabled(false); + captureB->setEnabled(false); + + stopB->setEnabled(true); + + pi->startAnimation(); + } + else + { + calibrateB->setEnabled(true); + captureB->setEnabled(true); + + if (state >=3D GUIDE_CALIBRATION_SUCESS) + guideB->setEnabled(true); + + stopB->setEnabled(false); + + pi->stopAnimation(); + } +} + void Guide::newFITS(IBLOB *bp) { INDI_UNUSED(bp); @@ -606,7 +709,7 @@ void Guide::newFITS(IBLOB *bp) targetChip->getFrame(&x,&y,&w,&h); targetChip->getBinning(&binx,&biny); = - FITSView *currentImage =3D targetChip->getImage(FITS_GUIDE); + FITSView *currentImage =3D targetChip->getImageView(FITS_GUIDE); FITSData *darkData =3D NULL; uint16_t offsetX =3D x / binx; uint16_t offsetY =3D y / biny; @@ -633,13 +736,11 @@ void Guide::newFITS(IBLOB *bp) = void Guide::setCaptureComplete() { - - DarkLibrary::Instance()->disconnect(this); = ISD::CCDChip *targetChip =3D currentCCD->getChip(useGuideHead ? ISD::C= CDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD); = - FITSView *targetImage =3D targetChip->getImage(FITS_GUIDE); + FITSView *targetImage =3D targetChip->getImageView(FITS_GUIDE); = if (targetImage =3D=3D NULL) { @@ -653,23 +754,19 @@ void Guide::setCaptureComplete() if (Options::guideLogging()) qDebug() << "Guide: received guide frame."; = - FITSData *image_data =3D targetImage->getImageData(); - Q_ASSERT(image_data); - - // FIXME - /* + //FITSData *image_data =3D targetImage->getImageData(); + //Q_ASSERT(image_data); = - - pmath->setImageView(targetImage); - guider->setImageView(targetImage); + //pmath->setImageView(targetImage); + //guider->setImageView(targetImage); = int subBinX=3D1, subBinY=3D1; targetChip->getBinning(&subBinX, &subBinY); = // It should be false in case we do not need to process the image for = motion // which happens when we take an image for auto star selection. - if (calibration->setImageView(targetImage) =3D=3D false) - return; + //if (calibration->setImageView(targetImage) =3D=3D false) + // return; = if (starCenter.x() =3D=3D 0 && starCenter.y() =3D=3D 0) { @@ -683,7 +780,54 @@ void Guide::setCaptureComplete() = syncTrackingBoxPosition(); = - if (isSuspended) + switch (state) + { + case GUIDE_IDLE: + case GUIDE_ABORTED: + case GUIDE_CONNECTED: + case GUIDE_DISCONNECTED: + case GUIDE_CALIBRATION_SUCESS: + case GUIDE_CALIBRATION_ERROR: + setBusy(false); + break; + + case GUIDE_CALIBRATION_CAPTURE: + { + if (Options::autoStarEnabled()) + { + autoStarCaptured =3D selectAutoStar(); + if (autoStarCaptured) + { + appendLogText(i18n("Auto star selected. Starting calib= ration...")); + guider->setStarPosition(starCenter); + guider->calibrate(); + } + else + { + appendLogText(i18n("Failed to select an auto star.")); + state =3D GUIDE_CALIBRATION_ERROR; + emit newStatus(state); + setBusy(false); + } + } + else + { + appendLogText(i18n("Select a guide star to calibrate.")); + state =3D GUIDE_CALIBRATION_STAR; + emit newStatus(state); + } + } + break; + case GUIDE_CALIBRATING: + guider->calibrate(); + break; + + default: + break; + + } + + /*if (isSuspended) { if (Options::guideLogging()) qDebug() << "Guide: Guider is suspended."; @@ -750,12 +894,11 @@ void Guide::setDECSwap(bool enable) if (ST4Driver =3D=3D NULL || guider =3D=3D NULL) return; = - // FIXME - /* - guider->setDECSwap(enable); - ST4Driver->setDECSwap(enable); - */ - + if (guiderType =3D=3D GUIDE_INTERNAL) + { + dynamic_cast(guider)->setDECSwap(enable); + ST4Driver->setDECSwap(enable); + } } = bool Guide::sendPulse( GuideDirection ra_dir, int ra_msecs, GuideDirection= dec_dir, int dec_msecs ) @@ -764,11 +907,8 @@ bool Guide::sendPulse( GuideDirection ra_dir, int ra_m= secs, GuideDirection dec_d if (GuideDriver =3D=3D NULL || (ra_dir =3D=3D NO_DIR && dec_dir =3D=3D= NO_DIR)) return false; = - // FIXME - /* - if (calibration->isCalibrating()) + if (state =3D=3D GUIDE_CALIBRATING) QTimer::singleShot( (ra_msecs > dec_msecs ? ra_msecs : dec_msecs) = + 100, this, SLOT(capture())); - */ = return GuideDriver->doPulse(ra_dir, ra_msecs, dec_dir, dec_msecs); } @@ -778,11 +918,8 @@ bool Guide::sendPulse( GuideDirection dir, int msecs ) if (GuideDriver =3D=3D NULL || dir=3D=3DNO_DIR) return false; = - // FIXME - /* - if (calibration->isCalibrating()) + if (state =3D=3D GUIDE_CALIBRATING) QTimer::singleShot(msecs+100, this, SLOT(capture())); - */ = return GuideDriver->doPulse(dir, msecs); = @@ -958,34 +1095,28 @@ void Guide::updateGuideDriver(double delta_ra, doubl= e delta_dec) */ } = -bool Guide::startCalibration() +bool Guide::calibrate() { saveSettings(); = - // FIXME - /* - if (Options::useEkosGuider()) - return calibration->startCalibration(); - else - return phd2->startGuiding(); + autoStarCaptured =3D false; = - */ - - return true; -} + if (starCenter.isNull() || Options::autoStarEnabled()) + { + state =3D GUIDE_CALIBRATION_CAPTURE; + emit newStatus(state); = -bool Guide::stopCalibration() -{ - // FIXME - /* - if (Options::useEkosGuider()) - return calibration->stopCalibration(); - else - return phd2->stopGuiding(); + appendLogText(i18n("Capturing image...")); + capture(); + return true; + } = - */ + guider->setStarPosition(starCenter); + bool rc =3D guider->calibrate(); + if (rc) + setBusy(true); = - return true; + return rc; } = bool Guide::startGuiding() @@ -1008,22 +1139,6 @@ bool Guide::startGuiding() = } = -bool Guide::stopGuiding() -{ - // FIXME - /* - isSuspended=3Dfalse; - - if (Options::useEkosGuider()) - return guider->abort(true); - else - // guider stop will call phd2->stopGuide() and change GUI elements= accordingly - return guider->stop(); - */ - - return true; -} - void Guide::setSuspended(bool enable) { /* @@ -1108,7 +1223,7 @@ void Guide::setSubFrameEnabled(bool enable) //guider->setGuideOptions(guider->getAlgorithm(), enable , guider->use= RapidGuide()); } = -void Guide::setGuideRapid(bool enable) +void Guide::setGuideRapidEnabled(bool enable) { //guider->setGuideOptions(guider->getAlgorithm(), guider->useSubFrame(= ) , enable); } @@ -1172,6 +1287,20 @@ void Guide::setStatus(Ekos::GuideState newState) = state =3D newState; = + switch (state) + { + case GUIDE_CALIBRATION_SUCESS: + setBusy(false); + break; + + case GUIDE_CALIBRATION_ERROR: + setBusy(false); + break; + + default: + break; + } + emit newStatus(newState); } = @@ -1251,11 +1380,9 @@ void Guide::syncTrackingBoxPosition() Q_ASSERT(targetChip); = int subBinX=3D1, subBinY=3D1; - targetChip->getBinning(&subBinX, &subBinY); - - FITSView *targetImage =3D targetChip->getImage(FITS_GUIDE); + targetChip->getBinning(&subBinX, &subBinY); = = - if (targetImage && starCenter.isNull() =3D=3D false) + if (starCenter.isNull() =3D=3D false) { double boxSize =3D boxSizeCombo->currentText().toInt(); int x,y,w,h; @@ -1280,8 +1407,8 @@ void Guide::syncTrackingBoxPosition() } = QRect starRect =3D QRect( starCenter.x()-boxSize/(2*subBinX), star= Center.y()-boxSize/(2*subBinY), boxSize/subBinX, boxSize/subBinY); - targetImage->setTrackingBoxEnabled(true); - targetImage->setTrackingBox(starRect); + guideView->setTrackingBoxEnabled(true); + guideView->setTrackingBox(starRect); } } = @@ -1307,7 +1434,7 @@ bool Guide::selectAutoStar() if (targetChip =3D=3D NULL) return false; = - FITSView *targetImage =3D targetChip->getImage(FITS_GUIDE); + FITSView *targetImage =3D targetChip->getImageView(FITS_GUIDE); if (targetImage =3D=3D NULL) return false; = @@ -1560,7 +1687,7 @@ void Guide::loadSettings() spinBox_MaxPulseDEC->setValue(Options::dECMaximumPulse()); // Min Pulse Duration (ms) spinBox_MinPulseRA->setValue(Options::rAMinimumPulse()); - spinBox_MinPulseDEC->setValue(Options::dECMinimumPulse()); + spinBox_MinPulseDEC->setValue(Options::dECMinimumPulse()); = } = void Guide::saveSettings() @@ -1597,6 +1724,25 @@ void Guide::saveSettings() Options::setDECMinimumPulse(spinBox_MinPulseDEC->value()); } = +void Guide::refreshColorScheme() +{ + // Drift color legend + RADriftLabel->setStyleSheet(QString("background-color: %1;").arg(KStar= sData::Instance()->colorScheme()->colorNamed("RAGuideError").name(QColor::H= exRgb))); + DEDriftLabel->setStyleSheet(QString("background-color: %1;").arg(KStar= sData::Instance()->colorScheme()->colorNamed("DEGuideError").name(QColor::H= exRgb))); +} + +void Guide::setTrackingStar(int x, int y) +{ + QVector3D newStarPosition(x,y, -1); + setStarPosition(newStarPosition, true); + + if (state =3D=3D GUIDE_CALIBRATION_STAR) + { + guider->setStarPosition(newStarPosition); + guider->calibrate(); + } +} + } = = diff --git a/kstars/ekos/guide/guide.h b/kstars/ekos/guide/guide.h index 77910cf..68dfa13 100644 --- a/kstars/ekos/guide/guide.h +++ b/kstars/ekos/guide/guide.h @@ -27,7 +27,7 @@ #include "ui_guide.h" = class QTabWidget; -class FITSData; +class FITSView; class ScrollGraph; class QProgressIndicator; = @@ -158,7 +158,7 @@ public: * Set rapid guiding option. The options must be set before starting t= he guiding operation. If no options are set, the options loaded from the us= er configuration are used. * @param enable if true, it will activate RapidGuide in the CCD drive= r. When Rapid Guide is used, no frames are sent to Ekos for analysis and th= e centeroid calculations are done in the CCD driver. */ - Q_SCRIPTABLE Q_NOREPLY void setGuideRapid(bool enable); + Q_SCRIPTABLE Q_NOREPLY void setGuideRapidEnabled(bool enable); = /** DBUS interface function. * Enable or disables dithering @@ -190,9 +190,7 @@ public: = void clearLog(); = - void setDECSwap(bool enable); - bool sendPulse( GuideDirection ra_dir, int ra_msecs, GuideDirection de= c_dir, int dec_msecs ); - bool sendPulse( GuideDirection dir, int msecs ); + void setDECSwap(bool enable); = = QString getLogText() { return logText.join("\n"); } = @@ -205,6 +203,11 @@ public: void startRapidGuide(); void stopRapidGuide(); = + /** + * @brief refreshColorScheme Update any colors that depend on updates = in the color scheme + */ + void refreshColorScheme(); + GuideInterface * getGuider() { return guider;} = public slots: @@ -216,22 +219,16 @@ public slots: Q_SCRIPTABLE bool startGuiding(); = /** DBUS interface function. - * Stop the autoguiding operation. - * @return Returns true if guiding stopped successfully, false otherwi= se. + * Stop any active calibration, guiding, or dithering operation + * @return Returns true if operation is stopped successfully, false ot= herwise. */ - Q_SCRIPTABLE bool stopGuiding(); + Q_SCRIPTABLE bool abort(); = /** DBUS interface function. * Start the calibration operation. * @return Returns true if calibration started successfully, false oth= erwise. */ - Q_SCRIPTABLE bool startCalibration(); - - /** DBUS interface function. - * Stop the calibration operation. - * @return Returns true if calibration stopped successfully, false oth= erwise. - */ - Q_SCRIPTABLE bool stopCalibration(); + Q_SCRIPTABLE bool calibrate(); = /** DBUS interface function. * Capture a guide frame @@ -259,8 +256,10 @@ public slots: void dither(); void setSuspended(bool enable); = + // Append Log entry void appendLogText(const QString &); = + // Update Guide module status void setStatus(Ekos::GuideState newState); = // Star Position @@ -269,6 +268,10 @@ public slots: // Capture void setCaptureComplete(); = + // Send pulse to ST4 driver + bool sendPulse( GuideDirection ra_dir, int ra_msecs, GuideDirection d= ec_dir, int dec_msecs ); + bool sendPulse( GuideDirection dir, int msecs ); + protected slots: void updateCCDBin(int index); = @@ -278,6 +281,13 @@ protected slots: */ void processCCDNumber(INumberVectorProperty *nvp); = + /** + * @brief setTrackingStar Gets called when the user select a star in = the guide frame + * @param x X coordinate of star + * @param y Y coordinate of star + */ + void setTrackingStar(int x, int y); + void saveDefaultGuideExposure(); = = void updateTrackingBoxSize(int currentIndex); @@ -328,6 +338,12 @@ private: */ void saveSettings(); = + /** + * @brief setBusy Indicate busy status within the module visually + * @param enable True if module is busy, false otherwise + */ + void setBusy(bool enable); + // Devices ISD::CCD *currentCCD; ISD::Telescope *currentTelescope; @@ -371,6 +387,12 @@ private: OpsCalibration *opsCalibration; OpsGuide *opsGuide; = + // Guide Frame + FITSView *guideView; + + // Auto star operation + bool autoStarCaptured; + }; = } diff --git a/kstars/ekos/guide/guide.ui b/kstars/ekos/guide/guide.ui index 03d12a1..8f44f58 100644 --- a/kstars/ekos/guide/guide.ui +++ b/kstars/ekos/guide/guide.ui @@ -6,8 +6,8 @@ 0 0 - 702 - 515 + 697 + 510 @@ -42,6 +42,21 @@ Control + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + @@ -55,7 +70,7 @@ - + true @@ -115,9 +130,12 @@ - + 1 + + 5 + @@ -586,32 +604,19 @@ - + 320 240 - - background-color:gray; - - - QAbstractScrollArea::AdjustToContentsOnFirstShow - - - true + + + 40 + 30 + - - - - 0 - 0 - 462 - 238 - - - @@ -714,6 +719,9 @@ 16 + + QFrame::Box + @@ -733,6 +741,13 @@ + + + Qt::Vertical + + + + @@ -746,6 +761,9 @@ 16 + + QFrame::Box + @@ -765,6 +783,13 @@ + + + Qt::Vertical + + + + X @@ -1157,12 +1182,6 @@ - FITSView - QScrollArea -
fitsviewer/fitsview.h
- 1 -
- ScrollGraph QWidget
ekos/guide/scroll_graph.h
diff --git a/kstars/ekos/guide/guideinterface.cpp b/kstars/ekos/guide/guide= interface.cpp index ff819aa..edcbaa1 100644 --- a/kstars/ekos/guide/guideinterface.cpp +++ b/kstars/ekos/guide/guideinterface.cpp @@ -95,6 +95,11 @@ bool GuideInterface::getFrameParams(uint16_t *x, uint16_= t *y, uint16_t *w, uint1 return true; } = +void GuideInterface::setStarPosition(QVector3D starCenter) +{ + INDI_UNUSED(starCenter); +} + } = = diff --git a/kstars/ekos/guide/guideinterface.h b/kstars/ekos/guide/guidein= terface.h index d5082dd..f8ca60a 100644 --- a/kstars/ekos/guide/guideinterface.h +++ b/kstars/ekos/guide/guideinterface.h @@ -38,7 +38,7 @@ public: virtual bool guide() =3D 0; virtual bool suspend() =3D 0; virtual bool resume() =3D 0; - virtual bool stop() =3D 0; + virtual bool abort() =3D 0; virtual bool dither(double pixels) =3D 0; = virtual bool setGuiderParams(double ccdPixelSizeX, double ccdPixelSize= Y, double mountAperture, double mountFocalLength); @@ -47,6 +47,8 @@ public: virtual bool setFrameParams(uint16_t x, uint16_t y, uint16_t w, uint16= _t h, uint16_t binX, uint16_t binY); virtual bool getFrameParams(uint16_t *x, uint16_t *y, uint16_t *w, uin= t16_t *h, uint16_t *binX, uint16_t *binY); = + virtual void setStarPosition(QVector3D starCenter); + signals: void newLog(const QString &); void newStatus(Ekos::GuideState); diff --git a/kstars/ekos/guide/internalguide/gmath.cpp b/kstars/ekos/guide/= internalguide/gmath.cpp index e6773ae..debe3a5 100644 --- a/kstars/ekos/guide/internalguide/gmath.cpp +++ b/kstars/ekos/guide/internalguide/gmath.cpp @@ -53,8 +53,7 @@ typedef struct cgmath::cgmath() : QObject() { // sys... - ticks =3D 0; - pdata =3D NULL; + ticks =3D 0; = video_width =3D -1; video_height =3D -1; ccd_pixel_width =3D 0; @@ -123,38 +122,18 @@ bool cgmath::setVideoParameters( int vid_wd, int vid_= ht ) return true; } = -void cgmath::setDataBuffer(float *buffer) -{ - pdata =3D buffer; -} - -void cgmath::setImageView(FITSView *image) +void cgmath::setGuideView(FITSView *image) { guideView =3D image; = - if (guideView) + /*if (guideView) { FITSData *image_data =3D guideView->getImageData(); setDataBuffer(image_data->getImageBuffer()); setVideoParameters(image_data->getWidth(), image_data->getHeight()= ); - } -} - -float *cgmath::getDataBuffer( int *width, int *height, int *length, int *s= ize ) -{ - if( width ) - *width =3D video_width; - if( height ) - *height =3D video_height; - if( length ) - *length =3D video_width * video_height; - if( size ) - *size =3D video_width * video_height * sizeof(float); - - return pdata; + }*/ } = - bool cgmath::setGuiderParameters( double ccd_pix_wd, double ccd_pix_ht, do= uble guider_aperture, double guider_focal ) { if( ccd_pix_wd < 0 ) @@ -215,7 +194,8 @@ bool cgmath::getReticleParameters( double *x, double *y= , double *ang ) const *x =3D reticle_pos.x; *y =3D reticle_pos.y; = - *ang =3D reticle_angle; + if (ang) + *ang =3D reticle_angle; = return true; } @@ -573,6 +553,16 @@ Vector cgmath::findLocalStarPosition( void ) const if (trackingBox.isValid() =3D=3D false) return Vector(-1,-1,-1); = + FITSData *imageData =3D guideView->getImageData(); + if (imageData =3D=3D NULL) + { + if (Options::guideLogging()) + qDebug() << "Guide: Cannot process a NULL image."; + return Vector(-1,-1,-1); + } + + float *pdata =3D imageData->getImageBuffer(); + if (Options::guideLogging()) qDebug() << "Guide: Tracking Square " << trackingBox; = diff --git a/kstars/ekos/guide/internalguide/gmath.h b/kstars/ekos/guide/in= ternalguide/gmath.h index e4cf01e..6574349 100644 --- a/kstars/ekos/guide/internalguide/gmath.h +++ b/kstars/ekos/guide/internalguide/gmath.h @@ -109,8 +109,7 @@ public: virtual ~cgmath(); = // functions - bool setVideoParameters( int vid_wd, int vid_ht ); - float *getDataBuffer( int *width, int *height, int *length, int *size = ); + bool setVideoParameters( int vid_wd, int vid_ht ); = bool setGuiderParameters( double ccd_pix_wd, double ccd_pix_ht, double= guider_aperture, double guider_focal ); void getGuiderParameters( double *ccd_pix_wd, double *ccd_pix_ht, doub= le *guider_aperture, double *guider_focal ); bool setReticleParameters( double x, double y, double ang ); @@ -127,11 +126,10 @@ public: info_params_t getInfoParameters( void ) const; uint32_t getTicks( void ) const; = - void setDataBuffer(float *buffer); - void setImageView(FITSView *image); + void setGuideView(FITSView *image); bool declinationSwapEnabled() { return dec_swap;} void setDeclinationSwapEnabled(bool enable) { dec_swap =3D enable;} - FITSView *getImageView() { return guideView; } + FITSView *getGuideView() { return guideView; } void setPreviewMode(bool enable) { preview_mode =3D enable;} = /*void moveSquare( double newx, double newy ); @@ -176,8 +174,7 @@ signals: = private: // sys... - uint32_t ticks; // global channel ticker - float *pdata; // pointer to data buffer + uint32_t ticks; // global channel ticker = QPointer guideView; // pointer to image int video_width, video_height; // video frame dimensions double ccd_pixel_width, ccd_pixel_height, aperture, focal; diff --git a/kstars/ekos/guide/internalguide/internalguider.cpp b/kstars/ek= os/guide/internalguide/internalguider.cpp index 6517618..2f93446 100644 --- a/kstars/ekos/guide/internalguide/internalguider.cpp +++ b/kstars/ekos/guide/internalguide/internalguider.cpp @@ -10,6 +10,7 @@ */ = #include +#include = #include "internalguider.h" #include "gmath.h" @@ -29,10 +30,11 @@ InternalGuider::InternalGuider() = connect(pmath, SIGNAL(newAxisDelta(double,double)), this, SIGNAL(newAx= isDelta(double,double))); connect(pmath, SIGNAL(newAxisDelta(double,double)), this, SLOT(updateG= uideDriver(double,double))); - connect(pmath, SIGNAL(newStarPosition(QVector3D,bool)), this, SLOT(set= StarPosition(QVector3D,bool))); + //connect(pmath, SIGNAL(newStarPosition(QVector3D,bool)), this, SLOT(s= etStarPosition(QVector3D,bool))); + connect(pmath, SIGNAL(newStarPosition(QVector3D,bool)), this, SIGNAL(n= ewStarPosition(QVector3D,bool))); = // Calibration - calibrationStage =3D CAL_CAPTURE_IMAGE; + calibrationStage =3D CAL_IDLE; = is_started =3D false; axis =3D GUIDE_RA; @@ -47,10 +49,6 @@ InternalGuider::InternalGuider() okColor =3D Qt::green; busyColor =3D Qt::yellow; alertColor =3D Qt::red; - - - - } = InternalGuider::~InternalGuider() @@ -62,9 +60,10 @@ bool InternalGuider::guide() return false; } = -bool InternalGuider::stop() +bool InternalGuider::abort() { -return false; + calibrationStage =3D CAL_IDLE; + return true; } = bool InternalGuider::suspend() @@ -99,46 +98,33 @@ bool InternalGuider::getReticleParameters(double *x, do= uble *y, double *angle) = bool InternalGuider::setGuiderParams(double ccdPixelSizeX, double ccdPixel= SizeY, double mountAperture, double mountFocalLength) { - // TODO - return true; + this->ccdPixelSizeX =3D ccdPixelSizeX; + this->ccdPixelSizeY =3D ccdPixelSizeY; + this->mountAperture =3D mountAperture; + this->mountFocalLength =3D mountFocalLength; + return pmath->setGuiderParameters(ccdPixelSizeX, ccdPixelSizeY, mountA= perture, mountFocalLength); } = - -bool InternalGuider::calibrate() +bool InternalGuider::setFrameParams(uint16_t x, uint16_t y, uint16_t w, ui= nt16_t h, uint16_t binX, uint16_t binY) { + if( w <=3D 0 || h <=3D 0 ) + return false; = - //FIXME - -#if 0 - /* // Capture final image - if (calibrationType =3D=3D CAL_MANUAL && calibrationStage =3D=3D CAL_S= TART) - { - guideModule->capture(); - return; - } - - if (calibrationStage > CAL_START) - { - stopCalibration(); - return; - } - - startCalibration();*/ + subX =3D x; + subY =3D y; + subW =3D w; + subH =3D h; = + subBinX =3D binX; + subBinY =3D binY; = - /*if (guideModule->isGuiding()) - { - guideModule->appendLogText(i18n("Cannot calibrate while autoguidin= g is active.")); - return false; - }*/ + pmath->setVideoParameters(w, h); = - if (calibrationStage !=3D CAL_START && Options::autoStarEnabled()) - { - calibrationStage =3D CAL_CAPTURE_IMAGE; - emit frameCaptureRequested(); - return true; - } + return true; +} = +bool InternalGuider::calibrate() +{ bool ccdInfo=3Dtrue, scopeInfo=3Dtrue; QString errMsg; = @@ -159,57 +145,68 @@ bool InternalGuider::calibrate() = if (ccdInfo =3D=3D false || scopeInfo =3D=3D false) { - KMessageBox::error(this, i18n("%1 info are missing. Please set the= values in INDI Control Panel.", errMsg)); + KMessageBox::error(NULL, i18n("Missing Information"), i18n("%1 inf= o are missing. Please set the values in INDI Control Panel.", errMsg)); return false; } = - disconnect(guideFrame, SIGNAL(trackingStarSelected(int,int)), this, SL= OT(trackingStarSelected(int, int))); + if (state !=3D GUIDE_CALIBRATING) + { + calibrationStage =3D CAL_IDLE; + state =3D GUIDE_CALIBRATING; + emit newStatus(GUIDE_CALIBRATING); + } = + // Capture final image + + // FIXME check how to do manual + // and fucking document it + /* + if (calibrationType =3D=3D CAL_MANUAL && calibrationStage =3D=3D CAL_S= TART) + { + calibrationStage =3D CAL_CAPTURE_IMAGE; + emit frameCaptureRequested(); + return; + }*/ = = - calibrationStage =3D CAL_START; - emit newStatus(Ekos::GUIDE_CALIBRATING); = - // Must reset dec swap before we run any calibration procedure! + //startCalibration(); = - // FIXME - //guideModule->setDECSwap(false); - //pmath->setDeclinationSwapEnabled(false); = - pmath->setLostStar(false); - //pmain_wnd->capture(); + /*if (guideModule->isGuiding()) + { + guideModule->appendLogText(i18n("Cannot calibrate while autoguidin= g is active.")); + return false; + }*/ = - // FIXME - /*Options::setCalibrationPulseDuration(ui.spinBox_Pulse->value()); - Options::setUseAutoMode(ui.autoModeCheck->isChecked()); - Options::setUseTwoAxis(ui.twoAxisCheck->isChecked()); - Options::setAutoModeIterations(ui.spinBox_DriftTime->value()); - Options::setAutoStar(ui.autoStarCheck->isChecked()); - if (ui.autoStarCheck->isChecked()) - Options::setAutoSquareSize(ui.autoSquareSizeCheck->isChecked()); - */ - - // manual - if( ui.autoModeCheck->checkState() !=3D Qt::Checked ) + if (calibrationStage > CAL_START) { - calibrateManualReticle(); + //abort(); + processCalibration(); return true; } = - ui.progressBar->setVisible(true); + disconnect(guideFrame, SIGNAL(trackingStarSelected(int,int)), this, SL= OT(trackingStarSelected(int, int))); + + // Must reset dec swap before we run any calibration procedure! + + emit DESwapChanged(false); + pmath->setDeclinationSwapEnabled(false); + pmath->setLostStar(false); + //pmain_wnd->capture(); + + calibrationStage =3D CAL_START; + = // automatic - if( ui.twoAxisCheck->checkState() =3D=3D Qt::Checked ) + // If two axies (RA/DEC) are required + if( Options::twoAxisEnabled() ) calibrateRADECRecticle(false); else + // Just RA calibrateRADECRecticle(true); = - - #endif return true; - - - } = bool InternalGuider::stopCalibration() @@ -233,22 +230,22 @@ return true; = void InternalGuider::processCalibration() { - - //FIXME - -#if 0 //if (pmath->get_image()) //guide_frame->setTrackingBox(QRect(pmath-> square_pos.x, square_pos.y= , square_size*2, square_size*2)); //pmath->get_image()->setTrackingBoxSize(QSize(pmath->get_square_size(= ), pmath->get_square_size())); = + pmath->performProcessing(); + if (pmath->isStarLost()) - { + { = + //ui.startCalibrationLED->setColor(alertColor); + //KMessageBox::error(NULL, i18n("Lost track of the guide star. Try= increasing the square size or reducing pulse duration.")); + emit newLog(i18n("Lost track of the guide star. Try increasing the= square size or reducing pulse duration.")); + reset(); + calibrationStage =3D CAL_ERROR; emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); = - ui.startCalibrationLED->setColor(alertColor); - KMessageBox::error(NULL, i18n("Lost track of the guide star. Try i= ncreasing the square size or reducing pulse duration.")); - reset(); return; } = @@ -257,10 +254,6 @@ void InternalGuider::processCalibration() case CAL_NONE: break; = - case CAL_MANUAL: - calibrateManualReticle(); - break; - case CAL_RA_AUTO: calibrateRADECRecticle(true); break; @@ -269,8 +262,6 @@ void InternalGuider::processCalibration() calibrateRADECRecticle(false); break; } - -#endif } = /*bool InternalGuider::isCalibrating() @@ -281,10 +272,24 @@ void InternalGuider::processCalibration() return false; }*/ = +void InternalGuider::setGuideView(FITSView *guideView) +{ + guideFrame =3D guideView; + + pmath->setGuideView(guideFrame); + + //connect(guideFrame, SIGNAL(trackingStarSelected(int,int)), this, SLO= T(trackingStarSelected(int, int)), Qt::UniqueConnection); +} + void InternalGuider::reset() { //FIXME = + is_started =3D false; + state =3D GUIDE_IDLE; + //calibrationStage =3D CAL_IDLE; + connect(guideFrame, SIGNAL(trackingStarSelected(int,int)), this, SLOT(= trackingStarSelected(int, int)), Qt::UniqueConnection); + #if 0 is_started =3D false; ui.pushButton_StartCalibration->setText( i18n("Start") ); @@ -295,129 +300,15 @@ void InternalGuider::reset() #endif } = -void InternalGuider::calibrateManualReticle( void ) -{ - //----- manual mode ---- - // get start point - - calibrationType =3D CAL_MANUAL; - - // FIXME - -#if 0 - - if( !is_started ) - { - if( ui.twoAxisCheck->checkState() =3D=3D Qt::Checked ) - { - ui.pushButton_StartCalibration->setText( i18n("Stop GUIDE_RA")= ); - } - else - { - ui.pushButton_StartCalibration->setText( i18n("Stop") ); - } - guideModule->appendLogText(i18n("Drift scope in RA. Press stop whe= n done.")); - - calibrationStage =3D CAL_START; - pmath->getStarScreenPosition( &start_x1, &start_y1 ); - - axis =3D GUIDE_RA; - is_started =3D true; - } - else // get end point and calc orientation - { - if( ui.twoAxisCheck->checkState() =3D=3D Qt::Checked ) - { - if( axis =3D=3D GUIDE_RA ) - { - pmath->getStarScreenPosition( &end_x1, &end_y1 ); - - start_x2 =3D end_x1; - start_y2 =3D end_y1; - - axis =3D GUIDE_DEC; - - ui.pushButton_StartCalibration->setText( i18n("Stop GUIDE_= DEC") ); - guideModule->appendLogText(i18n("Drift scope in DEC. Press= Stop when done.")); - return; - } - else - { - pmath->getStarScreenPosition( &end_x2, &end_y2 ); - bool dec_swap=3Dfalse; - // calc orientation - if( pmath->calculateAndSetReticle2D( start_x1, start_y1, e= nd_x1, end_y1, start_x2, start_y2, end_x2, end_y2, &dec_swap ) ) - { - fillInterface(); - if (dec_swap) - guideModule->appendLogText(i18n("DEC swap enabled.= ")); - else - guideModule->appendLogText(i18n("DEC swap disabled= .")); - - guideModule->appendLogText(i18n("Calibration completed= .")); - - KNotification::event( QLatin1String( "CalibrationSucce= ssful" ) , i18n("Guiding calibration completed successfully")); - calibrationStage =3D CAL_FINISH; - - emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS); - - guideModule->setDECSwap(dec_swap); - } - else - { - QMessageBox::warning( this, i18n("Error"), i18n("Calib= ration rejected. Start drift is too short."), QMessageBox::Ok ); - is_started =3D false; - calibrationStage =3D CAL_ERROR; - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); - } - } - } - else - { - pmath->getStarScreenPosition( &end_x1, &end_y1 ); - - if( pmath->calculateAndSetReticle1D( start_x1, start_y1, end_x= 1, end_y1 ) ) - { - calibrationStage =3D CAL_FINISH; - fillInterface(); - guideModule->appendLogText(i18n("Calibration completed.")); - - emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS); - - KNotification::event( QLatin1String( "CalibrationSuccessfu= l" ) , i18n("Guiding calibration completed successfully")); - } - else - { - calibrationStage =3D CAL_ERROR; - - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); - - QMessageBox::warning( this, i18n("Error"), i18n("Calibrati= on rejected. Start drift is too short."), QMessageBox::Ok ); - is_started =3D false; - KNotification::event( QLatin1String( "CalibrationFailed" )= , i18n("Guiding calibration failed with errors")); - } - } - - reset(); - - } - -#endif -} - void InternalGuider::calibrateRADECRecticle( bool ra_only ) { = - // FIXME -#if 0 bool auto_term_ok =3D false; = + Q_ASSERT(pmath); = - if( !pmath ) - return; - - int pulseDuration =3D ui.spinBox_Pulse->value(); - int totalPulse =3D pulseDuration * auto_drift_time; + int pulseDuration =3D Options::calibrationPulseDuration(); + int totalPulse =3D pulseDuration * Options::autoModeIterations(); = if (ra_only) calibrationType =3D CAL_RA_AUTO; @@ -429,7 +320,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_on= ly ) = case CAL_START: //----- automatic mode ----- - auto_drift_time =3D ui.spinBox_DriftTime->value(); + auto_drift_time =3D Options::autoModeIterations(); = if (ra_only) turn_back_time =3D auto_drift_time*2 + auto_drift_time/2; @@ -437,39 +328,26 @@ void InternalGuider::calibrateRADECRecticle( bool ra_= only ) turn_back_time =3D auto_drift_time*6; iterations =3D 0; = - ui.progressBar->setMaximum( turn_back_time ); - - ui.progressBar->setValue( 0 ); + emit newLog(i18n("GUIDE_RA drifting forward...")); = - ui.pushButton_StartCalibration->setText(i18n("Abort")); - - guideModule->appendLogText(i18n("GUIDE_RA drifting forward...")); - - // get start point - //pmath->get_star_screen_pos( &start_x1, &start_y1 ); - - start_x1 =3D ui.spinBox_ReticleX->value(); - start_y1 =3D ui.spinBox_ReticleY->value(); + pmath->getReticleParameters(&start_x1, &start_y1, NULL); = if (Options::guideLogging()) qDebug() << "Guide: Start X1 " << start_x1 << " Start Y1 " << = start_y1; = - guideModule->sendPulse( RA_INC_DIR, pulseDuration ); + emit newPulse( RA_INC_DIR, pulseDuration ); + if (Options::guideLogging()) qDebug() << "Guide: Iteration " << iterations << " Direction: = " << RA_INC_DIR << " Duration: " << pulseDuration << " ms."; = iterations++; = - ui.progressBar->setValue( iterations ); - calibrationStage =3D CAL_RA_INC; = - ui.startCalibrationLED->setColor(busyColor); - break; = case CAL_RA_INC: - guideModule->sendPulse( RA_INC_DIR, pulseDuration ); + emit newPulse( RA_INC_DIR, pulseDuration ); = if (Options::guideLogging()) { @@ -477,12 +355,10 @@ void InternalGuider::calibrateRADECRecticle( bool ra_= only ) double cur_x, cur_y; pmath->getStarScreenPosition( &cur_x, &cur_y ); qDebug() << "Guide: Iteration #" << iterations-1 << ": STAR " = << cur_x << "," << cur_y; - qDebug() << "Guide: Iteration " << iterations << " Direction: = " << RA_INC_DIR << " Duration: " << pulseDuration << " ms."; } = iterations++; - ui.progressBar->setValue( iterations ); = if (iterations =3D=3D auto_drift_time) calibrationStage =3D CAL_RA_DEC; @@ -500,7 +376,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_on= ly ) phi =3D pmath->calculatePhi( start_x1, start_y1, end_x1, end_y= 1 ); ROT_Z =3D RotateZ( -M_PI*phi/180.0 ); // derotates... = - guideModule->appendLogText(i18n("GUIDE_RA drifting reverse..."= )); + emit newLog(i18n("GUIDE_RA drifting reverse...")); = } = @@ -528,7 +404,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_on= ly ) { if (iterations < turn_back_time) { - guideModule->sendPulse( RA_DEC_DIR, pulseDuration ); + emit newPulse( RA_DEC_DIR, pulseDuration ); = if (Options::guideLogging()) { @@ -536,13 +412,10 @@ void InternalGuider::calibrateRADECRecticle( bool ra_= only ) double cur_x, cur_y; pmath->getStarScreenPosition( &cur_x, &cur_y ); qDebug() << "Guide: Iteration #" << iterations-1 << ":= STAR " << cur_x << "," << cur_y; - qDebug() << "Guide: Iteration " << iterations << " Dir= ection: " << RA_INC_DIR << " Duration: " << pulseDuration << " ms."; } = iterations++; - - ui.progressBar->setValue( iterations ); break; } = @@ -550,10 +423,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_o= nly ) = emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); = - if (ui.autoStarCheck->isChecked()) - guideModule->appendLogText(i18np("GUIDE_RA: Scope cannot r= each the start point after %1 iteration. Possible mount or drive problems..= .", "GUIDE_RA: Scope cannot reach the start point after %1 iterations. Poss= ible mount or drive problems...", turn_back_time)); - else - QMessageBox::warning( this, i18n("Warning"), i18np("GUIDE_= RA: Scope cannot reach the start point after %1 iteration. Possible mount o= r drive problems...", "GUIDE_RA: Scope cannot reach the start point after %= 1 iterations. Possible mount or drive problems...", turn_back_time), QMessa= geBox::Ok ); + emit newLog(i18np("GUIDE_RA: Scope cannot reach the start poin= t after %1 iteration. Possible mount or drive problems...", "GUIDE_RA: Scop= e cannot reach the start point after %1 iterations. Possible mount or drive= problems...", turn_back_time)); = KNotification::event( QLatin1String( "CalibrationFailed" ) , i= 18n("Guiding calibration failed with errors")); reset(); @@ -569,7 +439,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_on= ly ) if (Options::guideLogging()) qDebug() << "Guide: Start X2 " << start_x2 << " start Y2 "= << start_y2; = - guideModule->sendPulse( DEC_INC_DIR, pulseDuration ); + emit newPulse( DEC_INC_DIR, pulseDuration ); = if (Options::guideLogging()) { @@ -577,37 +447,34 @@ void InternalGuider::calibrateRADECRecticle( bool ra_= only ) double cur_x, cur_y; pmath->getStarScreenPosition( &cur_x, &cur_y ); qDebug() << "Guide: Iteration #" << iterations-1 << ": STA= R " << cur_x << "," << cur_y; - qDebug() << "Guide: Iteration " << iterations << " Directi= on: " << RA_INC_DIR << " Duration: " << pulseDuration << " ms."; } = iterations++; - dec_iterations =3D 1; - ui.progressBar->setValue( iterations ); - guideModule->appendLogText(i18n("GUIDE_DEC drifting forward...= ")); + dec_iterations =3D 1; = + emit newLog(i18n("GUIDE_DEC drifting forward...")); break; } // calc orientation if( pmath->calculateAndSetReticle1D( start_x1, start_y1, end_x1, e= nd_y1, totalPulse) ) { - calibrationStage =3D CAL_FINISH; - fillInterface(); - guideModule->appendLogText(i18n("Calibration completed.")); + calibrationStage =3D CAL_IDLE; + + // FIXME what is this for? + //fillInterface(); + + emit newLog(i18n("Calibration completed.")); = emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS); = - ui.startCalibrationLED->setColor(okColor); KNotification::event( QLatin1String( "CalibrationSuccessful" )= , i18n("Guiding calibration completed successfully")); //if (ui.autoStarCheck->isChecked()) //guideModule->selectAutoStar(); } else { - if (ui.autoStarCheck->isChecked()) - guideModule->appendLogText(i18n("Calibration rejected. Sta= r drift is too short.")); - else - QMessageBox::warning( this, i18n("Error"), i18n("Calibrati= on rejected. Star drift is too short."), QMessageBox::Ok ); - ui.startCalibrationLED->setColor(alertColor); + emit newLog(i18n("Calibration rejected. Star drift is too shor= t.")); + calibrationStage =3D CAL_ERROR; = emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); @@ -620,7 +487,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_on= ly ) } = case CAL_DEC_INC: - guideModule->sendPulse( DEC_INC_DIR, pulseDuration ); + emit newPulse( DEC_INC_DIR, pulseDuration ); = if (Options::guideLogging()) { @@ -628,13 +495,11 @@ void InternalGuider::calibrateRADECRecticle( bool ra_= only ) double cur_x, cur_y; pmath->getStarScreenPosition( &cur_x, &cur_y ); qDebug() << "Guide: Iteration #" << iterations-1 << ": STAR " = << cur_x << "," << cur_y; - qDebug() << "Guide: Iteration " << iterations << " Direction: = " << RA_INC_DIR << " Duration: " << pulseDuration << " ms."; } = iterations++; dec_iterations++; - ui.progressBar->setValue( iterations ); = if (dec_iterations =3D=3D auto_drift_time) calibrationStage =3D CAL_DEC_DEC; @@ -652,7 +517,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_on= ly ) phi =3D pmath->calculatePhi( start_x2, start_y2, end_x2, end_y= 2 ); ROT_Z =3D RotateZ( -M_PI*phi/180.0 ); // derotates... = - guideModule->appendLogText(i18n("GUIDE_DEC drifting reverse...= ")); + emit newLog(i18n("GUIDE_DEC drifting reverse...")); } = //----- Z-check (new!) ----- @@ -684,7 +549,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_on= ly ) { if (iterations < turn_back_time) { - guideModule->sendPulse( DEC_DEC_DIR, pulseDuration ); + emit newPulse(DEC_DEC_DIR, pulseDuration ); = if (Options::guideLogging()) { @@ -692,14 +557,11 @@ void InternalGuider::calibrateRADECRecticle( bool ra_= only ) double cur_x, cur_y; pmath->getStarScreenPosition( &cur_x, &cur_y ); qDebug() << "Guide: Iteration #" << iterations-1 << ":= STAR " << cur_x << "," << cur_y; - qDebug() << "Guide: Iteration " << iterations << " Dir= ection: " << RA_INC_DIR << " Duration: " << pulseDuration << " ms."; } = iterations++; dec_iterations++; - - ui.progressBar->setValue( iterations ); break; } = @@ -707,10 +569,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_o= nly ) = emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); = - if (ui.autoStarCheck->isChecked()) - guideModule->appendLogText(i18np("GUIDE_DEC: Scope cannot = reach the start point after %1 iteration.\nPossible mount or drive problems= ...", "GUIDE_DEC: Scope cannot reach the start point after %1 iterations.\n= Possible mount or drive problems...", turn_back_time)); - else - QMessageBox::warning( this, i18n("Warning"), i18np("GUIDE_= DEC: Scope cannot reach the start point after %1 iteration.\nPossible mount= or drive problems...", "GUIDE_DEC: Scope cannot reach the start point afte= r %1 iterations.\nPossible mount or drive problems...", turn_back_time), QM= essageBox::Ok ); + emit newLog(i18np("GUIDE_DEC: Scope cannot reach the start poi= nt after %1 iteration.\nPossible mount or drive problems...", "GUIDE_DEC: S= cope cannot reach the start point after %1 iterations.\nPossible mount or d= rive problems...", turn_back_time)); = KNotification::event( QLatin1String( "CalibrationFailed" ) , i= 18n("Guiding calibration failed with errors")); reset(); @@ -721,18 +580,18 @@ void InternalGuider::calibrateRADECRecticle( bool ra_= only ) // calc orientation if( pmath->calculateAndSetReticle2D( start_x1, start_y1, end_x1, e= nd_y1, start_x2, start_y2, end_x2, end_y2, &swap_dec, totalPulse ) ) { - calibrationStage =3D CAL_FINISH; - fillInterface(); + calibrationStage =3D CAL_IDLE; + //fillInterface(); if (swap_dec) - guideModule->appendLogText(i18n("DEC swap enabled.")); + emit newLog(i18n("DEC swap enabled.")); else - guideModule->appendLogText(i18n("DEC swap disabled.")); - guideModule->appendLogText(i18n("Calibration completed.")); + emit newLog(i18n("DEC swap disabled.")); + + emit newLog(i18n("Calibration completed.")); = emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS); = - ui.startCalibrationLED->setColor(okColor); - guideModule->setDECSwap(swap_dec); + emit DESwapChanged(swap_dec); = KNotification::event( QLatin1String( "CalibrationSuccessful" )= , i18n("Guiding calibration completed successfully")); = @@ -742,14 +601,11 @@ void InternalGuider::calibrateRADECRecticle( bool ra_= only ) } else { - if (ui.autoStarCheck->isChecked()) - guideModule->appendLogText(i18n("Calibration rejected. Sta= r drift is too short.")); - else - QMessageBox::warning( this, i18n("Error"), i18n("Calibrati= on rejected. Star drift is too short."), QMessageBox::Ok ); + emit newLog(i18n("Calibration rejected. Star drift is too shor= t.")); = emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); = - ui.startCalibrationLED->setColor(alertColor); + //ui.startCalibrationLED->setColor(alertColor); calibrationStage =3D CAL_ERROR; KNotification::event( QLatin1String( "CalibrationFailed" ) , i= 18n("Guiding calibration failed with errors")); } @@ -764,41 +620,41 @@ void InternalGuider::calibrateRADECRecticle( bool ra_= only ) break; = } +} = -#endif +void InternalGuider::setStarPosition(QVector3D starCenter) +{ + pmath->setReticleParameters(starCenter.x(), starCenter.y(), -1); } = void InternalGuider::trackingStarSelected(int x, int y) { + if (calibrationStage =3D=3D CAL_IDLE) + return; = - // FIXME - -#if 0 //int square_size =3D guide_squares[pmath->getSquareIndex()].size; = - pmath->setReticleParameters(x, y, ui.spinBox_ReticleAngle->value()); + pmath->setReticleParameters(x, y, -1); //pmath->moveSquare(x-square_size/(2*pmath->getBinX()), y-square_size/= (2*pmath->getBinY())); = - update_reticle_pos(x, y); + //update_reticle_pos(x, y); + = - if (calibrationStage =3D=3D CAL_FINISH) - return; = - ui.selectStarLED->setColor(okColor); + //ui.selectStarLED->setColor(okColor); = calibrationStage =3D CAL_START; = - ui.pushButton_StartCalibration->setEnabled(true); + //ui.pushButton_StartCalibration->setEnabled(true); = - QVector3D starCenter =3D guideModule->getStarPosition(); + QVector3D starCenter; // =3D guideModule->getStarPosition(); starCenter.setX(x); - starCenter.setY(y); - guideModule->setStarPosition(starCenter, true); + starCenter.setY(y); = + emit newStarPosition(starCenter, true); = - if (ui.autoStarCheck->isChecked()) - startCalibration(); - -#endif + //if (ui.autoStarCheck->isChecked()) + if (Options::autoStarEnabled()) + calibrate(); } = #if 0 @@ -905,5 +761,8 @@ void InternalGuider::toggleAutoSquareSize(bool enable) = #endif = - +void InternalGuider::setDECSwap(bool enable) +{ + pmath->setDeclinationSwapEnabled(enable); +} } diff --git a/kstars/ekos/guide/internalguide/internalguider.h b/kstars/ekos= /guide/internalguide/internalguider.h index 0f825df..b3b1c8f 100644 --- a/kstars/ekos/guide/internalguide/internalguider.h +++ b/kstars/ekos/guide/internalguide/internalguider.h @@ -15,6 +15,7 @@ #include #include = +#include "indi/indicommon.h" #include "fitsviewer/fitsview.h" = #include "matr.h" @@ -27,11 +28,12 @@ namespace Ekos = class InternalGuider : public GuideInterface { + Q_OBJECT = public: = - enum CalibrationStage { CAL_CAPTURE_IMAGE, CAL_SELECT_STAR, CAL_FINISH= , CAL_ERROR, CAL_START, CAL_RA_INC, CAL_RA_DEC, CAL_DEC_INC, CAL_DEC_DEC }; - enum CalibrationType { CAL_NONE, CAL_MANUAL, CAL_RA_AUTO, CAL_RA_DEC_A= UTO }; + enum CalibrationStage { CAL_IDLE, CAL_ERROR, CAL_CAPTURE_IMAGE, CAL_SE= LECT_STAR, CAL_START, CAL_RA_INC, CAL_RA_DEC, CAL_DEC_INC, CAL_DEC_DEC }; + enum CalibrationType { CAL_NONE, CAL_RA_AUTO, CAL_RA_DEC_AUTO }; = InternalGuider(); ~InternalGuider(); @@ -41,19 +43,27 @@ public: = bool calibrate() override; bool guide() override; - bool stop() override; + bool abort() override; bool suspend() override; bool resume() override; bool dither(double pixels) override; = + bool setFrameParams(uint16_t x, uint16_t y, uint16_t w, uint16_t h, ui= nt16_t binX, uint16_t binY) override; bool setGuiderParams(double ccdPixelSizeX, double ccdPixelSizeY, doubl= e mountAperture, double mountFocalLength) override; = + // Set Star Position + void setStarPosition(QVector3D starCenter) override; + + // Select algorithm void setSquareAlgorithm( int index ); = // Reticle Parameters void setReticleParameters(double x, double y, double angle); bool getReticleParameters(double *x, double *y, double *angle); = + // Guide View + void setGuideView(FITSView *guideView); + = = /// IMPORTED CHECK THEM ALL @@ -79,22 +89,25 @@ public slots: void setDECSwap(bool enable); = // OBSELETE - void connectPHD2(); - void setPHD2Connected(); - void setPHD2Disconnected(); + //void connectPHD2(); + //void setPHD2Connected(); + //void setPHD2Disconnected(); // Only called by PHD2 - void toggleExternalGuideStateGUI(Ekos::GuideState state); + //void toggleExternalGuideStateGUI(Ekos::GuideState state); = protected slots: - void openCalibrationOptions(); - void openGuideOptions(); + //void openCalibrationOptions(); + //void openGuideOptions(); = - void capture(); + //void capture(); void trackingStarSelected(int x, int y); = = signals: void newProfilePixmap(QPixmap &); + void newPulse( GuideDirection ra_dir, int ra_msecs, GuideDirection dec= _dir, int dec_msecs ); + void newPulse( GuideDirection dir, int msecs ); + void DESwapChanged(bool enable); = private: cgmath *pmath; @@ -115,7 +128,7 @@ private: = = // IMPORTED FROM R_CALIBRATION - CLEAN UP - void fillInterface( void ); + //void fillInterface( void ); void calibrateManualReticle( void ); void calibrateRADECRecticle( bool ra_only ); // 1 or 2-axis calibration = diff --git a/kstars/ekos/guide/opscalibration.cpp b/kstars/ekos/guide/opsca= libration.cpp index f45bc76..f4ddcc8 100644 --- a/kstars/ekos/guide/opscalibration.cpp +++ b/kstars/ekos/guide/opscalibration.cpp @@ -36,8 +36,7 @@ OpsCalibration::OpsCalibration(InternalGuider *guiderObje= ct) : QFrame( KStars:: m_ConfigDialog =3D KConfigDialog::exists( "guidesettings" ); = connect( m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL( clic= ked() ), SLOT( slotApply() ) ); - connect( m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL( clicked= () ), SLOT( slotApply() ) ); - connect( m_ConfigDialog->button(QDialogButtonBox::Cancel), SIGNAL( cli= cked() ), SLOT( slotCancel() ) ); + connect( m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL( clicked= () ), SLOT( slotApply() ) ); = } = = @@ -64,8 +63,4 @@ void OpsCalibration::slotApply() guider->setReticleParameters(spinBox_ReticleX->value(), spinBox_Reticl= eY->value(), spinBox_ReticleAngle->value()); } = -void OpsCalibration::slotCancel() -{ -} - } diff --git a/kstars/ekos/guide/opscalibration.h b/kstars/ekos/guide/opscali= bration.h index 0146122..9123411 100644 --- a/kstars/ekos/guide/opscalibration.h +++ b/kstars/ekos/guide/opscalibration.h @@ -40,7 +40,6 @@ protected: private slots: = void slotApply(); - void slotCancel(); = private: KConfigDialog *m_ConfigDialog; diff --git a/kstars/ekos/guide/opscalibration.ui b/kstars/ekos/guide/opscal= ibration.ui index d29d886..ba6a570 100644 --- a/kstars/ekos/guide/opscalibration.ui +++ b/kstars/ekos/guide/opscalibration.ui @@ -6,7 +6,7 @@ 0 0 - 298 + 273 168
@@ -22,14 +22,27 @@ - + Pulse: - + + + + 3 + + + 10 + + + 5 + + + + 100 @@ -45,26 +58,10 @@ - - - - Auto mode - - - true - - - - - - 3 - - - 10 - - - 5 + + + Iterations: diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg index d33e42e..55dfd73 100644 --- a/kstars/kstars.kcfg +++ b/kstars/kstars.kcfg @@ -1608,11 +1608,7 @@ sky map. 1 - = - - - true - + = false diff --git a/kstars/org.kde.kstars.Ekos.Guide.xml b/kstars/org.kde.kstars.E= kos.Guide.xml index 51cb54c..db4a65a 100644 --- a/kstars/org.kde.kstars.Ekos.Guide.xml +++ b/kstars/org.kde.kstars.Ekos.Guide.xml @@ -4,13 +4,10 @@ - + - - - - + @@ -77,7 +74,7 @@ - +