[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kstars/filtermanager] kstars/ekos/align: Migrate Alignment module to Filter Manager
From: Jasem Mutlaq <null () kde ! org>
Date: 2017-09-30 19:55:52
Message-ID: E1dyNrc-0002Vj-MQ () code ! kde ! org
[Download RAW message or body]
Git commit 87d13980c9cc8f62b29b14874bc99bdfc7438c27 by Jasem Mutlaq.
Committed on 30/09/2017 at 19:53.
Pushed by mutlaqja into branch 'filtermanager'.
Migrate Alignment module to Filter Manager
M +76 -91 kstars/ekos/align/align.cpp
M +7 -4 kstars/ekos/align/align.h
M +1 -1 kstars/ekos/align/align.ui
https://commits.kde.org/kstars/87d13980c9cc8f62b29b14874bc99bdfc7438c27
diff --git a/kstars/ekos/align/align.cpp b/kstars/ekos/align/align.cpp
index fd7789bff..4db94679a 100644
--- a/kstars/ekos/align/align.cpp
+++ b/kstars/ekos/align/align.cpp
@@ -101,19 +101,18 @@ Align::Align()
connect(correctAzB, SIGNAL(clicked()), this, SLOT(correctAzError()));
connect(loadSlewB, SIGNAL(clicked()), this, SLOT(loadAndSlew()));
- FilterCaptureCombo->addItem("--");
- connect(FilterCaptureCombo, static_cast<void(QComboBox::*)(const QString \
&)>(&QComboBox::activated), + FilterDevicesCombo->addItem("--");
+ connect(FilterDevicesCombo, static_cast<void(QComboBox::*)(const QString \
&)>(&QComboBox::activated), [=](const QString &text)
{
Options::setDefaultAlignFW(text);
});
- connect(FilterCaptureCombo, SIGNAL(activated(int)), this, \
SLOT(checkFilter(int))); + connect(FilterDevicesCombo, SIGNAL(activated(int)), \
this, SLOT(checkFilter(int)));
connect(FilterPosCombo, \
static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), [=](int index)
{
- lockedFilterIndex = index;
Options::setLockAlignFilterIndex(index);
}
);
@@ -2352,13 +2351,19 @@ bool Align::captureAndSolve()
return false;
}
- if (currentFilter != nullptr && lockedFilterIndex != -1)
+ if (currentFilter != nullptr)
{
- if (lockedFilterIndex != currentFilterIndex)
+ if (currentFilter->isConnected() == false)
+ {
+ appendLogText(i18n("Error: Lost connection to filter wheel."));
+ return false;
+ }
+
+ if (FilterPosCombo->currentIndex()+1 != currentFilterPosition)
{
- int lockedFilterPosition = lockedFilterIndex + 1;
filterPositionPending = true;
- currentFilter->runCommand(INDI_SET_FILTER, &lockedFilterPosition);
+ int targetPosition = FilterPosCombo->currentIndex() + 1;
+ filterManager->setFilterPosition(targetPosition);
return true;
}
}
@@ -4073,27 +4078,27 @@ void Align::addFilter(ISD::GDInterface *newFilter)
}
FilterCaptureLabel->setEnabled(true);
- FilterCaptureCombo->setEnabled(true);
+ FilterDevicesCombo->setEnabled(true);
FilterPosLabel->setEnabled(true);
FilterPosCombo->setEnabled(true);
- FilterCaptureCombo->addItem(newFilter->getDeviceName());
+ FilterDevicesCombo->addItem(newFilter->getDeviceName());
Filters.append(static_cast<ISD::Filter *>(newFilter));
checkFilter(1);
- FilterCaptureCombo->setCurrentIndex(1);
+ FilterDevicesCombo->setCurrentIndex(1);
}
bool Align::setFilter(QString device, int filterSlot)
{
bool deviceFound = false;
- for (int i = 0; i < FilterCaptureCombo->count(); i++)
- if (device == FilterCaptureCombo->itemText(i))
+ for (int i = 0; i < FilterDevicesCombo->count(); i++)
+ if (device == FilterDevicesCombo->itemText(i))
{
- FilterCaptureCombo->setCurrentIndex(i);
+ FilterDevicesCombo->setCurrentIndex(i);
deviceFound = true;
break;
}
@@ -4101,8 +4106,8 @@ bool Align::setFilter(QString device, int filterSlot)
if (deviceFound == false)
return false;
- if (filterSlot >=0 && filterSlot < FilterCaptureCombo->count())
- FilterCaptureCombo->setCurrentIndex(filterSlot);
+ if (filterSlot >=0 && filterSlot < FilterDevicesCombo->count())
+ FilterDevicesCombo->setCurrentIndex(filterSlot);
return true;
}
@@ -4111,101 +4116,32 @@ void Align::checkFilter(int filterNum)
{
if (filterNum == -1)
{
- filterNum = FilterCaptureCombo->currentIndex();
+ filterNum = FilterDevicesCombo->currentIndex();
if (filterNum == -1)
return;
}
+ // "--" is no filter
if (filterNum == 0)
{
currentFilter = nullptr;
- currentFilterIndex=-1;
+ currentFilterPosition=-1;
FilterPosCombo->clear();
- //syncFilterInfo();
return;
}
- QStringList filterAlias = Options::filterAlias();
-
if (filterNum <= Filters.count())
currentFilter = Filters.at(filterNum-1);
FilterPosCombo->clear();
- ITextVectorProperty *filterName = \
currentFilter->getBaseDevice()->getText("FILTER_NAME");
- INumberVectorProperty *filterSlot = \
currentFilter->getBaseDevice()->getNumber("FILTER_SLOT");
-
- if (filterSlot == nullptr)
- {
- KMessageBox::error(0, i18n("Unable to find FILTER_SLOT property in driver \
%1",
- \
currentFilter->getBaseDevice()->getDeviceName()));
- return;
- }
-
- currentFilterIndex = filterSlot->np[0].value - 1;
+ FilterPosCombo->addItems(filterManager->getFilterLabels());
- for (int i = 0; i < filterSlot->np[0].max; i++)
- {
- QString item;
+ currentFilterPosition = filterManager->getFilterPosition();
- if (filterName != nullptr && (i < filterName->ntp))
- item = filterName->tp[i].text;
- else if (i < filterAlias.count() && filterAlias[i].isEmpty() == false)
- item = filterAlias.at(i);
- else
- item = QString("Filter_%1").arg(i + 1);
-
- FilterPosCombo->addItem(item);
- }
-
- if (lockedFilterIndex < 0)
- lockedFilterIndex = Options::lockAlignFilterIndex();
- FilterPosCombo->setCurrentIndex(lockedFilterIndex);
-
- // If we are waiting to change the filter wheel, let's check if the condition is \
now met.
- if (filterPositionPending)
- {
- if (lockedFilterIndex == currentFilterIndex)
- {
- filterPositionPending = false;
- captureAndSolve();
- }
- }
+ FilterPosCombo->setCurrentIndex(currentFilterPosition-1);
}
-/*void Align::setLockedFilter(ISD::GDInterface *filter, int lockedPosition)
-{
- currentFilter = filter;
- if (currentFilter)
- {
- lockedFilterIndex = lockedPosition;
-
- INumberVectorProperty *filterSlot = \
filter->getBaseDevice()->getNumber("FILTER_SLOT");
- if (filterSlot)
- currentFilterIndex = filterSlot->np[0].value - 1;
-
- connect(currentFilter, SIGNAL(numberUpdated(INumberVectorProperty*)), this,
- SLOT(processFilterNumber(INumberVectorProperty*)), \
Qt::UniqueConnection);
- }
-}*/
-
-/*void Align::processFilterNumber(INumberVectorProperty *nvp)
-{
- if (currentFilter && !strcmp(nvp->name, "FILTER_SLOT") && !strcmp(nvp->device, \
currentFilter->getDeviceName()))
- {
- currentFilterIndex = nvp->np[0].value - 1;
-
- if (filterPositionPending)
- {
- if (currentFilterIndex == lockedFilterIndex)
- {
- filterPositionPending = false;
- captureAndSolve();
- }
- }
- }
-}*/
-
void Align::setWCSEnabled(bool enable)
{
if (currentCCD == nullptr)
@@ -5192,4 +5128,53 @@ void Align::refreshAlignOptions()
alignTimer.setInterval(Options::astrometryTimeout() * 1000);
}
+void Align::setFilterManager(const QSharedPointer<FilterManager> &manager)
+{
+ filterManager = manager;
+
+ connect(filterManager.data(), &FilterManager::ready, [this]()
+ {
+ if (filterPositionPending)
+ {
+ filterPositionPending = false;
+ captureAndSolve();
+ }
+ }
+ );
+
+ connect(filterManager.data(), &FilterManager::failed, [this]()
+ {
+ appendLogText(i18n("Filter operation failed."));
+ abort();
+ }
+ );
+
+ connect(filterManager.data(), &FilterManager::newStatus, \
[this](Ekos::FilterState filterState) + {
+ if (filterPositionPending)
+ {
+ switch (filterState)
+ {
+ case FILTER_OFFSET:
+ appendLogText(i18n("Changing focus offset by %1 steps...", \
filterManager->getTargetFilterOffset())); + break;
+
+ case FILTER_CHANGE:
+ appendLogText(i18n("Changing filter to %1...", \
FilterPosCombo->itemText(filterManager->getTargetFilterPosition()-1))); + \
break; +
+ case FILTER_AUTOFOCUS:
+ appendLogText(i18n("Auto focus on filter change..."));
+ break;
+
+ default:
+ break;
+ }
+ }
+ });
+
+ connect(filterManager.data(), &FilterManager::labelsChanged, this, [this]() { \
checkFilter(); }); + connect(filterManager.data(), \
&FilterManager::positionChanged, this, [this]() { checkFilter();}); +}
+
}
diff --git a/kstars/ekos/align/align.h b/kstars/ekos/align/align.h
index d605260ec..482e38f29 100644
--- a/kstars/ekos/align/align.h
+++ b/kstars/ekos/align/align.h
@@ -16,6 +16,7 @@
#include "indi/indistd.h"
#include "indi/inditelescope.h"
#include "indi/indidome.h"
+#include "ekos/auxiliary/filtermanager.h"
#include <QTime>
#include <QTimer>
@@ -261,6 +262,8 @@ class Align : public QWidget, public Ui::Align
*/
void getFOVScale(double &fov_w, double &fov_h, double &fov_scale);
+ void setFilterManager(const QSharedPointer<FilterManager> &manager);
+
/**
* @brief generateOptions Generate astrometry.net option given the supplied \
map
* @param optionsMap List of key=value pairs for all astrometry.net options
@@ -364,8 +367,6 @@ class Align : public QWidget, public Ui::Align
*/
void syncTelescopeInfo();
- //void setLockedFilter(ISD::GDInterface *filter, int lockedPosition);
-
void setFocusStatus(Ekos::FocusState state);
// Log
@@ -633,8 +634,7 @@ class Align : public QWidget, public Ui::Align
ISD::GDInterface *currentFilter { nullptr };
/// They're generic GDInterface because they could be either ISD::CCD or \
ISD::Filter QList<ISD::GDInterface *> Filters;
- int lockedFilterIndex { -1 };
- int currentFilterIndex { -1 };
+ int currentFilterPosition { -1 };
/// True if we need to change filter position and wait for result before \
continuing capture bool filterPositionPending { false };
@@ -727,5 +727,8 @@ class Align : public QWidget, public Ui::Align
double primaryFL = -1, primaryAperture = -1, guideFL = -1, guideAperture = -1;
bool domeReady = true;
+
+ // Filter Manager
+ QSharedPointer<FilterManager> filterManager;
};
}
diff --git a/kstars/ekos/align/align.ui b/kstars/ekos/align/align.ui
index b0ed89af6..6bd0e769b 100644
--- a/kstars/ekos/align/align.ui
+++ b/kstars/ekos/align/align.ui
@@ -604,7 +604,7 @@
</widget>
</item>
<item row="3" column="1">
- <widget class="QComboBox" name="FilterCaptureCombo"/>
+ <widget class="QComboBox" name="FilterDevicesCombo"/>
</item>
<item row="3" column="2">
<widget class="QLabel" name="FilterPosLabel">
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic