Kstars

internalguider.h
1/*
2 SPDX-FileCopyrightText: 2016 Jasem Mutlaq <mutlaqja@ikarustech.com>.
3
4 Based on lin_guider
5
6 SPDX-License-Identifier: GPL-2.0-or-later
7*/
8
9#pragma once
10
11#include "matr.h"
12#include "indi/indicommon.h"
13#include "../guideinterface.h"
14#include "guidelog.h"
15#include "calibration.h"
16#include "calibrationprocess.h"
17#include "gmath.h"
18#include "ekos_guide_debug.h"
19#include <QFile>
20#include <QPointer>
21#include <QQueue>
22#include <QTime>
23
24#include <memory>
25
26class QVector3D;
27class FITSData;
28class cgmath;
29class GuideView;
30class Edge;
31
32namespace Ekos
33{
34class InternalGuider : public GuideInterface
35{
37
38 public:
39 InternalGuider();
40
41 bool Connect() override
42 {
43 state = GUIDE_IDLE;
44 return true;
45 }
46 bool Disconnect() override
47 {
48 return true;
49 }
50 bool isConnected() override
51 {
52 return true;
53 }
54
55 bool calibrate() override;
56 bool guide() override;
57 bool abort() override;
58 bool suspend() override;
59 bool resume() override;
60
61 bool dither(double pixels) override;
62 bool ditherXY(double x, double y);
63
64 bool clearCalibration() override;
65 bool restoreCalibration();
66
67 bool reacquire() override;
68
69 bool setFrameParams(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t binX, uint16_t binY) override;
70 bool setGuiderParams(double ccdPixelSizeX, double ccdPixelSizeY, double mountAperture,
71 double mountFocalLength) override;
72
73 // Set Star Position
74 void setStarPosition(QVector3D &starCenter) override;
75
76 // Select algorithm
77 void setSquareAlgorithm(int index);
78
79 // Reticle Parameters
80 bool getReticleParameters(double *x, double *y);
81
82 // Guide Square Box Size
83 void setGuideBoxSize(uint32_t value)
84 {
85 guideBoxSize = value;
86 }
87
88 // Guide View
89 void setGuideView(const QSharedPointer<GuideView> &guideView);
90 // Image Data
91 void setImageData(const QSharedPointer<FITSData> &data);
92
93 bool start();
94
95 bool isGuiding(void) const;
96 void setInterface(void);
97
98 void setSubFramed(bool enable)
99 {
100 m_isSubFramed = enable;
101 }
102
103 bool useSubFrame();
104
105 const Calibration &getCalibration() const;
106
107 // Select a guide star automatically
108 bool selectAutoStar();
109 bool selectAutoStarSEPMultistar();
110 bool SEPMultiStarEnabled();
111
112 // Manual Dither
113 bool processManualDithering();
114
115 void updateGPGParameters();
116 void resetGPG() override;
117 void resetDarkGuiding();
118 void setExposureTime();
119 void setDarkGuideTimerInterval();
120 void setTimer(std::unique_ptr<QTimer> &timer, Seconds seconds);
121
122 public slots:
123 void setDECSwap(bool enable);
124
125
126 protected slots:
127 void trackingStarSelected(int x, int y);
128 void setDitherSettled();
129 void darkGuide();
130
131 signals:
132 void newMultiPulse(GuideDirection ra_dir, int ra_msecs, GuideDirection dec_dir, int dec_msecs,
133 CaptureAfterPulses followWithCapture);
134 void newSinglePulse(GuideDirection dir, int msecs, CaptureAfterPulses followWithCapture);
135 //void newStarPosition(QVector3D, bool);
136 void DESwapChanged(bool enable);
137 private:
138 // Guiding
139 bool processGuiding();
140 void startDarkGuiding();
141 bool abortDither();
142 bool onePulseDither(double pixels);
143
144 void reset();
145
146 // Logging
147 void fillGuideInfo(GuideLog::GuideInfo *info);
148
149 std::unique_ptr<cgmath> pmath;
150 QSharedPointer<GuideView> m_GuideFrame;
151 QSharedPointer<FITSData> m_ImageData;
152 bool m_isStarted { false };
153 bool m_isSubFramed { false };
154 bool m_isFirstFrame { false };
155 int m_starLostCounter { 0 };
156
157 QFile logFile;
158 uint32_t guideBoxSize { 32 };
159
160 GuiderUtils::Vector m_DitherTargetPosition;
161 uint8_t m_DitherRetries {0};
162
163 QElapsedTimer reacquireTimer;
164 int m_highRMSCounter {0};
165
166 GuiderUtils::Matrix ROT_Z;
167 Ekos::GuideState rememberState { GUIDE_IDLE };
168
169 // Progressive Manual Dither
170 QQueue<GuiderUtils::Vector> m_ProgressiveDither;
171
172 // Dark guiding timer
173 std::unique_ptr<QTimer> m_darkGuideTimer;
174 std::unique_ptr<QTimer> m_captureTimer;
175 std::pair<Seconds, Seconds> calculateGPGTimeStep();
176 bool isInferencePeriodFinished();
177
178
179 // How many high RMS pulses before we stop
180 static const uint8_t MAX_RMS_THRESHOLD = 10;
181 // How many lost stars before we stop
182 static const uint8_t MAX_LOST_STAR_THRESHOLD = 5;
183
184 // Maximum pulse time limit for immediate capture. Any pulses longer that this
185 // will be delayed until pulse is over
186 static const uint16_t MAX_IMMEDIATE_CAPTURE = 250;
187 // When to start capture before pulse delay is over
188 static const uint16_t PROPAGATION_DELAY = 100;
189
190 // How many 'random' pixels can we move before we have to force direction reversal?
191 static const uint8_t MAX_DITHER_TRAVEL = 15;
192
193 // This keeps track of the distance dithering has moved. It's used to make sure
194 // the "random walk" dither doesn't wander too far away.
195 QVector3D m_DitherOrigin;
196
197 GuideLog guideLog;
198
199 void iterateCalibration();
200 std::unique_ptr<CalibrationProcess> calibrationProcess;
201 double calibrationStartX = 0;
202 double calibrationStartY = 0;
203
204
205 bool isPoorGuiding(const cproc_out_params *out);
206 void emitAxisPulse(const cproc_out_params *out);
207};
208}
The main change relative to fitsview is to add the capability of displaying the 'neighbor guide stars...
Definition guideview.h:22
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:79
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:26 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.