From ee946e36d836e4d6426c126beeea45d0401ffad0 Mon Sep 17 00:00:00 2001 From: Jasem Mutlaq Date: Mon, 20 Mar 2017 13:56:54 +0300 Subject: [PATCH] Add support for observers in capture module. Observer names are sent to INDI CCD driver where they are recorded in the FITS header. Furthermore, target name is also sent to the CCD driver to be recorded as OBJECT --- kstars/data/icons/breeze/default/im-user.svg | 14 + kstars/data/kstars.qrc | 1 + kstars/ekos/capture/capture.cpp | 82 ++- kstars/ekos/capture/capture.h | 10 + kstars/ekos/capture/capture.ui | 619 ++++++++++--------- kstars/indi/indiccd.cpp | 24 + kstars/indi/indiccd.h | 3 + kstars/kstars.kcfg | 3 + kstars/oal/observeradd.ui | 27 +- 9 files changed, 478 insertions(+), 305 deletions(-) create mode 100644 kstars/data/icons/breeze/default/im-user.svg diff --git a/kstars/data/icons/breeze/default/im-user.svg b/kstars/data/icons/breeze/default/im-user.svg new file mode 100644 index 000000000..ecee9917a --- /dev/null +++ b/kstars/data/icons/breeze/default/im-user.svg @@ -0,0 +1,14 @@ + + + + + + diff --git a/kstars/data/kstars.qrc b/kstars/data/kstars.qrc index 559b1650d..a36eba9d9 100644 --- a/kstars/data/kstars.qrc +++ b/kstars/data/kstars.qrc @@ -136,6 +136,7 @@ icons/AlignSuccess.svg icons/AlignWarning.svg icons/breeze/default/draw-cuboid.svg + icons/breeze/default/im-user.svg kstars.knsrc diff --git a/kstars/ekos/capture/capture.cpp b/kstars/ekos/capture/capture.cpp index 287f993e8..31df779b1 100644 --- a/kstars/ekos/capture/capture.cpp +++ b/kstars/ekos/capture/capture.cpp @@ -24,6 +24,7 @@ #include "oal/log.h" #include "kstars.h" +#include "skymap.h" #include "kstarsdata.h" #include "capture.h" @@ -51,7 +52,7 @@ #define MF_RA_DIFF_LIMIT 4 #define MAX_CAPTURE_RETRIES 3 -#define SQ_FORMAT_VERSION 1.5 +#define SQ_FORMAT_VERSION 1.6 namespace Ekos { @@ -225,6 +226,10 @@ Capture::Capture() connect(uploadModeCombo, SIGNAL(activated(int)), this, SLOT(setDirty())); connect(remoteDirIN, SIGNAL(editingFinished()), this, SLOT(setDirty())); + observerName = Options::defaultObserver(); + observerB->setIcon(QIcon::fromTheme("im-user", QIcon(":/icons/breeze/default/im-user.svg") )); + observerB->setAttribute(Qt::WA_LayoutUsesWidgetRect); + connect(observerB, SIGNAL(clicked()), this, SLOT(showObserverDialog())); // Post capture script connect(&postCaptureScript, SIGNAL(finished(int)), this, SLOT(postScriptFinished(int))); @@ -2090,6 +2095,19 @@ void Capture::executeJob() currentCCD->setNextSequenceID(nextSequenceID); } + QMap FITSHeader; + if (observerName.isEmpty() == false) + FITSHeader["FITS_OBSERVER"] = observerName; + if (targetName.isEmpty() == false) + FITSHeader["FITS_OBJECT"] = targetName; + else if (activeJob->getRawPrefix().isEmpty() == false) + { + FITSHeader["FITS_OBJECT"] = activeJob->getRawPrefix(); + } + + if (FITSHeader.count() > 0) + currentCCD->setFITSHeader(FITSHeader); + // Update button status setBusy(true); @@ -2359,7 +2377,11 @@ bool Capture::loadSequenceQueue(const QString &fileURL) for (ep = nextXMLEle(root, 1) ; ep != NULL ; ep = nextXMLEle(root, 0)) { - if (!strcmp(tagXMLEle(ep), "GuideDeviation")) + if (!strcmp(tagXMLEle(ep), "Observer")) + { + observerName = QString(pcdataXMLEle(ep)); + } + else if (!strcmp(tagXMLEle(ep), "GuideDeviation")) { if (!strcmp(findXMLAttValu(ep, "enabled"), "true")) { @@ -2690,6 +2712,8 @@ bool Capture::saveSequenceQueue(const QString &path) outstream << "" << endl; outstream << "" << endl; + if (observerName.isEmpty() == false) + outstream << "" << observerName << "" << endl; outstream << "" << guideDeviation->value() << "" << endl; outstream << "" << HFRPixels->value() << "" << endl; outstream << "" << meridianHours->value() << "" << endl; @@ -4205,4 +4229,58 @@ void Capture::setMountStatus(ISD::Telescope::TelescopeStatus newState) } } +void Capture::showObserverDialog() +{ + QList m_observerList; + KStars::Instance()->data()->userdb()->GetAllObservers(m_observerList); + QStringList observers; + foreach( OAL::Observer *o, m_observerList ) + observers << QString("%1 %2").arg(o->name()).arg(o->surname()); + + QDialog observersDialog(this); + observersDialog.setWindowTitle(i18n("Select Current Observer")); + + QLabel label(i18n("Current Observer:")); + + QComboBox observerCombo(&observersDialog); + observerCombo.addItems(observers); + observerCombo.setCurrentText(observerName); + observerCombo.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + + QPushButton manageObserver(&observersDialog); + manageObserver.setFixedSize(QSize(32,32)); + manageObserver.setIcon(QIcon::fromTheme("document-edit", QIcon(":/icons/breeze/default/document-edit.svg"))); + manageObserver.setAttribute(Qt::WA_LayoutUsesWidgetRect); + manageObserver.setToolTip(i18n("Manage Observers")); + connect(&manageObserver, &QPushButton::clicked, this, [&]() + { + ObserverAdd add; + add.exec(); + + QList m_observerList; + KStars::Instance()->data()->userdb()->GetAllObservers(m_observerList); + QStringList observers; + foreach( OAL::Observer *o, m_observerList ) + observers << QString("%1 %2").arg(o->name()).arg(o->surname()); + + observerCombo.clear(); + observerCombo.addItems(observers); + observerCombo.setCurrentText(observerName); + + }); + + QHBoxLayout *layout = new QHBoxLayout; + layout->addWidget(&label); + layout->addWidget(&observerCombo); + layout->addWidget(&manageObserver); + + observersDialog.setLayout(layout); + + observersDialog.exec(); + + observerName = observerCombo.currentText(); + + Options::setDefaultObserver(observerName); +} + } diff --git a/kstars/ekos/capture/capture.h b/kstars/ekos/capture/capture.h index 98effbc90..ae00a9ef8 100644 --- a/kstars/ekos/capture/capture.h +++ b/kstars/ekos/capture/capture.h @@ -133,6 +133,12 @@ public: */ Q_SCRIPTABLE Q_NOREPLY void setTargetName(const QString &name) { targetName = name; } + /** DBUS interface function. + * Sets Observer name. Observer name is sent to INDI CCD driver to include it in the FITS header + * @param name Full name of observer + */ + Q_SCRIPTABLE Q_NOREPLY void setObservrName(const QString &name) { observerName = name; } + /** DBUS interface function. * Enables or disables the maximum guiding deviation and sets its value. * @param enable If true, enable the guiding deviation check, otherwise, disable it. @@ -450,6 +456,9 @@ private slots: void toggleVideoStream(bool enable); void setVideoStreamEnabled(bool enabled); + // Observer + void showObserverDialog(); + signals: void newLog(); void checkFocus(double); @@ -506,6 +515,7 @@ private: bool useGuideHead; QString targetName; + QString observerName; SequenceJob *activeJob; diff --git a/kstars/ekos/capture/capture.ui b/kstars/ekos/capture/capture.ui index cc8883378..15d4aa45b 100644 --- a/kstars/ekos/capture/capture.ui +++ b/kstars/ekos/capture/capture.ui @@ -6,7 +6,7 @@ 0 0 - 590 + 623 519 @@ -236,58 +236,55 @@ 3 - - - - Image Transfer Format - - - - FITS - - - - - Native - - - - - - + + - + 0 0 - - - - - - Set the exposure time in seconds for individual images, if applicable + + + 0 + 0 + - - + + + 16777215 + 16777215 + + + + Reset CCD frame & size values to default values - Exposure: + Reset + + + + 16 + 16 + - - + + - + 0 0 + + 3600 + - - + + @@ -295,12 +292,12 @@ - Filter: + Frame: - - + + @@ -308,57 +305,57 @@ - H: + Type: - - + + 0 0 + + + + - Vertical binning - - - 1 + - - 10 + + - - 1 + + Size: - - + + - + 0 0 - - - - - - Delay in seconds between consecutive images + + 3 - - + + 0.001000000000000 - - Delay: + + 3600.000000000000000 + + + 1.000000000000000 - - + + @@ -366,11 +363,11 @@ - Y: + H: - + @@ -380,55 +377,75 @@ - - + + 0 0 - - 3 + + Horizontal binning - 0.001000000000000 + 1 - 3600.000000000000000 + 10 - 1.000000000000000 + 1 - - + + - Horizontal and Vertical binning + - Binning: + V: - - + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + - Number of images to capture + Delay in seconds between consecutive images - Count: + Delay: - + @@ -441,8 +458,11 @@ - - + + + + false + 0 @@ -450,137 +470,127 @@ - Horizontal binning + ISO settings - - 1 + + + + + + ISO: - - 10 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - 1 + + + + + + Number of images to capture + + + + + + Count: - - - - - 0 - 0 - + + + + Format: - - 3600 + + + + + + Image Transfer Format + + + FITS + + + + + Native + + - - + + 0 0 - - - - - - + + 1 - - + + 999 - - H: + + 1 - - + + - + Set the exposure time in seconds for individual images, if applicable - Frame: + Exposure: - - + + 0 0 - - 99 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - + + - Reset CCD frame & size values to default values + - - Reset + + - - - 16 - 16 - + + Y: - - + + - + Horizontal and Vertical binning - Size: - - - - - - - Format: + Binning: - - + + @@ -588,44 +598,34 @@ - X: + H: - - + + 0 0 - - 1 - - - 999 - - - 1 - - - - - - + Vertical binning - - + + 1 - - V: + + 10 + + + 1 - - + + @@ -633,37 +633,37 @@ - Type: + Filter: - - - - false - + + - + 0 0 - - ISO settings + + 99 - - - - ISO: + + + + - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + X: - + false @@ -734,6 +734,87 @@ 3 + + + + When storing images on remote devices, specify the directory where captured images are saved to. + + + Remote: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + /home/pi + + + + + + + Post-capture script to be executed after an image is captured. The capture sequence is resumed when the script is executed successfully. + + + Script: + + + + + + + + + + + 0 + 0 + + + + + Client + + + + + Local + + + + + Both + + + + + + + + Local directory to save sequence images + + + + + + Directory: + + + + + + + Target + + + @@ -753,10 +834,19 @@ - - - - Target + + + + <p>Select how captured images are uploaded:</p> +<ol> +<li><strong>Client</strong>: Captured images are only uploaded to Ekos.</li> +<li><strong>Local</strong>: Captured images are only saved locally on the remote computer.</li> +<li><strong>Both</strong>: Captured images are saved on remote device <b>and</b> uploaded to Ekos.</li> +</ol> +<p>When selecting <i>Local</i> or <i>Both</i>, you must specify the remote directory where the remote images are saved to. By default, all captured images are uploaded to Ekos. + + + Upload: @@ -800,35 +890,6 @@ - - - - Post-capture script to be executed after an image is captured. The capture sequence is resumed when the script is executed successfully. - - - Script: - - - - - - - - - - Local directory to save sequence images - - - - - - Directory: - - - - - - @@ -854,69 +915,8 @@ - - - - <p>Select how captured images are uploaded:</p> -<ol> -<li><strong>Client</strong>: Captured images are only uploaded to Ekos.</li> -<li><strong>Local</strong>: Captured images are only saved locally on the remote computer.</li> -<li><strong>Both</strong>: Captured images are saved on remote device <b>and</b> uploaded to Ekos.</li> -</ol> -<p>When selecting <i>Local</i> or <i>Both</i>, you must specify the remote directory where the remote images are saved to. By default, all captured images are uploaded to Ekos. - - - Upload: - - - - - - - - 0 - 0 - - - - - Client - - - - - Local - - - - - Both - - - - - - - - When storing images on remote devices, specify the directory where captured images are saved to. - - - Remote: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - false - - - /home/pi - - + + @@ -1275,6 +1275,28 @@ + + + + + 32 + 32 + + + + + 32 + 32 + + + + Select Observer + + + + + + @@ -1840,8 +1862,6 @@ - optionsGroup - CCDFWGroup CCDCaptureCombo @@ -1854,7 +1874,6 @@ FilterPosCombo countIN delayIN - frameTypeCombo frameXIN frameYIN resetFrameB diff --git a/kstars/indi/indiccd.cpp b/kstars/indi/indiccd.cpp index e33cc588d..40429ad02 100644 --- a/kstars/indi/indiccd.cpp +++ b/kstars/indi/indiccd.cpp @@ -2322,4 +2322,28 @@ bool CCD::stopRecording() return true; } +bool CCD::setFITSHeader(const QMap &values) +{ + ITextVectorProperty *tvp = baseDevice->getText("FITS_HEADER"); + if (tvp == NULL) + return false; + + QMapIterator i(values); + + while (i.hasNext()) + { + i.next(); + + IText *headerT = IUFindText(tvp, i.key().toLatin1().data()); + if (headerT == NULL) + continue; + IUSaveText(headerT, i.value().toLatin1().data()); + } + + clientManager->sendNewText(tvp); + + return true; +} + + } diff --git a/kstars/indi/indiccd.h b/kstars/indi/indiccd.h index 4d1be77a9..ae3fca25e 100644 --- a/kstars/indi/indiccd.h +++ b/kstars/indi/indiccd.h @@ -199,6 +199,9 @@ public: TelescopeType getTelescopeType() { return telescopeType; } bool setTelescopeType(TelescopeType type); + // Update FITS Header + bool setFITSHeader(const QMap & values); + FITSViewer *getViewer() { return fv;} CCDChip * getChip(CCDChip::ChipType cType); void setFITSDir(const QString &dir) { fitsDir = dir;} diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg index 8609c04b7..f27a27c35 100644 --- a/kstars/kstars.kcfg +++ b/kstars/kstars.kcfg @@ -1384,6 +1384,9 @@ + + + If guide deviation exceeds this limit, the exposure will be automatically aborted and only resumed when the deviation is within this limit. diff --git a/kstars/oal/observeradd.ui b/kstars/oal/observeradd.ui index 000e005e2..26901ca28 100644 --- a/kstars/oal/observeradd.ui +++ b/kstars/oal/observeradd.ui @@ -6,8 +6,8 @@ 0 0 - 489 - 182 + 455 + 190 @@ -25,7 +25,22 @@ Manage Observers - + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + @@ -144,6 +159,12 @@ 0 + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + -- GitLab