13#include "capturetypes.h"
16#include "indi/indistd.h"
17#include "indi/indidustcap.h"
18#include "indi/indicamera.h"
19#include "indi/indimount.h"
20#include "indi/indidome.h"
22#include "ekos/manager/meridianflipstate.h"
23#include "ekos/auxiliary/filtermanager.h"
24#include "ekos/scheduler/schedulertypes.h"
25#include "ekos/capture/refocusstate.h"
26#include "ekos/focus/focusutils.h"
27#include "placeholderpath.h"
31#define CAPTURE_TIMEOUT_THRESHOLD 180000
38constexpr double HFR_CHECK_DEFAULT_THRESHOLD = 10.0;
42class CaptureDeviceAdaptor;
45class CameraState:
public QObject
64 return m_sequenceQueue;
73 const QUrl &sequenceURL()
const;
74 void setSequenceURL(
const QUrl &newSequenceURL);
85 m_ImageData = newImageData;
92 int currentFilterID { Ekos::INVALID_VALUE };
106 MANUAL_COVER_CLOSED_LIGHT,
107 MANUAL_COVER_CLOSED_DARK
110 ManualCoverState m_ManualCoverState { MANAUL_COVER_OPEN };
112 bool hasLightBox {
false };
114 bool hasDustCap {
false };
116 bool hasTelescope {
false };
118 bool hasDome {
false };
123 ShutterStatus shutterStatus { SHUTTER_UNKNOWN };
132 void initCapturePreparation();
137 CaptureState getCaptureState()
const
139 return m_CaptureState;
141 void setCaptureState(CaptureState value);
143 bool isStartingCapture()
const
145 return m_StartingCapture;
147 void setStartingCapture(
bool newStartingCapture)
149 m_StartingCapture = newStartingCapture;
152 CaptureContinueAction getContinueAction()
const
154 return m_ContinueAction;
156 void setContinueAction(CaptureContinueAction newPauseFunction)
158 m_ContinueAction = newPauseFunction;
161 FocusState getFocusState()
const
165 void setFocusState(FocusState value)
167 m_FocusState = value;
170 GuideState getGuideState()
const
174 void setGuideState(GuideState state);
179 bool isActivelyGuiding();
181 bool useGuideHead()
const
183 return m_useGuideHead;
185 void setUseGuideHead(
bool value)
187 m_useGuideHead = value;
189 bool isGuidingDeviationDetected()
const
191 return m_GuidingDeviationDetected;
193 void setGuidingDeviationDetected(
bool newDeviationDetected)
195 m_GuidingDeviationDetected = newDeviationDetected;
198 bool suspendGuidingOnDownload()
const
200 return m_SuspendGuidingOnDownload;
202 void setSuspendGuidingOnDownload(
bool value)
204 m_SuspendGuidingOnDownload = value;
207 uint SpikesDetected()
const
209 return m_SpikesDetected;
211 uint increaseSpikesDetected()
213 return ++m_SpikesDetected;
215 void resetSpikesDetected()
217 m_SpikesDetected = 0;
220 IPState getDitheringState()
const
222 return m_DitheringState;
224 void setDitheringState(IPState value)
226 m_DitheringState = value;
229 AlignState getAlignState()
const
233 void setAlignState(AlignState value);
235 FilterState getFilterManagerState()
const
237 return m_FilterManagerState;
239 void setFilterManagerState(FilterState value)
241 m_FilterManagerState = value;
244 int getCurrentFilterPosition()
const
246 return m_CurrentFilterPosition;
249 const QString &getCurrentFilterName()
const
251 return m_CurrentFilterName;
254 const QString &CurrentFocusFilterName()
const
256 return m_CurrentFocusFilterName;
259 void setCurrentFilterPosition(
int position,
const QString &name,
const QString &focusFilterName);
261 LightState getLightBoxLightState()
const
263 return m_lightBoxLightState;
265 void setLightBoxLightState(LightState value)
267 m_lightBoxLightState = value;
270 bool lightBoxLightEnabled()
const
272 return m_lightBoxLightEnabled;
274 void setLightBoxLightEnabled(
bool value)
276 m_lightBoxLightEnabled = value;
282 void dustCapStateChanged(ISD::DustCap::Status status);
284 CapState getDustCapState()
const
286 return m_dustCapState;
288 void setDustCapState(CapState value)
290 m_dustCapState = value;
293 ISD::Mount::Status getScopeState()
const
297 void setScopeState(ISD::Mount::Status value)
299 m_scopeState = value;
302 ISD::Mount::PierSide getPierSide()
const
306 void setPierSide(ISD::Mount::PierSide value)
311 ISD::ParkStatus getScopeParkState()
const
313 return m_scopeParkState;
315 void setScopeParkState(ISD::ParkStatus value)
317 m_scopeParkState = value;
320 ISD::Dome::Status getDomeState()
const
324 void setDomeState(ISD::Dome::Status value)
334 return m_refocusState;
337 const QString &observerName()
const
339 return m_ObserverName;
341 void setObserverName(
const QString &value);
343 bool ignoreJobProgress()
const
345 return m_ignoreJobProgress;
347 void setIgnoreJobProgress(
bool value)
349 m_ignoreJobProgress = value;
352 bool isRememberFastExposure()
const
354 return m_RememberFastExposure;
356 void setRememberFastExposure(
bool value)
358 m_RememberFastExposure = value;
365 void setDirty(
bool value)
374 void setBusy(
bool busy);
376 bool isLooping()
const
380 void setLooping(
bool newLooping)
382 m_Looping = newLooping;
387 return m_SequenceArray;
391 m_SequenceArray = value;
394 PlaceholderPath &placeholderPath()
396 return m_currentPlaceholderPath;
398 void initPlaceholderPath()
400 m_currentPlaceholderPath = PlaceholderPath();
409 bool generateFilename(
const QString &extension,
QString *filename);
415 int getAlignmentRetries()
const
417 return m_AlignmentRetries;
419 int increaseAlignmentRetries()
421 return ++m_AlignmentRetries;
423 void resetAlignmentRetries()
425 m_AlignmentRetries = 0;
428 int getDitherCounter()
const
430 return m_ditherCounter;
432 void decreaseDitherCounter();
438 void resetDitherCounter();
440 int nextSequenceID()
const
442 return m_nextSequenceID;
444 void setNextSequenceID(
int id)
446 m_nextSequenceID = id;
449 uint16_t capturedFramesCount(
const QString &signature)
const
451 return m_capturedFramesMap[signature];
453 void setCapturedFramesCount(
const QString &signature, uint16_t count);
455 double lastRemainingFrameTimeMS()
const
457 return m_lastRemainingFrameTimeMS;
459 void setLastRemainingFrameTimeMS(
double value)
461 m_lastRemainingFrameTimeMS = value;
467 QTimer &getCaptureTimeout()
469 return m_captureTimeout;
471 uint8_t captureTimeoutCounter()
const
473 return m_CaptureTimeoutCounter;
475 void setCaptureTimeoutCounter(uint8_t value)
477 m_CaptureTimeoutCounter = value;
479 uint8_t deviceRestartCounter()
const
481 return m_DeviceRestartCounter;
483 void setDeviceRestartCounter(uint8_t value)
485 m_DeviceRestartCounter = value;
487 QTimer &downloadProgressTimer()
489 return m_downloadProgressTimer;
493 return m_DownloadTimer;
495 QTimer &getCaptureDelayTimer()
497 return m_captureDelayTimer;
499 QTimer &getGuideDeviationTimer()
501 return m_guideDeviationTimer;
504 QTime &imageCountDown()
506 return m_imageCountDown;
508 void imageCountDownAddMSecs(
int value)
510 m_imageCountDown = m_imageCountDown.
addMSecs(value);
513 QTime &sequenceCountDown()
515 return m_sequenceCountDown;
517 void sequenceCountDownAddMSecs(
int value)
519 m_sequenceCountDown = m_sequenceCountDown.
addMSecs(value);
547 bool checkDithering();
549 bool checkCapturing()
557 void updateMFMountState(MeridianFlipState::MeridianFlipMountState status);
562 void updateMeridianFlipStage(
const MeridianFlipState::MFStage &stage);
568 bool checkMeridianFlipActive();
574 bool checkMeridianFlipReady();
581 bool checkPostMeridianFlipActions();
588 bool checkAlignmentAfterFlip();
593 void checkGuideDeviationTimeout();
601 bool checkGuidingAfterFlip();
613 void processGuidingFailed();
618 void updateFocusState(FocusState state);
624 bool checkFocusRunning()
626 return (m_FocusState != FOCUS_IDLE && m_FocusState != FOCUS_COMPLETE && m_FocusState != FOCUS_ABORTED);
634 AutofocusReason getAFReason(RefocusState::RefocusReason state,
QString &reasonInfo);
640 bool startFocusIfRequired();
647 void updateAdaptiveFocusState(
bool success);
652 void updateHFRThreshold();
671 void setGuideDeviation(
double deviation_rms);
676 void addDownloadTime(
double time);
682 double averageDownloadTime()
684 return (downloadsCounter == 0 ? 0 : totalDownloadTime / downloadsCounter);
704 void checkSeqBoundary();
708 bool isModelinDSLRInfo(
const QString &model);
722 int pendingJobCount();
741 CCDFrameType jobFrameType(
int id);
747 int jobImageProgress(
int id);
753 int jobImageCount(
int id);
759 double jobExposureProgress(
int id);
765 double jobExposureDuration(
int id);
770 double progressPercentage();
775 bool isActiveJobPreview();
780 int activeJobRemainingTime();
785 int overallRemainingTime();
803 void setCalibrationSettings(
const QJsonObject &settings);
808 bool hasCapturedFramesMap()
810 return m_capturedFramesMap.
count() > 0;
815 void addCapturedFrame(
const QString &signature);
819 void removeCapturedFrameCount(
const QString &signature, uint16_t count);
823 void clearCapturedFramesMap()
825 m_capturedFramesMap.
clear();
828 bool isCaptureRunning()
834 bool isCaptureStopped()
839 bool isCapturePausing()
844 ScriptTypes captureScriptType()
const
846 return m_CaptureScriptType;
848 void setCaptureScriptType(ScriptTypes value)
850 m_CaptureScriptType = value;
852 double targetADU()
const
856 void setTargetADU(
double value)
860 double targetADUTolerance()
const
862 return m_TargetADUTolerance;
864 void setTargetADUTolerance(
double value)
866 m_TargetADUTolerance = value;
872 void setSkyFlat(
bool enabled)
884 const DoubleRange &exposureRange()
const
886 return m_ExposureRange;
888 void setExposureRange(
double min,
double max)
890 m_ExposureRange.min = min;
891 m_ExposureRange.max = max;
896 return m_frameSettings;
900 m_frameSettings = value;
903 FlatFieldDuration flatFieldDuration()
const
905 return m_flatFieldDuration;
907 void setFlatFieldDuration(FlatFieldDuration value)
909 m_flatFieldDuration = value;
912 uint32_t calibrationPreAction()
const
914 return m_CalibrationPreAction;
916 void setCalibrationPreAction(uint32_t value)
918 m_CalibrationPreAction = value;
926 const QString &opticalTrain()
const
928 return m_opticalTrain;
930 void setOpticalTrain(
const QString &newOpticalTrain)
932 m_opticalTrain = newOpticalTrain;
935 void setPrepareComplete(
bool success);
939 void captureBusy(
bool busy);
942 void suspendCapture();
943 void executeActiveJob();
944 void updatePrepareState(CaptureState state);
945 void captureStarted(CaptureResult rc);
947 void requestAction(CaptureWorkflowActionType action);
949 void newMeridianFlipStage(MeridianFlipState::MFStage status);
951 void meridianFlipStarted();
953 void newGuiderDrift(
double deviation_rms);
955 void guideAfterMeridianFlip();
957 void resetNonGuidedDither();
959 void newStatus(CaptureState status);
961 void newFocusStatus(FocusState status);
963 void newAdaptiveFocusStatus(
bool success);
965 void checkFocus(
double hfr);
967 void runAutoFocus(AutofocusReason autofocusReason,
const QString &reasonInfo);
969 void resetFocusFrame();
971 void adaptiveFocus();
973 void abortFastExposure();
975 void newLimitFocusHFR(
double hfr);
977 void newFilterPosition(
int targetFilterPosition, FilterManager::FilterPolicy policy = FilterManager::ALL_POLICIES);
979 void sequenceChanged(
const QJsonArray &sequence);
981 void newLog(
const QString &text);
1002 int m_CurrentFilterPosition { -1 };
1004 QString m_CurrentFilterName {
"--" };
1006 QString m_CurrentFocusFilterName {
"--" };
1010 bool m_StartingCapture {
true };
1012 bool m_useGuideHead {
false };
1014 bool m_GuidingDeviationDetected {
false };
1016 bool m_SuspendGuidingOnDownload {
false };
1018 uint m_SpikesDetected { 0 };
1020 QTimer m_guideDeviationTimer;
1023 uint8_t m_CaptureTimeoutCounter { 0 };
1024 uint8_t m_DeviceRestartCounter { 0 };
1026 QTime m_imageCountDown;
1027 double m_lastRemainingFrameTimeMS;
1030 QTimer m_captureDelayTimer;
1032 QTime m_sequenceCountDown;
1034 QTimer m_downloadProgressTimer;
1038 double totalDownloadTime {0};
1040 uint downloadsCounter {0};
1042 PlaceholderPath m_currentPlaceholderPath;
1044 int m_nextSequenceID { 0 };
1046 CaptureContinueAction m_ContinueAction { CAPTURE_CONTINUE_ACTION_NONE };
1050 bool m_ignoreJobProgress {
true };
1052 bool m_RememberFastExposure {
false};
1054 bool m_Dirty {
false };
1056 bool m_Busy {
false };
1058 bool m_Looping {
false };
1060 ScriptTypes m_CaptureScriptType { SCRIPT_N };
1062 double m_TargetADUTolerance { 1000 };
1063 double m_targetADU { 0 };
1064 bool m_skyFlat {
false };
1066 FlatFieldDuration m_flatFieldDuration { DURATION_MANUAL };
1067 uint32_t m_CalibrationPreAction { CAPTURE_PREACTION_NONE };
1068 bool m_lightBoxLightEnabled {
false };
1070 DoubleRange m_ExposureRange;
1078 FocusState m_FocusState { FOCUS_IDLE };
1079 GuideState m_GuideState { GUIDE_IDLE };
1080 IPState m_DitheringState {IPS_IDLE};
1082 FilterState m_FilterManagerState { FILTER_IDLE };
1083 LightState m_lightBoxLightState { CAP_LIGHT_UNKNOWN };
1084 CapState m_dustCapState { CAP_UNKNOWN };
1085 ISD::Mount::Status m_scopeState { ISD::Mount::MOUNT_IDLE };
1086 ISD::Mount::PierSide m_pierSide { ISD::Mount::PIER_UNKNOWN };
1087 ISD::ParkStatus m_scopeParkState { ISD::PARK_UNKNOWN };
1088 ISD::Dome::Status m_domeState { ISD::Dome::DOME_IDLE };
1094 int m_AlignmentRetries { 0 };
1096 uint m_ditherCounter { 0 };
1106 void appendLogText(
const QString &message);
Sequence Job is a container for the details required to capture a series of images.
The sky coordinates of a point in the sky.
Ekos is an advanced Astrophotography tool for Linux.
QMap< QString, uint16_t > CapturedFramesMap
mapping signature --> frames count
@ ALIGN_IDLE
No ongoing operations.
@ CAPTURE_CHANGING_FILTER
size_type count() const const
QObject * parent() const const
QTime addMSecs(int ms) const const