summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-10-07 23:54:07 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-10-07 23:54:07 (GMT)
commit9d9d7490c14479c5c99cd0130feea64f9a39527d (patch)
treef76de9946f55e1b76164ded8663e73f9f392af63
parent484f8f599fb09da4abba301431b6c28b2015e04a (diff)
More progress on internal guider implementation
-rw-r--r--kstars/CMakeLists.txt6
-rw-r--r--kstars/ekos/capture/capture.cpp9
-rw-r--r--kstars/ekos/capture/capture.ui66
-rw-r--r--kstars/ekos/ekos.h4
-rw-r--r--kstars/ekos/guide/guide.cpp937
-rw-r--r--kstars/ekos/guide/guide.h97
-rw-r--r--kstars/ekos/guide/guide.ui12
-rw-r--r--kstars/ekos/guide/internalguide/common.cpp17
-rw-r--r--kstars/ekos/guide/internalguide/common.h34
-rw-r--r--kstars/ekos/guide/internalguide/gmath.cpp16
-rw-r--r--kstars/ekos/guide/internalguide/gmath.h4
-rw-r--r--kstars/ekos/guide/internalguide/internalguider.cpp436
-rw-r--r--kstars/ekos/guide/internalguide/internalguider.h22
-rw-r--r--kstars/ekos/guide/opscalibration.ui4
-rw-r--r--kstars/ekos/guide/opsguide.ui3
-rw-r--r--kstars/ekos/guide/scroll_graph.cpp412
-rw-r--r--kstars/ekos/guide/scroll_graph.h85
-rw-r--r--kstars/kstars.kcfg10
-rw-r--r--kstars/org.kde.kstars.Ekos.Guide.xml18
19 files changed, 889 insertions, 1303 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index 0327d1c..8524c50 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -178,12 +178,10 @@ if (INDI_FOUND)
# Guide
ekos/guide/guide.cpp
- ekos/guide/guideinterface.cpp
- ekos/guide/scroll_graph.cpp
+ ekos/guide/guideinterface.cpp
ekos/guide/opscalibration.cpp
ekos/guide/opsguide.cpp
- # Internal Guide
- ekos/guide/internalguide/common.cpp
+ # Internal Guide
ekos/guide/internalguide/gmath.cpp
ekos/guide/internalguide/internalguider.cpp
#ekos/guide/internalguide/guider.cpp
diff --git a/kstars/ekos/capture/capture.cpp b/kstars/ekos/capture/capture.cpp
index 0e6135e..c04f018 100644
--- a/kstars/ekos/capture/capture.cpp
+++ b/kstars/ekos/capture/capture.cpp
@@ -1151,8 +1151,10 @@ void Capture::captureOne()
void Capture::captureImage()
{
- seqTimer->stop();
- //bool isDark=false;
+ if (activeJob == NULL)
+ return;
+
+ seqTimer->stop();
SequenceJob::CAPTUREResult rc=SequenceJob::CAPTURE_OK;
if (focusState >= FOCUS_PROGRESS)
@@ -1162,9 +1164,6 @@ void Capture::captureImage()
return;
}
- //if (useGuideHead == false && darkSubCheck->isChecked() && calibrationState == CALIBRATE_NONE)
- //isDark = true;
-
if (filterSlot != NULL)
{
currentFilterPosition = (int) filterSlot->np[0].value;
diff --git a/kstars/ekos/capture/capture.ui b/kstars/ekos/capture/capture.ui
index 0a87956..dde9e74 100644
--- a/kstars/ekos/capture/capture.ui
+++ b/kstars/ekos/capture/capture.ui
@@ -365,6 +365,12 @@
</item>
<item>
<widget class="QPushButton" name="resetFrameB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
@@ -806,6 +812,12 @@
</property>
<item>
<widget class="QPushButton" name="addToQueueB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
@@ -831,6 +843,12 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
@@ -856,6 +874,12 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
@@ -881,6 +905,12 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
@@ -906,6 +936,12 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
@@ -944,6 +980,12 @@
</item>
<item>
<widget class="QPushButton" name="queueLoadB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
@@ -969,6 +1011,12 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
@@ -994,6 +1042,12 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
@@ -1112,6 +1166,12 @@
</item>
<item>
<widget class="QPushButton" name="startB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
@@ -1143,6 +1203,12 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimumSize">
<size>
<width>32</width>
diff --git a/kstars/ekos/ekos.h b/kstars/ekos/ekos.h
index 43daf1f..c1a6266 100644
--- a/kstars/ekos/ekos.h
+++ b/kstars/ekos/ekos.h
@@ -7,11 +7,11 @@ namespace Ekos
{
// Guide States
- static const QStringList guideStates = { I18N_NOOP("Idle"), I18N_NOOP("Aborted"), I18N_NOOP("Connected"), I18N_NOOP("Disconnected"), I18N_NOOP("Capturing")
+ static const QStringList guideStates = { I18N_NOOP("Idle"), I18N_NOOP("Aborted"), I18N_NOOP("Connected"), I18N_NOOP("Disconnected"), I18N_NOOP("Capturing"), I18N_NOOP("Subtracting"), I18N_NOOP("Subframing"),
I18N_NOOP("Selecting star"), I18N_NOOP("Calibrating"), I18N_NOOP("Calibration error"), I18N_NOOP("Calibration successful"), I18N_NOOP("Guiding"),
I18N_NOOP("Suspended"), I18N_NOOP("Dithering"), I18N_NOOP("Dithering error"), I18N_NOOP("Dithering successful")};
- typedef enum { GUIDE_IDLE, GUIDE_ABORTED, GUIDE_CONNECTED, GUIDE_DISCONNECTED, GUIDE_CALIBRATION_CAPTURE, GUIDE_CALIBRATION_STAR, GUIDE_CALIBRATING, GUIDE_CALIBRATION_ERROR,
+ typedef enum { GUIDE_IDLE, GUIDE_ABORTED, GUIDE_CONNECTED, GUIDE_DISCONNECTED, GUIDE_CAPTURE, GUIDE_DARK, GUIDE_SUBFRAME, GUIDE_STAR_SELECT, GUIDE_CALIBRATING, GUIDE_CALIBRATION_ERROR,
GUIDE_CALIBRATION_SUCESS, GUIDE_GUIDING, GUIDE_SUSPENDED, GUIDE_DITHERING, GUIDE_DITHERING_ERROR, GUIDE_DITHERING_SUCCESS} GuideState;
const QString & getGuideStatusString(GuideState state);
diff --git a/kstars/ekos/guide/guide.cpp b/kstars/ekos/guide/guide.cpp
index b6e0f09..f9d87df 100644
--- a/kstars/ekos/guide/guide.cpp
+++ b/kstars/ekos/guide/guide.cpp
@@ -24,7 +24,6 @@
#include "opsguide.h"
#include "internalguide/internalguider.h"
-#include "scroll_graph.h"
#include "externalguide/phd2.h"
#include "ekos/auxiliary/darklibrary.h"
@@ -43,7 +42,6 @@
#define driftGraph_WIDTH 200
#define driftGraph_HEIGHT 200
-#define MAX_DITHER_RETIRES 20
#define MAX_GUIDE_STARS 10
namespace Ekos
@@ -69,6 +67,12 @@ Guide::Guide() : QWidget()
// Auto Star
autoStarCaptured = false;
+ // Subframe
+ subFramed = false;
+
+ // To do calibrate + guide in one command
+ autoCalibrateGuide = false;
+
guideView = new FITSView(guideWidget);
guideView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
guideView->setBaseSize(guideWidget->size());
@@ -81,7 +85,7 @@ Guide::Guide() : QWidget()
guideDeviationRA = guideDeviationDEC = 0;
useGuideHead = false;
- rapidGuideReticleSet = false;
+ //rapidGuideReticleSet = false;
// Load all settings
loadSettings();
@@ -108,6 +112,9 @@ Guide::Guide() : QWidget()
// Dark Frame Check
connect(darkFrameCheck, SIGNAL(toggled(bool)), this, SLOT(setDarkFrameEnabled(bool)));
+ // Subframe check
+ connect(subFrameCheck, SIGNAL(toggled(bool)), this, SLOT(setSubFrameEnabled(bool)));
+
// ST4 Selection
connect(ST4Combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setST4(int)));
//connect(ST4Combo, SIGNAL(activated(QString)), this, SLOT(setDefaultST4(QString)));
@@ -116,10 +123,6 @@ Guide::Guide() : QWidget()
// Binning Combo Selection
connect(binningCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateCCDBin(int)));
- // Drift Graph scales
- //connect( spinBox_XScale, SIGNAL(valueChanged(int)), this, SLOT(onXscaleChanged(int)) );
- //connect( spinBox_YScale, SIGNAL(valueChanged(int)), this, SLOT(onYscaleChanged(int)) );
-
// Guiding Rate - Advisory only
connect( spinBox_GuideRate, SIGNAL(valueChanged(double)), this, SLOT(onInfoRateChanged(double)) );
@@ -221,67 +224,12 @@ Guide::Guide() : QWidget()
driftGraph->setInteractions(QCP::iRangeZoom);
- connect(driftGraph, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseOverLine(QMouseEvent*)));
-
- //driftGraph = new ScrollGraph( this, driftGraph_WIDTH, driftGraph_HEIGHT );
- //driftGraphics->setSize(driftGraph_WIDTH, driftGraph_HEIGHT);
- //driftGraphics->setSize(200, 200);
- //driftGraphics->setVisibleRanges( 200, 60 );
- //driftGraphics->update();
- //driftGraphics->on_paint();
- //ui.frame_Graph->resize( driftGraph_WIDTH + 2*ui.frame_Graph->frameWidth(), driftGraph_HEIGHT + 2*ui.frame_Graph->frameWidth() );
+ connect(driftGraph, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(driftMouseOverLine(QMouseEvent*)));
+ connect(driftGraph, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(driftMouseClicked(QMouseEvent*)));
guiderType = static_cast<GuiderType>(Options::guiderType());
- switch (guiderType)
- {
- case GUIDE_INTERNAL:
- {
- guider= new InternalGuider();
- InternalGuider *internalGuider = dynamic_cast<InternalGuider*>(guider);
- // Options
- KConfigDialog* dialog = new KConfigDialog(this, "guidesettings", Options::self());
- opsCalibration = new OpsCalibration(internalGuider);
- dialog->addPage(opsCalibration, i18n("Calibration Settings"));
- opsGuide = new OpsGuide(internalGuider);
- dialog->addPage(opsGuide, i18n("Guide Settings"));
- connect(guideOptionsB, SIGNAL(clicked()), dialog, SLOT(show()));
-
- connect(internalGuider, SIGNAL(newPulse(GuideDirection,int)), this, SLOT(sendPulse(GuideDirection,int)));
- connect(internalGuider, SIGNAL(newPulse(GuideDirection,int,GuideDirection,int)), this, SLOT(sendPulse(GuideDirection,int,GuideDirection,int)));
- connect(internalGuider, SIGNAL(DESwapChanged(bool)), swapCheck, SLOT(setChecked(bool)));
- //connect(swapCheck, SIGNAL(toggled(bool)), internalGuider, SLOT(setDECSwap(bool)));
-
- internalGuider->setGuideView(guideView);
-
- calibrateB->setEnabled(true);
- captureB->setEnabled(true);
- }
- break;
-
- case GUIDE_PHD2:
- //guider = new PHD2();
-
- // Do NOT receive BLOBs from the driver
- //currentCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_NEVER, currentCCD->getDeviceName(), useGuideHead ? "CCD2" : "CCD1");
-
- calibrateB->setEnabled(false);
- captureB->setEnabled(false);
- break;
-
-
- case GUIDE_LINGUIDER:
- //guider = new LINGuider();
-
- // Do NOT receive BLOBs from the driver
- //currentCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_NEVER, currentCCD->getDeviceName(), useGuideHead ? "CCD2" : "CCD1");
- calibrateB->setEnabled(false);
- captureB->setEnabled(false);
- break;
- }
-
-
- state = GUIDE_IDLE;
+ setGuideType(guiderType);
connect(guider, SIGNAL(frameCaptureRequested()), this, SLOT(capture()));
connect(guider, SIGNAL(newLog(QString)), this, SLOT(appendLogText(QString)));
@@ -292,11 +240,9 @@ Guide::Guide() : QWidget()
connect(guider, SIGNAL(newAxisPulse(double,double)), this, SLOT(setAxisPulse(double,double)));
connect(guider, SIGNAL(newAxisSigma(double,double)), this, SLOT(setAxisSigma(double,double)));
- // FIXME we emit this directly TODO
- //connect(guider, SIGNAL(newProfilePixmap(QPixmap &)), this, SIGNAL(newProfilePixmap(QPixmap &)));
-
-
guider->Connect();
+
+ state = GUIDE_IDLE;
}
Guide::~Guide()
@@ -525,11 +471,11 @@ void Guide::updateGuideParams()
}
binningCombo->setEnabled(targetChip->canBin());
- int binX=1,binY=1;
+ int subBinX=1,subBinY=1;
if (targetChip->canBin())
{
- int binX,binY, maxBinX, maxBinY;
- targetChip->getBinning(&binX, &binY);
+ int maxBinX, maxBinY;
+ targetChip->getBinning(&subBinX, &subBinY);
targetChip->getMaxBin(&maxBinX, &maxBinY);
binningCombo->blockSignals(true);
@@ -539,11 +485,33 @@ void Guide::updateGuideParams()
for (int i=1; i <= maxBinX; i++)
binningCombo->addItem(QString("%1x%2").arg(i).arg(i));
- binningCombo->setCurrentIndex(binX-1);
+ binningCombo->setCurrentIndex(subBinX-1);
binningCombo->blockSignals(false);
}
+ if (frameSettings.contains(targetChip) == false)
+ {
+ int x,y,w,h;
+ if (targetChip->getFrame(&x, &y, &w, &h))
+ {
+ if (w > 0 && h > 0)
+ {
+ QVariantMap settings;
+
+ settings["x"] = x;
+ settings["y"] = y;
+ settings["w"] = w;
+ settings["h"] = h;
+ settings["binx"] = subBinX;
+ settings["biny"] = subBinY;
+
+ frameSettings[targetChip] = settings;
+ }
+ }
+ }
+
+
if (ccdPixelSizeX != -1 && ccdPixelSizeY != -1 && mountAperture != -1 && mountFocalLength != -1)
{
guider->setGuiderParams(ccdPixelSizeX, ccdPixelSizeY, mountAperture, mountFocalLength);
@@ -557,7 +525,7 @@ void Guide::updateGuideParams()
int x,y,w,h;
if (targetChip->getFrame(&x,&y,&w,&h))
{
- guider->setFrameParams(x,y,w,h, binX, binY);
+ guider->setFrameParams(x,y,w,h, subBinX, subBinY);
//pmath->setVideoParameters(w, h);
}
@@ -631,6 +599,13 @@ void Guide::setAO(ISD::ST4 *newAO)
bool Guide::capture()
{
+ buildOperationStack(GUIDE_CAPTURE);
+
+ return executeOperationStack();
+}
+
+bool Guide::captureOneFrame()
+{
if (currentCCD == NULL)
return false;
@@ -665,6 +640,52 @@ bool Guide::capture()
else
targetChip->setCaptureFilter((FITSScale) filterCombo->currentIndex());
+ // Do not subframe if we are capturing calibration frame
+#if 0
+ if (Options::guideSubframeEnabled() &&
+ subFramed == false && targetChip->canSubframe())
+ {
+ int minX, maxX, minY, maxY, minW, maxW, minH, maxH;//, fx,fy,fw,fh;
+ targetChip->getFrameMinMax(&minX, &maxX, &minY, &maxY, &minW, &maxW, &minH, &maxH);
+
+ int subBinX, subBinY;
+ targetChip->getBinning(&subBinX, &subBinY);
+
+ int offset = boxSizeCombo->currentText().toInt()/subBinX;
+ int x = guideView->getTrackingBox().x() + guideView->getTrackingBox().width()/2;
+ int y = guideView->getTrackingBox().y() + guideView->getTrackingBox().height()/2;
+
+ x = (x - offset*2) * subBinX;
+ y = (y - offset*2) * subBinY;
+ int w=offset*4*subBinX;
+ int h=offset*4*subBinY;
+
+ if (x<minX)
+ x=minX;
+ if (y<minY)
+ y=minY;
+ if ((x+w)>maxW)
+ w=maxW-x;
+ if ((y+h)>maxH)
+ h=maxH-y;
+
+ targetChip->setFrame(x,y,w,h);
+
+ subFramed = true;
+
+ //starRect = QRect((w-focusBoxSize->value())/(subBinX*2), (h-focusBoxSize->value())/(subBinY*2), focusBoxSize->value()/subBinX, focusBoxSize->value()/subBinY);
+ starCenter.setX(0);
+ starCenter.setY(0);
+
+ state = GUIDE_CALIBRATION_SUBFRAME;
+ }
+ else if (subFramed && Options::guideSubframeEnabled() == false)
+ {
+ targetChip->resetFrame();
+ subFramed = false;
+ }
+
+#endif
/*if (guider->isGuiding())
{
@@ -681,6 +702,13 @@ bool Guide::capture()
guideView->setBaseSize(guideWidget->size());
setBusy(true);
+ if (frameSettings.contains(targetChip))
+ {
+ QVariantMap settings = frameSettings[targetChip];
+ targetChip->setFrame(settings["x"].toInt(), settings["y"].toInt(), settings["w"].toInt(), settings["h"].toInt());
+ }
+
+#if 0
switch (state)
{
case GUIDE_GUIDING:
@@ -692,7 +720,8 @@ bool Guide::capture()
default:
break;
- }
+ }
+#endif
connect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)), Qt::UniqueConnection);
targetChip->capture(seqExpose);
@@ -716,8 +745,8 @@ bool Guide::abort()
break;
case GUIDE_CALIBRATING:
- case GUIDE_CALIBRATION_STAR:
- case GUIDE_CALIBRATION_CAPTURE:
+ case GUIDE_STAR_SELECT:
+ case GUIDE_CAPTURE:
case GUIDE_GUIDING:
guider->abort();
default:
@@ -730,27 +759,42 @@ bool Guide::abort()
void Guide::setBusy(bool enable)
{
+ if (enable && pi->isAnimated())
+ return;
+ else if (enable == false && pi->isAnimated() == false)
+ return;
+
if (enable)
{
calibrateB->setEnabled(false);
guideB->setEnabled(false);
captureB->setEnabled(false);
+ darkFrameCheck->setEnabled(false);
+ subFrameCheck->setEnabled(false);
+
stopB->setEnabled(true);
pi->startAnimation();
+
+ //disconnect(guideView, SIGNAL(trackingStarSelected(int,int)), this, SLOT(setTrackingStar(int,int)));
}
else
{
calibrateB->setEnabled(true);
captureB->setEnabled(true);
+ darkFrameCheck->setEnabled(true);
+ subFrameCheck->setEnabled(true);
+
if (state >= GUIDE_CALIBRATION_SUCESS)
guideB->setEnabled(true);
stopB->setEnabled(false);
pi->stopAnimation();
+
+ connect(guideView, SIGNAL(trackingStarSelected(int,int)), this, SLOT(setTrackingStar(int,int)), Qt::UniqueConnection);
}
}
@@ -758,84 +802,30 @@ void Guide::newFITS(IBLOB *bp)
{
INDI_UNUSED(bp);
- //FITSViewer *fv = currentCCD->getViewer();
-
- disconnect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
-
- ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
-
- // Do we need to take a dark frame?
- if (Options::guideDarkFrameEnabled())
- {
- int x,y,w,h;
- int binx,biny;
-
- targetChip->getFrame(&x,&y,&w,&h);
- targetChip->getBinning(&binx,&biny);
-
- FITSView *currentImage = targetChip->getImageView(FITS_GUIDE);
- FITSData *darkData = NULL;
- uint16_t offsetX = x / binx;
- uint16_t offsetY = y / biny;
-
- darkData = DarkLibrary::Instance()->getDarkFrame(targetChip, exposureIN->value());
-
- connect(DarkLibrary::Instance(), SIGNAL(darkFrameCompleted(bool)), this, SLOT(setCaptureComplete()));
- connect(DarkLibrary::Instance(), SIGNAL(newLog(QString)), this, SLOT(appendLogText(QString)));
-
- if (darkData)
- DarkLibrary::Instance()->subtract(darkData, currentImage, targetChip->getCaptureFilter(), offsetX, offsetY);
- else
- {
- //if (calibration->useAutoStar() == false)
- //KMessageBox::information(NULL, i18n("If the guide camera is not equipped with a shutter, cover the telescope or camera in order to take a dark exposure."), i18n("Dark Exposure"), "dark_exposure_dialog_notification");
-
- DarkLibrary::Instance()->captureAndSubtract(targetChip, currentImage, exposureIN->value(), offsetX, offsetY);
- }
- return;
- }
-
- setCaptureComplete();
-}
-
-void Guide::setCaptureComplete()
-{
- DarkLibrary::Instance()->disconnect(this);
-
- ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
-
- FITSView *targetImage = targetChip->getImageView(FITS_GUIDE);
-
- if (targetImage == NULL)
- {
- if (Options::guideLogging())
- qDebug() << "Guide: guide frame is missing! Capturing again...";
-
- capture();
- return;
- }
+ disconnect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
if (Options::guideLogging())
qDebug() << "Guide: received guide frame.";
- //FITSData *image_data = targetImage->getImageData();
- //Q_ASSERT(image_data);
-
- //pmath->setImageView(targetImage);
- //guider->setImageView(targetImage);
+ ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
int subBinX=1, subBinY=1;
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) == false)
- // return;
-
if (starCenter.x() == 0 && starCenter.y() == 0)
{
- int x,y,w,h;
- targetChip->getFrame(&x,&y,&w,&h);
+ int x=0, y=0, w=0,h=0;
+
+ if (frameSettings.contains(targetChip))
+ {
+ QVariantMap settings = frameSettings[targetChip];
+ x = settings["x"].toInt();
+ y = settings["y"].toInt();
+ w = settings["w"].toInt();
+ h = settings["h"].toInt();
+ }
+ else
+ targetChip->getFrame(&x, &y, &w, &h);
starCenter.setX(w/(2*subBinX));
starCenter.setY(h/(2*subBinY));
@@ -844,6 +834,16 @@ void Guide::setCaptureComplete()
syncTrackingBoxPosition();
+ if (operationStack.isEmpty())
+ setCaptureComplete();
+ else
+ executeOperationStack();
+}
+
+void Guide::setCaptureComplete()
+{
+ DarkLibrary::Instance()->disconnect(this);
+
switch (state)
{
case GUIDE_IDLE:
@@ -852,36 +852,10 @@ void Guide::setCaptureComplete()
case GUIDE_DISCONNECTED:
case GUIDE_CALIBRATION_SUCESS:
case GUIDE_CALIBRATION_ERROR:
+ case GUIDE_DITHERING_ERROR:
setBusy(false);
break;
- case GUIDE_CALIBRATION_CAPTURE:
- {
- if (Options::autoStarEnabled())
- {
- autoStarCaptured = selectAutoStar();
- if (autoStarCaptured)
- {
- appendLogText(i18n("Auto star selected. Starting calibration..."));
- guider->setStarPosition(starCenter);
- guider->calibrate();
- }
- else
- {
- appendLogText(i18n("Failed to select an auto star."));
- state = GUIDE_CALIBRATION_ERROR;
- emit newStatus(state);
- setBusy(false);
- }
- }
- else
- {
- appendLogText(i18n("Select a guide star to calibrate."));
- state = GUIDE_CALIBRATION_STAR;
- emit newStatus(state);
- }
- }
- break;
case GUIDE_CALIBRATING:
guider->calibrate();
break;
@@ -890,54 +864,16 @@ void Guide::setCaptureComplete()
guider->guide();
break;
- default:
+ case GUIDE_DITHERING:
+ guider->dither(Options::ditherPixels());
break;
+ default:
+ break;
}
- /*if (isSuspended)
- {
- if (Options::guideLogging())
- qDebug() << "Guide: Guider is suspended.";
-
- return;
- }
-
- 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 if (guider->isGuiding())
- {
- guider->guide();
-
- if (guider->isGuiding())
- capture();
- }
- else if (calibration->isCalibrating())
- {
- GuideDriver = ST4Driver;
- pmath->performProcessing();
- calibration->processCalibration();
-
- if (calibration->isCalibrationComplete())
- {
- guider->setReady(true);
- tabWidget->setTabEnabled(1, true);
- //emit guideReady();
- }
- }
-
- emit newStarPixmap(targetImage->getTrackingBoxPixmap());
+ emit newStarPixmap(guideView->getTrackingBoxPixmap());
- */
}
void Guide::appendLogText(const QString &text)
@@ -1003,17 +939,9 @@ QStringList Guide::getST4Devices()
return devices;
}
-/*void Guide::viewerClosed()
-{
- pmath->set_image(NULL);
- guider->setImage(NULL);
- calibration->setImage(NULL);
-}*/
-
+#if 0
void Guide::processRapidStarData(ISD::CCDChip *targetChip, double dx, double dy, double fit)
{
- // FIXME
- /*
// Check if guide star is lost
if (dx == -1 && dy == -1 && fit == -1)
{
@@ -1059,17 +987,12 @@ void Guide::processRapidStarData(ISD::CCDChip *targetChip, double dx, double dy,
{
guider->guide();
capture();
- }
-
- */
+ }
}
void Guide::startRapidGuide()
{
-
- // FIXME
- /*
ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
if (currentCCD->setRapidGuide(targetChip, true) == false)
@@ -1084,15 +1007,10 @@ void Guide::startRapidGuide()
pmath->setRapidGuide(true);
currentCCD->configureRapidGuide(targetChip, true);
connect(currentCCD, SIGNAL(newGuideStarData(ISD::CCDChip*,double,double,double)), this, SLOT(processRapidStarData(ISD::CCDChip*,double,double,double)));
- */
-
}
void Guide::stopRapidGuide()
{
-
- // FIXME
- /*
ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
pmath->setRapidGuide(false);
@@ -1104,33 +1022,18 @@ void Guide::stopRapidGuide()
currentCCD->configureRapidGuide(targetChip, false, false, false);
currentCCD->setRapidGuide(targetChip, false);
- */
-
}
-
+#endif
bool Guide::calibrate()
{
saveSettings();
- autoStarCaptured = false;
+ buildOperationStack(GUIDE_CALIBRATING);
- if (starCenter.isNull() || Options::autoStarEnabled())
- {
- state = GUIDE_CALIBRATION_CAPTURE;
- emit newStatus(state);
-
- appendLogText(i18n("Capturing image..."));
- capture();
- return true;
- }
-
- guider->setStarPosition(starCenter);
- bool rc = guider->calibrate();
- if (rc)
- setBusy(true);
+ executeOperationStack();
- return rc;
+ return true;
}
bool Guide::guide()
@@ -1144,9 +1047,7 @@ bool Guide::guide()
driftGraph->graph(0)->data().clear();
driftGraph->graph(1)->data().clear();
guideTimer = QTime::currentTime();
- refreshColorScheme();
- //TODO reset data?
- //driftGraphics->resetData();
+ refreshColorScheme();
}
return rc;
@@ -1154,40 +1055,23 @@ bool Guide::guide()
bool Guide::dither()
{
- return false;
+ return guider->dither(Options::ditherPixels());
}
-void Guide::setSuspended(bool enable)
+bool Guide::suspend()
{
- /*
- if (enable == isSuspended || (enable && isGuiding() == false))
- return;
+ if (state == GUIDE_SUSPENDED)
+ return true;
- isSuspended = enable;
+ return guider->suspend();
+}
- if (isSuspended)
- {
- if (Options::usePHD2Guider())
- phd2->pauseGuiding();
- }
- else
- {
- if (Options::useEkosGuider())
- capture();
- else
- phd2->resumeGuiding();
- //phd2->startGuiding();
- }
+bool Guide::resume()
+{
+ if (state == GUIDE_GUIDING)
+ return true;
- if (isSuspended)
- {
- appendLogText(i18n("Guiding suspended."));
- }
- else
- {
- appendLogText(i18n("Guiding resumed."));
- }
- */
+ return guider->resume();
}
void Guide::setExposure(double value)
@@ -1195,7 +1079,6 @@ void Guide::setExposure(double value)
exposureIN->setValue(value);
}
-
void Guide::setImageFilter(const QString & value)
{
for (int i=0; i < filterCombo->count(); i++)
@@ -1208,47 +1091,51 @@ void Guide::setImageFilter(const QString & value)
void Guide::setCalibrationTwoAxis(bool enable)
{
- // calibration->setCalibrationTwoAxis(enable);
+ Options::setTwoAxisEnabled(enable);
}
void Guide::setCalibrationAutoStar(bool enable)
{
- //calibration->setCalibrationAutoStar(enable);
+ Options::setGuideAutoStarEnabled(enable);
}
void Guide::setCalibrationAutoSquareSize(bool enable)
{
- //calibration->setCalibrationAutoSquareSize(enable);
+ Options::setGuideAutoSquareSizeEnabled(enable);
}
void Guide::setCalibrationPulseDuration(int pulseDuration)
{
- // calibration->setCalibrationPulseDuration(pulseDuration);
+ Options::setCalibrationPulseDuration(pulseDuration);
}
-void Guide::setGuideBoxSizeIndex(int boxSize)
+void Guide::setGuideBoxSizeIndex(int index)
{
- //boxSizeCombo->setCurrentIndex(boxSize);
+ Options::setGuideSquareSizeIndex(index);
}
void Guide::setGuideAlgorithm(const QString & algorithm)
{
+ //TODO
//guider->setGuideOptions(algorithm, guider->useSubFrame(), guider->useRapidGuide());
}
void Guide::setSubFrameEnabled(bool enable)
{
- //guider->setGuideOptions(guider->getAlgorithm(), enable , guider->useRapidGuide());
+ Options::setGuideSubframeEnabled(enable);
}
+#if 0
void Guide::setGuideRapidEnabled(bool enable)
{
//guider->setGuideOptions(guider->getAlgorithm(), guider->useSubFrame() , enable);
}
+#endif
-void Guide::setDither(bool enable, double value)
+void Guide::setDitherSettings(bool enable, double value)
{
- //guider->setDither(enable, value);
+ Options::setDitherEnabled(enable);
+ Options::setDitherPixels(value);
}
QList<double> Guide::getGuidingDeviation()
@@ -1260,86 +1147,99 @@ QList<double> Guide::getGuidingDeviation()
return deviation;
}
-void Guide::startAutoCalibrateGuiding()
+void Guide::startAutoCalibrateGuide()
{
- // FIXME
- /*
- if (Options::useEkosGuider())
- connect(calibration, SIGNAL(newStatus(Ekos::GuideState)), this, SLOT(checkAutoCalibrateGuiding(Ekos::GuideState)));
- else
- connect(phd2, SIGNAL(newStatus(Ekos::GuideState)), this, SLOT(checkAutoCalibrateGuiding(Ekos::GuideState)));
+ // A must for auto stuff
+ Options::setGuideAutoStarEnabled(true);
- startCalibration();
+ autoCalibrateGuide = true;
- */
-}
-
-void Guide::checkAutoCalibrateGuiding(Ekos::GuideState state)
-{
- // FIXME
- /*
- if (state < GUIDE_CALIBRATION_SUCESS || state > GUIDE_CALIBRATION_ERROR)
- return;
-
- if (Options::useEkosGuider())
- disconnect(calibration, SIGNAL(newStatus(GuideState)), this, SLOT(checkAutoCalibrateGuiding(GuideState)));
- else
- disconnect(phd2, SIGNAL(newStatus(GuideState)), this, SLOT(checkAutoCalibrateGuiding(GuideState)));
-
- if (state == GUIDE_CALIBRATION_SUCESS)
- {
- appendLogText(i18n("Auto calibration successful. Starting guiding..."));
- startGuiding();
- }
- else
- {
- appendLogText(i18n("Auto calibration failed."));
- }
- */
+ calibrate();
}
void Guide::setStatus(Ekos::GuideState newState)
{
if (newState == state)
- return;
+ return;
+
+ GuideState previousState = state;
state = newState;
+ emit newStatus(state);
switch (state)
{
case GUIDE_CALIBRATION_SUCESS:
- setBusy(false);
+ appendLogText(i18n("Calibration completed."));
+ if (autoCalibrateGuide)
+ {
+ autoCalibrateGuide = false;
+ guide();
+ }
+ else
+ setBusy(false);
break;
case GUIDE_CALIBRATION_ERROR:
setBusy(false);
break;
+ case GUIDE_CALIBRATING:
+ appendLogText(i18n("Calibration started."));
+ setBusy(true);
+ break;
+
case GUIDE_GUIDING:
- appendLogText(i18n("Autoguiding started."));
- setBusy(true);
+ if (previousState == GUIDE_SUSPENDED)
+ appendLogText(i18n("Guiding resumed."));
+ else
+ {
+ appendLogText(i18n("Autoguiding started."));
+ setBusy(true);
+ }
+
+ break;
+
+ case GUIDE_ABORTED:
+ appendLogText(i18n("Autoguiding aborted."));
+ setBusy(false);
break;
+ case GUIDE_SUSPENDED:
+ appendLogText(i18n("Guiding suspended."));
+ break;
+
+ case GUIDE_DITHERING:
+ appendLogText(i18n("Dithering in progress."));
+ break;
+
+ case GUIDE_DITHERING_ERROR:
+ appendLogText(i18n("Dithering failed!"));
+ break;
+
+ case GUIDE_DITHERING_SUCCESS:
+ appendLogText(i18n("Dithering completed successfully."));
+ state = GUIDE_GUIDING;
+ capture();
+ break;
default:
break;
}
-
- emit newStatus(newState);
}
void Guide::updateCCDBin(int index)
{
- // FIXME
- /*
- if (currentCCD == NULL && Options::usePHD2Guider())
+ if (currentCCD == NULL && guiderType != GUIDE_INTERNAL)
return;
ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
targetChip->setBinning(index+1, index+1);
- */
-
+ QVariantMap settings = frameSettings[targetChip];
+ settings["binx"] = index+1;
+ settings["biny"] = index+1;
+ frameSettings[targetChip] = settings;
}
void Guide::processCCDNumber(INumberVectorProperty *nvp)
@@ -1357,27 +1257,18 @@ void Guide::processCCDNumber(INumberVectorProperty *nvp)
void Guide::checkExposureValue(ISD::CCDChip *targetChip, double exposure, IPState state)
{
- // FIXME
- /*
INDI_UNUSED(exposure);
- if (state == IPS_ALERT && (guider->isGuiding() || guider->isDithering() || calibration->isCalibrating()))
+ if (state == IPS_ALERT && (state == GUIDE_GUIDING) || (state == GUIDE_DITHERING) || (state == GUIDE_CALIBRATING))
{
appendLogText(i18n("Exposure failed. Restarting exposure..."));
targetChip->capture(exposureIN->value());
- }
- */
+ }
}
void Guide::setDarkFrameEnabled(bool enable)
{
- // FIXME
- /*
- Options::setUseGuideDarkFrame(enable);
-*/
- /*if (enable && calibration && calibration->useAutoStar())
- appendLogText(i18n("Warning: In auto mode, you will not be asked to cover cameras unequipped with shutters in order to capture a dark frame. The dark frame capture will proceed without warning."
- " You can capture dark frames with auto mode off and they shall be saved in the dark library for use when ever needed."));*/
+ Options::setGuideDarkFrameEnabled(enable);
}
void Guide::saveDefaultGuideExposure()
@@ -1437,8 +1328,56 @@ void Guide::syncTrackingBoxPosition()
bool Guide::setGuideType(int type)
{
- // FIXME
- return false;
+ switch (type)
+ {
+ case GUIDE_INTERNAL:
+ {
+ if (internalGuider.isNull())
+ {
+ internalGuider = new InternalGuider();
+ KConfigDialog* dialog = new KConfigDialog(this, "guidesettings", Options::self());
+ opsCalibration = new OpsCalibration(internalGuider);
+ dialog->addPage(opsCalibration, i18n("Calibration Settings"));
+ opsGuide = new OpsGuide(internalGuider);
+ dialog->addPage(opsGuide, i18n("Guide Settings"));
+ connect(guideOptionsB, SIGNAL(clicked()), dialog, SLOT(show()));
+
+ connect(internalGuider, SIGNAL(newPulse(GuideDirection,int)), this, SLOT(sendPulse(GuideDirection,int)));
+ connect(internalGuider, SIGNAL(newPulse(GuideDirection,int,GuideDirection,int)), this, SLOT(sendPulse(GuideDirection,int,GuideDirection,int)));
+ connect(internalGuider, SIGNAL(DESwapChanged(bool)), swapCheck, SLOT(setChecked(bool)));
+
+ internalGuider->setGuideView(guideView);
+ }
+
+ guider= internalGuider;
+
+ calibrateB->setEnabled(true);
+ captureB->setEnabled(true);
+ }
+ break;
+
+ case GUIDE_PHD2:
+ //guider = new PHD2();
+
+ // Do NOT receive BLOBs from the driver
+ //currentCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_NEVER, currentCCD->getDeviceName(), useGuideHead ? "CCD2" : "CCD1");
+
+ calibrateB->setEnabled(false);
+ captureB->setEnabled(false);
+ break;
+
+
+ case GUIDE_LINGUIDER:
+ //guider = new LINGuider();
+
+ // Do NOT receive BLOBs from the driver
+ //currentCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_NEVER, currentCCD->getDeviceName(), useGuideHead ? "CCD2" : "CCD1");
+ calibrateB->setEnabled(false);
+ captureB->setEnabled(false);
+ break;
+ }
+
+ return true;
}
void Guide::updateTrackingBoxSize(int currentIndex)
@@ -1589,12 +1528,12 @@ void Guide::onInfoRateChanged( double val )
void Guide::onEnableDirRA(bool enable)
{
- //Options::setEnableRAGuide(enable);
+ Options::setRAGuideEnabled(enable);
}
void Guide::onEnableDirDEC(bool enable)
{
- //Options::setEnableDECGuide(enable);
+ Options::setDECGuideEnabled(enable);
}
void Guide::onInputParamChanged()
@@ -1634,34 +1573,29 @@ void Guide::onInputParamChanged()
void Guide::onControlDirectionChanged(bool enable)
{
- // FIXME
- /*
QObject *obj = sender();
if (northControlCheck == dynamic_cast<QCheckBox*>(obj))
{
- Options::setEnableNorthDECGuide(enable);
+ Options::setNorthDECGuideEnabled(enable);
}
else if (southControlCheck == dynamic_cast<QCheckBox*>(obj))
{
- Options::setEnableSouthDECGuide(enable);
+ Options::setSouthDECGuideEnabled(enable);
}
else if (westControlCheck == dynamic_cast<QCheckBox*>(obj))
{
- Options::setEnableWestRAGuide(enable);
+ Options::setWestRAGuideEnabled(enable);
}
else if (eastControlCheck == dynamic_cast<QCheckBox*>(obj))
{
- Options::setEnableEastRAGuide(enable);
+ Options::setEastRAGuideEnabled(enable);
}
-
- */
}
+#if 0
void Guide::onRapidGuideChanged(bool enable)
{
- // FIXME
- /*
if (m_isStarted)
{
guideModule->appendLogText(i18n("You must stop auto guiding before changing this setting."));
@@ -1676,10 +1610,8 @@ void Guide::onRapidGuideChanged(bool enable)
}
else
guideModule->appendLogText(i18n("Rapid Guiding is disabled."));
-
- */
-
}
+#endif
void Guide::loadSettings()
{
@@ -1689,6 +1621,8 @@ void Guide::loadSettings()
boxSizeCombo->setCurrentIndex(Options::guideSquareSizeIndex());
// Dark frame?
darkFrameCheck->setChecked(Options::guideDarkFrameEnabled());
+ // Subframed?
+ subFrameCheck->setChecked(Options::guideSubframeEnabled());
// RA/DEC enabled?
checkBox_DirRA->setChecked(Options::rAGuideEnabled());
checkBox_DirDEC->setChecked(Options::dECGuideEnabled());
@@ -1723,6 +1657,8 @@ void Guide::saveSettings()
Options::setGuideSquareSizeIndex(boxSizeCombo->currentIndex());
// Dark frame?
Options::setGuideDarkFrameEnabled(darkFrameCheck->isChecked());
+ // Subframed?
+ Options::setGuideSubframeEnabled(subFrameCheck->isChecked());
// RA/DEC enabled?
Options::setRAGuideEnabled(checkBox_DirRA->isChecked());
Options::setDECGuideEnabled(checkBox_DirDEC->isChecked());
@@ -1750,15 +1686,18 @@ void Guide::saveSettings()
}
void Guide::setTrackingStar(int x, int y)
-{
+{
QVector3D newStarPosition(x,y, -1);
setStarPosition(newStarPosition, true);
- if (state == GUIDE_CALIBRATION_STAR)
+ /*if (state == GUIDE_STAR_SELECT)
{
guider->setStarPosition(newStarPosition);
guider->calibrate();
- }
+ }*/
+
+ if (operationStack.isEmpty() == false)
+ executeOperationStack();
}
void Guide::setAxisDelta(double ra, double de)
@@ -1770,6 +1709,9 @@ void Guide::setAxisDelta(double ra, double de)
driftGraph->graph(1)->addData(key, de);
// Expand range if it doesn't fit already
+ if (driftGraph->yAxis->range().contains(ra) == false)
+ driftGraph->yAxis->setRange(-1.25*ra, 1.25*ra);
+
if (driftGraph->yAxis->range().contains(de) == false)
driftGraph->yAxis->setRange(-1.25*de, 1.25*de);
@@ -1782,6 +1724,10 @@ void Guide::setAxisDelta(double ra, double de)
l_DeltaDEC->setText(QString::number(de, 'f', 2));
emit newAxisDelta(ra,de);
+
+ profilePixmap = driftGraph->grab(QRect(QPoint(0, 100), QSize(driftGraph->width(), 101)));
+ emit newProfilePixmap(profilePixmap);
+
}
void Guide::setAxisSigma(double ra, double de)
@@ -1807,7 +1753,15 @@ void Guide::refreshColorScheme()
driftGraph->graph(1)->setPen(QPen(KStarsData::Instance()->colorScheme()->colorNamed("DEGuideError")));
}
-void Guide::mouseOverLine(QMouseEvent *event)
+void Guide::driftMouseClicked(QMouseEvent *event)
+{
+ if (event->buttons() & Qt::RightButton)
+ {
+ driftGraph->yAxis->setRange(-3, 3);
+ }
+}
+
+void Guide::driftMouseOverLine(QMouseEvent *event)
{
double key = driftGraph->xAxis->pixelToCoord(event->localPos().x());
@@ -1845,7 +1799,246 @@ void Guide::mouseOverLine(QMouseEvent *event)
}
+void Guide::buildOperationStack(GuideState operation)
+{
+ operationStack.clear();
+
+ switch (operation)
+ {
+ case GUIDE_CAPTURE:
+ if (Options::guideDarkFrameEnabled())
+ operationStack.push(GUIDE_DARK);
+
+ operationStack.push(GUIDE_CAPTURE);
+ operationStack.push(GUIDE_SUBFRAME);
+ break;
+
+ case GUIDE_CALIBRATING:
+ operationStack.push(GUIDE_CALIBRATING);
+ if (starCenter.isNull() || (Options::guideAutoStarEnabled()))
+ {
+ if (Options::guideDarkFrameEnabled())
+ operationStack.push(GUIDE_DARK);
+
+ // If subframe is enabled and we need to auto select a star, then we need to make the final capture
+ // of the subframed image. This is only done if we aren't already subframed.
+ if (subFramed == false && Options::guideSubframeEnabled() && Options::guideAutoStarEnabled())
+ operationStack.push(GUIDE_CAPTURE);
+
+ operationStack.push(GUIDE_SUBFRAME);
+ operationStack.push(GUIDE_STAR_SELECT);
+ operationStack.push(GUIDE_CAPTURE);
+
+ // If we are being ask to go full frame, let's do that first
+ if (subFramed == true && Options::guideSubframeEnabled() == false)
+ operationStack.push(GUIDE_SUBFRAME);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+bool Guide::executeOperationStack()
+{
+ if (operationStack.isEmpty())
+ return false;
+
+ GuideState nextOperation = operationStack.pop();
+
+ bool actionRequired = false;
+ switch (nextOperation)
+ {
+ case GUIDE_SUBFRAME:
+ actionRequired = executeOneOperation(nextOperation);
+ break;
+
+ case GUIDE_DARK:
+ actionRequired = executeOneOperation(nextOperation);
+ break;
+
+ case GUIDE_CAPTURE:
+ actionRequired = captureOneFrame();
+ break;
+
+ case GUIDE_STAR_SELECT:
+ actionRequired = executeOneOperation(nextOperation);
+ break;
+
+ case GUIDE_CALIBRATING:
+ guider->setStarPosition(starCenter);
+ if (guider->calibrate())
+ {
+ disconnect(guideView, SIGNAL(trackingStarSelected(int,int)), this, SLOT(setTrackingStar(int,int)));
+ setBusy(true);
+ }
+ else
+ appendLogText(i18n("Calibration failed to start!"));
+ break;
+
+ default:
+ break;
+ }
+
+ // If an additional action is required, return return and continue later
+ if (actionRequired)
+ return true;
+ // Othereise, continue processing the stack
+ else
+ return executeOperationStack();
+}
+
+bool Guide::executeOneOperation(GuideState operation)
+{
+ bool actionRequired = false;
+
+ ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
+
+ int subBinX, subBinY;
+ targetChip->getBinning(&subBinX, &subBinY);
+
+ switch (operation)
+ {
+ case GUIDE_SUBFRAME:
+ {
+ // Do not subframe if we are capturing calibration frame
+ if (subFramed == false && Options::guideSubframeEnabled() == true && targetChip->canSubframe())
+ {
+ int minX, maxX, minY, maxY, minW, maxW, minH, maxH;//, fx,fy,fw,fh;
+ targetChip->getFrameMinMax(&minX, &maxX, &minY, &maxY, &minW, &maxW, &minH, &maxH);
+
+ int offset = boxSizeCombo->currentText().toInt()/subBinX;
+ //int x = guideView->getTrackingBox().x() + guideView->getTrackingBox().width()/2;
+ //int y = guideView->getTrackingBox().y() + guideView->getTrackingBox().height()/2;
+
+ int x = starCenter.x();
+ int y = starCenter.y();
+
+ x = (x - offset*2) * subBinX;
+ y = (y - offset*2) * subBinY;
+ int w=offset*4*subBinX;
+ int h=offset*4*subBinY;
+
+ if (x<minX)
+ x=minX;
+ if (y<minY)
+ y=minY;
+ if ((x+w)>maxW)
+ w=maxW-x;
+ if ((y+h)>maxH)
+ h=maxH-y;
+
+ targetChip->setFrame(x,y,w,h);
+
+ subFramed = true;
+ QVariantMap settings = frameSettings[targetChip];
+ settings["x"] = x;
+ settings["y"] = y;
+ settings["w"] = w;
+ settings["h"] = h;
+ settings["binx"] = subBinX;
+ settings["biny"] = subBinY;
+
+ frameSettings[targetChip] = settings;
+
+ starCenter.setX(w/(2*subBinX));
+ starCenter.setY(h/(2*subBinX));
+ }
+ else if (subFramed && Options::guideSubframeEnabled() == false)
+ {
+ targetChip->resetFrame();
+
+ int x,y,w,h;
+ targetChip->getFrame(&x,&y,&w, &h);
+
+ QVariantMap settings;
+ settings["x"] = x;
+ settings["y"] = y;
+ settings["w"] = w;
+ settings["h"] = h;
+ settings["binx"] = 1;
+ settings["biny"] = 1;
+ frameSettings[targetChip] = settings;
+
+ subFramed = false;
+
+ starCenter.setX(w/(2*subBinX));
+ starCenter.setY(h/(2*subBinX));
+
+ //starCenter.setX(0);
+ //starCenter.setY(0);
+ }
+ }
+ break;
+
+ case GUIDE_DARK:
+ {
+ // Do we need to take a dark frame?
+ if (Options::guideDarkFrameEnabled())
+ {
+ FITSData *darkData = NULL;
+ QVariantMap settings = frameSettings[targetChip];
+ uint16_t offsetX = settings["x"].toInt() / settings["binx"].toInt();
+ uint16_t offsetY = settings["y"].toInt() / settings["biny"].toInt();
+
+ darkData = DarkLibrary::Instance()->getDarkFrame(targetChip, exposureIN->value());
+
+ connect(DarkLibrary::Instance(), SIGNAL(darkFrameCompleted(bool)), this, SLOT(setCaptureComplete()));
+ connect(DarkLibrary::Instance(), SIGNAL(newLog(QString)), this, SLOT(appendLogText(QString)));
+
+ if (darkData)
+ {
+ DarkLibrary::Instance()->subtract(darkData, guideView, targetChip->getCaptureFilter(), offsetX, offsetY);
+ setCaptureComplete();
+ }
+ else
+ {
+ //if (calibration->useAutoStar() == false)
+ //KMessageBox::information(NULL, i18n("If the guide camera is not equipped with a shutter, cover the telescope or camera in order to take a dark exposure."), i18n("Dark Exposure"), "dark_exposure_dialog_notification");
+
+ DarkLibrary::Instance()->captureAndSubtract(targetChip, guideView, exposureIN->value(), offsetX, offsetY);
+ actionRequired = true;
+ }
+ }
+ }
+ break;
+
+ case GUIDE_STAR_SELECT:
+ {
+ state = GUIDE_STAR_SELECT;
+ emit newStatus(state);
+
+ if (Options::guideAutoStarEnabled())
+ {
+ bool autoStarCaptured = selectAutoStar();
+ if (autoStarCaptured)
+ {
+ appendLogText(i18n("Auto star selected."));
+ }
+ else
+ {
+ appendLogText(i18n("Failed to select an auto star."));
+ state = GUIDE_CALIBRATION_ERROR;
+ emit newStatus(state);
+ setBusy(false);
+ }
+ }
+ else
+ {
+ appendLogText(i18n("Select a guide star to calibrate."));
+ actionRequired = true;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return actionRequired;
+}
}
diff --git a/kstars/ekos/guide/guide.h b/kstars/ekos/guide/guide.h
index 2dda80a..ba58d95 100644
--- a/kstars/ekos/guide/guide.h
+++ b/kstars/ekos/guide/guide.h
@@ -37,6 +37,9 @@ namespace Ekos
class GuideInterface;
class OpsCalibration;
class OpsGuide;
+class InternalGuider;
+class PHD2;
+class LinGuider;
/**
*@class Guide
@@ -138,34 +141,28 @@ public:
/** DBUS interface function.
* Set guiding box size. The options must be set before starting the guiding operation. If no options are set, the options loaded from the user configuration are used.
- * @param boxSizeIndex box size index (0 to 4) for box size from 8 to 128 pixels. The box size should be suitable for the size of the guide star selected. The boxSize is also used to select the subframe size around the guide star. Default is 16 pixels
+ * @param index box size index (0 to 4) for box size from 8 to 128 pixels. The box size should be suitable for the size of the guide star selected. The boxSize is also used to select the subframe size around the guide star. Default is 16 pixels
*/
- Q_SCRIPTABLE Q_NOREPLY void setGuideBoxSizeIndex(int boxSizeIndex);
+ Q_SCRIPTABLE Q_NOREPLY void setGuideBoxSizeIndex(int index);
/** DBUS interface function.
* Set guiding algorithm. The options must be set before starting the guiding operation. If no options are set, the options loaded from the user configuration are used.
* @param algorithm Select the algorithm used to calculate the centroid of the guide star (Smart, Fast, Auto, No thresh).
*/
- Q_SCRIPTABLE Q_NOREPLY void setGuideAlgorithm(const QString & algorithm);
-
- /** DBUS interface function.
- * Set guiding options. The options must be set before starting the guiding operation. If no options are set, the options loaded from the user configuration are used.
- * @param enable if true, it will select a subframe around the guide star depending on the boxSize size.
- */
- Q_SCRIPTABLE Q_NOREPLY void setSubFrameEnabled(bool enable);
+ Q_SCRIPTABLE Q_NOREPLY void setGuideAlgorithm(const QString & algorithm);
/** DBUS interface function.
* Set rapid guiding option. The options must be set before starting the guiding operation. If no options are set, the options loaded from the user configuration are used.
* @param enable if true, it will activate RapidGuide in the CCD driver. When Rapid Guide is used, no frames are sent to Ekos for analysis and the centeroid calculations are done in the CCD driver.
*/
- Q_SCRIPTABLE Q_NOREPLY void setGuideRapidEnabled(bool enable);
+ //Q_SCRIPTABLE Q_NOREPLY void setGuideRapidEnabled(bool enable);
/** DBUS interface function.
- * Enable or disables dithering
+ * Enable or disables dithering. Set dither range
* @param enable if true, dithering is enabled and is performed after each exposure is complete. Otheriese, dithering is disabled.
* @param value dithering range in pixels. Ekos will move the guide star in a random direction for the specified dithering value in pixels.
*/
- Q_SCRIPTABLE Q_NOREPLY void setDither(bool enable, double value);
+ Q_SCRIPTABLE Q_NOREPLY void setDitherSettings(bool enable, double value);
/** DBUS interface function.
@@ -208,8 +205,8 @@ public:
void setTrackingBoxSize(int index) { boxSizeCombo->setCurrentIndex(index); }
int getTrackingBoxSize() { return boxSizeCombo->currentText().toInt(); }
- void startRapidGuide();
- void stopRapidGuide();
+ //void startRapidGuide();
+ //void stopRapidGuide();
GuideInterface * getGuider() { return guider;}
@@ -233,13 +230,25 @@ public slots:
*/
Q_SCRIPTABLE bool calibrate();
- /** BUS interface function.
+ /** DBUS interface function.
* @brief dither Starts dithering process in a random direction restricted by the number of pixels specified in dither options
* @return True if dither started successfully, false otherwise.
*/
Q_SCRIPTABLE bool dither();
/** DBUS interface function.
+ * @brief suspend Suspend autoguiding
+ * @return True if successful, false otherwise.
+ */
+ Q_SCRIPTABLE bool suspend();
+
+ /** DBUS interface function.
+ * @brief resume Resume autoguiding
+ * @return True if successful, false otherwise.
+ */
+ Q_SCRIPTABLE bool resume();
+
+ /** DBUS interface function.
* Capture a guide frame
* @return Returns true if capture command is sent successfully to INDI server.
*/
@@ -251,6 +260,17 @@ public slots:
*/
Q_SCRIPTABLE bool selectAutoStar();
+ /** DBUS interface function.
+ * Set guiding options. The options must be set before starting the guiding operation. If no options are set, the options loaded from the user configuration are used.
+ * @param enable if true, it will select a subframe around the guide star depending on the boxSize size.
+ */
+ Q_SCRIPTABLE Q_NOREPLY void setSubFrameEnabled(bool enable);
+
+ /** DBUS interface function.
+ * @brief startAutoCalibrateGuide Start calibration with auto star selected followed immediately by guiding.
+ */
+ Q_SCRIPTABLE Q_NOREPLY void startAutoCalibrateGuide();
+
/**
* @brief checkCCD Check all CCD parameters and ensure all variables are updated to reflect the selected CCD
* @param ccdNum CCD index number in the CCD selection combo box
@@ -274,7 +294,7 @@ public slots:
* @brief setST4 Sets a new ST4 device from the combobox index
* @param index Index of selected ST4 in the combobox
*/
- void setST4(int index);
+ void setST4(int index);
/**
* @brief processRapidStarData is called by INDI framework when we receive new Rapid Guide data
@@ -283,13 +303,7 @@ public slots:
* @param dy Deviation in Y
* @param fit fitting score
*/
- void processRapidStarData(ISD::CCDChip *targetChip, double dx, double dy, double fit);
-
- // Auto Calibration Guiding (Cablirate first then start guiding immediately)
- void startAutoCalibrateGuiding();
- void checkAutoCalibrateGuiding(Ekos::GuideState state);
-
- void setSuspended(bool enable);
+ //void processRapidStarData(ISD::CCDChip *targetChip, double dx, double dy, double fit);
// Append Log entry
void appendLogText(const QString &);
@@ -334,7 +348,10 @@ protected slots:
void updateTrackingBoxSize(int currentIndex);
// Display guide information when hovering over the drift graph
- void mouseOverLine(QMouseEvent *event);
+ void driftMouseOverLine(QMouseEvent *event);
+
+ // Reset graph if right clicked
+ void driftMouseClicked(QMouseEvent *event);
//void onXscaleChanged( int i );
//void onYscaleChanged( int i );
@@ -343,7 +360,8 @@ protected slots:
void onEnableDirRA( bool enable );
void onEnableDirDEC( bool enable );
void onInputParamChanged();
- void onRapidGuideChanged(bool enable);
+
+ //void onRapidGuideChanged(bool enable);
void setAxisDelta(double ra, double de);
void setAxisSigma(double ra, double de);
@@ -391,6 +409,13 @@ private:
*/
void setBusy(bool enable);
+ void buildOperationStack(GuideState operation);
+ bool executeOperationStack();
+ bool executeOneOperation(GuideState operation);
+
+ bool captureOneFrame();
+
+
void refreshColorScheme();
// Devices
@@ -415,7 +440,7 @@ private:
double ccdPixelSizeX, ccdPixelSizeY, mountAperture, mountFocalLength, guideDeviationRA, guideDeviationDEC, pixScaleX, pixScaleY;
// Rapid Guide
- bool rapidGuideReticleSet;
+ //bool rapidGuideReticleSet;
// State
GuideState state;
@@ -445,6 +470,26 @@ private:
// Auto star operation
bool autoStarCaptured;
+ // Was the modified frame subFramed?
+ bool subFramed;
+
+ // Operation stack
+ QStack<GuideState> operationStack;
+
+ // CCD Chip frame settings
+ QMap<ISD::CCDChip *, QVariantMap> frameSettings;
+
+ // Profile Pixmap
+ QPixmap profilePixmap;
+
+ // Flag to start auto calibration followed immediately by guiding
+ bool autoCalibrateGuide;
+
+ // Pointers of guider processes
+ QPointer<InternalGuider> internalGuider;
+ // TODO implement those
+ //QPointer<PHD2> phd2Guider;
+ //QPointer<LinGuider> linGuider;
};
}
diff --git a/kstars/ekos/guide/guide.ui b/kstars/ekos/guide/guide.ui
index e4d3c1b..760ad59 100644
--- a/kstars/ekos/guide/guide.ui
+++ b/kstars/ekos/guide/guide.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>686</width>
- <height>505</height>
+ <width>681</width>
+ <height>486</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
@@ -755,7 +755,7 @@
<string>East Direction Guiding</string>
</property>
<property name="text">
- <string>E</string>
+ <string>+</string>
</property>
</widget>
</item>
@@ -765,7 +765,7 @@
<string>West Direction Guiding</string>
</property>
<property name="text">
- <string>W</string>
+ <string>-</string>
</property>
</widget>
</item>
@@ -795,7 +795,7 @@
<string>North Direction Guiding</string>
</property>
<property name="text">
- <string>N</string>
+ <string>+</string>
</property>
</widget>
</item>
@@ -805,7 +805,7 @@
<string>South Direction Guiding</string>
</property>
<property name="text">
- <string>S</string>
+ <string>-</string>
</property>
</widget>
</item>
diff --git a/kstars/ekos/guide/internalguide/common.cpp b/kstars/ekos/guide/internalguide/common.cpp
deleted file mode 100644
index cf6fcb8..0000000
--- a/kstars/ekos/guide/internalguide/common.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Ekos guide tool
- Copyright (C) 2012 Andrew Stepanenko
-
- Modified by Jasem Mutlaq <mutlaqja@ikarustech.com> for KStars.
-
- This application is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
- */
-
-#include "common.h"
-
-#include <QMessageBox>
-#include <sys/types.h>
-
-
diff --git a/kstars/ekos/guide/internalguide/common.h b/kstars/ekos/guide/internalguide/common.h
deleted file mode 100644
index 0e4496e..0000000
--- a/kstars/ekos/guide/internalguide/common.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Ekos guide tool
- Copyright (C) 2012 Andrew Stepanenko
-
- Modified by Jasem Mutlaq <mutlaqja@ikarustech.com> for KStars.
-
- This application is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
- */
-
-
-#ifndef COMMON_H_
-#define COMMON_H_
-
-#include <QPainter>
-#include <QMouseEvent>
-#include <QWidget>
-
-#include "../indi/indicommon.h"
-
-
-
-struct guide_dir_desc
-{
- GuideDirection dir;
- const char desc[10];
-};
-
-
-
-
-
-#endif /* COMMON_H_ */
diff --git a/kstars/ekos/guide/internalguide/gmath.cpp b/kstars/ekos/guide/internalguide/gmath.cpp
index b4752ad..5f9d727 100644
--- a/kstars/ekos/guide/internalguide/gmath.cpp
+++ b/kstars/ekos/guide/internalguide/gmath.cpp
@@ -812,6 +812,18 @@ void cgmath::process_axes( void )
in_params.max_pulse_length[0] = Options::rAMaximumPulse();
in_params.max_pulse_length[1] = Options::dECMaximumPulse();
+ // RA W/E enable
+ // East RA+ enabled?
+ in_params.enabled_axis1[0] = Options::eastRAGuideEnabled();
+ // West RA- enabled?
+ in_params.enabled_axis2[0] = Options::westRAGuideEnabled();
+
+ // DEC N/S enable
+ // North DEC+ enabled?
+ in_params.enabled_axis1[1] = Options::northDECGuideEnabled();
+ // South DEC- enabled?
+ in_params.enabled_axis2[1] = Options::southDECGuideEnabled();
+
// process axes...
for( int k = GUIDE_RA;k <= GUIDE_DEC;k++ )
{
@@ -859,9 +871,11 @@ void cgmath::process_axes( void )
qDebug() << "Guide: pulse_length [" << k << "]= " << out_params.pulse_length[k];
// calc direction
- if( !in_params.enabled[k] )
+ // We do not send pulse if direction is disabled completely, or if direction in a specific axis (e.g. N or S) is disabled
+ if ( !in_params.enabled[k] || (out_params.delta[k] > 0 && !in_params.enabled_axis1[k]) || (out_params.delta[k] < 0 && !in_params.enabled_axis2[k]))
{
out_params.pulse_dir[k] = NO_DIR;
+ out_params.pulse_length[k] = 0;
continue;
}
diff --git a/kstars/ekos/guide/internalguide/gmath.h b/kstars/ekos/guide/internalguide/gmath.h
index ba19038..7fb09d4 100644
--- a/kstars/ekos/guide/internalguide/gmath.h
+++ b/kstars/ekos/guide/internalguide/gmath.h
@@ -20,10 +20,10 @@
#include <QPointer>
#include "fitsviewer/fitsview.h"
+#include "indi/indicommon.h"
#include "vect.h"
#include "matr.h"
-#include "common.h"
typedef struct
{
@@ -68,6 +68,8 @@ public:
int threshold_alg_idx;
double guiding_rate;
bool enabled[CHANNEL_CNT];
+ bool enabled_axis1[CHANNEL_CNT];
+ bool enabled_axis2[CHANNEL_CNT];
bool average;
uint32_t accum_frame_cnt[CHANNEL_CNT];
double proportional_gain[CHANNEL_CNT];
diff --git a/kstars/ekos/guide/internalguide/internalguider.cpp b/kstars/ekos/guide/internalguide/internalguider.cpp
index 1ce942f..2db5283 100644
--- a/kstars/ekos/guide/internalguide/internalguider.cpp
+++ b/kstars/ekos/guide/internalguide/internalguider.cpp
@@ -19,6 +19,7 @@
#include "Options.h"
+#define MAX_DITHER_RETIRES 20
namespace Ekos
{
@@ -44,11 +45,6 @@ InternalGuider::InternalGuider()
end_x1 = end_y1 = 0;
start_x2 = start_y2 = 0;
end_x2 = end_y2 = 0;
-
- idleColor.setRgb(200,200,200);
- okColor = Qt::green;
- busyColor = Qt::yellow;
- alertColor = Qt::red;
}
InternalGuider::~InternalGuider()
@@ -57,24 +53,8 @@ InternalGuider::~InternalGuider()
bool InternalGuider::guide()
{
-#if 0
- Options::setUseDither(ui.ditherCheck->isChecked());
- Options::setDitherPixels(ui.ditherPixels->value());
- Options::setAOLimit(ui.spinBox_AOLimit->value());
- Options::setGuidingRate(ui.spinBox_GuideRate->value());
- Options::setEnableRAGuide(ui.checkBox_DirRA->isChecked());
- Options::setEnableDECGuide(ui.checkBox_DirDEC->isChecked());
- Options::setRAPropotionalGain(ui.spinBox_PropGainRA->value());
- Options::setDECPropotionalGain(ui.spinBox_PropGainDEC->value());
- Options::setRAIntegralGain(ui.spinBox_IntGainRA->value());
- Options::setDECIntegralGain(ui.spinBox_IntGainDEC->value());
- Options::setRADerivativeGain(ui.spinBox_DerGainRA->value());
- Options::setDECDerivativeGain(ui.spinBox_DerGainDEC->value());
- Options::setRAMaximumPulse(ui.spinBox_MaxPulseRA->value());
- Options::setDECMaximumPulse(ui.spinBox_MaxPulseDEC->value());
- Options::setRAMinimumPulse(ui.spinBox_MinPulseRA->value());
- Options::setDECMinimumPulse(ui.spinBox_MinPulseDEC->value());
-#endif
+ if (state == GUIDE_SUSPENDED)
+ return true;
if (state >= GUIDE_GUIDING)
{
@@ -82,53 +62,22 @@ bool InternalGuider::guide()
}
guideFrame->disconnect(this);
- //disconnect(guideFrame, SIGNAL(trackingStarSelected(int,int)), 0, 0);
- // Let everyone know about dither option status
- //emit ditherToggled(ui.ditherCheck->isChecked());
-
-#if 0
- if (phd2)
- {
- phd2->startGuiding();
-
- m_isStarted = true;
- m_useRapidGuide = ui.rapidGuideCheck->isChecked();
-
- //pmain_wnd->setSuspended(false);
-
- ui.pushButton_StartStop->setText( i18n("Stop") );
- guideModule->appendLogText(i18n("Autoguiding started."));
-
- return true;
- }
+ logFile.open(QIODevice::WriteOnly | QIODevice::Text);
+ QTextStream out(&logFile);
-#endif
-
- //logFile.open(QIODevice::WriteOnly | QIODevice::Text);
- //QTextStream out(&logFile);
-
- /* FIXME Have to re-enable guide logging file
-
- out << "Guiding rate,x15 arcsec/sec: " << ui.spinBox_GuideRate->value() << endl;
- out << "Focal,mm: " << ui.l_Focal->text() << endl;
- out << "Aperture,mm: " << ui.l_Aperture->text() << endl;
- out << "F/D: " << ui.l_FbyD->text() << endl;
- out << "FOV: " << ui.l_FOV->text() << endl;
+ out << "Guiding rate,x15 arcsec/sec: " << Options::guidingRate() << endl;
+ out << "Focal,mm: " << mountFocalLength << endl;
+ out << "Aperture,mm: " << mountAperture << endl;
+ out << "F/D: " << mountFocalLength/mountAperture << endl;
out << "Frame #, Time Elapsed (ms), RA Error (arcsec), RA Correction (ms), RA Correction Direction, DEC Error (arcsec), DEC Correction (ms), DEC Correction Direction" << endl;
- */
-
- //drift_graph->reset_data();
- //ui.pushButton_StartStop->setText( i18n("Stop") );
-
- //guideModule->appendLogText(i18n("Autoguiding started."));
-
pmath->start();
+ pmath->setLogFile(&logFile);
m_lostStarTries=0;
- // FIXME
+ // TODO re-enable rapid check later on
#if 0
m_isStarted = true;
m_useRapidGuide = ui.rapidGuideCheck->isChecked();
@@ -148,8 +97,6 @@ bool InternalGuider::guide()
#endif
- //pmath->setLogFile(&logFile);
-
isFirstFrame = true;
state = GUIDE_GUIDING;
@@ -176,17 +123,107 @@ bool InternalGuider::abort()
bool InternalGuider::suspend()
{
-return false;
+ state = GUIDE_SUSPENDED;
+ emit newStatus(state);
+
+ pmath->suspend(true);
+
+ return true;
}
bool InternalGuider::resume()
{
-return false;
+ state = GUIDE_GUIDING;
+ emit newStatus(state);
+
+ pmath->suspend(false);
+
+ emit frameCaptureRequested();
+
+ return true;
}
bool InternalGuider::dither(double pixels)
{
-return false;
+ static Vector target_pos;
+ static unsigned int retries=0;
+
+ //if (ui.ditherCheck->isChecked() == false)
+ //return false;
+
+ double cur_x, cur_y, ret_angle;
+ pmath->getReticleParameters(&cur_x, &cur_y, &ret_angle);
+ pmath->getStarScreenPosition( &cur_x, &cur_y );
+ Matrix ROT_Z = pmath->getROTZ();
+
+ //qDebug() << "Star Pos X " << cur_x << " Y " << cur_y;
+
+ if (state != GUIDE_DITHERING)
+ {
+ retries =0;
+
+ // JM 2016-05-8: CCD would abort if required.
+ //targetChip->abortExposure();
+
+ int polarity = (rand() %2 == 0) ? 1 : -1;
+ double angle = ((double) rand() / RAND_MAX) * M_PI/2.0;
+ double diff_x = pixels * cos(angle);
+ double diff_y = pixels * sin(angle);
+
+ if (pmath->declinationSwapEnabled())
+ diff_y *= -1;
+
+ if (polarity > 0)
+ target_pos = Vector( cur_x, cur_y, 0 ) + Vector( diff_x, diff_y, 0 );
+ else
+ target_pos = Vector( cur_x, cur_y, 0 ) - Vector( diff_x, diff_y, 0 );
+
+ if (Options::guideLogging())
+ qDebug() << "Guide: Dithering process started.. Reticle Target Pos X " << target_pos.x << " Y " << target_pos.y;
+
+ pmath->setReticleParameters(target_pos.x, target_pos.y, ret_angle);
+
+ state = GUIDE_DITHERING;
+ emit newStatus(state);
+
+ processGuiding();
+
+ return true;
+ }
+
+ Vector star_pos = Vector( cur_x, cur_y, 0 ) - Vector( target_pos.x, target_pos.y, 0 );
+ star_pos.y = -star_pos.y;
+ star_pos = star_pos * ROT_Z;
+
+ if (Options::guideLogging())
+ qDebug() << "Guide: Dithering in progress. Diff star X:" << star_pos.x << "Y:" << star_pos.y;
+
+ if (fabs(star_pos.x) < 1 && fabs(star_pos.y) < 1)
+ {
+ pmath->setReticleParameters(cur_x, cur_y, ret_angle);
+
+ // Back to guiding
+ state = GUIDE_GUIDING;
+
+ if (Options::guideLogging())
+ qDebug() << "Guide: Dither complete.";
+
+ //emit ditherComplete();
+ emit newStatus(Ekos::GUIDE_DITHERING_SUCCESS);
+ }
+ else
+ {
+ if (++retries > MAX_DITHER_RETIRES)
+ {
+ emit newStatus(Ekos::GUIDE_DITHERING_ERROR);
+ abort();
+ return false;
+ }
+
+ processGuiding();
+ }
+
+ return true;
}
bool InternalGuider::calibrate()
@@ -222,45 +259,18 @@ bool InternalGuider::calibrate()
emit newStatus(GUIDE_CALIBRATING);
}
- // Capture final image
-
- // FIXME check how to do manual
- // and fucking document it
- /*
- if (calibrationType == CAL_MANUAL && calibrationStage == CAL_START)
- {
- calibrationStage = CAL_CAPTURE_IMAGE;
- emit frameCaptureRequested();
- return;
- }*/
-
-
-
- //startCalibration();
-
-
- /*if (guideModule->isGuiding())
- {
- guideModule->appendLogText(i18n("Cannot calibrate while autoguiding is active."));
- return false;
- }*/
-
if (calibrationStage > CAL_START)
{
- //abort();
processCalibration();
return true;
}
- //disconnect(guideFrame, SIGNAL(trackingStarSelected(int,int)), this, SLOT(trackingStarSelected(int, int)));
guideFrame->disconnect(this);
// Must reset dec swap before we run any calibration procedure!
-
emit DESwapChanged(false);
pmath->setDeclinationSwapEnabled(false);
pmath->setLostStar(false);
- //pmain_wnd->capture();
calibrationStage = CAL_START;
@@ -270,43 +280,18 @@ bool InternalGuider::calibrate()
if( Options::twoAxisEnabled() )
calibrateRADECRecticle(false);
else
- // Just RA
+ // Just RA
calibrateRADECRecticle(true);
return true;
}
-bool InternalGuider::stopCalibration()
-{
- if (!pmath)
- return false;
-
- calibrationStage = CAL_ERROR;
-
- emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR);
-
- reset();
-
- return true;
-}
-
-bool InternalGuider::startCalibration()
-{
-return true;
-}
-
void InternalGuider::processCalibration()
-{
- //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();
@@ -331,45 +316,22 @@ void InternalGuider::processCalibration()
}
}
-/*bool InternalGuider::isCalibrating()
-{
- if (calibrationStage >= CAL_START)
- return true;
-
- return false;
-}*/
-
void InternalGuider::setGuideView(FITSView *guideView)
{
guideFrame = guideView;
pmath->setGuideView(guideFrame);
-
- //connect(guideFrame, SIGNAL(trackingStarSelected(int,int)), this, SLOT(trackingStarSelected(int, int)), Qt::UniqueConnection);
}
void InternalGuider::reset()
{
- //FIXME
-
- //is_started = false;
state = GUIDE_IDLE;
//calibrationStage = CAL_IDLE;
connect(guideFrame, SIGNAL(trackingStarSelected(int,int)), this, SLOT(trackingStarSelected(int, int)), Qt::UniqueConnection);
-
-#if 0
- is_started = false;
- ui.pushButton_StartCalibration->setText( i18n("Start") );
- ui.startCalibrationLED->setColor(idleColor);
- ui.progressBar->setVisible(false);
- connect(pmath->getImageView(), SIGNAL(trackingStarSelected(int,int)), this, SLOT(trackingStarSelected(int, int)), Qt::UniqueConnection);
-
-#endif
}
void InternalGuider::calibrateRADECRecticle( bool ra_only )
{
-
bool auto_term_ok = false;
Q_ASSERT(pmath);
@@ -395,7 +357,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_only )
turn_back_time = auto_drift_time*6;
iterations = 0;
- emit newLog(i18n("GUIDE_RA drifting forward..."));
+ emit newLog(i18n("RA drifting forward..."));
pmath->getReticleParameters(&start_x1, &start_y1, NULL);
@@ -443,7 +405,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_only )
phi = pmath->calculatePhi( start_x1, start_y1, end_x1, end_y1 );
ROT_Z = RotateZ( -M_PI*phi/180.0 ); // derotates...
- emit newLog(i18n("GUIDE_RA drifting reverse..."));
+ emit newLog(i18n("RA drifting reverse..."));
}
@@ -490,7 +452,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_only )
emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR);
- emit newLog(i18np("GUIDE_RA: Scope cannot reach the start point after %1 iteration. Possible mount or drive problems...", "GUIDE_RA: Scope cannot reach the start point after %1 iterations. Possible mount or drive problems...", turn_back_time));
+ emit newLog(i18np("Guide RA: Scope cannot reach the start point after %1 iteration. Possible mount or drive problems...", "GUIDE_RA: Scope cannot reach the start point after %1 iterations. Possible mount or drive problems...", turn_back_time));
KNotification::event( QLatin1String( "CalibrationFailed" ) , i18n("Guiding calibration failed with errors"));
reset();
@@ -518,8 +480,8 @@ void InternalGuider::calibrateRADECRecticle( bool ra_only )
}
iterations++;
- dec_iterations = 1;
- emit newLog(i18n("GUIDE_DEC drifting forward..."));
+ dec_iterations = 1;
+ emit newLog(i18n("DEC drifting forward..."));
break;
}
// calc orientation
@@ -530,13 +492,11 @@ void InternalGuider::calibrateRADECRecticle( bool ra_only )
// FIXME what is this for?
//fillInterface();
- emit newLog(i18n("Calibration completed."));
-
emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS);
KNotification::event( QLatin1String( "CalibrationSuccessful" ) , i18n("Guiding calibration completed successfully"));
//if (ui.autoStarCheck->isChecked())
- //guideModule->selectAutoStar();
+ //guideModule->selectAutoStar();
}
else
{
@@ -584,7 +544,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_only )
phi = pmath->calculatePhi( start_x2, start_y2, end_x2, end_y2 );
ROT_Z = RotateZ( -M_PI*phi/180.0 ); // derotates...
- emit newLog(i18n("GUIDE_DEC drifting reverse..."));
+ emit newLog(i18n("DEC drifting reverse..."));
}
//----- Z-check (new!) -----
@@ -636,7 +596,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_only )
emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR);
- emit newLog(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.\nPossible mount or drive problems...", turn_back_time));
+ emit newLog(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.\nPossible mount or drive problems...", turn_back_time));
KNotification::event( QLatin1String( "CalibrationFailed" ) , i18n("Guiding calibration failed with errors"));
reset();
@@ -650,11 +610,9 @@ void InternalGuider::calibrateRADECRecticle( bool ra_only )
calibrationStage = CAL_IDLE;
//fillInterface();
if (swap_dec)
- emit newLog(i18n("DEC swap enabled."));
+ emit newLog(i18n("DEC swap enabled."));
else
- emit newLog(i18n("DEC swap disabled."));
-
- emit newLog(i18n("Calibration completed."));
+ emit newLog(i18n("DEC swap disabled."));
emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS);
@@ -663,7 +621,7 @@ void InternalGuider::calibrateRADECRecticle( bool ra_only )
KNotification::event( QLatin1String( "CalibrationSuccessful" ) , i18n("Guiding calibration completed successfully"));
//if (ui.autoStarCheck->isChecked())
- //guideModule->selectAutoStar();
+ //guideModule->selectAutoStar();
}
else
@@ -714,120 +672,16 @@ void InternalGuider::trackingStarSelected(int x, int y)
//ui.pushButton_StartCalibration->setEnabled(true);
- QVector3D starCenter; // = guideModule->getStarPosition();
+ /*QVector3D starCenter;
starCenter.setX(x);
- starCenter.setY(y);
- emit newStarPosition(starCenter, true);
+ starCenter.setY(y);
+ emit newStarPosition(starCenter, true);*/
//if (ui.autoStarCheck->isChecked())
- if (Options::autoStarEnabled())
- calibrate();
-}
-
-#if 0
-void InternalGuider::capture()
-{
- /*
- if (isCalibrating())
- stopCalibration();
-
- calibrationStage = CAL_CAPTURE_IMAGE;
-
- if (guideModule->capture())
- {
- ui.captureLED->setColor(busyColor);
- guideModule->appendLogText(i18n("Capturing image..."));
- }
- else
- {
- ui.captureLED->setColor(alertColor);
- calibrationStage = CAL_ERROR;
- emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR);
- }
- */
-}
-#endif
-
-//FIXME
-#if 0
-bool InternalGuider::setImageView(FITSView *image)
-{
- guideFrame = image;
-
- switch (calibrationStage)
- {
- case CAL_CAPTURE_IMAGE:
- case CAL_SELECT_STAR:
- {
- guideModule->appendLogText(i18n("Image captured..."));
-
- ui.captureLED->setColor(okColor);
- calibrationStage = CAL_SELECT_STAR;
- ui.selectStarLED->setColor(busyColor);
-
- FITSData *image_data = guideFrame->getImageData();
-
- setVideoParams(image_data->getWidth(), image_data->getHeight());
-
- if (ui.autoStarCheck->isChecked())
- {
- bool rc = guideModule->selectAutoStar();
-
- if (rc == false)
- {
- guideModule->appendLogText(i18n("Failed to automatically select a guide star. Please select a guide star..."));
- connect(guideFrame, SIGNAL(trackingStarSelected(int,int)), this, SLOT(trackingStarSelected(int, int)), Qt::UniqueConnection);
- return true;
- }
- else
- trackingStarSelected(guideModule->getStarPosition().x(), guideModule->getStarPosition().y());
- return false;
- }
- else
- {
- connect(guideFrame, SIGNAL(trackingStarSelected(int,int)), this, SLOT(trackingStarSelected(int, int)), Qt::UniqueConnection);
- }
- }
- break;
-
- default:
- break;
- }
-
- return true;
-}
-#endif
-
-//FIXME
-
-#if 0
-void InternalGuider::setCalibrationTwoAxis(bool enable)
-{
- ui.twoAxisCheck->setChecked(enable);
-}
-
-void InternalGuider::setCalibrationAutoStar(bool enable)
-{
- ui.autoStarCheck->setChecked(enable);
-}
-
-void InternalGuider::setCalibrationAutoSquareSize(bool enable)
-{
- ui.autoSquareSizeCheck->setChecked(enable);
-}
-
-void InternalGuider::setCalibrationPulseDuration(int pulseDuration)
-{
- ui.spinBox_Pulse->setValue(pulseDuration);
-}
-
-void InternalGuider::toggleAutoSquareSize(bool enable)
-{
- ui.autoSquareSizeCheck->setEnabled(enable);
+ //if (Options::autoStarEnabled())
+ //calibrate();
}
-#endif
-
void InternalGuider::setDECSwap(bool enable)
{
pmath->setDeclinationSwapEnabled(enable);
@@ -883,28 +737,6 @@ bool InternalGuider::processGuiding()
uint32_t tick = 0;
double drift_x = 0, drift_y = 0;
- /*Q_ASSERT( pmath );
-
- if (first_subframe)
- {
- first_subframe = false;
- return;
- }
- else if (first_frame)
- {
- if (m_isDithering == false)
- {
- Vector star_pos = pmath->findLocalStarPosition();
- pmath->setReticleParameters(star_pos.x, star_pos.y, -1);
-
-
- //pmath->moveSquare( round(star_pos.x) - (double)square_size/(2*binx), round(star_pos.y) - (double)square_size/(2*biny) );
-
- }
- first_frame=false;
- }
- */
-
// On first frame, center the box (reticle) around the star so we do not start with an offset the results in
// unnecessary guiding pulses.
if (isFirstFrame)
@@ -920,9 +752,6 @@ bool InternalGuider::processGuiding()
// calc math. it tracks square
pmath->performProcessing();
- //if(!m_isStarted )
- //return true;
-
if (pmath->isStarLost() && ++m_lostStarTries > 2)
{
emit newLog(i18n("Lost track of the guide star. Try increasing the square size and check the mount."));
@@ -952,14 +781,9 @@ bool InternalGuider::processGuiding()
emit frameCaptureRequested();
- //if (m_isDithering)
if (state == GUIDE_DITHERING)
return true;
- //pmath->getStarDrift( &drift_x, &drift_y );
-
- //drift_graph->add_point( drift_x, drift_y );
-
tick = pmath->getTicks();
if( tick & 1 )
@@ -967,30 +791,18 @@ bool InternalGuider::processGuiding()
// draw some params in window
emit newAxisDelta(out->delta[GUIDE_RA], out->delta[GUIDE_DEC]);
- //ui.l_DeltaRA->setText(str.setNum(out->delta[GUIDE_RA], 'f', 2) );
- //ui.l_DeltaDEC->setText(str.setNum(out->delta[GUIDE_DEC], 'f', 2) );
-
emit newAxisPulse(out->pulse_length[GUIDE_RA], out->pulse_length[GUIDE_DEC]);
- //ui.l_PulseRA->setText(str.setNum(out->pulse_length[GUIDE_RA]) );
- //ui.l_PulseDEC->setText(str.setNum(out->pulse_length[GUIDE_DEC]) );
-
- //ui.l_ErrRA->setText( str.setNum(out->sigma[GUIDE_RA], 'g', 3));
- //ui.l_ErrDEC->setText( str.setNum(out->sigma[GUIDE_DEC], 'g', 3 ));
-
emit newAxisSigma(out->sigma[GUIDE_RA], out->sigma[GUIDE_DEC]);
}
// skip half frames
//if( half_refresh_rate && (tick & 1) )
- //return;
+ //return;
//drift_graph->on_paint();
//pDriftOut->update();
- //profilePixmap = pDriftOut->grab(QRect(QPoint(0, 100), QSize(pDriftOut->width(), 101)));
- //emit newProfilePixmap(profilePixmap);
-
return true;
}
diff --git a/kstars/ekos/guide/internalguide/internalguider.h b/kstars/ekos/guide/internalguide/internalguider.h
index 74e31db..c5149ef 100644
--- a/kstars/ekos/guide/internalguide/internalguider.h
+++ b/kstars/ekos/guide/internalguide/internalguider.h
@@ -103,8 +103,7 @@ protected slots:
void trackingStarSelected(int x, int y);
-signals:
- void newProfilePixmap(QPixmap &);
+signals:
void newPulse( GuideDirection ra_dir, int ra_msecs, GuideDirection dec_dir, int dec_msecs );
void newPulse( GuideDirection dir, int msecs );
void DESwapChanged(bool enable);
@@ -131,23 +130,10 @@ private:
double ret_x, ret_y, ret_angle;
bool m_isDithering;
- QFile logFile;
- QPixmap profilePixmap;
-
-
- // IMPORTED FROM R_CALIBRATION - CLEAN UP
- //void fillInterface( void );
-
-
- bool startCalibration();
- bool stopCalibration();
-
-
+ QFile logFile;
void reset();
- //bool is_started;
-
int axis;
int auto_drift_time;
int turn_back_time;
@@ -157,9 +143,7 @@ private:
double end_x2, end_y2;
int iterations, dec_iterations;
double phi;
- Matrix ROT_Z;
-
- QColor idleColor, okColor, busyColor, alertColor;
+ Matrix ROT_Z;
CalibrationStage calibrationStage;
CalibrationType calibrationType;
diff --git a/kstars/ekos/guide/opscalibration.ui b/kstars/ekos/guide/opscalibration.ui
index ba6a570..74b18d1 100644
--- a/kstars/ekos/guide/opscalibration.ui
+++ b/kstars/ekos/guide/opscalibration.ui
@@ -78,7 +78,7 @@
</widget>
</item>
<item>
- <widget class="QCheckBox" name="kcfg_AutoStarEnabled">
+ <widget class="QCheckBox" name="kcfg_GuideAutoStarEnabled">
<property name="toolTip">
<string>Automatically select the calibration star.</string>
</property>
@@ -91,7 +91,7 @@
</widget>
</item>
<item>
- <widget class="QCheckBox" name="kcfg_AutoSquareSizeEnabled">
+ <widget class="QCheckBox" name="kcfg_GuideAutoSquareSizeEnabled">
<property name="enabled">
<bool>false</bool>
</property>
diff --git a/kstars/ekos/guide/opsguide.ui b/kstars/ekos/guide/opsguide.ui
index 0f319f5..c7fbbbf 100644
--- a/kstars/ekos/guide/opsguide.ui
+++ b/kstars/ekos/guide/opsguide.ui
@@ -150,6 +150,9 @@
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="kcfg_RapidGuideEnabled">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Rapid Guide</string>
</property>
diff --git a/kstars/ekos/guide/scroll_graph.cpp b/kstars/ekos/guide/scroll_graph.cpp
deleted file mode 100644
index a9068a6..0000000
--- a/kstars/ekos/guide/scroll_graph.cpp
+++ /dev/null
@@ -1,412 +0,0 @@
-/* Ekos guide tool
- Copyright (C) 2012 Andrew Stepanenko
-
- Modified by Jasem Mutlaq <mutlaqja@ikarustech.com> for KStars.
-
- This application is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
- */
-
-#include <QtGui>
-#include <QWidget>
-
-#include "scroll_graph.h"
-//#include "common.h"
-#include "kstars.h"
-#include "kstarsdata.h"
-#include "colorscheme.h"
-
-// define some colors
-const uint8_t DEF_BKGD_COLOR[3] = {0, 0, 0};
-const uint8_t DEF_RA_COLOR[3] = {0, 255, 0};
-const uint8_t DEF_DEC_COLOR[3] = {0, 165, 255};
-const uint8_t DEF_GRID_COLOR[3] = {128, 128, 128};
-const uint8_t DEF_WHITE_COLOR[3] = {255, 255, 255};
-const uint8_t DEF_GRID_FONT_COLOR[3] = {0, 255, 128};
-
-const uint8_t DEF_SQR_OVL_COLOR[3] = {0, 255, 0};
-
-ScrollGraph::ScrollGraph(QWidget *parent) : QWidget(parent)
-{
- grid_N = 6;
-
- RAEnabled=DEEnabled=true;
-
- data_cnt = 10*grid_N*10;
- data.line[ RA_LINE ] = new double[ data_cnt ];
- data.line[ DEC_LINE ] = new double[ data_cnt ];
- resetData();
-
- //graphics...
- pen.setStyle( Qt::SolidLine );
- pen.setWidth(1);
- brush.setStyle(Qt::SolidPattern);
-
- RA_COLOR = QColor(KStars::Instance()->data()->colorScheme()->colorNamed( "RAGuideError" ));
- DEC_COLOR = QColor(KStars::Instance()->data()->colorScheme()->colorNamed( "DEGuideError" ));
- GRID_COLOR = QColor( DEF_GRID_COLOR[0], DEF_GRID_COLOR[1], DEF_GRID_COLOR[2] );
- BKGD_COLOR = QColor( DEF_BKGD_COLOR[0], DEF_BKGD_COLOR[1], DEF_BKGD_COLOR[2] );
- WHITE_COLOR = QColor( DEF_WHITE_COLOR[0], DEF_WHITE_COLOR[1], DEF_WHITE_COLOR[2] );
- GRID_FONT_COLOR = QColor( DEF_GRID_FONT_COLOR[0], DEF_GRID_FONT_COLOR[1], DEF_GRID_FONT_COLOR[2] );
- brush.setColor( BKGD_COLOR );
-
-}
-
-ScrollGraph::~ScrollGraph()
-{
- delete [] data.line[ RA_LINE ];
- delete [] data.line[ DEC_LINE ];
-}
-
-void ScrollGraph::setSize(int w, int h)
-{
- client_rect_wd = w;
- client_rect_ht = h;
-
- //buffer = new QImage( client_rect_wd, client_rect_ht, QImage::Format_RGB32 );
-
- vis_range_x = client_rect_wd; // horizontal range in ticks
- vis_range_y = 100; // whole visible vertical range in arcsecs!
-
- // init...
- initRenderVariables();
-
- need_refresh = true;
-}
-
-void ScrollGraph::resizeEvent(QResizeEvent *event)
-{
- if (event->size().width() >= data_cnt)
- {
- event->ignore();
- return;
- }
-
- setSize(event->size().width(), event->size().height());
- setVisibleRanges(event->size().width(), 60);
- update();
-}
-
-void ScrollGraph::initRenderVariables( void )
-{
- half_buffer_size_wd = client_rect_wd / 2;
- half_buffer_size_ht = client_rect_ht / 2;
-
-
- grid_view_step_x = (double)client_rect_wd / (double)grid_N;
- grid_view_step_y = (double)client_rect_ht / (double)grid_N;
-
- grid_step_x = (double)vis_range_x / (double)grid_N;
- grid_step_y = (double)vis_range_y / (double)grid_N;
-
- half_vis_range_x = vis_range_x / 2;
- half_vis_range_y = vis_range_y / 2;
-
-}
-
-
-void ScrollGraph::setVisibleRanges( int rx, int ry )
-{
- if( rx >= 10*grid_N && rx < (double)data_cnt )
- {
- if( vis_range_x != rx )
- need_refresh = true;
- vis_range_x = rx;
- }
- else
- {
- qWarning() << "set_visible_ranges: must be >= " << 10*grid_N << " and < " << data_cnt;
- return;
- }
-
- if( ry >= 5*grid_N )
- {
- if( vis_range_x != ry )
- need_refresh = true;
- vis_range_y = ry;
- }
- else
- {
- qWarning() << "set_visible_ranges: must be >= " << 5*grid_N << " and < " << data_cnt;
- return;
- }
-
- initRenderVariables();
-}
-
-
-void ScrollGraph::getVisibleRanges( int *rx, int *ry )
-{
- *rx = vis_range_x;
- *ry = vis_range_y;
-}
-
-
-int ScrollGraph::getGridN( void )
-{
- return grid_N;
-}
-
-
-void ScrollGraph::resetView( void )
-{
-
- setVisibleRanges( client_rect_wd, 100 );
-
- initRenderVariables();
-
- need_refresh = true;
-}
-
-
-void ScrollGraph::resetData( void )
-{
- memset( data.line[RA_LINE], 0, sizeof(double)*data_cnt );
- memset( data.line[DEC_LINE], 0, sizeof(double)*data_cnt );
- data_idx = 0;
-
- RA_COLOR = QColor(KStars::Instance()->data()->colorScheme()->colorNamed( "RAGuideError" ));
- DEC_COLOR = QColor(KStars::Instance()->data()->colorScheme()->colorNamed( "DEGuideError" ));
-}
-
-
-
-void ScrollGraph::getScreenSize( int *sx, int *sy )
-{
- *sx = client_rect_wd;
- *sy = client_rect_ht;
-}
-
-
-/*************
-*
-* Main Drawing function
-*
-**************/
-void ScrollGraph::paintEvent( QPaintEvent * )
-{
- QPainter p;
- p.begin( this );
- p.setRenderHint( QPainter::Antialiasing, true );
-
- int i, j, k;
- double kx, ky, step;
- double *data_ptr;
- int start_idx;
- int /*band1_wd,*/ band1_start, band1_end;
- int band2_wd, band2_start, band2_end;
- int x, y;
- int px, py;
-
- font_ht_k = p.fontMetrics().ascent();
-
- // fill background
- p.fillRect( 0, 0, client_rect_wd, client_rect_ht, brush);
-
- start_idx = (data_idx + data_cnt - vis_range_x) % data_cnt;
- // split visible region in 2 ranges
- if( data_idx > start_idx ) // only 1 band
- {
- //band1_wd = data_idx - start_idx; // = vis_range_x
- band1_start = start_idx;
- band1_end = data_idx; // -1;
- band2_start = band2_end = band2_wd = 0;
- }
- else // 2 bands
- {
- //band1_wd = data_idx;
- band1_start = 0;
- band1_end = data_idx; //-1;
-
- band2_wd = data_cnt - start_idx;
- band2_start = start_idx;
- band2_end = data_cnt-1;
- }
-
- // Rasterizing coefficients
- kx = (double)client_rect_wd / vis_range_x;
- ky = (double)client_rect_ht / vis_range_y;
-
- drawGrid(&p, kx, ky );
-
- // analize kx and select optimal algorithm
- if( client_rect_wd <= vis_range_x )
- {
- step = 1.0 / kx;
-
- for( k = 0;k < 2;k++ )
- {
- if (k == 0 && RAEnabled == false)
- continue;
- else if (k==1 && DEEnabled == false)
- continue;
-
- data_ptr = data.line[k];
-
- if( k == RA_LINE )
- pen.setColor( RA_COLOR );
- else
- pen.setColor( DEC_COLOR );
-
- p.setPen( pen );
-
- // process band 1
- px = client_rect_wd;;
- py = half_buffer_size_ht - (int)(data_ptr[band1_end] * ky);
-
- x = client_rect_wd;
-
- for( i = band1_end, j = 0;i >= band1_start; )
- {
- y = half_buffer_size_ht - (int)(data_ptr[i] * ky);
- x--;
-
- p.drawLine( px, py, x, y );
-
- px = x;
- py = y;
-
- //------------------------------------------
- ++j;
- i = band1_end - (int)((double)j*step);
- }
-
- // process band 2
- for( i = band2_end, j = 0;i > band2_start; )
- {
- y = half_buffer_size_ht - (int)(data_ptr[i] * ky);
- x--;
-
- p.drawLine( px, py, x, y );
-
- px = x;
- py = y;
-
- //------------------------------------------
- ++j;
- i = band2_end - (int)((double)j*step);
- }
- }
- }
- else
- {
- step = kx;
-
- for( k = 0;k < 2;k++ )
- {
- data_ptr = data.line[k];
-
- if( k == RA_LINE )
- pen.setColor( RA_COLOR );
- else
- pen.setColor( DEC_COLOR );
-
- p.setPen( pen );
-
- // process band 1
- px = client_rect_wd;
- py = half_buffer_size_ht - (int)(data_ptr[band1_end] * ky);
-
- x = client_rect_wd;
-
- for( i = band1_end, j = 0;i >= band1_start;i--, ++j )
- {
- y = half_buffer_size_ht - (int)(data_ptr[i] * ky);
- x = client_rect_wd - (int)((double)j*step) - 1;
-
- p.drawLine( px, py, x, y );
-
- px = x;
- py = y;
-
- }
-
-
- // process band 2
- for( i = band2_end;i > band2_start;i--, ++j )
- {
- y = half_buffer_size_ht - (int)(data_ptr[i] * ky);
- x = client_rect_wd - (int)((double)j*step) - 1;
-
- p.drawLine( px, py, x, y );
-
- px = x;
- py = y;
- }
-
- }
- }
-
- need_refresh = false;
-}
-
-
-void ScrollGraph::drawGrid(QPainter *p, double kx, double )
-{
- int i, x, sx, y;
- int grid_column, val;
- QString str;
-
- pen.setColor( GRID_COLOR );
- p->setPen( pen );
-
- grid_column = data_idx / (int)grid_step_x * (int)grid_step_x;
- sx = client_rect_wd - (double)(data_idx % (int)grid_step_x)*kx;
-
- for( i = 0;i < grid_N;++i )
- {
- x = sx - (double)i*grid_view_step_x;
- y = (double)i*grid_view_step_y;
-
- p->drawLine( x, 0, x, client_rect_ht );
-
- if( i == grid_N/2 )
- {
- pen.setColor( WHITE_COLOR );
- p->setPen( pen );
- p->drawLine( 0, y, client_rect_wd, y );
- pen.setColor( GRID_COLOR );
- p->setPen( pen );
- }
- else
- p->drawLine( 0, y, client_rect_wd, y );
- }
-
- // draw all digits
- pen.setColor( GRID_FONT_COLOR );
- p->setPen( pen );
- for( i = 0;i < grid_N;++i )
- {
- x = sx - (double)i*grid_view_step_x;
- y = (double)i*grid_view_step_y;
-
- if( (val = grid_column - i*(int)grid_step_x) >= 0 )
- {
- str.setNum( val );
- p->drawText( x, half_buffer_size_ht + font_ht_k, str );
- }
- str.setNum( (int)(half_vis_range_y - grid_step_y*i) );
- p->drawText( 2, y + font_ht_k, str );
- }
-
-}
-
-
-
-bool ScrollGraph::addPoint( double ra, double dec )
-{
- data_idx++;
-
- if( data_idx == data_cnt-1 )
- data_idx = 0;
-
- data.line[ RA_LINE ][ data_idx ] = ra;
- data.line[ DEC_LINE ][ data_idx ] = dec;
-
- need_refresh = true;
-
- return true;
-}
-
diff --git a/kstars/ekos/guide/scroll_graph.h b/kstars/ekos/guide/scroll_graph.h
deleted file mode 100644
index a1d1c76..0000000
--- a/kstars/ekos/guide/scroll_graph.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Ekos guide tool
- Copyright (C) 2012 Andrew Stepanenko
-
- Modified by Jasem Mutlaq <mutlaqja@ikarustech.com> for KStars.
-
- This application is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
- */
-
-#ifndef ScrollGraph_H_
-#define ScrollGraph_H_
-
-#include <QtGui>
-#include <QWidget>
-#include <QImage>
-#include <QPainter>
-
-
-#define RA_LINE 0
-#define DEC_LINE 1
-
-typedef struct
-{
- double *line[2];
-}delta_data_t;
-
-
-
-class ScrollGraph : public QWidget
-{
-public:
- ScrollGraph(QWidget *parent);
- virtual ~ScrollGraph();
-
- //QImage *get_buffer( void );
- void setSize(int w, int h);
- bool addPoint( double ra, double dec );
- void setVisibleRanges( int rx, int ry );
- void getVisibleRanges( int *rx, int *ry );
- int getGridN( void );
- void resetView( void );
- void resetData( void );
- void getScreenSize( int *sx, int *sy );
- void setRAEnabled(bool enable) { RAEnabled = enable; }
- void setDEEnabled(bool enable) { DEEnabled = enable; }
-
-protected:
- void paintEvent( QPaintEvent * );
- void resizeEvent(QResizeEvent *event);
-
-private:
- QColor BKGD_COLOR, RA_COLOR, DEC_COLOR, GRID_COLOR, WHITE_COLOR, GRID_FONT_COLOR;
- QPen pen;
- QBrush brush;
- int half_buffer_size_wd;
- int half_buffer_size_ht;
- int client_rect_wd;
- int client_rect_ht;
- bool need_refresh;
-
- // data
- delta_data_t data;
- int data_cnt;
- int data_idx;
- int grid_N;
-
- // grid vars...
- double grid_step_x, grid_step_y, grid_view_step_x, grid_view_step_y;
- int font_ht_k;
-
- // control
- int vis_range_x, vis_range_y;
- int half_vis_range_x, half_vis_range_y;
-
- bool RAEnabled, DEEnabled;
-
- void refresh( void );
- void drawGrid(QPainter *p, double kx, double ky );
- void initRenderVariables( void );
-
-};
-
-#endif /*ScrollGraph_H_*/
diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg
index 0ee01ca..da1cdf9 100644
--- a/kstars/kstars.kcfg
+++ b/kstars/kstars.kcfg
@@ -1481,7 +1481,7 @@
<label>Subframe the focus star during the autofocus procedure.</label>
<default>true</default>
</entry>
- <entry name="AutoSelectStar" type="Bool">
+ <entry name="FocusAutoStarEnabled" type="Bool">
<label>Automatically select a star to focus.</label>
<default>false</default>
</entry>
@@ -1621,11 +1621,11 @@
<label>Guide square size index (0 to 4) corresponding to pixel sizes (8 to 128).</label>
<default>1</default>
</entry>
- <entry name="AutoStarEnabled" type="Bool">
+ <entry name="GuideAutoStarEnabled" type="Bool">
<label>Automatically select calibration star and perform calibration.</label>
<default>false</default>
</entry>
- <entry name="AutoSquareSizeEnabled" type="Bool">
+ <entry name="GuideAutoSquareSizeEnabled" type="Bool">
<label>Automatically select the square size based on the selected star width.</label>
<default>false</default>
</entry>
@@ -1645,6 +1645,10 @@
<label>Take dark frame for autoguider images.</label>
<default>false</default>
</entry>
+ <entry name="GuideSubframeEnabled" type="Bool">
+ <label>Subframe guide image around selected region</label>
+ <default>false</default>
+ </entry>
<entry name="DitherPixels" type="Double">
<label>How many pixels to move between subsequent exposures under auto dithering mode.</label>
<default>2</default>
diff --git a/kstars/org.kde.kstars.Ekos.Guide.xml b/kstars/org.kde.kstars.Ekos.Guide.xml
index 5d3c4b2..7b62785 100644
--- a/kstars/org.kde.kstars.Ekos.Guide.xml
+++ b/kstars/org.kde.kstars.Ekos.Guide.xml
@@ -13,9 +13,21 @@
<method name="capture">
<arg type="b" direction="out"/>
</method>
+ <method name="dither">
+ <arg type="b" direction="out"/>
+ </method>
+ <method name="suspend">
+ <arg type="b" direction="out"/>
+ </method>
+ <method name="resume">
+ <arg type="b" direction="out"/>
+ </method>
<method name="selectAutoStar">
<arg type="b" direction="out"/>
</method>
+ <method name="startAutoCalibrateGuide">
+ <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
+ </method>
<method name="setCCD">
<arg type="b" direction="out"/>
<arg name="device" type="s" direction="in"/>
@@ -26,7 +38,7 @@
</method>
<method name="getST4Devices">
<arg type="as" direction="out"/>
- </method>
+ </method>
<method name="getStatus">
<arg type="ui" direction="out"/>
</method>
@@ -74,11 +86,13 @@
<arg name="enable" type="b" direction="in"/>
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
+ <!--
<method name="setGuideRapidEnabled">
<arg name="enable" type="b" direction="in"/>
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
- <method name="setDither">
+ !-->
+ <method name="setDitherSettings">
<arg name="enable" type="b" direction="in"/>
<arg name="value" type="d" direction="in"/>
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>