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 ////////////////////////////////////////////////////////////////////////
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 // Setter: Set upload mode
241 void setUploadMode(ISD::Camera::UploadMode value);
242 // Getter: get upload mode
243 ISD::Camera::UploadMode getUploadMode() const;
244
245 // Setter: Set flat field source
246 void setCalibrationPreAction(uint32_t value);
247 // Getter: Get flat field source
248 uint32_t getCalibrationPreAction() const;
249
250 // Setter: Set Wall SkyPoint Azimuth coords
251 void setWallCoord(const SkyPoint &value);
252 // Getter: Get Flat field source wall coords
253 const SkyPoint &getWallCoord() const;
254
255 // Setter: Set flat field duration
256 void setFlatFieldDuration(FlatFieldDuration value);
257 // Getter: Get flat field duration
258 FlatFieldDuration getFlatFieldDuration() const;
259
260 // Setter: Set job progress ignored flag
261 void setJobProgressIgnored(bool value);
262 bool getJobProgressIgnored() const;
263
264 /**
265 * @brief updateDeviceStates Update for all used device types whether there
266 * is one connected.
267 */
268 void updateDeviceStates();
269 /**
270 * @brief Set the light box device
271 */
272 void setLightBox(ISD::LightBox *lightBox);
273
274 /**
275 * @brief Set the dust cap device
276 */
277 void setDustCap(ISD::DustCap *dustCap);
278
279 /**
280 * @brief Set the telescope device
281 */
282 void addMount(ISD::Mount *scope);
283
284 /**
285 * @brief Set the dome device
286 */
287 void setDome(ISD::Dome *dome);
288
289
290 // ////////////////////////////////////////////////////////////////////////////
291 // Facade to state machine
292 // ////////////////////////////////////////////////////////////////////////////
293 /**
294 * @brief Retrieve the current status of the capture sequence job from the state machine
295 */
296 JOBStatus getStatus()
297 {
298 return state->getStatus();
299 }
300
301 void setFrameType(CCDFrameType value)
302 {
303 state->setFrameType(value);
304 }
305 CCDFrameType getFrameType() const
306 {
307 return state->getFrameType();
308 }
309
310 int getTargetFilter() const
311 {
312 return state->targetFilterID;
313 }
314
315 double getTargetTemperature() const
316 {
317 return state->targetTemperature;
318 }
319 void setTargetTemperature(double value)
320 {
321 state->targetTemperature = value;
322 }
323
324 void setFocusStatus(FocusState value)
325 {
326 state->setFocusStatus(value);
327 }
328
329 double getTargetRotation() const
330 {
331 return state->targetPositionAngle;
332 }
333 void setTargetRotation(double value)
334 {
335 state->targetPositionAngle = value;
336 }
337
338 SequenceJobState::CalibrationStage getCalibrationStage() const
339 {
340 return state->calibrationStage;
341 }
342 void setCalibrationStage(SequenceJobState::CalibrationStage value)
343 {
344 state->calibrationStage = value;
345 }
346
347 SequenceJobState::PreparationState getPreparationState() const
348 {
349 return state->m_PreparationState;
350 }
351 void setPreparationState(SequenceJobState::PreparationState value)
352 {
353 state->m_PreparationState = value;
354 }
355
356 bool getAutoFocusReady() const
357 {
358 return state->autoFocusReady;
359 }
360 void setAutoFocusReady(bool value)
361 {
362 state->autoFocusReady = value;
363 }
364
365 /**
366 * @brief Central entry point to start all activities that are necessary
367 * before capturing may start. Signals {@see prepareComplete()} as soon as
368 * everything is ready.
369 */
370 void prepareCapture();
371 /**
372 * @brief processPrepareComplete All preparations necessary for capturing are completed
373 * @param success true iff preparation succeeded
374 */
375 void processPrepareComplete(bool success = true);
376 /**
377 * @brief Abort capturing
378 */
379 void processAbortCapture();
380
381 /**
382 * @brief Check if all initial tasks are completed so that capturing
383 * of flats may start.
384 * @return IPS_OK if cap is closed, IPS_BUSY if not and IPS_ALERT if the
385 * process should be aborted.
386 */
387 IPState checkFlatFramePendingTasksCompleted();
388
389 // current values
390 double currentTemperature() const;
391 double currentGain() const;
392 double currentOffset() const;
393
394 void saveTo(QTextStream &outstream, const QLocale &cLocale) const;
395 void loadFrom(XMLEle *root, const QString &targetName, SequenceJobType jobType,
397
398 signals:
399 // All preparations necessary for capturing are completed
400 void prepareComplete(bool success = true);
401 // Manage the result when capturing has been started
402 void captureStarted(CaptureModuleState::CAPTUREResult rc);
403 // Abort capturing
404 void abortCapture();
405 // log entry
406 void newLog(QString);
407
408 void prepareState(CaptureState state);
409 // signals to be forwarded to the state machine
410 void prepareCapture(CCDFrameType frameType, bool enforceCCDTemp, bool enforceStartGuiderDrift, bool isPreview);
411 // update the current guiding deviation
412 void updateGuiderDrift(double deviation_rms);
413
414private:
415 /**
416 * @brief init Initialize the sequence job from its XML representation
417 */
418 void init(SequenceJobType jobType, XMLEle *root, QSharedPointer<CaptureModuleState> sharedState, const QString &targetName);
419
420 // job type (batch, preview, ...)
421 SequenceJobType m_jobType;
422
423 void setStatus(JOBStatus const);
424
425 //////////////////////////////////////////////////////////////
426 /// Custom Types
427 /// We save all core sequence properties in QVariant map
428 //////////////////////////////////////////////////////////////
429 QMap<PropertyID, QVariant> m_CoreProperties;
430
431 //////////////////////////////////////////////////////////////
432 /// Custom Types
433 /// We don't use Q_PROPERTY for these to simplify use
434 //////////////////////////////////////////////////////////////
435 QMap<QString, QMap<QString, QVariant>> m_CustomProperties;
436 FlatFieldDuration m_FlatFieldDuration { DURATION_MANUAL };
437 // Capture Scripts
439 // Upload Mode
440 ISD::Camera::UploadMode m_UploadMode { ISD::Camera::UPLOAD_CLIENT };
441 // Transfer Format
442 QString m_TransferFormat { "FITS" };
443
444 //////////////////////////////////////////////////////////////
445 /// Status Variables
446 //////////////////////////////////////////////////////////////
447 int m_CaptureRetires { 0 };
448 uint32_t m_Completed { 0 };
449 double m_ExposeLeft { 0 };
450 bool m_JobProgressIgnored {false};
451
452 //////////////////////////////////////////////////////////////
453 /// Device access
454 //////////////////////////////////////////////////////////////
455
456 /**
457 * @brief frameTypes Retrieve the frame types from the active camera's primary chip.
458 */
459 QStringList frameTypes() const;
460 /**
461 * @brief filterLabels list of currently available filter labels
462 */
463 QStringList filterLabels() const;
464
465 //////////////////////////////////////////////////////////////
466 /// State machines encapsulating the state of this capture sequence job
467 //////////////////////////////////////////////////////////////
470};
471
472}
Class handles control of INDI dome devices.
Definition indidome.h:23
Handles operation of a remotely controlled dust cover cap.
Definition indidustcap.h:23
Handles operation of a remotely controlled light box.
device handle controlling Mounts.
Definition indimount.h:27
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:78
Q_OBJECTQ_OBJECT
QString & remove(int position, int n)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:45:34 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.