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

KDE's Doxygen guidelines are available online.