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 showOptions Open the options dialog for the currently selected focuser
50 */
51 void showOptions();
52
53 /**
54 * @brief Run the autofocus process for the currently selected filter
55 * @param The reason Autofocus has been called.
56 * @param trainname name of the optical train to select the focuser
57 */
58 void runAutoFocus(const AutofocusReason autofocusReason, const QString &reasonInfo, const QString &trainname);
59
60 /**
61 * @brief Reset the camera frame being used by the focuser.
62 * @param trainname name of the optical train to select the focuser
63 */
64 void resetFrame(const QString &trainname);
65
66 /**
67 * @brief Abort the autofocus operation.
68 * @param trainname name of the optical train to select the focuser
69 */
70 void abort(const QString &trainname);
71
72 /**
73 * @brief adaptiveFocus moves the focuser between subframes to stay at focus
74 * @param trainname name of the optical train to select the focuser
75 */
76 void adaptiveFocus(const QString &trainname);
77
78 /**
79 * @brief React when a meridian flip has been started
80 * @param trainname name of the optical train to select the focuser
81 */
82 void meridianFlipStarted(const QString &trainname);
83
84 // Update Mount module status
85 void setMountStatus(ISD::Mount::Status newState);
86
87 // Update Altitude From Mount
88 void setMountCoords(const SkyPoint &position, ISD::Mount::PierSide pierSide, const dms &ha);
89
90 // ////////////////////////////////////////////////////////////////////
91 // Device handling
92 // ////////////////////////////////////////////////////////////////////
93 /**
94 * @brief removeDevice Remove device from Focus module
95 * @param deviceRemoved pointer to device
96 */
97 void removeDevice(const QSharedPointer<ISD::GenericDevice> &deviceRemoved);
98
99 /**
100 * @brief addTemperatureSource Add temperature source to the list of available sources.
101 * @param newSource Device with temperature reporting capability
102 * @return True if added successfully, false if duplicate or failed to add.
103 */
104 bool addTemperatureSource(const QSharedPointer<ISD::GenericDevice> &device);
105
106 /**
107 * @brief syncCameraInfo Read current CCD information and update settings accordingly.
108 */
109 void syncCameraInfo(const char *devicename);
110
111 /**
112 * @brief Check all focusers and make sure information is updated accordingly.
113 */
114 void checkFocusers()
115 {
116 // iterate over all focusers
117 for (auto focuser : m_Focusers)
118 focuser->checkFocuser();
119 }
120
121 /**
122 * @brief Check all CCDs and make sure information is updated accordingly.
123 */
124 void checkCameras()
125 {
126 // iterate over all focusers
127 for (auto focuser : m_Focusers)
128 focuser->checkCamera();
129 }
130
131
132 // ////////////////////////////////////////////////////////////////////
133 // Module logging
134 // ////////////////////////////////////////////////////////////////////
135 void clearLog();
136 void appendLogText(const QString &logtext);
137 void appendFocusLogText(const QString &lines);
138
139 QStringList logText()
140 {
141 return m_LogText;
142 }
143 QString getLogText()
144 {
145 return m_LogText.join("\n");
146 }
147
148
149signals:
150 void newLog(const QString &text);
151 void suspendGuiding();
152 void resumeGuiding();
153 void newStatus(FocusState state, const QString &trainname);
154 void focusAdaptiveComplete(bool success, const QString &trainname);
155 void newHFR(double hfr, int position, bool inAutofocus, const QString &trainname);
156 void newFocusTemperatureDelta(double delta, double absTemperature, const QString &trainname);
157 void inSequenceAF(bool requested, const QString &trainname);
158
159
160private:
161 // ////////////////////////////////////////////////////////////////////
162 // focuser handling
163 // ////////////////////////////////////////////////////////////////////
164
165 /**
166 * @brief addFocuser Add a new focuser under focus management control
167 * @param trainname name of the optical train
168 */
169 QSharedPointer<Focus> addFocuser(const QString &trainname = "");
170
171 void initFocuser(QSharedPointer<Focus> newFocuser);
172
173 /**
174 * @brief Update the focuser
175 * @param ID that holds the focuser
176 * @param current focuser is valid
177 */
178 void updateFocuser(int tabID, bool isValid);
179
180 void closeFocuserTab(int tabIndex);
181
182 void checkCloseFocuserTab(int tabIndex);
183
184 // ////////////////////////////////////////////////////////////////////
185 // Helper functions
186 // ////////////////////////////////////////////////////////////////////
187 /**
188 * @brief findUnusedOpticalTrain Find the name of the first optical train that is not used by another tab
189 * @return
190 */
191 const QString findUnusedOpticalTrain();
192
193 // ////////////////////////////////////////////////////////////////////
194 // Attributes
195 // ////////////////////////////////////////////////////////////////////
196 QList<QSharedPointer<Focus>> m_Focusers;
197
198 /// They're generic GDInterface because they could be either ISD::Camera or ISD::FilterWheel or ISD::Weather
199 QList<QSharedPointer<ISD::GenericDevice>> m_TemperatureSources;
200
201 // ////////////////////////////////////////////////////////////////////
202 // Logging
203 // ////////////////////////////////////////////////////////////////////
204 QStringList m_LogText;
205 QFile m_FocusLogFile;
206 QString m_FocusLogFileName;
207 bool m_FocusLogEnabled { false };
208
209};
210
211}
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-2025 The KDE developers.
Generated on Fri Jan 3 2025 11:47:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.