Commit ee946e36 authored by Jasem Mutlaq's avatar Jasem Mutlaq

Add support for observers in capture module. Observer names are sent to INDI...

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
parent 390c59f8
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#f2f2f2;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 11 3 A 3.9999902 4.0000296 0 0 0 7 7 A 3.9999902 4.0000296 0 0 0 11 11 A 3.9999902 4.0000296 0 0 0 15 7 A 3.9999902 4.0000296 0 0 0 11 3 z M 11 4 A 3 3.0000296 0 0 1 14 7 A 3 3.0000296 0 0 1 11 10 A 3 3.0000296 0 0 1 8 7 A 3 3.0000296 0 0 1 11 4 z M 11 12 A 7.9999504 8.0000296 0 0 0 3.0722656 19 L 4.0800781 19 A 6.9999604 7.0000296 0 0 1 11 13 A 6.9999604 7.0000296 0 0 1 17.921875 19 L 18.929688 19 A 7.9999504 8.0000296 0 0 0 11 12 z "
class="ColorScheme-Text"
/>
</svg>
......@@ -136,6 +136,7 @@
<file>icons/AlignSuccess.svg</file>
<file>icons/AlignWarning.svg</file>
<file>icons/breeze/default/draw-cuboid.svg</file>
<file>icons/breeze/default/im-user.svg</file>
</qresource>
<qresource prefix="/kconfig">
<file>kstars.knsrc</file>
......
......@@ -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<QString, QString> 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 << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
outstream << "<SequenceQueue version='" << SQ_FORMAT_VERSION << "'>" << endl;
if (observerName.isEmpty() == false)
outstream << "<Observer>" << observerName << "</Observer>" << endl;
outstream << "<GuideDeviation enabled='" << (guideDeviationCheck->isChecked() ? "true" : "false") << "'>" << guideDeviation->value() << "</GuideDeviation>" << endl;
outstream << "<Autofocus enabled='" << (autofocusCheck->isChecked() ? "true" : "false") << "'>" << HFRPixels->value() << "</Autofocus>" << endl;
outstream << "<MeridianFlip enabled='" << (meridianCheck->isChecked() ? "true" : "false") << "'>" << meridianHours->value() << "</MeridianFlip>" << endl;
......@@ -4205,4 +4229,58 @@ void Capture::setMountStatus(ISD::Telescope::TelescopeStatus newState)
}
}
void Capture::showObserverDialog()
{
QList<OAL::Observer *> 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<OAL::Observer *> 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);
}
}
......@@ -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;
......
This diff is collapsed.
......@@ -2322,4 +2322,28 @@ bool CCD::stopRecording()
return true;
}
bool CCD::setFITSHeader(const QMap<QString, QString> &values)
{
ITextVectorProperty *tvp = baseDevice->getText("FITS_HEADER");
if (tvp == NULL)
return false;
QMapIterator<QString, QString> 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;
}
}
......@@ -199,6 +199,9 @@ public:
TelescopeType getTelescopeType() { return telescopeType; }
bool setTelescopeType(TelescopeType type);
// Update FITS Header
bool setFITSHeader(const QMap<QString,QString> & values);
FITSViewer *getViewer() { return fv;}
CCDChip * getChip(CCDChip::ChipType cType);
void setFITSDir(const QString &dir) { fitsDir = dir;}
......
......@@ -1384,6 +1384,9 @@
<entry name="DefaultCaptureCCD" type="String">
<label>Default capture module CCD.</label>
</entry>
<entry name="DefaultObserver" type="String">
<label>Default observer full name.</label>
</entry>
<entry name="GuideDeviation" type="Double">
<label>Default maximum permittable guide deviation</label>
<whatsthis>If guide deviation exceeds this limit, the exposure will be automatically aborted and only resumed when the deviation is within this limit.</whatsthis>
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>489</width>
<height>182</height>
<width>455</width>
<height>190</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -25,7 +25,22 @@
<property name="windowTitle">
<string>Manage Observers</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="2,3">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
......@@ -144,6 +159,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
</layout>
......
Markdown is supported
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