Kstars

sequencejob.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 "sequencejobstate.h"
10
11#include <QTableWidgetItem>
12
13class SkyPoint;
14
15/**
16 * @class SequenceJob
17 * @short Sequence Job is a container for the details required to capture a series of images.
18 *
19 * @author Jasem Mutlaq
20 * @version 1.0
21 */
22namespace Ekos
23{
24
25class CaptureDeviceAdaptor;
26
27class SequenceJob : public QObject
28{
30
31 public:
32 static QString const &ISOMarker;
33 static const QStringList StatusStrings();
34
35 // Core Properties
36 typedef enum
37 {
38 // Bool
39 SJ_EnforceTemperature,
40 // Bool
41 // SJ_EnforceStartGuiderDrift, // no specific option
42 // Bool
43 SJ_GuiderActive,
44 // Double
45 SJ_Exposure,
46 // QString
47 SJ_Filter,
48 // QString
49 SJ_Format,
50 // QString
51 SJ_Encoding,
52 // QPoint
53 SJ_Binning,
54 // QRect
55 SJ_ROI,
56 // QString
57 SJ_FullPrefix,
58 // Int
59 SJ_Count,
60 // Int
61 SJ_Delay,
62 // QString
63 SJ_ISO,
64 // Int
65 SJ_ISOIndex,
66 // Double
67 SJ_Gain,
68 // Double
69 SJ_Offset,
70 // QString
71 SJ_TargetName,
72 //QString
73 SJ_LocalDirectory,
74 // QString
75 SJ_PlaceholderFormat,
76 // Uint
77 SJ_PlaceholderSuffix,
78 // QString
79 SJ_RemoteDirectory,
80 // QString
81 SJ_RemoteFormatDirectory,
82 // QString
83 SJ_RemoteFormatFilename,
84 // QString
85 SJ_Filename,
86 // Double
87 SJ_TargetADU,
88 // Double
89 SJ_TargetADUTolerance,
90 // QString
91 SJ_Signature,
92 // Int
93 SJ_DitherPerJobFrequency,
94 // Bool
95 SJ_SkyFlat
96 } PropertyID;
97
98 typedef enum
99 {
100 JOBTYPE_BATCH, /* regular batch job */
101 JOBTYPE_PREVIEW, /* previews (single or looping) */
102 JOBTYPE_DARKFLAT /* capturing dark flats */
103 } SequenceJobType;
104
105 ////////////////////////////////////////////////////////////////////////
106 /// Constructors
107 ////////////////////////////////////////////////////////////////////////
109 const QSharedPointer<CameraState> sharedState,
110 SequenceJobType jobType, XMLEle *root = nullptr, QString targetName = "");
111 SequenceJob(XMLEle *root, QString targetName);
112 ~SequenceJob() = default;
113
114 ////////////////////////////////////////////////////////////////////////
115 /// Capture Fuctions
116 ////////////////////////////////////////////////////////////////////////
117 /**
118 * @brief startCapturing Initialize the camera and start capturing
119 *
120 * This step calls {@see SequenceJobState::initCapture()}, which triggers
121 * all actions before the camera may start to capture. If the initialization
122 * is completed, the sequence job state machine sends the signal
123 * {@see SequenceJobState::initCaptureComplete()} which will trigger the
124 * camera device to finally start capturing ({@see capture()}).
125 *
126 * @param autofocusReady was there a successful focus run previously?
127 * @param mode what is the purpose of capturing?
128 */
129 void startCapturing(bool autofocusReady, FITSMode mode);
130 /**
131 * @brief capture As soon as everything is ready for the camera to start
132 * capturing, this method triggers the camera device to start capturing.
133 * @param mode what is the purpose of capturing?
134 */
135 void capture(FITSMode mode);
136 void abort();
137 void done();
138
139 ////////////////////////////////////////////////////////////////////////
140 /// Core Properties
141 ////////////////////////////////////////////////////////////////////////
142 void setCoreProperty(PropertyID id, const QVariant &value);
143 QVariant getCoreProperty(PropertyID id) const;
144
145 ////////////////////////////////////////////////////////////////////////
146 /// Job Status Functions
147 ////////////////////////////////////////////////////////////////////////
148 const QString &getStatusString()
149 {
150 return StatusStrings()[getStatus()];
151 }
152 // Setter: Set how many captures have completed thus far
153 void setCompleted(int value)
154 {
155 m_Completed = value;
156 }
157 // Getter: How many captured have completed thus far.
158 int getCompleted() const
159 {
160 return m_Completed;
161 }
162 // Setter: Set how many more seconds to expose in this job
163 void setExposeLeft(double value);
164 // Getter: Get how many more seconds are left to expose.
165 double getExposeLeft() const;
166 // Reset: Reset the job status
167 void resetStatus(JOBStatus status = JOB_IDLE);
168 // Setter: Set how many times we re-try this job.
169 void setCaptureRetires(int value);
170 // Getter: Get many timed we retried this job already.
171 int getCaptureRetires() const;
172 // Getter: How many more seconds are remaining in this job given the
173 // estimated download time.
174 int getJobRemainingTime(double estimatedDownloadTime);
175
176 ////////////////////////////////////////////////////////////////////////
177 /// State Machine Functions
178 ////////////////////////////////////////////////////////////////////////
179 // Create all event connections between the state machine and the command processor
180 void connectDeviceAdaptor();
181 // Disconnect all event connections between the state machine and the command processor
182 void disconnectDeviceAdaptor();
183 // Setter: Set Target Filter Name
184 void setTargetFilter(int pos, const QString &name);
185 // Getter: Get Current Filter Slot
186 int getCurrentFilter() const;
187 // Retrieve the pier side from the state
188 ISD::Mount::PierSide getPierSide() const;
189
190 ////////////////////////////////////////////////////////////////////////
191 /// Job Attribute Functions
192 ////////////////////////////////////////////////////////////////////////
193 // job type
194 SequenceJobType jobType() const
195 {
196 return m_jobType;
197 }
198 void setJobType(SequenceJobType newJobType)
199 {
200 m_jobType = newJobType;
201 }
202 QString getSignature()
203 {
204 return (getCoreProperty(SJ_Signature).toString()).remove(".fits");
205 }
206 // Scripts
207 const QMap<ScriptTypes, QString> &getScripts() const
208 {
209 return m_Scripts;
210 }
211 void setScripts(const QMap<ScriptTypes, QString> &scripts)
212 {
213 m_Scripts = scripts;
214 }
215 const QString getScript(ScriptTypes type) const
216 {
217 return m_Scripts[type];
218 }
219 void setScript(ScriptTypes type, const QString &value)
220 {
221 m_Scripts[type] = value;
222 }
223
224 // helper function setting both ISO index and ISO value
225 void setISO(int index);
226
227 // Custom Properties
228 const QMap<QString, QMap<QString, QVariant> > getCustomProperties() const
229 {
230 return m_CustomProperties;
231 }
232 void setCustomProperties(const QMap<QString, QMap<QString, QVariant> > &value)
233 {
234 m_CustomProperties = value;
235 }
236
237 // Core Properties
238 const QMap<PropertyID, QVariant> &getCoreProperties() const
239 {
240 return m_CoreProperties;
241 }
242
243 // Setter: Set upload mode
244 void setUploadMode(ISD::Camera::UploadMode value);
245 // Getter: get upload mode
246 ISD::Camera::UploadMode getUploadMode() const;
247
248 // Setter: Set flat field source
249 void setCalibrationPreAction(uint32_t value);
250 // Getter: Get flat field source
251 uint32_t getCalibrationPreAction() const;
252
253 // Setter: Set Wall SkyPoint Azimuth coords
254 void setWallCoord(const SkyPoint &value);
255 // Getter: Get Flat field source wall coords
256 const SkyPoint &getWallCoord() const;
257
258 // Setter: Set flat field duration
259 void setFlatFieldDuration(FlatFieldDuration value);
260 // Getter: Get flat field duration
261 FlatFieldDuration getFlatFieldDuration() const;
262
263 // Setter: Set job progress ignored flag
264 void setJobProgressIgnored(bool value);
265 bool getJobProgressIgnored() const;
266
267 /**
268 * @brief updateDeviceStates Update for all used device types whether there
269 * is one connected.
270 */
271 void updateDeviceStates();
272 /**
273 * @brief Set the light box device
274 */
275 void setLightBox(ISD::LightBox *lightBox);
276
277 /**
278 * @brief Set the dust cap device
279 */
280 void setDustCap(ISD::DustCap *dustCap);
281
282 /**
283 * @brief Set the telescope device
284 */
285 void addMount(ISD::Mount *scope);
286
287 /**
288 * @brief Set the dome device
289 */
290 void setDome(ISD::Dome *dome);
291
292
293 // ////////////////////////////////////////////////////////////////////////////
294 // Facade to state machine
295 // ////////////////////////////////////////////////////////////////////////////
296 /**
297 * @brief Retrieve the current status of the capture sequence job from the state machine
298 */
299 JOBStatus getStatus()
300 {
301 return state->getStatus();
302 }
303
304 void setFrameType(CCDFrameType value)
305 {
306 state->setFrameType(value);
307 }
308 CCDFrameType getFrameType() const
309 {
310 return state->getFrameType();
311 }
312
313 int getTargetFilter() const
314 {
315 return state->targetFilterID;
316 }
317
318 double getTargetTemperature() const
319 {
320 return state->targetTemperature;
321 }
322 void setTargetTemperature(double value)
323 {
324 state->targetTemperature = value;
325 }
326
327 void setFocusStatus(FocusState value)
328 {
329 state->setFocusStatus(value);
330 }
331
332 double getTargetRotation() const
333 {
334 return state->targetPositionAngle;
335 }
336 void setTargetRotation(double value)
337 {
338 state->targetPositionAngle = value;
339 }
340
341 SequenceJobState::CalibrationStage getCalibrationStage() const
342 {
343 return state->calibrationStage;
344 }
345 void setCalibrationStage(SequenceJobState::CalibrationStage value)
346 {
347 state->calibrationStage = value;
348 }
349
350 SequenceJobState::PreparationState getPreparationState() const
351 {
352 return state->m_PreparationState;
353 }
354 void setPreparationState(SequenceJobState::PreparationState value)
355 {
356 state->m_PreparationState = value;
357 }
358
359 bool getAutoFocusReady() const
360 {
361 return state->autoFocusReady;
362 }
363 void setAutoFocusReady(bool value)
364 {
365 state->autoFocusReady = value;
366 }
367
368 /**
369 * @brief Central entry point to start all activities that are necessary
370 * before capturing may start. Signals {@see prepareComplete()} as soon as
371 * everything is ready.
372 */
373 void prepareCapture();
374 /**
375 * @brief processPrepareComplete All preparations necessary for capturing are completed
376 * @param success true iff preparation succeeded
377 */
378 void processPrepareComplete(bool success = true);
379 /**
380 * @brief Abort capturing
381 */
382 void processAbortCapture();
383
384 /**
385 * @brief Check if all initial tasks are completed so that capturing
386 * of flats may start.
387 * @return IPS_OK if cap is closed, IPS_BUSY if not and IPS_ALERT if the
388 * process should be aborted.
389 */
390 IPState checkFlatFramePendingTasksCompleted();
391
392 // current values
393 double currentTemperature() const;
394 double currentGain() const;
395 double currentOffset() const;
396
397 void saveTo(QTextStream &outstream, const QLocale &cLocale) const;
398 void loadFrom(XMLEle *root, const QString &targetName, SequenceJobType jobType);
399
400 signals:
401 // All preparations necessary for capturing are completed
402 void prepareComplete(bool success = true);
403 // Manage the result when capturing has been started
404 void captureStarted(CaptureResult rc);
405 // Abort capturing
406 void abortCapture();
407 // log entry
408 void newLog(QString);
409
410 void prepareState(CaptureState state);
411 // signals to be forwarded to the state machine
412 void prepareCapture(CCDFrameType frameType, bool enforceCCDTemp, bool enforceStartGuiderDrift, bool isPreview);
413 // update the current guiding deviation
414 void updateGuiderDrift(double deviation_rms);
415
416private:
417 /**
418 * @brief init Initialize the sequence job from its XML representation
419 */
420 void init(SequenceJobType jobType, XMLEle *root, QSharedPointer<CameraState> sharedState, const QString &targetName);
421
422 // job type (batch, preview, ...)
423 SequenceJobType m_jobType;
424
425 void setStatus(JOBStatus const);
426
427 //////////////////////////////////////////////////////////////
428 /// Custom Types
429 /// We save all core sequence properties in QVariant map
430 //////////////////////////////////////////////////////////////
431 QMap<PropertyID, QVariant> m_CoreProperties;
432
433 //////////////////////////////////////////////////////////////
434 /// Custom Types
435 /// We don't use Q_PROPERTY for these to simplify use
436 //////////////////////////////////////////////////////////////
437 QMap<QString, QMap<QString, QVariant>> m_CustomProperties;
438 FlatFieldDuration m_FlatFieldDuration { DURATION_MANUAL };
439 // Capture Scripts
441 // Upload Mode
442 ISD::Camera::UploadMode m_UploadMode { ISD::Camera::UPLOAD_CLIENT };
443 // Transfer Format
444 QString m_TransferFormat { "FITS" };
445
446 //////////////////////////////////////////////////////////////
447 /// Status Variables
448 //////////////////////////////////////////////////////////////
449 int m_CaptureRetires { 0 };
450 uint32_t m_Completed { 0 };
451 double m_ExposeLeft { 0 };
452 bool m_JobProgressIgnored {false};
453
454 //////////////////////////////////////////////////////////////
455 /// Device access
456 //////////////////////////////////////////////////////////////
457
458 /**
459 * @brief frameTypes Retrieve the frame types from the active camera's primary chip.
460 */
461 QStringList frameTypes() const;
462 /**
463 * @brief filterLabels list of currently available filter labels
464 */
465 QStringList filterLabels() const;
466
467 //////////////////////////////////////////////////////////////
468 /// State machines encapsulating the state of this capture sequence job
469 //////////////////////////////////////////////////////////////
472};
473
474}
Class handles control of INDI dome devices.
Definition indidome.h:25
Handles operation of a remotely controlled dust cover cap.
Definition indidustcap.h:25
Handles operation of a remotely controlled light box.
device handle controlling Mounts.
Definition indimount.h:29
Sequence Job is a container for the details required to capture a series of images.
The sky coordinates of a point in the sky.
Definition skypoint.h:45
Type type(const QSqlDatabase &db)
char * toString(const EngineQuery &query)
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
Q_OBJECTQ_OBJECT
QString & remove(QChar ch, Qt::CaseSensitivity cs)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.