Kstars

align.h
1 /*
2  SPDX-FileCopyrightText: 2013 Jasem Mutlaq <[email protected]>
3  SPDX-FileCopyrightText: 2013-2021 Jasem Mutlaq <[email protected]>
4  SPDX-FileCopyrightText: 2018-2020 Robert Lancaster <[email protected]>
5  SPDX-FileCopyrightText: 2019-2021 Hy Murveit <[email protected]>
6 
7  SPDX-License-Identifier: GPL-2.0-or-later
8 */
9 
10 #pragma once
11 
12 #include "ekos/auxiliary/filtermanager.h"
13 #include "ui_align.h"
14 #include "ekos/ekos.h"
15 #include "indi/indicamera.h"
16 #include "indi/indistd.h"
17 #include "indi/indimount.h"
18 #include "indi/indidome.h"
19 #include "ksuserdb.h"
20 #include "ekos/auxiliary/darkprocessor.h"
21 
22 #include <QTime>
23 #include <QTimer>
24 #include <QElapsedTimer>
25 #include <KConfigDialog>
26 
27 #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
28 #include <QtDBus/qtdbusglobal.h>
29 #else
30 #include <QtDBus/qdbusmacros.h>
31 #endif
32 
33 #include <stellarsolver.h>
34 #include <memory>
35 
36 class QProgressIndicator;
37 
38 class AlignView;
39 class FOV;
40 class StarObject;
41 class ProfileInfo;
42 
43 namespace Ekos
44 {
45 class AstrometryParser;
46 class RemoteAstrometryParser;
47 class OpsAstrometry;
48 class OpsAlign;
49 class StellarSolverProfileEditor;
50 class OpsPrograms;
51 class OpsASTAP;
52 class OpsAstrometryIndexFiles;
53 class MountModel;
54 class PolarAlignmentAssistant;
55 class ManualRotator;
56 
57 /**
58  *@class Align
59  *@short Align class handles plate-solving and polar alignment measurement and correction using astrometry.net
60  * The align class employs StellarSolver library for local solvers and supports remote INDI-based solver.
61  * StellarSolver supports internal and external solvers (Astrometry.net, ASTAP, Online Astrometry).
62  * If an image is solved successfully, the image central J2000 RA & DE coordinates along with pixel scale, rotation, and partiy are
63  * reported back.
64  * Index files management is supported with ability to download astrometry.net files. The user may select and edit different solver
65  * profiles that provide settings to control both extraction and solving profiles in detail. Manual and automatic field rotation
66  * is supported in order to align the solved images to a particular orientation in the sky. The manual rotation assistant is an interactive
67  * tool that helps the user to arrive at the desired framing.
68  * Align module provide Polar Align Helper tool which enables easy-to-follow polar alignment procedure given wide FOVs (> 1.5 degrees)
69  * Legacy polar aligment is deprecated.
70  *@author Jasem Mutlaq
71  *@version 2.0
72  */
73 class Align : public QWidget, public Ui::Align
74 {
75  Q_OBJECT
76  Q_CLASSINFO("D-Bus Interface", "org.kde.kstars.Ekos.Align")
77  Q_PROPERTY(Ekos::AlignState status READ status NOTIFY newStatus)
78  Q_PROPERTY(QStringList logText READ logText NOTIFY newLog)
79  Q_PROPERTY(QString opticalTrain READ opticalTrain WRITE setOpticalTrain)
80  Q_PROPERTY(QString camera READ camera)
81  Q_PROPERTY(QString filterWheel READ filterWheel)
82  Q_PROPERTY(QString filter READ filter WRITE setFilter)
83  Q_PROPERTY(double exposure READ exposure WRITE setExposure)
84  Q_PROPERTY(QList<double> fov READ fov)
85  Q_PROPERTY(QList<double> cameraInfo READ cameraInfo)
86  Q_PROPERTY(QList<double> telescopeInfo READ telescopeInfo)
87  //Q_PROPERTY(QString solverArguments READ solverArguments WRITE setSolverArguments)
88 
89  public:
90  explicit Align(const QSharedPointer<ProfileInfo> &activeProfile);
91  virtual ~Align() override;
92 
93  typedef enum { GOTO_SYNC, GOTO_SLEW, GOTO_NOTHING } GotoMode;
94  typedef enum { SOLVER_LOCAL, SOLVER_REMOTE } SolverMode;
95  typedef enum
96  {
97  ALIGN_RESULT_SUCCESS,
98  ALIGN_RESULT_WARNING,
99  ALIGN_RESULT_FAILED
100  } AlignResult;
101 
102  typedef enum
103  {
104  BLIND_IDLE,
105  BLIND_ENGAGNED,
106  BLIND_USED
107  } BlindState;
108 
109  /** @defgroup AlignDBusInterface Ekos DBus Interface - Align Module
110  * Ekos::Align interface provides advanced scripting capabilities to solve images using online or offline astrometry.net
111  */
112 
113  /*@{*/
114 
115  /** DBUS interface function.
116  * Select CCD
117  * @param device CCD device name
118  * @return Returns true if device if found and selected, false otherwise.
119  */
120  Q_SCRIPTABLE QString camera();
121 
122  /** DBUS interface function.
123  * select the filter device from the available filter drivers. The filter device can be the same as the CCD driver if the filter functionality was embedded within the driver.
124  * @param device The filter device name
125  * @return Returns true if filter device is found and set, false otherwise.
126  */
127  Q_SCRIPTABLE QString filterWheel();
128 
129  /** DBUS interface function.
130  * select the filter from the available filters.
131  * @param filter The filter name
132  * @return Returns true if filter is found and set, false otherwise.
133  */
134  Q_SCRIPTABLE bool setFilter(const QString &filter);
135  Q_SCRIPTABLE QString filter();
136 
137  /** DBUS interface function.
138  * Start the plate-solving process given the passed image file.
139  * @param filename Name of image file to solve. FITS and JPG/JPG/TIFF formats are accepted.
140  * @param isGenerated Set to true if filename is generated from a CCD capture operation. If the file is loaded from any storage or network media, pass false.
141  * @return Returns true if device if found and selected, false otherwise.
142  */
143  Q_SCRIPTABLE Q_NOREPLY void startSolving();
144 
145  /** DBUS interface function.
146  * Select Solver Action after successfully solving an image.
147  * @param mode 0 for Sync, 1 for Slew To Target, 2 for Nothing (just display solution results)
148  */
149  Q_SCRIPTABLE Q_NOREPLY void setSolverAction(int mode);
150 
151  /** DBUS interface function.
152  * Returns the solver's solution results
153  * @return Returns array of doubles. First item is RA in degrees. Second item is DEC in degrees.
154  */
155  Q_SCRIPTABLE QList<double> getSolutionResult();
156 
157  /** DBUS interface function.
158  * Returns the solver's current status
159  * @return Returns solver status (Ekos::AlignState)
160  */
161  Q_SCRIPTABLE Ekos::AlignState status()
162  {
163  return state;
164  }
165 
166  /** DBUS interface function.
167  * @return Returns State of load slew procedure. Idle if not started. Busy if in progress. Ok if complete. Alert if procedure failed.
168  */
169  Q_SCRIPTABLE int getLoadAndSlewStatus()
170  {
171  return m_SolveFromFile;
172  }
173 
174  /** DBUS interface function.
175  * Sets the exposure of the selected CCD device.
176  * @param value Exposure value in seconds
177  */
178  Q_SCRIPTABLE Q_NOREPLY void setExposure(double value);
179  Q_SCRIPTABLE double exposure()
180  {
181  return alignExposure->value();
182  }
183 
184  /** DBUS interface function.
185  * Get currently active camera info in this order:
186  * width, height, pixel_size_x, pixel_size_y
187  */
188  Q_SCRIPTABLE QList<double> cameraInfo();
189 
190  /** DBUS interface function.
191  * Get current active telescope info in this order:
192  * focal length, aperture
193  */
194  Q_SCRIPTABLE QList<double> telescopeInfo();
195 
196  /** @}*/
197 
198  /**
199  * @brief Add Camera to the list of available Cameras.
200  * @param device pointer to camera device.
201  * @return True if added successfully, false if duplicate or failed to add.
202  */
203  bool setCamera(ISD::Camera *device);
204 
205  /**
206  * @brief addFilterWheel Add new filter wheel filter device.
207  * @param device pointer to filter device.
208  * @return True if added successfully, false if duplicate or failed to add.
209  */
210  bool setFilterWheel(ISD::FilterWheel *device);
211 
212  /**
213  * @brief Add new mount
214  * @param device pointer to mount device.
215  * @return True if added successfully, false if duplicate or failed to add.
216  */
217  bool setMount(ISD::Mount *device);
218 
219  /**
220  * @brief Add new Dome
221  * @param device pointer to dome device.
222  * @return True if added successfully, false if duplicate or failed to add.
223  */
224  bool setDome(ISD::Dome *device);
225 
226  /**
227  * @brief Add new Rotator
228  * @param device pointer to rotator device.
229  * @return True if added successfully, false if duplicate or failed to add.
230  */
231  bool setRotator(ISD::Rotator *device);
232 
233  void removeDevice(const QSharedPointer<ISD::GenericDevice> &device);
234 
235  /**
236  * @brief setAstrometryDevice
237  * @param newAstrometry
238  */
240 
241  /**
242  * @brief CCD information is updated, sync them.
243  */
244  void syncCameraInfo();
245 
246  /**
247  * @brief syncCCDControls Update camera controls like gain, offset, ISO..etc.
248  */
249  void syncCameraControls();
250 
251  /**
252  * @brief Generate arguments we pass to the remote solver.
253  */
255 
256  /**
257  * @brief Does our parser exist in the system?
258  */
259  bool isParserOK();
260 
261  // Log
262  QStringList logText()
263  {
264  return m_LogText;
265  }
266  QString getLogText()
267  {
268  return m_LogText.join("\n");
269  }
270  void clearLog();
271 
272  /**
273  * @brief getFOVScale Returns calculated FOV values
274  * @param fov_w FOV width in arcmins
275  * @param fov_h FOV height in arcmins
276  * @param fov_scale FOV scale in arcsec per pixel
277  */
278  void getFOVScale(double &fov_w, double &fov_h, double &fov_scale);
279  QList<double> fov();
280 
281  /**
282  * @brief getCalculatedFOVScale Get calculated FOV scales from the current CCD+Telescope combination.
283  * @param fov_w return calculated fov width in arcminutes
284  * @param fov_h return calculated fov height in arcminutes
285  * @param fov_scale return calculated fov pixcale in arcsecs per pixel.
286  * @note This is NOT the same as effective FOV which is the measured FOV from astrometry. It is the
287  * theoretical FOV from calculated values.
288  */
289  void getCalculatedFOVScale(double &fov_w, double &fov_h, double &fov_scale);
290 
291  void setupFilterManager();
292  void setupPlot();
293  void setupSolutionTable();
294  void setupOptions();
295 
296  /**
297  * @brief Sync the telescope to the solved alignment coordinate.
298  */
299  void Sync();
300 
301  /**
302  * @brief Slew the telescope to the solved alignment coordinate.
303  */
304  void Slew();
305 
306  /**
307  * @brief Sync the telescope to the solved alignment coordinate, and then slew to the target coordinate.
308  */
309  void SlewToTarget();
310 
311  /**
312  * @brief getStellarSolverProfiles
313  * @return list of StellarSolver profile names
314  */
316 
317  GotoMode currentGOTOMode() const
318  {
319  return m_CurrentGotoMode;
320  }
321 
322  /**
323  * @brief generateOptions Generate astrometry.net option given the supplied map
324  * @param optionsMap List of key=value pairs for all astrometry.net options
325  * @return String List of valid astrometry.net options
326  */
327  static QStringList generateRemoteOptions(const QVariantMap &optionsMap);
328  static void generateFOVBounds(double fov_h, QString &fov_low, QString &fov_high, double tolerance = 0.05);
329 
330  // access to the mount model UI, required for testing
331  MountModel * mountModel() const
332  {
333  return m_MountModel;
334  }
335 
336  PolarAlignmentAssistant *polarAlignmentAssistant() const
337  {
338  return m_PolarAlignmentAssistant;
339  }
340 
341  bool wcsSynced() const
342  {
343  return m_wcsSynced;
344  }
345 
346  /**
347  * @brief Process updated device properties
348  * @param prop INDI Property
349  */
350  void updateProperty(INDI::Property prop);
351 
352 
353  /**
354  * @brief Check CCD and make sure information is updated and FOV is re-calculated.
355  * @param CCDNum By default, we check the already selected CCD in the dropdown menu. If CCDNum is specified, the check is made against this specific CCD in the dropdown menu. CCDNum is the index of the CCD in the dropdown menu.
356  */
357  void checkCamera();
358 
359  /**
360  * @brief Check Filter and make sure information is updated accordingly.
361  * @param filterNum By default, we check the already selected filter in the dropdown menu. If filterNum is specified, the check is made against this specific filter in the dropdown menu.
362  * filterNum is the index of the filter in the dropdown menu.
363  */
364  void checkFilter();
365 
366  /**
367  * @brief checkCameraExposureProgress Track the progress of CCD exposure
368  * @param targetChip Target chip under exposure
369  * @param remaining how many seconds remaining
370  * @param state status of exposure
371  */
372  void checkCameraExposureProgress(ISD::CameraChip *targetChip, double remaining, IPState state);
373  /**
374  * @brief Process new FITS received from CCD.
375  * @param bp pointer to blob property
376  */
377  void processData(const QSharedPointer<FITSData> &data);
378 
379  /** DBUS interface function.
380  * Loads an image (FITS, RAW, or JPG/PNG) and solve its coordinates, then it slews to the solved coordinates and an image is captured and solved to ensure
381  * the telescope is pointing to the same coordinates of the image.
382  * @param image buffer to image data.
383  * @param extension image extension (e.g. cr2, jpg, fits,..etc).
384  */
385  bool loadAndSlew(const QByteArray &image, const QString &extension);
386 
387  /** \addtogroup AlignDBusInterface
388  * @{
389  */
390 
391  /**
392  * @brief Stop aligning
393  * @param mode stop mode (abort or suspend)
394  */
395  void stop(Ekos::AlignState mode);
396 
397  /** DBUS interface function.
398  * Aborts the solving operation, handle outside of the align module.
399  */
400  Q_SCRIPTABLE Q_NOREPLY void abort()
401  {
403  }
404 
405  /**
406  * @brief Suspend aligning, recovery handled by the align module itself.
407  */
408  void suspend()
409  {
411  }
412 
413  /** DBUS interface function.
414  * Select the solver mode
415  * @param type Set solver type. 0 LOCAL, 1 REMOTE (requires remote astrometry driver to be activated)
416  */
417  Q_SCRIPTABLE Q_NOREPLY void setSolverMode(int mode);
418 
419  /** DBUS interface function.
420  * Capture and solve an image using the astrometry.net engine
421  * @return Returns true if the procedure started successful, false otherwise.
422  */
423  Q_SCRIPTABLE bool captureAndSolve();
424 
425  /** DBUS interface function.
426  * Loads an image (FITS, RAW, or JPG/PNG) and solve its coordinates, then it slews to the solved coordinates and an image is captured and solved to ensure
427  * the telescope is pointing to the same coordinates of the image.
428  * @param fileURL URL to the image to solve
429  */
430  Q_SCRIPTABLE bool loadAndSlew(QString fileURL = QString());
431 
432  /** DBUS interface function.
433  * Sets the target coordinates that the solver compares the solution coordinates to.
434  * By default, the target coordinates are those of the current mount when the capture and
435  * solve operation is started. In case of SYNC, only the error between the the solution and target
436  * coordinates is calculated. When Slew to Target is selected, the mount would be slewed afterwards to
437  * this target coordinate.
438  * @param ra0 J2000 Right Ascension in hours.
439  * @param de0 J2000 Declination in degrees.
440  */
441  Q_SCRIPTABLE Q_NOREPLY void setTargetCoords(double ra0, double de0);
442 
443  /**
444  * @brief getTargetCoords QList of target coordinates.
445  * @return First value is J2000 RA in hours. Second value is J2000 DE in degrees.
446  */
447  Q_SCRIPTABLE QList<double> getTargetCoords();
448 
449 
450  /**
451  * @brief Set the alignment target where the mount is expected to point at.
452  * @param targetCoord exact coordinates of the target position.
453  */
454  void setTarget(const SkyPoint &targetCoord);
455 
456  /**
457  * @brief Set the coordinates that the mount reports as its position
458  * @param position current mount position
459  */
460  void setTelescopeCoordinates(const SkyPoint &position)
461  {
462  m_TelescopeCoord = position;
463  }
464 
465  Q_SCRIPTABLE Q_NOREPLY void setTargetPositionAngle(double value);
466 
467  /** DBUS interface function.
468  * Sets the binning of the selected CCD device.
469  * @param binIndex Index of binning value. Default values range from 0 (binning 1x1) to 3 (binning 4x4)
470  */
471  Q_SCRIPTABLE Q_NOREPLY void setBinningIndex(int binIndex);
472 
473  /** @}*/
474 
475  /**
476  * @brief Solver finished successfully, process the data and execute the required actions depending on the mode.
477  * @param orientation Orientation of image in degrees (East of North)
478  * @param ra Center RA in solved image, degrees.
479  * @param dec Center DEC in solved image, degrees.
480  * @param pixscale Image scale is arcsec/pixel
481  * @param eastToTheRight When the image is rotated, so that North is up, East would be to the right.
482  */
483  void solverFinished(double orientation, double ra, double dec, double pixscale, bool eastToTheRight);
484 
485  void solverComplete();
486 
487  /**
488  * @brief Process solver failure.
489  */
490  void solverFailed();
491 
492  /**
493  * @brief We received new telescope info, process them and update FOV.
494  */
495  bool syncTelescopeInfo();
496 
497  void setFocusStatus(Ekos::FocusState state);
498 
499  // Log
500  void appendLogText(const QString &);
501 
502  // Capture
503  void setCaptureComplete();
504 
505  // Update Capture Module status
506  void setCaptureStatus(Ekos::CaptureState newState);
507  // Update Mount module status
508  void setMountStatus(ISD::Mount::Status newState);
509 
510  void zoomAlignView();
511  void setAlignZoom(double scale);
512 
513  // Manual Rotator Dialog
514  void toggleManualRotator(bool toggled);
515  /**
516  * @brief checkIfRotationRequired Check whether we need to perform an ALIGN_ROTATING action, whether manual or automatic.
517  * @return True if rotation is required as per the settings, false is not required.
518  */
520 
521  // Settings
522  QVariantMap getAllSettings() const;
523  void setAllSettings(const QVariantMap &settings);
524 
525  // Trains
526  QString opticalTrain() const
527  {
528  return opticalTrainCombo->currentText();
529  }
530  void setOpticalTrain(const QString &value)
531  {
532  opticalTrainCombo->setCurrentText(value);
533  }
534 
535  private slots:
536  // Solver timeout
537  void checkAlignmentTimeout();
538  void setAlignTableResult(AlignResult result);
539 
540  // External View
541  void showFITSViewer();
542  void toggleAlignWidgetFullScreen();
543 
544  /**
545  * @brief prepareCapture Set common settings for capture for align module
546  * @param targetChip target Chip
547  */
548  void prepareCapture(ISD::CameraChip *targetChip);
549 
550  //Solutions Display slots
551  void buildTarget();
552  void handlePointTooltip(QMouseEvent *event);
553  void handleVerticalPlotSizeChange();
554  void handleHorizontalPlotSizeChange();
555  void selectSolutionTableRow(int row, int column);
556  void slotClearAllSolutionPoints();
557  void slotRemoveSolutionPoint();
558  void slotAutoScaleGraph();
559 
560  // Model
561  void slotMountModel();
562 
563  // Capture Timeout
564  void processCaptureTimeout();
565 
566  protected slots:
567  /**
568  * @brief After a solver process is completed successfully, sync, slew to target, or do nothing as set by the user.
569  */
570  void executeGOTO();
571 
572  /**
573  * @brief refreshAlignOptions is called when settings are updated in OpsAlign.
574  */
575  void refreshAlignOptions();
576 
577  void processPAHStage(int stage);
578 
579  signals:
580  void newLog(const QString &text);
581  void newStatus(Ekos::AlignState state);
582  void newPAAStage(int stage);
583  void newSolution(const QVariantMap &solution);
584 
585  // This is sent when we load an image in the view
586  void newImage(const QSharedPointer<FITSView> &view);
587  // This is sent when the pixmap is updated within the view
588  void newFrame(const QSharedPointer<FITSView> &view);
589  // Send new solver results
590  void newSolverResults(double orientation, double ra, double dec, double pixscale);
591 
592  // Train changed
593  void trainChanged();
594 
595  // Settings
596  void settingsUpdated(const QVariantMap &settings);
597 
598  // Manual Rotator
599  void manualRotatorChanged(double currentPA, double targetPA, double threshold);
600 
601  private:
602 
603  void setupOpticalTrainManager();
604  void refreshOpticalTrain();
605 
606  ////////////////////////////////////////////////////////////////////
607  /// Settings
608  ////////////////////////////////////////////////////////////////////
609 
610  /**
611  * @brief Connect GUI elements to sync settings once updated.
612  */
613  void connectSettings();
614  /**
615  * @brief Stop updating settings when GUI elements are updated.
616  */
617  void disconnectSettings();
618  /**
619  * @brief loadSettings Load setting from Options and set them accordingly.
620  */
621  void loadGlobalSettings();
622 
623  /**
624  * @brief syncSettings When checkboxes, comboboxes, or spin boxes are updated, save their values in the
625  * global and per-train settings.
626  */
627  void syncSettings();
628 
629  /**
630  * @brief syncControl Sync setting to widget. The value depends on the widget type.
631  * @param settings Map of all settings
632  * @param key name of widget to sync
633  * @param widget pointer of widget to set
634  * @return True if sync successful, false otherwise
635  */
636  bool syncControl(const QVariantMap &settings, const QString &key, QWidget * widget);
637 
638  /**
639  * @brief Retrieve the align status indicator
640  */
641  QProgressIndicator *getProgressStatus();
642 
643  /**
644  * @brief Stop the progress animation in the solution table
645  */
646  void stopProgressAnimation();
647 
648  void exportSolutionPoints();
649 
650  /**
651  * @brief Calculate Field of View of CCD+Telescope combination that we need to pass to astrometry.net solver.
652  */
653  void calculateFOV();
654 
655  /**
656  * @brief calculateEffectiveFocalLength Calculate Focal Length purely form astrometric data.
657  */
658  void calculateEffectiveFocalLength(double newFOVW);
659 
660  /**
661  * @brief calculateAlignTargetDiff Find the difference between aligned vs. target coordinates and update
662  * the GUI accordingly.
663  */
664  void calculateAlignTargetDiff();
665 
666  /**
667  * @brief Get formatted RA & DEC coordinates compatible with astrometry.net format.
668  * @param ra Right ascension
669  * @param dec Declination
670  * @param ra_str will contain the formatted RA string
671  * @param dec_str will contain the formatted DEC string
672  */
673  void getFormattedCoords(double ra, double dec, QString &ra_str, QString &dec_str);
674 
675  uint8_t getSolverDownsample(uint16_t binnedW);
676 
677  /**
678  * @brief setWCSEnabled enables/disables World Coordinate System settings in the CCD driver.
679  * @param enable true to enable WCS, false to disable.
680  */
681  void setWCSEnabled(bool enable);
682 
683  void resizeEvent(QResizeEvent *event) override;
684 
685  KPageWidgetItem *m_IndexFilesPage;
686  QString savedOptionsProfiles;
687 
688  /**
689  * @brief React when a mount motion has been detected
690  */
691  void handleMountMotion();
692 
693  /**
694  * @brief Continue aligning according to the current mount status
695  */
696  void handleMountStatus();
697 
698  /**
699  * @brief initPolarAlignmentAssistant Initialize Polar Alignment Asssistant Tool
700  */
701  void setupPolarAlignmentAssistant();
702 
703  /**
704  * @brief initManualRotator Initialize Manual Rotator Tool
705  */
706  void setupManualRotator();
707 
708  /**
709  * @brief initDarkProcessor Initialize Dark Processor
710  */
711  void setuptDarkProcessor();
712 
713  bool matchPAHStage(uint32_t stage);
714 
715 
716  // Effective FOV
717 
718  /**
719  * @brief getEffectiveFOV Search database for effective FOV that matches the current profile and settings
720  * @return Variant Map containing effect FOV data or empty variant map if none found
721  */
722  QVariantMap getEffectiveFOV();
723  void saveNewEffectiveFOV(double newFOVW, double newFOVH);
724  QList<QVariantMap> effectiveFOVs;
725  void syncFOV();
726 
727  // We are using calculated FOV now until a more accurate effective FOV is found.
728  bool m_EffectiveFOVPending { false };
729  /// Which chip should we invoke in the current CCD?
730  bool useGuideHead { false };
731  /// Can the mount sync its coordinates to those set by Ekos?
732  bool canSync { false };
733  // m_SolveFromFile is true we load an image and solve it, no capture is done.
734  bool m_SolveFromFile { false };
735  // Target Position Angle of solver Load&Slew image to be used for rotator if necessary
736  double m_TargetPositionAngle { std::numeric_limits<double>::quiet_NaN() };
737  double currentRotatorPA { -1 };
738  /// Solver iterations count
739  uint8_t solverIterations { 0 };
740  /// Was solving with scale off used?
741  BlindState useBlindScale {BLIND_IDLE};
742  /// Was solving with position off used?
743  BlindState useBlindPosition {BLIND_IDLE};
744 
745  // FOV
746  double m_CameraPixelWidth { -1 };
747  double m_CameraPixelHeight { -1 };
748  uint16_t m_CameraWidth { 0 };
749  uint16_t m_CameraHeight { 0 };
750 
751  double m_FocalLength {-1};
752  double m_Aperture {-1};
753  double m_FocalRatio {-1};
754  double m_Reducer = {-1};
755 
756  double m_FOVWidth { 0 };
757  double m_FOVHeight { 0 };
758  double m_FOVPixelScale { 0 };
759 
760  // Keep track of solver results
761  double sOrientation { INVALID_VALUE };
762  double sRA { INVALID_VALUE };
763  double sDEC { INVALID_VALUE };
764 
765  /// Solver alignment coordinates
766  SkyPoint m_AlignCoord;
767  /// Target coordinates we need to slew to
768  SkyPoint m_TargetCoord;
769  /// Current telescope coordinates
770  SkyPoint m_TelescopeCoord;
771  /// Difference between solution and target coordinate
772  double m_TargetDiffTotal { 1e6 };
773  double m_TargetDiffRA { 1e6 };
774  double m_TargetDiffDE { 1e6 };
775 
776  /// Progress icon if the solver is running
777  std::unique_ptr<QProgressIndicator> pi;
778 
779  /// Keep track of how long the solver is running
780  QElapsedTimer solverTimer;
781 
782  // The StellarSolver
783  std::unique_ptr<StellarSolver> m_StellarSolver;
784  // StellarSolver Profiles
785  QList<SSolver::Parameters> m_StellarSolverProfiles;
786 
787  /// Have we slewed?
788  bool m_wasSlewStarted { false };
789  // Above flag only stays false for 10s after slew start.
790  QElapsedTimer slewStartTimer;
791  bool didSlewStart();
792  // Only wait this many milliseconds for slew to start.
793  // Otherwise assume it has begun.
794  static constexpr int MAX_WAIT_FOR_SLEW_START_MSEC = 10000;
795 
796  // Online and Offline parsers
797  AstrometryParser* parser { nullptr };
798  std::unique_ptr<RemoteAstrometryParser> remoteParser;
799  QSharedPointer<ISD::GenericDevice> m_RemoteParserDevice;
800 
801  // Pointers to our devices
802  ISD::Mount *m_Mount { nullptr };
803  ISD::Dome *m_Dome { nullptr };
804  ISD::Camera *m_Camera { nullptr };
805  ISD::Rotator *m_Rotator { nullptr };
806  ISD::FilterWheel *m_FilterWheel { nullptr };
807 
808  int currentFilterPosition { -1 };
809  /// True if we need to change filter position and wait for result before continuing capture
810  bool filterPositionPending { false };
811 
812  /// Keep track of solver FOV to be plotted in the skymap after each successful solve operation
813  std::shared_ptr<FOV> solverFOV;
814  std::shared_ptr<FOV> sensorFOV;
815 
816  /// WCS
817  bool m_wcsSynced { false };
818 
819  /// Log
820  QStringList m_LogText;
821 
822  /// Issue counters
823  uint8_t m_CaptureTimeoutCounter { 0 };
824  uint8_t m_CaptureErrorCounter { 0 };
825  uint8_t m_SlewErrorCounter { 0 };
826 
827  QTimer m_CaptureTimer;
828 
829  // State
830  AlignState state { ALIGN_IDLE };
831  FocusState m_FocusState { FOCUS_IDLE };
832  CaptureState m_CaptureState { CAPTURE_IDLE };
833 
834  // Track which upload mode the CCD is set to. If set to UPLOAD_LOCAL, then we need to switch it to UPLOAD_CLIENT in order to do focusing, and then switch it back to UPLOAD_LOCAL
835  ISD::Camera::UploadMode rememberUploadMode { ISD::Camera::UPLOAD_CLIENT };
836 
837  GotoMode m_CurrentGotoMode;
838 
839  QString dirPath;
840 
841  // Timer
842  QTimer m_AlignTimer;
843 
844  // Align Frame
845  QSharedPointer<AlignView> m_AlignView;
846 
847  // FITS Viewer in case user want to display in it instead of internal view
849 
850  QUrl alignURL;
851  QUrl alignURLPath;
852 
853  // keep track of autoWSC
854  bool rememberAutoWCS { false };
855  bool rememberSolverWCS { false };
856 
857  // Differential Slewing
858  bool differentialSlewingActivated { false };
859  bool targetAccuracyNotMet { false };
860 
861  // Astrometry Options
862  OpsAstrometry *opsAstrometry { nullptr };
863  OpsAlign *opsAlign { nullptr };
864  OpsPrograms *opsPrograms { nullptr };
865  OpsAstrometryIndexFiles *opsAstrometryIndexFiles { nullptr };
866  OpsASTAP *opsASTAP { nullptr };
867  StellarSolverProfileEditor *optionsProfileEditor { nullptr };
868 
869  // Drawing
870  QCPCurve *centralTarget { nullptr };
871  QCPCurve *yellowTarget { nullptr };
872  QCPCurve *redTarget { nullptr };
873  QCPCurve *concentricRings { nullptr };
874 
875  // Telescope Settings
876  double effectiveFocalLength = -1;
877  bool m_isRateSynced = false;
878  bool domeReady = true;
879 
880  // CCD Exposure Looping
881  bool m_RememberCameraFastExposure = { false };
882 
883  // Controls
884  double alignGainSpecialValue {INVALID_VALUE};
885  double TargetCustomGainValue {-1};
886 
887  // Data
888  QSharedPointer<FITSData> m_ImageData;
889 
890  // Active Profile
891  QSharedPointer<ProfileInfo> m_ActiveProfile;
892 
893  // Threshold to notify settle time is 3 seconds
894  static constexpr uint16_t DELAY_THRESHOLD_NOTIFY { 3000 };
895 
896  // Mount Model
897  // N.B. We do not need to use "smart pointer" here as the object memroy
898  // is taken care of by the Qt framework.
899  MountModel *m_MountModel {nullptr};
900  PolarAlignmentAssistant *m_PolarAlignmentAssistant {nullptr};
901  ManualRotator *m_ManualRotator {nullptr};
902 
903  // Dark Processor
904  QPointer<DarkProcessor> m_DarkProcessor;
905 
906  // Filter Manager
907  QSharedPointer<FilterManager> m_FilterManager;
908 
909  // Settings
910  QVariantMap m_Settings;
911  QVariantMap m_GlobalSettings;
912 };
913 }
Q_OBJECTQ_OBJECT
Definition: fov.h:27
A plottable representing a parametric curve in a plot.
Definition: qcustomplot.h:5576
Q_PROPERTY(...)
Q_SCRIPTABLE Q_NOREPLY void setSolverAction(int mode)
DBUS interface function.
Definition: align.cpp:1702
void Sync()
Sync the telescope to the solved alignment coordinate.
Definition: align.cpp:2707
Q_SCRIPTABLE bool captureAndSolve()
DBUS interface function.
Definition: align.cpp:1377
void stop(Ekos::AlignState mode)
Stop aligning.
Definition: align.cpp:2298
Q_SCRIPTABLE Q_NOREPLY void setExposure(double value)
DBUS interface function.
Definition: align.cpp:2872
Q_SCRIPTABLE QList< double > getSolutionResult()
DBUS interface function.
Definition: align.cpp:2384
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:69
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
void checkCamera()
Check CCD and make sure information is updated and FOV is re-calculated.
Definition: align.cpp:577
Q_SCRIPTABLE QList< double > getTargetCoords()
getTargetCoords QList of target coordinates.
Definition: align.cpp:3551
bool checkIfRotationRequired()
checkIfRotationRequired Check whether we need to perform an ALIGN_ROTATING action,...
Definition: align.cpp:2204
void setTelescopeCoordinates(const SkyPoint &position)
Set the coordinates that the mount reports as its position.
Definition: align.h:460
Q_CLASSINFO(Name, Value)
Q_SCRIPTABLE bool setFilter(const QString &filter)
DBUS interface function.
Definition: align.cpp:2935
Q_SCRIPTABLE Q_NOREPLY void setSolverMode(int mode)
DBUS interface function.
Definition: align.cpp:534
virtual bool event(QEvent *event) override
@ ALIGN_SUSPENDED
Alignment operations suspended.
Definition: ekos.h:155
void syncCameraControls()
syncCCDControls Update camera controls like gain, offset, ISO..etc.
Definition: align.cpp:879
void processData(const QSharedPointer< FITSData > &data)
Process new FITS received from CCD.
Definition: align.cpp:1603
Q_SCRIPTABLE Q_NOREPLY void setTargetCoords(double ra0, double de0)
DBUS interface function.
Definition: align.cpp:3535
static QStringList generateRemoteOptions(const QVariantMap &optionsMap)
generateOptions Generate astrometry.net option given the supplied map
Definition: align.cpp:1157
void SlewToTarget()
Sync the telescope to the solved alignment coordinate, and then slew to the target coordinate.
Definition: align.cpp:2742
bool loadAndSlew(const QByteArray &image, const QString &extension)
DBUS interface function.
Definition: align.cpp:2850
bool setCamera(ISD::Camera *device)
Add Camera to the list of available Cameras.
Definition: align.cpp:615
Q_SCRIPTABLE Ekos::AlignState status()
DBUS interface function.
Definition: align.h:161
The QProgressIndicator class lets an application display a progress indicator to show that a long tas...
bool setRotator(ISD::Rotator *device)
Add new Rotator.
Definition: align.cpp:3196
void Slew()
Slew the telescope to the solved alignment coordinate.
Definition: align.cpp:2725
bool setDome(ISD::Dome *device)
Add new Dome.
Definition: align.cpp:722
void getCalculatedFOVScale(double &fov_w, double &fov_h, double &fov_scale)
getCalculatedFOVScale Get calculated FOV scales from the current CCD+Telescope combination.
Definition: align.cpp:972
subclass of SkyObject specialized for stars.
Definition: starobject.h:32
@ CAPTURE_IDLE
Definition: ekos.h:93
QStringList generateRemoteArgs(const QSharedPointer< FITSData > &imageData)
Generate arguments we pass to the remote solver.
Definition: align.cpp:1247
CaptureState
Capture states.
Definition: ekos.h:91
bool isParserOK()
Does our parser exist in the system?
Definition: align.cpp:503
void refreshAlignOptions()
refreshAlignOptions is called when settings are updated in OpsAlign.
Definition: align.cpp:3213
void updateProperty(INDI::Property prop)
Process updated device properties.
Definition: align.cpp:2409
void suspend()
Suspend aligning, recovery handled by the align module itself.
Definition: align.h:408
QString join(const QString &separator) const const
@ ALIGN_ABORTED
Alignment aborted by user or agent.
Definition: ekos.h:149
void checkCameraExposureProgress(ISD::CameraChip *targetChip, double remaining, IPState state)
checkCameraExposureProgress Track the progress of CCD exposure
Definition: align.cpp:3016
void setAstrometryDevice(const QSharedPointer< ISD::GenericDevice > &device)
setAstrometryDevice
Definition: align.cpp:3183
void solverFinished(double orientation, double ra, double dec, double pixscale, bool eastToTheRight)
Solver finished successfully, process the data and execute the required actions depending on the mode...
Definition: align.cpp:1901
Q_SCRIPTABLE Q_NOREPLY void setBinningIndex(int binIndex)
DBUS interface function.
Definition: align.cpp:2877
QStringList getStellarSolverProfiles()
getStellarSolverProfiles
Definition: align.cpp:3638
@ ALIGN_IDLE
No ongoing operations.
Definition: ekos.h:146
Q_SCRIPTABLE Q_NOREPLY void abort()
DBUS interface function.
Definition: align.h:400
void checkFilter()
Check Filter and make sure information is updated accordingly.
Definition: align.cpp:2952
bool setMount(ISD::Mount *device)
Add new mount.
Definition: align.cpp:665
bool syncTelescopeInfo()
We received new telescope info, process them and update FOV.
Definition: align.cpp:785
bool setFilterWheel(ISD::FilterWheel *device)
addFilterWheel Add new filter wheel filter device.
Definition: align.cpp:2892
Align class handles plate-solving and polar alignment measurement and correction using astrometry....
Definition: align.h:73
void executeGOTO()
After a solver process is completed successfully, sync, slew to target, or do nothing as set by the u...
Definition: align.cpp:2689
Q_SCRIPTABLE Q_NOREPLY void startSolving()
DBUS interface function.
Definition: align.cpp:1708
void setTarget(const SkyPoint &targetCoord)
Set the alignment target where the mount is expected to point at.
Definition: align.cpp:3544
AlignState
Definition: ekos.h:144
void syncCameraInfo()
CCD information is updated, sync them.
Definition: align.cpp:828
Q_SCRIPTABLE int getLoadAndSlewStatus()
DBUS interface function.
Definition: align.h:169
void solverFailed()
Process solver failure.
Definition: align.cpp:2151
void getFOVScale(double &fov_w, double &fov_h, double &fov_scale)
getFOVScale Returns calculated FOV values
Definition: align.cpp:938
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Mar 22 2023 04:02:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.