Kstars

capturemodulestate.h
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3 SPDX-FileCopyrightText: 2024 Wolfgang Reissenberger <sterne-jaeger@openfuture.de>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#pragma once
9
10#include "capturetypes.h"
11#include "ekos/manager/meridianflipstate.h"
12#include "ekos/ekos.h"
13
14#include <QObject>
15#include <QTimer>
16
17namespace Ekos
18{
19class Camera;
20class CameraState;
21
22class CaptureModuleState : public QObject
23{
25
26 friend class Capture;
27
28signals:
29 void dither();
30 // new log text for the module log window
31 void newLog(const QString &text);
32
33public:
34 explicit CaptureModuleState(QObject *parent = nullptr);
35
36 // ////////////////////////////////////////////////////////////////////
37 // shared attributes
38 // ////////////////////////////////////////////////////////////////////
39 bool forceInSeqAF(const QString opticaltrain) const
40 {
41 if (m_ForceInSeqAF.contains(opticaltrain))
42 return m_ForceInSeqAF[opticaltrain];
43 else
44 // default value is off
45 return false;
46 }
47 void setForceInSeqAF(bool value, const QString opticaltrain)
48 {
49 m_ForceInSeqAF[opticaltrain] = value;
50 }
51
52 // ////////////////////////////////////////////////////////////////////
53 // Cameras
54 // ////////////////////////////////////////////////////////////////////
55 const QList<QSharedPointer<Camera>> &cameras() const
56 {
57 return m_Cameras;
58 }
59 QList<QSharedPointer<Camera>> &mutableCameras()
60 {
61 return m_Cameras;
62 }
63
64 void addCamera(QSharedPointer<Camera> newCamera);
65 void removeCamera(int pos);
66
67 // ////////////////////////////////////////////////////////////////////
68 // State handling
69 // ////////////////////////////////////////////////////////////////////
70
71 // Capturing
72 void captureStateChanged(CaptureState value, const QString &trainname, int cameraID);
73 // Guiding
74 void setGuideStatus(GuideState newstate);
75 void setGuideDeviation(double delta_ra, double delta_dec);
76 // meridian flip
77 void updateMFMountState(MeridianFlipState::MeridianFlipMountState status);
78
79 // ////////////////////////////////////////////////////////////////////
80 // Action handling
81 // ////////////////////////////////////////////////////////////////////
82 /**
83 * @brief activeAction Currently active action for a single camera, coordinated by the capture module
84 * @param cameraID ID of the camera
85 * @return workflow action, or CAPTURE_ACTION_NONE if none is active
86 */
87 CaptureWorkflowActionType activeAction(int cameraID);
88
89 /**
90 * @brief isActionActive Determine whether an action is actively coordinated by the capture module
91 * @param cameraID ID of the camera
92 */
93 bool isActionActive(int cameraID)
94 {
95 return m_activeActions.contains(cameraID);
96 }
97
98private:
99
100 // ////////////////////////////////////////////////////////////////////
101 // shared attributes
102 // ////////////////////////////////////////////////////////////////////
103 // User has requested an autofocus run as soon as possible
104 QMap<QString, bool> m_ForceInSeqAF;
105
106 // ////////////////////////////////////////////////////////////////////
107 // Cameras
108 // ////////////////////////////////////////////////////////////////////
110
111 // ////////////////////////////////////////////////////////////////////
112 // Action handling
113 // ////////////////////////////////////////////////////////////////////
114
115 // currently active actions, maximal one per camera
117 // planned action queues, one queue per camera
119
120 /**
121 * @brief getActionQueue Retrieve the action queue for a given camera ID
122 */
123 QQueue<CaptureWorkflowActionType> &getActionQueue(int cameraId);
124
125 /**
126 * @brief setActiveAction Set the currently active action for a camera, that is
127 * coordinated by the capture module
128 * @param cameraID ID of the camera
129 * @param action workflow action, or CAPTURE_ACTION_NONE if none is active
130 */
131 void setActiveAction(int cameraID, CaptureWorkflowActionType action);
132
133 /**
134 * @brief requestAction Handle the execution request of an action.
135 * @param cameraID ID of the camera
136 * @param action workflow action
137 */
138 void handleActionRequest(int cameraID, CaptureWorkflowActionType action);
139
140 /**
141 * @brief checkActionExecution Check if next actions need to be executed.
142 */
143 void checkActionExecution();
144
145 /**
146 * @brief enqueueAction enqueue an action for future execution
147 * @param cameraID ID of the camera for which the action should be executed
148 */
149 void enqueueAction(int cameraID, CaptureWorkflowActionType action);
150
151 /**
152 * @brief checkActiveActions Iterate over all cameras and check if the active
153 * actions may be executed and trigger next action from the action queue
154 * if no active action exists.
155 */
156 void checkActiveActions();
157
158 /**
159 * @brief checkAndExecuteNextAction check if there is an action pending for the
160 * given camera.
161 * @param cameraID ID of the camera for which the action should be executed. If the
162 * ID == -1, execute this check for all cameras.
163 */
164 void checkNextActionExecution(int cameraID = -1);
165
166 /**
167 * @brief clearAllActions Clear all action queues and reset the active actions.
168 */
169 void clearAllActions(int cameraID);
170
171 // ////////////////////////////////////////////////////////////////////
172 // Action execution
173 // ////////////////////////////////////////////////////////////////////
174
175 /**
176 * @brief prepareDitheringAction If a dither request has been received, capturing
177 * either requests all capturing cameras to pause or, if this would take too long,
178 * aborts their capturing. As a threshold, we set to pause all cameras where the
179 * remaining time is less than 50% of the exposure time of the camera that requested
180 * the dithering. All others will be aborted.
181 * @param cameraId ID of the camera that requests dithering
182 */
183 void prepareDitheringAction(int cameraId);
184
185 /**
186 * @brief checkReadyForDithering Check if dithering may be requested, i.e. for no camera
187 * capturing is still running. If this is the case, request dithering.
188 * @param cameraId ID of the camera that requests dithering
189 */
190 void checkReadyForDithering(int cameraId);
191
192 /**
193 * @brief startDithering Enforce dithering, abort all other capturing processes
194 */
195 void startDithering();
196
197 /**
198 * @brief setupRestartPostMF Setup the checks required before the suspended follower jobs
199 * might be restarted.
200 */
201 void setupRestartPostMF();
202
203 /**
204 * @brief pauseCapturingImmediately Pause capturing immediately by calling first to pause
205 * and subsequently to suspend.
206 */
207 void pauseCapturingImmediately(int cameraID = -1, bool followersOnly = true);
208
209 // timer to avoid waiting infinitely long for settling of other cameras
210 QTimer m_DitheringTimer;
211
212 // meridian flip mount state
213 MeridianFlipState::MeridianFlipMountState m_MFMountState {MeridianFlipState::MOUNT_FLIP_NONE};
214
215 // ////////////////////////////////////////////////////////////////////
216 // helper functions
217 // ////////////////////////////////////////////////////////////////////
218 /**
219 * @brief Check if a meridian flip is ready to start, running or some post flip actions are not completed.
220 */
221 bool checkMeridianFlipActive();
222
223 /**
224 * @brief leadState Retrieve the state machine of the lead camera.
225 */
226 const QSharedPointer<CameraState> leadState();
227};
228} // namespace Ekos
229
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
bool contains(const Key &key) const const
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:57:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.