Kstars

focusmodule.h
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ui_focusmodule.h"
10#include "focus.h"
11
12
13namespace Ekos
14{
15
16
17class FocusModule : public QWidget, public Ui::FocusManager
18{
20
21public:
22 FocusModule();
23 ~FocusModule();
24
25 // ////////////////////////////////////////////////////////////////////
26 // Access to the focusers
27 // ////////////////////////////////////////////////////////////////////
28
29 QSharedPointer<Focus> &focuser(int i);
30
31 QSharedPointer<Focus> mainFocuser();
32
33 /**
34 * @brief find the focuser using the given train
35 * @param train optical train name
36 * @param addIfNecessary if true, add a new camera with the given train, if none uses this train
37 * @return index in the list of focusers (@see #camera(int))
38 */
39 int findFocuser(QString train, bool addIfNecessary);
40
41 /**
42 * @brief checkFocus Given the minimum required HFR, check focus and calculate HFR. If current HFR exceeds required HFR, start autofocus process, otherwise do nothing.
43 * @param requiredHFR Minimum HFR to trigger autofocus process.
44 * @param trainname name of the optical train to select the focuser
45 */
46 void checkFocus(double requiredHFR, const QString &trainname);
47
48 /**
49 * @brief Run the autofocus process for the currently selected filter
50 * @param The reason Autofocus has been called.
51 * @param trainname name of the optical train to select the focuser
52 */
53 void runAutoFocus(const AutofocusReason autofocusReason, const QString &reasonInfo, const QString &trainname);
54
55 /**
56 * @brief Reset the camera frame being used by the focuser.
57 * @param trainname name of the optical train to select the focuser
58 */
59 void resetFrame(const QString &trainname);
60
61 /**
62 * @brief Abort the autofocus operation.
63 * @param trainname name of the optical train to select the focuser
64 */
65 void abort(const QString &trainname);
66
67 /**
68 * @brief adaptiveFocus moves the focuser between subframes to stay at focus
69 * @param trainname name of the optical train to select the focuser
70 */
71 void adaptiveFocus(const QString &trainname);
72
73 /**
74 * @brief React when a meridian flip has been started
75 * @param trainname name of the optical train to select the focuser
76 */
77 void meridianFlipStarted(const QString &trainname);
78
79 // Update Mount module status
80 void setMountStatus(ISD::Mount::Status newState);
81
82 // Update Altitude From Mount
83 void setMountCoords(const SkyPoint &position, ISD::Mount::PierSide pierSide, const dms &ha);
84
85 // ////////////////////////////////////////////////////////////////////
86 // Device handling
87 // ////////////////////////////////////////////////////////////////////
88 /**
89 * @brief removeDevice Remove device from Focus module
90 * @param deviceRemoved pointer to device
91 */
92 void removeDevice(const QSharedPointer<ISD::GenericDevice> &deviceRemoved);
93
94 /**
95 * @brief addTemperatureSource Add temperature source to the list of available sources.
96 * @param newSource Device with temperature reporting capability
97 * @return True if added successfully, false if duplicate or failed to add.
98 */
99 bool addTemperatureSource(const QSharedPointer<ISD::GenericDevice> &device);
100
101 /**
102 * @brief syncCameraInfo Read current CCD information and update settings accordingly.
103 */
104 void syncCameraInfo(const char *devicename);
105
106 /**
107 * @brief Check all focusers and make sure information is updated accordingly.
108 */
109 void checkFocusers()
110 {
111 // iterate over all focusers
112 for (auto focuser : m_Focusers)
113 focuser->checkFocuser();
114 }
115
116 /**
117 * @brief Check all CCDs and make sure information is updated accordingly.
118 */
119 void checkCameras()
120 {
121 // iterate over all focusers
122 for (auto focuser : m_Focusers)
123 focuser->checkCamera();
124 }
125
126
127 // ////////////////////////////////////////////////////////////////////
128 // Module logging
129 // ////////////////////////////////////////////////////////////////////
130 void clearLog();
131 void appendLogText(const QString &logtext);
132 void appendFocusLogText(const QString &lines);
133
134 QStringList logText()
135 {
136 return m_LogText;
137 }
138 QString getLogText()
139 {
140 return m_LogText.join("\n");
141 }
142
143
144signals:
145 void newLog(const QString &text);
146 void suspendGuiding();
147 void resumeGuiding();
148 void newStatus(FocusState state, const QString &trainname);
149 void focusAdaptiveComplete(bool success, const QString &trainname);
150 void newHFR(double hfr, int position, bool inAutofocus, const QString &trainname);
151 void newFocusTemperatureDelta(double delta, double absTemperature, const QString &trainname);
152 void inSequenceAF(bool requested, const QString &trainname);
153
154
155private:
156 // ////////////////////////////////////////////////////////////////////
157 // focuser handling
158 // ////////////////////////////////////////////////////////////////////
159
160 /**
161 * @brief addFocuser Add a new focuser under focus management control
162 * @param trainname name of the optical train
163 */
164 QSharedPointer<Focus> addFocuser(const QString &trainname = "");
165
166 void initFocuser(QSharedPointer<Focus> newFocuser);
167
168 /**
169 * @brief Update the focuser
170 * @param ID that holds the focuser
171 * @param current focuser is valid
172 */
173 void updateFocuser(int tabID, bool isValid);
174
175 void closeFocuserTab(int tabIndex);
176
177 void checkCloseFocuserTab(int tabIndex);
178
179 // ////////////////////////////////////////////////////////////////////
180 // Helper functions
181 // ////////////////////////////////////////////////////////////////////
182 /**
183 * @brief findUnusedOpticalTrain Find the name of the first optical train that is not used by another tab
184 * @return
185 */
186 const QString findUnusedOpticalTrain();
187
188 // ////////////////////////////////////////////////////////////////////
189 // Attributes
190 // ////////////////////////////////////////////////////////////////////
191 QList<QSharedPointer<Focus>> m_Focusers;
192
193 /// They're generic GDInterface because they could be either ISD::Camera or ISD::FilterWheel or ISD::Weather
194 QList<QSharedPointer<ISD::GenericDevice>> m_TemperatureSources;
195
196 // ////////////////////////////////////////////////////////////////////
197 // Logging
198 // ////////////////////////////////////////////////////////////////////
199 QStringList m_LogText;
200 QFile m_FocusLogFile;
201 QString m_FocusLogFileName;
202 bool m_FocusLogEnabled { false };
203
204};
205
206}
The sky coordinates of a point in the sky.
Definition skypoint.h:45
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
Q_OBJECTQ_OBJECT
QString join(QChar separator) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.