Kstars

sequencejob.h
1 /*
2  SPDX-FileCopyrightText: 2012 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "sequencejobstate.h"
10 #include "capturedeviceadaptor.h"
11 #include "indi/indistd.h"
12 #include "indi/indicamera.h"
13 #include "ekos/auxiliary/filtermanager.h"
14 #include "skyobjects/skypoint.h"
15 
16 #include <QTableWidgetItem>
17 
18 class SchedulerJob;
19 /**
20  * @class SequenceJob
21  * @short Sequence Job is a container for the details required to capture a series of images.
22  *
23  * @author Jasem Mutlaq
24  * @version 1.0
25  */
26 namespace Ekos
27 {
28 class SequenceJob : public QObject
29 {
30  Q_OBJECT
31 
32  public:
33  static QString const &ISOMarker;
34  static const QStringList StatusStrings;
35 
36  // Core Properties
37  typedef enum
38  {
39  // Bool
40  SJ_Preview,
41  // Bool
42  SJ_EnforceTemperature,
43  // Bool
44  SJ_EnforceStartGuiderDrift,
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  // Int
66  SJ_ISOIndex,
67  // Double
68  SJ_Gain,
69  // Double
70  SJ_Offset,
71  // QString
72  SJ_LocalDirectory,
73  // QString
74  SJ_RemoteDirectory,
75  // QString
76  SJ_DirectoryPostfix,
77  // Bool
78  SJ_FilterPrefixEnabled,
79  // Bool
80  SJ_ExpPrefixEnabled,
81  // Bool
82  SJ_TimeStampPrefixEnabled,
83  // QString
84  SJ_RawPrefix,
85  // QString
86  SJ_TargetName,
87  // QString
88  SJ_Filename,
89  // Bool
90  SJ_DarkFlat,
91  // Double
92  SJ_TargetADU,
93  // Double
94  SJ_TargetADUTolerance,
95  } PropertyID;
96 
97  ////////////////////////////////////////////////////////////////////////
98  /// Constructors
99  ////////////////////////////////////////////////////////////////////////
101  SequenceJob(XMLEle *root);
102  ~SequenceJob() = default;
103 
104  ////////////////////////////////////////////////////////////////////////
105  /// Capture Fuctions
106  ////////////////////////////////////////////////////////////////////////
107  CAPTUREResult capture(bool autofocusReady, FITSMode mode);
108  void abort();
109  void done();
110 
111  ////////////////////////////////////////////////////////////////////////
112  /// Core Properties
113  ////////////////////////////////////////////////////////////////////////
114  void setCoreProperty(PropertyID id, const QVariant &value);
115  QVariant getCoreProperty(PropertyID id) const;
116 
117  ////////////////////////////////////////////////////////////////////////
118  /// Job Status Functions
119  ////////////////////////////////////////////////////////////////////////
120  const QString &getStatusString()
121  {
122  return StatusStrings[getStatus()];
123  }
124  // Setter: Set how many captures have completed thus far
125  void setCompleted(int value);
126  // Getter: How many captured have completed thus far.
127  int getCompleted() const;
128  // Setter: Set how many more seconds to expose in this job
129  void setExposeLeft(double value);
130  // Getter: Get how many more seconds are left to expose.
131  double getExposeLeft() const;
132  // Reset: Reset the job status
133  void resetStatus(JOBStatus status = JOB_IDLE);
134  // Setter: Set how many times we re-try this job.
135  void setCaptureRetires(int value);
136  // Getter: Get many timed we retried this job already.
137  int getCaptureRetires() const;
138  // Getter: How many more seconds are remaining in this job given the
139  // estimated download time.
140  int getJobRemainingTime(double estimatedDownloadTime);
141 
142  ////////////////////////////////////////////////////////////////////////
143  /// State Machine Functions
144  ////////////////////////////////////////////////////////////////////////
145  // Setter: Set Target Filter Name
146  void setTargetFilter(int pos, const QString &name);
147  // Setter: Set Current filter slot
148  void setCurrentFilter(int value);
149  // Getter: Get Current Filter Slot
150  int getCurrentFilter() const;
151  // Setter: Set active filter manager.
152  void setFilterManager(const QSharedPointer<FilterManager> &manager);
153 
154  ////////////////////////////////////////////////////////////////////////
155  /// GUI Related Functions
156  ////////////////////////////////////////////////////////////////////////
157  void setStatusCell(QTableWidgetItem * cell);
158  void setCountCell(QTableWidgetItem * cell);
159 
160  ////////////////////////////////////////////////////////////////////////
161  /// Job Attribute Functions
162  ////////////////////////////////////////////////////////////////////////
163  QString getSignature();
164  // Scripts
165  const QMap<ScriptTypes, QString> &getScripts() const;
166  void setScripts(const QMap<ScriptTypes, QString> &scripts);
167  QString getScript(ScriptTypes type) const;
168  void setScript(ScriptTypes type, const QString &value);
169  // Custome Properties
170  QMap<QString, QMap<QString, QVariant> > getCustomProperties() const;
171  void setCustomProperties(const QMap<QString, QMap<QString, QVariant> > &value);
172 
173  // Setter: Set Frame Type
174  void setFrameType(CCDFrameType value);
175  // Getter: Get Frame Type
176  CCDFrameType getFrameType() const;
177 
178  // Setter: Set upload mode
179  void setUploadMode(ISD::Camera::UploadMode value);
180  // Getter: get upload mode
181  ISD::Camera::UploadMode getUploadMode() const;
182 
183  // Setter: Set flat field source
184  void setFlatFieldSource(FlatFieldSource value);
185  // Getter: Get flat field source
186  FlatFieldSource getFlatFieldSource() const;
187 
188  // Setter: Set Wall SkyPoint Azimuth coords
189  void setWallCoord(const SkyPoint& value);
190  // Getter: Get Flat field source wall coords
191  const SkyPoint &getWallCoord() const;
192 
193  // Setter: Set flat field duration
194  void setFlatFieldDuration(FlatFieldDuration value);
195  // Getter: Get flat field duration
196  FlatFieldDuration getFlatFieldDuration() const;
197 
198  // Setter: Set job progress ignored flag
199  void setJobProgressIgnored(bool value);
200  bool getJobProgressIgnored() const;
201 
202  /**
203  * @brief Set the light box device
204  */
205  void setLightBox(ISD::LightBox *lightBox);
206 
207  /**
208  * @brief Set the dust cap device
209  */
210  void setDustCap(ISD::DustCap *dustCap);
211 
212  /**
213  * @brief Set the telescope device
214  */
215  void addMount(ISD::Mount *scope);
216 
217  /**
218  * @brief Set the dome device
219  */
220  void setDome(ISD::Dome *dome);
221 
222 
223  // ////////////////////////////////////////////////////////////////////////////
224  // Facade to state machine
225  // ////////////////////////////////////////////////////////////////////////////
226  /**
227  * @brief Retrieve the current status of the capture sequence job from the state machine
228  */
229  JOBStatus getStatus()
230  {
231  return stateMachine->getStatus();
232  }
233 
234  int getTargetFilter()
235  {
236  return stateMachine->targetFilterID;
237  }
238 
239  double getTargetTemperature()
240  {
241  return stateMachine->targetTemperature;
242  }
243  void setTargetTemperature(double value)
244  {
245  stateMachine->targetTemperature = value;
246  }
247 
248  double getTargetStartGuiderDrift() const
249  {
250  return stateMachine->targetStartGuiderDrift;
251  }
252  void setTargetStartGuiderDrift(double value)
253  {
254  stateMachine->targetStartGuiderDrift = value;
255  }
256 
257  double getTargetRotation() const
258  {
259  return stateMachine->targetPositionAngle;
260  }
261  void setTargetRotation(double value)
262  {
263  stateMachine->targetPositionAngle = value;
264  }
265 
266  bool getPreMountPark() const
267  {
268  return stateMachine->preMountPark;
269  }
270  void setPreMountPark(bool value)
271  {
272  stateMachine->preMountPark = value;
273  }
274 
275  bool getPreDomePark() const
276  {
277  return stateMachine->preDomePark;
278  }
279  void setPreDomePark(bool value)
280  {
281  stateMachine->preDomePark = value;
282  }
283 
284  SequenceJobState::CalibrationStage getCalibrationStage() const
285  {
286  return stateMachine->calibrationStage;
287  }
288  void setCalibrationStage(SequenceJobState::CalibrationStage value)
289  {
290  stateMachine->calibrationStage = value;
291  }
292 
293  SequenceJobState::PreparationState getPreparationState() const
294  {
295  return stateMachine->m_PreparationState;
296  }
297  void setPreparationState(SequenceJobState::PreparationState value)
298  {
299  stateMachine->m_PreparationState = value;
300  }
301 
302  bool getAutoFocusReady() const
303  {
304  return stateMachine->autoFocusReady;
305  }
306  void setAutoFocusReady(bool value)
307  {
308  stateMachine->autoFocusReady = value;
309  }
310 
311  /**
312  * @brief Central entry point to start all activities that are necessary
313  * before capturing may start. Signals {@see prepareComplete()} as soon as
314  * everything is ready.
315  */
316  void prepareCapture();
317  /**
318  * @brief All preparations necessary for capturing are completed
319  */
320  void processPrepareComplete();
321  /**
322  * @brief Abort capturing
323  */
324  void processAbortCapture();
325 
326  /**
327  * @brief Check if all initial tasks are completed so that capturing
328  * of flats may start.
329  * @return IPS_OK if cap is closed, IPS_BUSY if not and IPS_ALERT if the
330  * process should be aborted.
331  */
332  IPState checkFlatFramePendingTasksCompleted();
333 
334 signals:
335  // All preparations necessary for capturing are completed
336  void prepareComplete();
337  // Abort capturing
338  void abortCapture();
339  // log entry
340  void newLog(QString);
341 
342  void prepareState(CaptureState state);
343  void checkFocus();
344  // signals to be forwarded to the state machine
345  void prepareCapture(CCDFrameType frameType, bool enforceCCDTemp, bool enforceStartGuiderDrift, bool isPreview);
346  // update the current guiding deviation
347  void updateGuiderDrift(double deviation_rms);
348 
349 
350 private:
351  // should not be used from outside
352  SequenceJob();
353 
354  void setStatus(JOBStatus const);
355 
356  //////////////////////////////////////////////////////////////
357  /// Custom Types
358  /// We save all core sequence properties in QVariant map
359  //////////////////////////////////////////////////////////////
360  QMap<PropertyID, QVariant> m_CoreProperties;
361 
362  //////////////////////////////////////////////////////////////
363  /// Custom Types
364  /// We don't use Q_PROPERTY for these to simplify use
365  //////////////////////////////////////////////////////////////
366  QMap<QString, QMap<QString, QVariant>> m_CustomProperties;
367  FlatFieldDuration m_FlatFieldDuration { DURATION_MANUAL };
368  // Capture Scripts
369  QMap<ScriptTypes, QString> m_Scripts;
370  // Upload Mode
371  ISD::Camera::UploadMode m_UploadMode { ISD::Camera::UPLOAD_CLIENT };
372  // Transfer Format
373  QString m_TransferFormat { "FITS" };
374  // capture frame type (light, flat, dark, bias)
375  CCDFrameType m_FrameType { FRAME_LIGHT };
376 
377  //////////////////////////////////////////////////////////////
378  /// Filter Manager
379  //////////////////////////////////////////////////////////////
380  QSharedPointer<FilterManager> m_FilterManager;
381 
382  //////////////////////////////////////////////////////////////
383  /// Status Variable
384  //////////////////////////////////////////////////////////////
385  int m_CaptureRetires { 0 };
386  uint32_t m_Completed { 0 };
387  double m_ExposeLeft { 0 };
388  bool m_JobProgressIgnored {false};
389  QTableWidgetItem * statusCell { nullptr };
390  QTableWidgetItem * countCell { nullptr };
391 
392  //////////////////////////////////////////////////////////////
393  /// State machines encapsulating the state of this capture sequence job
394  //////////////////////////////////////////////////////////////
395  QSharedPointer<CaptureDeviceAdaptor> captureDeviceAdaptor;
396  SequenceJobState *stateMachine { nullptr };
397  /**
398  * @brief Create all event connections between the state machine and the command processor
399  */
400  void connectDeviceAdaptor();
401  /**
402  * @brief Disconnect all event connections between the state machine and the command processor
403  */
404  void disconnectDeviceAdaptor();
405 
406 };
407 }
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:70
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
ScriptTypes
Definition: ekos.h:169
Sequence Job is a container for the details required to capture a series of images.
Definition: sequencejob.h:18
CaptureState
Capture states.
Definition: ekos.h:91
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 15 2022 04:04:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.