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 "ui_align.h"
13 #include "ekos/ekos.h"
14 #include "indi/indicamera.h"
15 #include "indi/indistd.h"
16 #include "indi/indimount.h"
17 #include "skypoint.h"
18 
19 #include <QTime>
20 #include <QTimer>
21 #include <QElapsedTimer>
22 #include <KConfigDialog>
23 
24 #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
25 #include <qtdbusglobal.h>
26 #else
27 #include <qdbusmacros.h>
28 #endif
29 
30 #include <stellarsolver.h>
31 #include <memory>
32 
33 class QProgressIndicator;
34 
35 class AlignView;
36 class FOV;
37 class StarObject;
38 class ProfileInfo;
39 class RotatorSettings;
40 
41 namespace Ekos
42 {
43 class AstrometryParser;
44 class DarkProcessor;
45 class FilterManager;
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  */
230  void setRotator(ISD::Rotator *device);
231 
232  void removeDevice(const QSharedPointer<ISD::GenericDevice> &device);
233 
234  /**
235  * @brief setAstrometryDevice
236  * @param newAstrometry
237  */
239 
240  /**
241  * @brief CCD information is updated, sync them.
242  */
243  void syncCameraInfo();
244 
245  /**
246  * @brief syncCCDControls Update camera controls like gain, offset, ISO..etc.
247  */
248  void syncCameraControls();
249 
250  /**
251  * @brief Generate arguments we pass to the remote solver.
252  */
254 
255  /**
256  * @brief Does our parser exist in the system?
257  */
258  bool isParserOK();
259 
260  // Log
261  QStringList logText()
262  {
263  return m_LogText;
264  }
265  QString getLogText()
266  {
267  return m_LogText.join("\n");
268  }
269  void clearLog();
270 
271  /**
272  * @brief getFOVScale Returns calculated FOV values
273  * @param fov_w FOV width in arcmins
274  * @param fov_h FOV height in arcmins
275  * @param fov_scale FOV scale in arcsec per pixel
276  */
277  void getFOVScale(double &fov_w, double &fov_h, double &fov_scale);
278  QList<double> fov();
279 
280  /**
281  * @brief getCalculatedFOVScale Get calculated FOV scales from the current CCD+Telescope combination.
282  * @param fov_w return calculated fov width in arcminutes
283  * @param fov_h return calculated fov height in arcminutes
284  * @param fov_scale return calculated fov pixcale in arcsecs per pixel.
285  * @note This is NOT the same as effective FOV which is the measured FOV from astrometry. It is the
286  * theoretical FOV from calculated values.
287  */
288  void getCalculatedFOVScale(double &fov_w, double &fov_h, double &fov_scale);
289 
290  void setupFilterManager();
291  void setupPlot();
292  void setupSolutionTable();
293  void setupOptions();
294 
295  /**
296  * @brief Sync the telescope to the solved alignment coordinate.
297  */
298  void Sync();
299 
300  /**
301  * @brief Slew the telescope to the solved alignment coordinate.
302  */
303  void Slew();
304 
305  /**
306  * @brief Sync the telescope to the solved alignment coordinate, and then slew to the target coordinate.
307  */
308  void SlewToTarget();
309 
310  /**
311  * @brief getStellarSolverProfiles
312  * @return list of StellarSolver profile names
313  */
315 
316  GotoMode currentGOTOMode() const
317  {
318  return m_CurrentGotoMode;
319  }
320 
321  /**
322  * @brief generateOptions Generate astrometry.net option given the supplied map
323  * @param optionsMap List of key=value pairs for all astrometry.net options
324  * @return String List of valid astrometry.net options
325  */
326  static QStringList generateRemoteOptions(const QVariantMap &optionsMap);
327  static void generateFOVBounds(double fov_h, QString &fov_low, QString &fov_high, double tolerance = 0.05);
328 
329  // access to the mount model UI, required for testing
330  MountModel * mountModel() const
331  {
332  return m_MountModel;
333  }
334 
335  PolarAlignmentAssistant *polarAlignmentAssistant() const
336  {
337  return m_PolarAlignmentAssistant;
338  }
339 
340  bool wcsSynced() const
341  {
342  return m_wcsSynced;
343  }
344 
345  /**
346  * @brief Process updated device properties
347  * @param prop INDI Property
348  */
349  void updateProperty(INDI::Property prop);
350 
351 
352  /**
353  * @brief Check CCD and make sure information is updated and FOV is re-calculated.
354  * @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.
355  */
356  void checkCamera();
357 
358  /**
359  * @brief Check Filter and make sure information is updated accordingly.
360  * @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.
361  * filterNum is the index of the filter in the dropdown menu.
362  */
363  void checkFilter();
364 
365  /**
366  * @brief checkCameraExposureProgress Track the progress of CCD exposure
367  * @param targetChip Target chip under exposure
368  * @param remaining how many seconds remaining
369  * @param state status of exposure
370  */
371  void checkCameraExposureProgress(ISD::CameraChip *targetChip, double remaining, IPState state);
372  /**
373  * @brief Process new FITS received from CCD.
374  * @param bp pointer to blob property
375  */
376  void processData(const QSharedPointer<FITSData> &data);
377 
378  /** DBUS interface function.
379  * 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
380  * the telescope is pointing to the same coordinates of the image.
381  * @param image buffer to image data.
382  * @param extension image extension (e.g. cr2, jpg, fits,..etc).
383  */
384  bool loadAndSlew(const QByteArray &image, const QString &extension);
385 
386  /** \addtogroup AlignDBusInterface
387  * @{
388  */
389 
390  /**
391  * @brief Stop aligning
392  * @param mode stop mode (abort or suspend)
393  */
394  void stop(Ekos::AlignState mode);
395 
396  /** DBUS interface function.
397  * Aborts the solving operation, handle outside of the align module.
398  */
399  Q_SCRIPTABLE Q_NOREPLY void abort()
400  {
402  }
403 
404  /**
405  * @brief Suspend aligning, recovery handled by the align module itself.
406  */
407  void suspend()
408  {
410  }
411 
412  /** DBUS interface function.
413  * Select the solver mode
414  * @param type Set solver type. 0 LOCAL, 1 REMOTE (requires remote astrometry driver to be activated)
415  */
416  Q_SCRIPTABLE Q_NOREPLY void setSolverMode(int mode);
417 
418  /** DBUS interface function.
419  * Capture and solve an image using the astrometry.net engine
420  * @return Returns true if the procedure started successful, false otherwise.
421  */
422  Q_SCRIPTABLE bool captureAndSolve();
423 
424  /** DBUS interface function.
425  * 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
426  * the telescope is pointing to the same coordinates of the image.
427  * @param fileURL URL to the image to solve
428  */
429  Q_SCRIPTABLE bool loadAndSlew(QString fileURL = QString());
430 
431  /** DBUS interface function.
432  * Sets the target coordinates that the solver compares the solution coordinates to.
433  * By default, the target coordinates are those of the current mount when the capture and
434  * solve operation is started. In case of SYNC, only the error between the solution and target
435  * coordinates is calculated. When Slew to Target is selected, the mount would be slewed afterwards to
436  * this target coordinate.
437  * @param ra0 J2000 Right Ascension in hours.
438  * @param de0 J2000 Declination in degrees.
439  */
440  Q_SCRIPTABLE Q_NOREPLY void setTargetCoords(double ra0, double de0);
441 
442  /**
443  * @brief getTargetCoords QList of target coordinates.
444  * @return First value is J2000 RA in hours. Second value is J2000 DE in degrees.
445  */
446  Q_SCRIPTABLE QList<double> getTargetCoords();
447 
448 
449  /**
450  * @brief Set the alignment target where the mount is expected to point at.
451  * @param targetCoord exact coordinates of the target position.
452  */
453  void setTarget(const SkyPoint &targetCoord);
454 
455  /**
456  * @brief Set the coordinates that the mount reports as its position
457  * @param position current mount position
458  */
459  void setTelescopeCoordinates(const SkyPoint &position)
460  {
461  m_TelescopeCoord = position;
462  }
463 
464  Q_SCRIPTABLE Q_NOREPLY void setTargetPositionAngle(double value);
465 
466  /** DBUS interface function.
467  * Sets the binning of the selected CCD device.
468  * @param binIndex Index of binning value. Default values range from 0 (binning 1x1) to 3 (binning 4x4)
469  */
470  Q_SCRIPTABLE Q_NOREPLY void setBinningIndex(int binIndex);
471 
472  /** @}*/
473 
474  /**
475  * @brief Solver finished successfully, process the data and execute the required actions depending on the mode.
476  * @param orientation Orientation of image in degrees (East of North)
477  * @param ra Center RA in solved image, degrees.
478  * @param dec Center DEC in solved image, degrees.
479  * @param pixscale Image scale is arcsec/pixel
480  * @param eastToTheRight When the image is rotated, so that North is up, East would be to the right.
481  */
482  void solverFinished(double orientation, double ra, double dec, double pixscale, bool eastToTheRight);
483 
484  void solverComplete();
485 
486  /**
487  * @brief Process solver failure.
488  */
489  void solverFailed();
490 
491  /**
492  * @brief We received new telescope info, process them and update FOV.
493  */
494  bool syncTelescopeInfo();
495 
496  void setFocusStatus(Ekos::FocusState state);
497 
498  // Log
499  void appendLogText(const QString &);
500 
501  // Capture
502  void setCaptureComplete();
503 
504  // Update Capture Module status
505  void setCaptureStatus(Ekos::CaptureState newState);
506  // Update Mount module status
507  void setMountStatus(ISD::Mount::Status newState);
508 
509  void zoomAlignView();
510  void setAlignZoom(double scale);
511 
512  // Manual Rotator Dialog
513  void toggleManualRotator(bool toggled);
514 
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  Ekos::OpsAlign *getAlignOptionsModule()
536  {
537  return opsAlign;
538  }
539 
540  private slots:
541  // Solver timeout
542  void checkAlignmentTimeout();
543  void setAlignTableResult(AlignResult result);
544 
545  // External View
546  void showFITSViewer();
547  void toggleAlignWidgetFullScreen();
548 
549  /**
550  * @brief prepareCapture Set common settings for capture for align module
551  * @param targetChip target Chip
552  */
553  void prepareCapture(ISD::CameraChip *targetChip);
554 
555  //Solutions Display slots
556  void buildTarget();
557  void handlePointTooltip(QMouseEvent *event);
558  void handleVerticalPlotSizeChange();
559  void handleHorizontalPlotSizeChange();
560  void selectSolutionTableRow(int row, int column);
561  void slotClearAllSolutionPoints();
562  void slotRemoveSolutionPoint();
563  void slotAutoScaleGraph();
564 
565  // Model
566  void slotMountModel();
567 
568  // Capture Timeout
569  void processCaptureTimeout();
570 
571  protected slots:
572  /**
573  * @brief After a solver process is completed successfully, sync, slew to target, or do nothing as set by the user.
574  */
575  void executeGOTO();
576 
577  /**
578  * @brief refreshAlignOptions is called when settings are updated in OpsAlign.
579  */
580  void refreshAlignOptions();
581 
582  void processPAHStage(int stage);
583 
584  signals:
585  void newLog(const QString &text);
586  void newStatus(Ekos::AlignState state);
587  void newPAAStage(int stage);
588  void newSolution(const QVariantMap &solution);
589 
590  // This is sent when we load an image in the view
591  void newImage(const QSharedPointer<FITSView> &view);
592  // This is sent when the pixmap is updated within the view
593  void newFrame(const QSharedPointer<FITSView> &view);
594  // Send new solver results
595  void newSolverResults(double orientation, double ra, double dec, double pixscale);
596 
597  // Train changed
598  void trainChanged();
599 
600  // Settings
601  void settingsUpdated(const QVariantMap &settings);
602 
603  // Manual Rotator
604  void manualRotatorChanged(double currentPA, double targetPA, double pixscale);
605 
606  private:
607 
608  void setupOpticalTrainManager();
609  void refreshOpticalTrain();
610 
611  ////////////////////////////////////////////////////////////////////
612  /// Settings
613  ////////////////////////////////////////////////////////////////////
614 
615  /**
616  * @brief Connect GUI elements to sync settings once updated.
617  */
618  void connectSettings();
619  /**
620  * @brief Stop updating settings when GUI elements are updated.
621  */
622  void disconnectSettings();
623  /**
624  * @brief loadSettings Load setting from Options and set them accordingly.
625  */
626  void loadGlobalSettings();
627 
628  /**
629  * @brief syncSettings When checkboxes, comboboxes, or spin boxes are updated, save their values in the
630  * global and per-train settings.
631  */
632  void syncSettings();
633 
634  /**
635  * @brief syncControl Sync setting to widget. The value depends on the widget type.
636  * @param settings Map of all settings
637  * @param key name of widget to sync
638  * @param widget pointer of widget to set
639  * @return True if sync successful, false otherwise
640  */
641  bool syncControl(const QVariantMap &settings, const QString &key, QWidget * widget);
642 
643  void setState (AlignState value);
644  /**
645  * @brief Retrieve the align status indicator
646  */
647  QProgressIndicator *getProgressStatus();
648 
649  /**
650  * @brief Stop the progress animation in the solution table
651  */
652  void stopProgressAnimation();
653 
654  void exportSolutionPoints();
655 
656  /**
657  * @brief Calculate Field of View of CCD+Telescope combination that we need to pass to astrometry.net solver.
658  */
659  void calculateFOV();
660 
661  /**
662  * @brief calculateEffectiveFocalLength Calculate Focal Length purely form astrometric data.
663  */
664  void calculateEffectiveFocalLength(double newFOVW);
665 
666  /**
667  * @brief calculateAlignTargetDiff Find the difference between aligned vs. target coordinates and update
668  * the GUI accordingly.
669  */
670  void calculateAlignTargetDiff();
671 
672  /**
673  * @brief Get formatted RA & DEC coordinates compatible with astrometry.net format.
674  * @param ra Right ascension
675  * @param dec Declination
676  * @param ra_str will contain the formatted RA string
677  * @param dec_str will contain the formatted DEC string
678  */
679  void getFormattedCoords(double ra, double dec, QString &ra_str, QString &dec_str);
680 
681  uint8_t getSolverDownsample(uint16_t binnedW);
682 
683  /**
684  * @brief setWCSEnabled enables/disables World Coordinate System settings in the CCD driver.
685  * @param enable true to enable WCS, false to disable.
686  */
687  void setWCSEnabled(bool enable);
688 
689  void resizeEvent(QResizeEvent *event) override;
690 
691  KPageWidgetItem *m_IndexFilesPage;
692  QString savedOptionsProfiles;
693 
694  /**
695  * @brief React when a mount motion has been detected
696  */
697  void handleMountMotion();
698 
699  /**
700  * @brief Continue aligning according to the current mount status
701  */
702  void handleMountStatus();
703 
704  /**
705  * @brief initPolarAlignmentAssistant Initialize Polar Alignment Asssistant Tool
706  */
707  void setupPolarAlignmentAssistant();
708 
709  void setupRotatorControl();
710 
711  /**
712  * @brief initManualRotator Initialize Manual Rotator Tool
713  */
714  void setupManualRotator();
715 
716  /**
717  * @brief initDarkProcessor Initialize Dark Processor
718  */
719  void setuptDarkProcessor();
720 
721  bool matchPAHStage(uint32_t stage);
722 
723 
724  // Effective FOV
725 
726  /**
727  * @brief getEffectiveFOV Search database for effective FOV that matches the current profile and settings
728  * @return Variant Map containing effect FOV data or empty variant map if none found
729  */
730  QVariantMap getEffectiveFOV();
731  void saveNewEffectiveFOV(double newFOVW, double newFOVH);
732  QList<QVariantMap> effectiveFOVs;
733  void syncFOV();
734 
735  // We are using calculated FOV now until a more accurate effective FOV is found.
736  bool m_EffectiveFOVPending { false };
737  /// Which chip should we invoke in the current CCD?
738  bool useGuideHead { false };
739  /// Can the mount sync its coordinates to those set by Ekos?
740  bool canSync { false };
741  // m_SolveFromFile is true we load an image and solve it, no capture is done.
742  bool m_SolveFromFile { false };
743  // Target Position Angle of solver Load&Slew image to be used for rotator if necessary
744  double m_TargetPositionAngle { std::numeric_limits<double>::quiet_NaN() };
745  // Target Pierside of solver Load&Slew image to be used
746  ISD::Mount::PierSide m_TargetPierside = ISD::Mount::PIER_UNKNOWN;
747  double currentRotatorPA { -1 };
748  /// Solver iterations count
749  uint8_t solverIterations { 0 };
750  /// Was solving with scale off used?
751  BlindState useBlindScale {BLIND_IDLE};
752  /// Was solving with position off used?
753  BlindState useBlindPosition {BLIND_IDLE};
754 
755  // FOV
756  double m_CameraPixelWidth { -1 };
757  double m_CameraPixelHeight { -1 };
758  uint16_t m_CameraWidth { 0 };
759  uint16_t m_CameraHeight { 0 };
760 
761  double m_FocalLength {-1};
762  double m_Aperture {-1};
763  double m_FocalRatio {-1};
764  double m_Reducer = {-1};
765 
766  double m_FOVWidth { 0 };
767  double m_FOVHeight { 0 };
768  double m_FOVPixelScale { 0 };
769 
770  // Keep raw rotator angle
771  double sRawAngle { INVALID_VALUE };
772  // Keep track of solver results
773  double sOrientation { INVALID_VALUE };
774  double sRA { INVALID_VALUE };
775  double sDEC { INVALID_VALUE };
776 
777  /// Solver alignment coordinates
778  SkyPoint m_AlignCoord;
779  /// Target coordinates we need to slew to
780  SkyPoint m_TargetCoord;
781  /// Current telescope coordinates
782  SkyPoint m_TelescopeCoord;
783  /// Difference between solution and target coordinate
784  double m_TargetDiffTotal { 1e6 };
785  double m_TargetDiffRA { 1e6 };
786  double m_TargetDiffDE { 1e6 };
787 
788  /// Progress icon if the solver is running
789  std::unique_ptr<QProgressIndicator> pi;
790 
791  /// Keep track of how long the solver is running
792  QElapsedTimer solverTimer;
793 
794  // The StellarSolver
795  std::unique_ptr<StellarSolver> m_StellarSolver;
796  // StellarSolver Profiles
797  QList<SSolver::Parameters> m_StellarSolverProfiles;
798 
799  /// Have we slewed?
800  bool m_wasSlewStarted { false };
801  // Above flag only stays false for 10s after slew start.
802  QElapsedTimer slewStartTimer;
803  bool didSlewStart();
804  // Only wait this many milliseconds for slew to start.
805  // Otherwise assume it has begun.
806  static constexpr int MAX_WAIT_FOR_SLEW_START_MSEC = 10000;
807 
808  // Online and Offline parsers
809  AstrometryParser* parser { nullptr };
810  std::unique_ptr<RemoteAstrometryParser> remoteParser;
811  QSharedPointer<ISD::GenericDevice> m_RemoteParserDevice;
812 
813  // Pointers to our devices
814  ISD::Mount *m_Mount { nullptr };
815  ISD::Dome *m_Dome { nullptr };
816  ISD::Camera *m_Camera { nullptr };
817  ISD::Rotator *m_Rotator { nullptr };
818  ISD::FilterWheel *m_FilterWheel { nullptr };
819 
820  int currentFilterPosition { -1 };
821  /// True if we need to change filter position and wait for result before continuing capture
822  bool filterPositionPending { false };
823 
824  /// Keep track of solver FOV to be plotted in the skymap after each successful solve operation
825  std::shared_ptr<FOV> solverFOV;
826  std::shared_ptr<FOV> sensorFOV;
827 
828  /// WCS
829  bool m_wcsSynced { false };
830 
831  /// Log
832  QStringList m_LogText;
833 
834  /// Issue counters
835  uint8_t m_CaptureTimeoutCounter { 0 };
836  uint8_t m_CaptureErrorCounter { 0 };
837  uint8_t m_SlewErrorCounter { 0 };
838 
839  QTimer m_CaptureTimer;
840 
841  // State
842  AlignState state { ALIGN_IDLE };
843  FocusState m_FocusState { FOCUS_IDLE };
844  CaptureState m_CaptureState { CAPTURE_IDLE };
845 
846  // 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
847  ISD::Camera::UploadMode rememberUploadMode { ISD::Camera::UPLOAD_CLIENT };
848 
849  GotoMode m_CurrentGotoMode;
850 
851  QString dirPath;
852 
853  // Timer
854  QTimer m_AlignTimer;
855 
856  // Align Frame
857  QSharedPointer<AlignView> m_AlignView;
858 
859  // FITS Viewer in case user want to display in it instead of internal view
861 
862  QUrl alignURL;
863  QUrl alignURLPath;
864 
865  // keep track of autoWSC
866  bool rememberAutoWCS { false };
867  bool rememberSolverWCS { false };
868 
869  // Differential Slewing
870  bool differentialSlewingActivated { false };
871  bool targetAccuracyNotMet { false };
872 
873  // Astrometry Options
874  OpsAstrometry *opsAstrometry { nullptr };
875  OpsAlign *opsAlign { nullptr };
876  OpsPrograms *opsPrograms { nullptr };
877  OpsAstrometryIndexFiles *opsAstrometryIndexFiles { nullptr };
878  OpsASTAP *opsASTAP { nullptr };
879  StellarSolverProfileEditor *optionsProfileEditor { nullptr };
880 
881  // Drawing
882  QCPCurve *centralTarget { nullptr };
883  QCPCurve *yellowTarget { nullptr };
884  QCPCurve *redTarget { nullptr };
885  QCPCurve *concentricRings { nullptr };
886 
887  // Telescope Settings
888  double m_EffectiveFocalLength = -1;
889  bool m_isRateSynced = false;
890  bool domeReady = true;
891 
892  // CCD Exposure Looping
893  bool m_RememberCameraFastExposure = { false };
894 
895  // Controls
896  double alignGainSpecialValue {INVALID_VALUE};
897  double TargetCustomGainValue {-1};
898 
899  // Data
900  QSharedPointer<FITSData> m_ImageData;
901 
902  // Active Profile
903  QSharedPointer<ProfileInfo> m_ActiveProfile;
904 
905  // Threshold to notify settle time is 3 seconds
906  static constexpr uint16_t DELAY_THRESHOLD_NOTIFY { 3000 };
907 
908  // Mount Model
909  // N.B. We do not need to use "smart pointer" here as the object memroy
910  // is taken care of by the Qt framework.
911  MountModel *m_MountModel {nullptr};
912  PolarAlignmentAssistant *m_PolarAlignmentAssistant {nullptr};
913  ManualRotator *m_ManualRotator {nullptr};
914 
915  // Dark Processor
916  QPointer<DarkProcessor> m_DarkProcessor;
917 
918  // Filter Manager
919  QSharedPointer<FilterManager> m_FilterManager;
920 
921  // Rotator Control
922  QSharedPointer<RotatorSettings> m_RotatorControlPanel;
923 
924  // Settings
925  QVariantMap m_Settings;
926  QVariantMap m_GlobalSettings;
927 
928  bool m_UsedScale = false;
929  bool m_UsedPosition = false;
930  double m_ScaleUsed = 0;
931  double m_RAUsed = 0;
932  double m_DECUsed = 0;
933 };
934 }
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:1750
void Sync()
Sync the telescope to the solved alignment coordinate.
Definition: align.cpp:2856
Q_SCRIPTABLE bool captureAndSolve()
DBUS interface function.
Definition: align.cpp:1398
void stop(Ekos::AlignState mode)
Stop aligning.
Definition: align.cpp:2448
Q_SCRIPTABLE Q_NOREPLY void setExposure(double value)
DBUS interface function.
Definition: align.cpp:3029
Q_SCRIPTABLE QList< double > getSolutionResult()
DBUS interface function.
Definition: align.cpp:2534
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:76
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:589
Q_SCRIPTABLE QList< double > getTargetCoords()
getTargetCoords QList of target coordinates.
Definition: align.cpp:3738
bool checkIfRotationRequired()
checkIfRotationRequired Check whether we need to perform an ALIGN_ROTATING action,...
Definition: align.cpp:2369
void setTelescopeCoordinates(const SkyPoint &position)
Set the coordinates that the mount reports as its position.
Definition: align.h:459
Q_CLASSINFO(Name, Value)
Q_SCRIPTABLE bool setFilter(const QString &filter)
DBUS interface function.
Definition: align.cpp:3092
Q_SCRIPTABLE Q_NOREPLY void setSolverMode(int mode)
DBUS interface function.
Definition: align.cpp:546
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:897
void processData(const QSharedPointer< FITSData > &data)
Process new FITS received from CCD.
Definition: align.cpp:1635
Q_SCRIPTABLE Q_NOREPLY void setTargetCoords(double ra0, double de0)
DBUS interface function.
Definition: align.cpp:3722
static QStringList generateRemoteOptions(const QVariantMap &optionsMap)
generateOptions Generate astrometry.net option given the supplied map
Definition: align.cpp:1178
void SlewToTarget()
Sync the telescope to the solved alignment coordinate, and then slew to the target coordinate.
Definition: align.cpp:2903
bool loadAndSlew(const QByteArray &image, const QString &extension)
DBUS interface function.
Definition: align.cpp:3006
bool setCamera(ISD::Camera *device)
Add Camera to the list of available Cameras.
Definition: align.cpp:627
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...
void Slew()
Slew the telescope to the solved alignment coordinate.
Definition: align.cpp:2874
bool setDome(ISD::Dome *device)
Add new Dome.
Definition: align.cpp:734
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:990
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:1268
CaptureState
Capture states.
Definition: ekos.h:91
bool isParserOK()
Does our parser exist in the system?
Definition: align.cpp:515
void refreshAlignOptions()
refreshAlignOptions is called when settings are updated in OpsAlign.
Definition: align.cpp:3398
void updateProperty(INDI::Property prop)
Process updated device properties.
Definition: align.cpp:2559
void suspend()
Suspend aligning, recovery handled by the align module itself.
Definition: align.h:407
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:3207
void setAstrometryDevice(const QSharedPointer< ISD::GenericDevice > &device)
setAstrometryDevice
Definition: align.cpp:3385
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:2008
Q_SCRIPTABLE Q_NOREPLY void setBinningIndex(int binIndex)
DBUS interface function.
Definition: align.cpp:3034
void setRotator(ISD::Rotator *device)
Add new Rotator.
Definition: align.cpp:3143
QStringList getStellarSolverProfiles()
getStellarSolverProfiles
Definition: align.cpp:3827
@ ALIGN_IDLE
No ongoing operations.
Definition: ekos.h:146
Q_SCRIPTABLE Q_NOREPLY void abort()
DBUS interface function.
Definition: align.h:399
void checkFilter()
Check Filter and make sure information is updated accordingly.
Definition: align.cpp:3109
bool setMount(ISD::Mount *device)
Add new mount.
Definition: align.cpp:677
bool syncTelescopeInfo()
We received new telescope info, process them and update FOV.
Definition: align.cpp:803
bool setFilterWheel(ISD::FilterWheel *device)
addFilterWheel Add new filter wheel filter device.
Definition: align.cpp:3049
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:2838
Q_SCRIPTABLE Q_NOREPLY void startSolving()
DBUS interface function.
Definition: align.cpp:1756
void setTarget(const SkyPoint &targetCoord)
Set the alignment target where the mount is expected to point at.
Definition: align.cpp:3731
AlignState
Definition: ekos.h:144
void syncCameraInfo()
CCD information is updated, sync them.
Definition: align.cpp:846
Q_SCRIPTABLE int getLoadAndSlewStatus()
DBUS interface function.
Definition: align.h:169
void solverFailed()
Process solver failure.
Definition: align.cpp:2288
void getFOVScale(double &fov_w, double &fov_h, double &fov_scale)
getFOVScale Returns calculated FOV values
Definition: align.cpp:956
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 03:58:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.