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 bool isVideo() const
314 {
315 return state->getFrameType() == FRAME_VIDEO;
316 }
317
318 int getTargetFilter() const
319 {
320 return state->targetFilterID;
321 }
322
323 double getTargetTemperature() const
324 {
325 return state->targetTemperature;
326 }
327 void setTargetTemperature(double value)
328 {
329 state->targetTemperature = value;
330 }
331
332 void setFocusStatus(FocusState value)
333 {
334 state->setFocusStatus(value);
335 }
336
337 double getTargetRotation() const
338 {
339 return state->targetPositionAngle;
340 }
341 void setTargetRotation(double value)
342 {
343 state->targetPositionAngle = value;
344 }
345
346 SequenceJobState::CalibrationStage getCalibrationStage() const
347 {
348 return state->calibrationStage;
349 }
350 void setCalibrationStage(SequenceJobState::CalibrationStage value)
351 {
352 state->calibrationStage = value;
353 }
354
355 SequenceJobState::PreparationState getPreparationState() const
356 {
357 return state->m_PreparationState;
358 }
359 void setPreparationState(SequenceJobState::PreparationState value)
360 {
361 state->m_PreparationState = value;
362 }
363
364 bool getAutoFocusReady() const
365 {
366 return state->autoFocusReady;
367 }
368 void setAutoFocusReady(bool value)
369 {
370 state->autoFocusReady = value;
371 }
372
373 /**
374 * @brief Central entry point to start all activities that are necessary
375 * before capturing may start. Signals {@see prepareComplete()} as soon as
376 * everything is ready.
377 */
378 void prepareCapture();
379 /**
380 * @brief processPrepareComplete All preparations necessary for capturing are completed
381 * @param success true iff preparation succeeded
382 */
383 void processPrepareComplete(bool success = true);
384 /**
385 * @brief Abort capturing
386 */
387 void processAbortCapture();
388
389 /**
390 * @brief Check if all initial tasks are completed so that capturing
391 * of flats may start.
392 * @return IPS_OK if cap is closed, IPS_BUSY if not and IPS_ALERT if the
393 * process should be aborted.
394 */
395 IPState checkFlatFramePendingTasksCompleted();
396
397 // current values
398 double currentTemperature() const;
399 double currentGain() const;
400 double currentOffset() const;
401
402 void saveTo(QTextStream &outstream, const QLocale &cLocale) const;
403 void loadFrom(XMLEle *root, const QString &targetName, SequenceJobType jobType);
404
405 signals:
406 // All preparations necessary for capturing are completed
407 void prepareComplete(bool success = true);
408 // Manage the result when capturing has been started
409 void captureStarted(CaptureResult rc);
410 // Abort capturing
411 void abortCapture();
412 // log entry
413 void newLog(QString);
414
415 void prepareState(CaptureState state);
416 // signals to be forwarded to the state machine
417 void prepareCapture(CCDFrameType frameType, bool enforceCCDTemp, bool enforceStartGuiderDrift, bool isPreview);
418 // update the current guiding deviation
419 void updateGuiderDrift(double deviation_rms);
420
421private:
422 /**
423 * @brief init Initialize the sequence job from its XML representation
424 */
425 void init(SequenceJobType jobType, XMLEle *root, QSharedPointer<CameraState> sharedState, const QString &targetName);
426
427 // job type (batch, preview, ...)
428 SequenceJobType m_jobType;
429
430 void setStatus(JOBStatus const);
431
432 //////////////////////////////////////////////////////////////
433 /// Custom Types
434 /// We save all core sequence properties in QVariant map
435 //////////////////////////////////////////////////////////////
436 QMap<PropertyID, QVariant> m_CoreProperties;
437
438 //////////////////////////////////////////////////////////////
439 /// Custom Types
440 /// We don't use Q_PROPERTY for these to simplify use
441 //////////////////////////////////////////////////////////////
442 QMap<QString, QMap<QString, QVariant>> m_CustomProperties;
443 FlatFieldDuration m_FlatFieldDuration { DURATION_MANUAL };
444 // Capture Scripts
446 // Upload Mode
447 ISD::Camera::UploadMode m_UploadMode { ISD::Camera::UPLOAD_CLIENT };
448 // Transfer Format
449 QString m_TransferFormat { "FITS" };
450
451 //////////////////////////////////////////////////////////////
452 /// Status Variables
453 //////////////////////////////////////////////////////////////
454 int m_CaptureRetires { 0 };
455 uint32_t m_Completed { 0 };
456 double m_ExposeLeft { 0 };
457 bool m_JobProgressIgnored {false};
458
459 //////////////////////////////////////////////////////////////
460 /// Device access
461 //////////////////////////////////////////////////////////////
462
463 /**
464 * @brief frameTypes Retrieve the frame types from the active camera's primary chip.
465 */
466 QStringList frameTypes() const;
467 /**
468 * @brief filterLabels list of currently available filter labels
469 */
470 QStringList filterLabels() const;
471 /**
472 * @brief setCameraProperties Set all camera device properties required for capturing
473 */
474 QString setCameraDeviceProperties();
475
476 //////////////////////////////////////////////////////////////
477 /// State machines encapsulating the state of this capture sequence job
478 //////////////////////////////////////////////////////////////
481};
482
483}
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
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 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.