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 "indi/indidome.h"
18 #include "ksuserdb.h"
19 #include "ekos/auxiliary/filtermanager.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 1.5
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 camera READ camera WRITE setCamera)
80  Q_PROPERTY(QString filterWheel READ filterWheel WRITE setFilterWheel)
81  Q_PROPERTY(QString filter READ filter WRITE setFilter)
82  Q_PROPERTY(double exposure READ exposure WRITE setExposure)
83  Q_PROPERTY(QList<double> fov READ fov)
84  Q_PROPERTY(QList<double> cameraInfo READ cameraInfo)
85  Q_PROPERTY(QList<double> telescopeInfo READ telescopeInfo)
86  //Q_PROPERTY(QString solverArguments READ solverArguments WRITE setSolverArguments)
87 
88  public:
89  explicit Align(ProfileInfo *activeProfile);
90  virtual ~Align() override;
91 
92  typedef enum { GOTO_SYNC, GOTO_SLEW, GOTO_NOTHING } GotoMode;
93  typedef enum { SOLVER_LOCAL, SOLVER_REMOTE } SolverMode;
94  typedef enum
95  {
96  ALIGN_RESULT_SUCCESS,
97  ALIGN_RESULT_WARNING,
98  ALIGN_RESULT_FAILED
99  } AlignResult;
100 
101  typedef enum
102  {
103  BLIND_IDLE,
104  BLIND_ENGAGNED,
105  BLIND_USED
106  } BlindState;
107 
108  /** @defgroup AlignDBusInterface Ekos DBus Interface - Align Module
109  * Ekos::Align interface provides advanced scripting capabilities to solve images using online or offline astrometry.net
110  */
111 
112  /*@{*/
113 
114  /** DBUS interface function.
115  * Select CCD
116  * @param device CCD device name
117  * @return Returns true if device if found and selected, false otherwise.
118  */
119  Q_SCRIPTABLE bool setCamera(const QString &device);
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 bool setFilterWheel(const QString &device);
128  Q_SCRIPTABLE QString filterWheel();
129 
130  /** DBUS interface function.
131  * select the filter from the available filters.
132  * @param filter The filter name
133  * @return Returns true if filter is found and set, false otherwise.
134  */
135  Q_SCRIPTABLE bool setFilter(const QString &filter);
136  Q_SCRIPTABLE QString filter();
137 
138  /** DBUS interface function.
139  * Start the plate-solving process given the passed image file.
140  * @param filename Name of image file to solve. FITS and JPG/JPG/TIFF formats are accepted.
141  * @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.
142  * @return Returns true if device if found and selected, false otherwise.
143  */
144  Q_SCRIPTABLE Q_NOREPLY void startSolving();
145 
146  /** DBUS interface function.
147  * Select Solver Action after successfully solving an image.
148  * @param mode 0 for Sync, 1 for Slew To Target, 2 for Nothing (just display solution results)
149  */
150  Q_SCRIPTABLE Q_NOREPLY void setSolverAction(int mode);
151 
152  /** DBUS interface function.
153  * Returns the solver's solution results
154  * @return Returns array of doubles. First item is RA in degrees. Second item is DEC in degrees.
155  */
156  Q_SCRIPTABLE QList<double> getSolutionResult();
157 
158  /** DBUS interface function.
159  * Returns the solver's current status
160  * @return Returns solver status (Ekos::AlignState)
161  */
162  Q_SCRIPTABLE Ekos::AlignState status()
163  {
164  return state;
165  }
166 
167  /** DBUS interface function.
168  * @return Returns State of load slew procedure. Idle if not started. Busy if in progress. Ok if complete. Alert if procedure failed.
169  */
170  Q_SCRIPTABLE int getLoadAndSlewStatus()
171  {
172  return m_SolveFromFile;
173  }
174 
175  /** DBUS interface function.
176  * Sets the exposure of the selected CCD device.
177  * @param value Exposure value in seconds
178  */
179  Q_SCRIPTABLE Q_NOREPLY void setExposure(double value);
180  Q_SCRIPTABLE double exposure()
181  {
182  return exposureIN->value();
183  }
184 
185  /** DBUS interface function.
186  * Sets the telescope type (PRIMARY or GUIDE) that should be used for FOV calculations. This value is loaded form driver settings by default.
187  * @param index 0 for PRIMARY telescope, 1 for GUIDE telescope
188  */
189  Q_SCRIPTABLE Q_NOREPLY void setFOVTelescopeType(int index);
190  int FOVTelescopeType()
191  {
192  return FOVScopeCombo->currentIndex();
193  }
194 
195  /** DBUS interface function.
196  * Get currently active camera info in this order:
197  * width, height, pixel_size_x, pixel_size_y
198  */
199  Q_SCRIPTABLE QList<double> cameraInfo();
200 
201  /** DBUS interface function.
202  * Get current active telescope info in this order:
203  * focal length, aperture
204  */
205  Q_SCRIPTABLE QList<double> telescopeInfo();
206 
207  /** @}*/
208 
209  /**
210  * @brief Add Camera to the list of available Cameras.
211  * @param device pointer to camera device.
212  * @return True if added successfully, false if duplicate or failed to add.
213  */
214  bool addCamera(ISD::Camera *device);
215 
216  /**
217  * @brief addFilterWheel Add new filter wheel filter device.
218  * @param device pointer to filter device.
219  * @return True if added successfully, false if duplicate or failed to add.
220  */
221  bool addFilterWheel(ISD::FilterWheel *device);
222 
223  /**
224  * @brief Add new mount
225  * @param device pointer to mount device.
226  * @return True if added successfully, false if duplicate or failed to add.
227  */
228  bool addMount(ISD::Mount *device);
229 
230  /**
231  * @brief Add new Dome
232  * @param device pointer to dome device.
233  * @return True if added successfully, false if duplicate or failed to add.
234  */
235  bool addDome(ISD::Dome *device);
236 
237  /**
238  * @brief Add new Rotator
239  * @param device pointer to rotator device.
240  * @return True if added successfully, false if duplicate or failed to add.
241  */
242  bool addRotator(ISD::Rotator *device);
243 
244  void removeDevice(ISD::GenericDevice *device);
245 
246  /**
247  * @brief Set telescope and guide scope info. All measurements is in millimeters.
248  * @param primaryFocalLength Primary Telescope Focal Length. Set to 0 to skip setting this value.
249  * @param primaryAperture Primary Telescope Aperture. Set to 0 to skip setting this value.
250  * @param guideFocalLength Guide Telescope Focal Length. Set to 0 to skip setting this value.
251  * @param guideAperture Guide Telescope Aperture. Set to 0 to skip setting this value.
252  */
253  void setTelescopeInfo(double primaryFocalLength, double primaryAperture, double guideFocalLength, double guideAperture);
254 
255  /**
256  * @brief setAstrometryDevice
257  * @param newAstrometry
258  */
260 
261  /**
262  * @brief CCD information is updated, sync them.
263  */
264  void syncCameraInfo();
265 
266  /**
267  * @brief syncCCDControls Update camera controls like gain, offset, ISO..etc.
268  */
269  void syncCameraControls();
270 
271  /**
272  * @brief Generate arguments we pass to the remote solver.
273  */
275 
276  /**
277  * @brief Does our parser exist in the system?
278  */
279  bool isParserOK();
280 
281  // Log
282  QStringList logText()
283  {
284  return m_LogText;
285  }
286  QString getLogText()
287  {
288  return m_LogText.join("\n");
289  }
290  void clearLog();
291 
292  /**
293  * @brief getFOVScale Returns calculated FOV values
294  * @param fov_w FOV width in arcmins
295  * @param fov_h FOV height in arcmins
296  * @param fov_scale FOV scale in arcsec per pixel
297  */
298  void getFOVScale(double &fov_w, double &fov_h, double &fov_scale);
299  QList<double> fov();
300 
301  /**
302  * @brief getCalculatedFOVScale Get calculated FOV scales from the current CCD+Telescope combination.
303  * @param fov_w return calculated fov width in arcminutes
304  * @param fov_h return calculated fov height in arcminutes
305  * @param fov_scale return calculated fov pixcale in arcsecs per pixel.
306  * @note This is NOT the same as effective FOV which is the measured FOV from astrometry. It is the
307  * theoretical FOV from calculated values.
308  */
309  void getCalculatedFOVScale(double &fov_w, double &fov_h, double &fov_scale);
310 
311  void setFilterManager(const QSharedPointer<FilterManager> &manager);
312 
313  /**
314  * @brief Sync the telescope to the solved alignment coordinate.
315  */
316  void Sync();
317 
318  /**
319  * @brief Slew the telescope to the solved alignment coordinate.
320  */
321  void Slew();
322 
323  /**
324  * @brief Sync the telescope to the solved alignment coordinate, and then slew to the target coordinate.
325  */
326  void SlewToTarget();
327 
328  /**
329  * @brief getStellarSolverProfiles
330  * @return list of StellarSolver profile names
331  */
333 
334  GotoMode currentGOTOMode() const
335  {
336  return m_CurrentGotoMode;
337  }
338 
339  /**
340  * @brief generateOptions Generate astrometry.net option given the supplied map
341  * @param optionsMap List of key=value pairs for all astrometry.net options
342  * @return String List of valid astrometry.net options
343  */
344  static QStringList generateRemoteOptions(const QVariantMap &optionsMap);
345  static void generateFOVBounds(double fov_h, QString &fov_low, QString &fov_high, double tolerance = 0.05);
346 
347  // access to the mount model UI, required for testing
348  MountModel * mountModel() const
349  {
350  return m_MountModel;
351  }
352 
353  PolarAlignmentAssistant *polarAlignmentAssistant() const
354  {
355  return m_PolarAlignmentAssistant;
356  }
357 
358  bool wcsSynced() const
359  {
360  return m_wcsSynced;
361  }
362 
363  /**
364  * @brief Process updated device properties
365  * @param nvp pointer to updated property.
366  */
367  void processNumber(INumberVectorProperty *nvp);
368 
369  /**
370  * @brief Process updated device properties
371  * @param svp pointer to updated property.
372  */
373  void processSwitch(ISwitchVectorProperty *svp);
374 
375  /**
376  * @brief Check CCD and make sure information is updated and FOV is re-calculated.
377  * @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.
378  */
379  void checkCamera(int CCDNum = -1);
380 
381  /**
382  * @brief Check Filter and make sure information is updated accordingly.
383  * @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.
384  * filterNum is the index of the filter in the dropdown menu.
385  */
386  void checkFilter(int filterNum = -1);
387 
388  /**
389  * @brief checkCameraExposureProgress Track the progress of CCD exposure
390  * @param targetChip Target chip under exposure
391  * @param remaining how many seconds remaining
392  * @param state status of exposure
393  */
394  void checkCameraExposureProgress(ISD::CameraChip *targetChip, double remaining, IPState state);
395  /**
396  * @brief Process new FITS received from CCD.
397  * @param bp pointer to blob property
398  */
399  void processData(const QSharedPointer<FITSData> &data);
400 
401  /** DBUS interface function.
402  * 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
403  * the telescope is pointing to the same coordinates of the image.
404  * @param image buffer to image data.
405  * @param extension image extension (e.g. cr2, jpg, fits,..etc).
406  */
407  bool loadAndSlew(const QByteArray &image, const QString &extension);
408 
409  /** \addtogroup AlignDBusInterface
410  * @{
411  */
412 
413  /**
414  * @brief Stop aligning
415  * @param mode stop mode (abort or suspend)
416  */
417  void stop(Ekos::AlignState mode);
418 
419  /** DBUS interface function.
420  * Aborts the solving operation, handle outside of the align module.
421  */
422  Q_SCRIPTABLE Q_NOREPLY void abort()
423  {
424  stop(ALIGN_ABORTED);
425  }
426 
427  /**
428  * @brief Suspend aligning, recovery handled by the align module itself.
429  */
430  void suspend()
431  {
432  stop(ALIGN_SUSPENDED);
433  }
434 
435  /** DBUS interface function.
436  * Select the solver mode
437  * @param type Set solver type. 0 LOCAL, 1 REMOTE (requires remote astrometry driver to be activated)
438  */
439  Q_SCRIPTABLE Q_NOREPLY void setSolverMode(int mode);
440 
441  /** DBUS interface function.
442  * Capture and solve an image using the astrometry.net engine
443  * @return Returns true if the procedure started successful, false otherwise.
444  */
445  Q_SCRIPTABLE bool captureAndSolve();
446 
447  /** DBUS interface function.
448  * 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
449  * the telescope is pointing to the same coordinates of the image.
450  * @param fileURL URL to the image to solve
451  */
452  Q_SCRIPTABLE bool loadAndSlew(QString fileURL = QString());
453 
454  /** DBUS interface function.
455  * Sets the target coordinates that the solver compares the solution coordinates to.
456  * By default, the target coordinates are those of the current mount when the capture and
457  * solve operation is started. In case of SYNC, only the error between the the solution and target
458  * coordinates is calculated. When Slew to Target is selected, the mount would be slewed afterwards to
459  * this target coordinate.
460  * @param ra0 J2000 Right Ascension in hours.
461  * @param de0 J2000 Declination in degrees.
462  */
463  Q_SCRIPTABLE Q_NOREPLY void setTargetCoords(double ra0, double de0);
464 
465  /**
466  * @brief getTargetCoords QList of target coordinates.
467  * @return First value is J2000 RA in hours. Second value is J2000 DE in degrees.
468  */
469  Q_SCRIPTABLE QList<double> getTargetCoords();
470 
471 
472  /**
473  * @brief Set the alignment target where the mount is expected to point at.
474  * @param targetCoord exact coordinates of the target position.
475  */
476  void setTarget(const SkyPoint &targetCoord);
477 
478  /**
479  * @brief Clear the target, make it invalid.
480  */
481  Q_SCRIPTABLE Q_NOREPLY void clearTarget()
482  {
483  m_targetCoordValid = false;
484  }
485 
486  /**
487  * @brief Set the coordinates that the mount reports as its position
488  * @param position current mount position
489  */
490  void setTelescopeCoordinates(const SkyPoint &position)
491  {
492  telescopeCoord = position;
493  }
494 
495 
496  Q_SCRIPTABLE Q_NOREPLY void setTargetPositionAngle(double value);
497 
498  /** DBUS interface function.
499  * Sets the binning of the selected CCD device.
500  * @param binIndex Index of binning value. Default values range from 0 (binning 1x1) to 3 (binning 4x4)
501  */
502  Q_SCRIPTABLE Q_NOREPLY void setBinningIndex(int binIndex);
503 
504  /** @}*/
505 
506  /**
507  * @brief Solver finished successfully, process the data and execute the required actions depending on the mode.
508  * @param orientation Orientation of image in degrees (East of North)
509  * @param ra Center RA in solved image, degrees.
510  * @param dec Center DEC in solved image, degrees.
511  * @param pixscale Image scale is arcsec/pixel
512  * @param eastToTheRight When the image is rotated, so that North is up, East would be to the right.
513  */
514  void solverFinished(double orientation, double ra, double dec, double pixscale, bool eastToTheRight);
515 
516  void solverComplete();
517 
518  /**
519  * @brief If the target is valid (see m_targetCoordValid), simply return. If the target is not valid,
520  * use thecurrent mount coordinates as target coordinates.
521  */
522  void updateTargetCoords();
523 
524  /**
525  * @brief Process solver failure.
526  */
527  void solverFailed();
528 
529  /**
530  * @brief We received new telescope info, process them and update FOV.
531  */
532  bool syncTelescopeInfo();
533 
534  void setFocusStatus(Ekos::FocusState state);
535 
536  // Log
537  void appendLogText(const QString &);
538 
539  // Capture
540  void setCaptureComplete();
541 
542  // Update Capture Module status
543  void setCaptureStatus(Ekos::CaptureState newState);
544  // Update Mount module status
545  void setMountStatus(ISD::Mount::Status newState);
546 
547  // Align Settings
548  QJsonObject getSettings() const;
549  void setSettings(const QJsonObject &settings);
550 
551  void zoomAlignView();
552  void setAlignZoom(double scale);
553 
554  // Manual Rotator Dialog
555  void toggleManualRotator(bool toggled);
556 
557  private slots:
558 
559  void setDefaultCCD(QString ccd);
560 
561  void saveSettleTime();
562 
563  // Solver timeout
564  void checkAlignmentTimeout();
565  void setAlignTableResult(AlignResult result);
566 
567  void updateTelescopeType(int index);
568 
569  // External View
570  void showFITSViewer();
571  void toggleAlignWidgetFullScreen();
572 
573  /**
574  * @brief prepareCapture Set common settings for capture for align module
575  * @param targetChip target Chip
576  */
577  void prepareCapture(ISD::CameraChip *targetChip);
578 
579  //Solutions Display slots
580  void buildTarget();
581  void handlePointTooltip(QMouseEvent *event);
582  void handleVerticalPlotSizeChange();
583  void handleHorizontalPlotSizeChange();
584  void selectSolutionTableRow(int row, int column);
585  void slotClearAllSolutionPoints();
586  void slotRemoveSolutionPoint();
587  void slotAutoScaleGraph();
588 
589  void slotMountModel();
590 
591  // Settings
592  void syncSettings();
593 
594  protected slots:
595  /**
596  * @brief After a solver process is completed successfully, sync, slew to target, or do nothing as set by the user.
597  */
598  void executeGOTO();
599 
600  /**
601  * @brief refreshAlignOptions is called when settings are updated in OpsAlign.
602  */
603  void refreshAlignOptions();
604 
605  void processPAHStage(int stage);
606 
607  signals:
608  void newLog(const QString &text);
609  void newStatus(Ekos::AlignState state);
610  void newPAAStage(int stage);
611  void newSolution(const QVariantMap &solution);
612 
613  // This is sent when we load an image in the view
614  void newImage(const QSharedPointer<FITSView> &view);
615  // This is sent when the pixmap is updated within the view
616  void newFrame(const QSharedPointer<FITSView> &view);
617  // Send new solver results
618  void newSolverResults(double orientation, double ra, double dec, double pixscale);
619 
620  // Settings
621  void settingsUpdated(const QJsonObject &settings);
622 
623  // Manual Rotator
624  void manualRotatorChanged(double currentPA, double targetPA, double threshold);
625 
626  private:
627  /**
628  * @brief Retrieve the align status indicator
629  */
630  QProgressIndicator *getProgressStatus();
631 
632  /**
633  * @brief Stop the progress animation in the solution table
634  */
635  void stopProgressAnimation();
636 
637  void exportSolutionPoints();
638 
639  /**
640  * @brief Calculate Field of View of CCD+Telescope combination that we need to pass to astrometry.net solver.
641  */
642  void calculateFOV();
643 
644  /**
645  * @brief calculateEffectiveFocalLength Calculate Focal Length purely form astrometric data.
646  */
647  void calculateEffectiveFocalLength(double newFOVW);
648 
649  /**
650  * @brief calculateAlignTargetDiff Find the difference between aligned vs. target coordinates and update
651  * the GUI accordingly.
652  */
653  void calculateAlignTargetDiff();
654 
655  /**
656  * @brief Get formatted RA & DEC coordinates compatible with astrometry.net format.
657  * @param ra Right ascension
658  * @param dec Declination
659  * @param ra_str will contain the formatted RA string
660  * @param dec_str will contain the formatted DEC string
661  */
662  void getFormattedCoords(double ra, double dec, QString &ra_str, QString &dec_str);
663 
664  uint8_t getSolverDownsample(uint16_t binnedW);
665 
666  /**
667  * @brief setWCSEnabled enables/disables World Coordinate System settings in the CCD driver.
668  * @param enable true to enable WCS, false to disable.
669  */
670  void setWCSEnabled(bool enable);
671 
672  void resizeEvent(QResizeEvent *event) override;
673 
674  KPageWidgetItem *m_IndexFilesPage;
675  QString savedOptionsProfiles;
676 
677  /**
678  * @brief React when a mount motion has been detected
679  */
680  void handleMountMotion();
681 
682  /**
683  * @brief Continue aligning according to the current mount status
684  */
685  void handleMountStatus();
686 
687  /**
688  * @brief initPolarAlignmentAssistant Initialize Polar Alignment Asssistant Tool
689  */
690  void initPolarAlignmentAssistant();
691 
692  /**
693  * @brief initManualRotator Initialize Manual Rotator Tool
694  */
695  void initManualRotator();
696 
697  /**
698  * @brief initDarkProcessor Initialize Dark Processor
699  */
700  void initDarkProcessor();
701 
702  bool matchPAHStage(uint32_t stage);
703 
704 
705  // Effective FOV
706 
707  /**
708  * @brief getEffectiveFOV Search database for effective FOV that matches the current profile and settings
709  * @return Variant Map containing effect FOV data or empty variant map if none found
710  */
711  QVariantMap getEffectiveFOV();
712  void saveNewEffectiveFOV(double newFOVW, double newFOVH);
713  QList<QVariantMap> effectiveFOVs;
714  void syncFOV();
715 
716  // We are using calculated FOV now until a more accurate effective FOV is found.
717  bool m_EffectiveFOVPending { false };
718  /// Which chip should we invoke in the current CCD?
719  bool useGuideHead { false };
720  /// Can the mount sync its coordinates to those set by Ekos?
721  bool canSync { false };
722  // m_SolveFromFile is true we load an image and solve it, no capture is done.
723  bool m_SolveFromFile { false };
724  // Target Position Angle of solver Load&Slew image to be used for rotator if necessary
725  double loadSlewTargetPA { std::numeric_limits<double>::quiet_NaN() };
726  double currentRotatorPA { -1 };
727  /// Solver iterations count
728  uint8_t solverIterations { 0 };
729  /// Was solving with scale off used?
730  BlindState useBlindScale {BLIND_IDLE};
731  /// Was solving with position off used?
732  BlindState useBlindPosition {BLIND_IDLE};
733 
734  // FOV
735  double m_CameraPixelWidth { -1 };
736  double m_CameraPixelHeight { -1 };
737  double m_TelescopeFocalLength { -1 };
738  double m_TelescopeAperture { -1 };
739  double m_FOVWidth { 0 };
740  double m_FOVHeight { 0 };
741  double m_FOVPixelScale { 0 };
742  uint16_t m_CameraWidth { 0 };
743  uint16_t m_CameraHeight { 0 };
744 
745  // Keep track of solver results
746  double sOrientation { INVALID_VALUE };
747  double sRA { INVALID_VALUE };
748  double sDEC { INVALID_VALUE };
749 
750  /// Solver alignment coordinates
751  SkyPoint alignCoord;
752  /// Target coordinates we need to slew to
753  SkyPoint m_targetCoord;
754  /// do we have valid target coordinates?
755  bool m_targetCoordValid = false;
756  /// Current telescope coordinates
757  SkyPoint telescopeCoord;
758  /// Coord from Load & Slew
759  SkyPoint loadSlewCoord;
760  /// Difference between solution and target coordinate
761  double m_TargetDiffTotal { 1e6 };
762  double m_TargetDiffRA { 1e6 };
763  double m_TargetDiffDE { 1e6 };
764 
765  /// Progress icon if the solver is running
766  std::unique_ptr<QProgressIndicator> pi;
767 
768  /// Keep track of how long the solver is running
769  QElapsedTimer solverTimer;
770 
771  // The StellarSolver
772  std::unique_ptr<StellarSolver> m_StellarSolver;
773  // StellarSolver Profiles
774  QList<SSolver::Parameters> m_StellarSolverProfiles;
775 
776  /// Have we slewed?
777  bool m_wasSlewStarted { false };
778  // Above flag only stays false for 10s after slew start.
779  QElapsedTimer slewStartTimer;
780  bool didSlewStart();
781  // Only wait this many milliseconds for slew to start.
782  // Otherwise assume it has begun.
783  static constexpr int MAX_WAIT_FOR_SLEW_START_MSEC = 10000;
784 
785  // Online and Offline parsers
786  AstrometryParser* parser { nullptr };
787  std::unique_ptr<RemoteAstrometryParser> remoteParser;
788  ISD::GenericDevice *remoteParserDevice { nullptr };
789 
790  // Pointers to our devices
791  ISD::Mount *m_Mount { nullptr };
792  ISD::Dome *m_Dome { nullptr };
793  ISD::Camera *m_Camera { nullptr };
794  ISD::Rotator *m_Rotator { nullptr };
795  ISD::FilterWheel *m_FilterWheel { nullptr };
796 
797  // Containers
798  QList<ISD::Mount *> m_Mounts;
799  QList<ISD::Camera *> m_Cameras;
800  QList<ISD::Dome *> m_Domes;
801  QList<ISD::Rotator *> m_Rotators;
802  QList<ISD::FilterWheel *> m_FilterWheels;
803 
804  int currentFilterPosition { -1 };
805  /// True if we need to change filter position and wait for result before continuing capture
806  bool filterPositionPending { false };
807 
808  /// Keep track of solver FOV to be plotted in the skymap after each successful solve operation
809  std::shared_ptr<FOV> solverFOV;
810  std::shared_ptr<FOV> sensorFOV;
811 
812  /// WCS
813  bool m_wcsSynced { false };
814 
815  /// Log
816  QStringList m_LogText;
817 
818  /// Issue counters
819  uint8_t m_CaptureTimeoutCounter { 0 };
820  uint8_t m_CaptureErrorCounter { 0 };
821  uint8_t m_SlewErrorCounter { 0 };
822 
823  QTimer m_CaptureTimer;
824 
825  // State
826  AlignState state { ALIGN_IDLE };
827  FocusState m_FocusState { FOCUS_IDLE };
828  CaptureState m_CaptureState { CAPTURE_IDLE };
829 
830  // 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
831  ISD::Camera::UploadMode rememberUploadMode { ISD::Camera::UPLOAD_CLIENT };
832 
833  GotoMode m_CurrentGotoMode;
834 
835  QString dirPath;
836 
837  // Timer
838  QTimer m_AlignTimer;
839 
840  // Align Frame
841  QSharedPointer<AlignView> m_AlignView;
842 
843  // FITS Viewer in case user want to display in it instead of internal view
845 
846  QUrl alignURL;
847  QUrl alignURLPath;
848 
849  // keep track of autoWSC
850  bool rememberAutoWCS { false };
851  bool rememberSolverWCS { false };
852 
853  // Differential Slewing
854  bool differentialSlewingActivated { false };
855  bool targetAccuracyNotMet { false };
856 
857  // Astrometry Options
858  OpsAstrometry *opsAstrometry { nullptr };
859  OpsAlign *opsAlign { nullptr };
860  OpsPrograms *opsPrograms { nullptr };
861  OpsAstrometryIndexFiles *opsAstrometryIndexFiles { nullptr };
862  OpsASTAP *opsASTAP { nullptr };
863  StellarSolverProfileEditor *optionsProfileEditor { nullptr };
864 
865  // Drawing
866  QCPCurve *centralTarget { nullptr };
867  QCPCurve *yellowTarget { nullptr };
868  QCPCurve *redTarget { nullptr };
869  QCPCurve *concentricRings { nullptr };
870 
871  // Telescope Settings
872  ISD::Camera::TelescopeType rememberTelescopeType = { ISD::Camera::TELESCOPE_UNKNOWN };
873  double primaryFL = -1, primaryAperture = -1, guideFL = -1, guideAperture = -1;
874  double primaryEffectiveFL = -1, guideEffectiveFL = -1;
875  bool m_isRateSynced = false;
876  bool domeReady = true;
877 
878  // CCD Exposure Looping
879  bool m_RememberCameraFastExposure = { false };
880 
881  // Controls
882  double GainSpinSpecialValue {INVALID_VALUE};
883  double TargetCustomGainValue {-1};
884 
885  // Filter Manager
886  QSharedPointer<FilterManager> filterManager;
887 
888  // Data
889  QSharedPointer<FITSData> m_ImageData;
890 
891  // Active Profile
892  ProfileInfo *m_ActiveProfile { nullptr };
893 
894  // Threshold to notify settle time is 3 seconds
895  static constexpr uint16_t DELAY_THRESHOLD_NOTIFY { 3000 };
896 
897  // Mount Model
898  // N.B. We do not need to use "smart pointer" here as the object memroy
899  // is taken care of by the Qt framework.
900  MountModel *m_MountModel {nullptr};
901  PolarAlignmentAssistant *m_PolarAlignmentAssistant {nullptr};
902  ManualRotator *m_ManualRotator {nullptr};
903 
904  // Dark Processor
905  QPointer<DarkProcessor> m_DarkProcessor;
906 
907 };
908 }
Q_OBJECTQ_OBJECT
Definition: fov.h:27
A plottable representing a parametric curve in a plot.
Definition: qcustomplot.h:5580
Q_PROPERTY(...)
bool addFilterWheel(ISD::FilterWheel *device)
addFilterWheel Add new filter wheel filter device.
Definition: align.cpp:3129
Q_SCRIPTABLE Q_NOREPLY void setSolverAction(int mode)
DBUS interface function.
Definition: align.cpp:1949
void Sync()
Sync the telescope to the solved alignment coordinate.
Definition: align.cpp:2936
Q_SCRIPTABLE bool captureAndSolve()
DBUS interface function.
Definition: align.cpp:1618
void stop(Ekos::AlignState mode)
Stop aligning.
Definition: align.cpp:2527
Q_SCRIPTABLE Q_NOREPLY void setExposure(double value)
DBUS interface function.
Definition: align.cpp:3098
Q_SCRIPTABLE QList< double > getSolutionResult()
DBUS interface function.
Definition: align.cpp:2620
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
Q_SCRIPTABLE QList< double > getTargetCoords()
getTargetCoords QList of target coordinates.
Definition: align.cpp:3839
bool addDome(ISD::Dome *device)
Add new Dome.
Definition: align.cpp:882
void setTelescopeCoordinates(const SkyPoint &position)
Set the coordinates that the mount reports as its position.
Definition: align.h:490
bool addMount(ISD::Mount *device)
Add new mount.
Definition: align.cpp:847
Q_CLASSINFO(Name, Value)
Q_SCRIPTABLE bool setFilterWheel(const QString &device)
DBUS interface function.
Definition: align.cpp:3160
Q_SCRIPTABLE bool setCamera(const QString &device)
DBUS interface function.
Definition: align.cpp:752
Q_SCRIPTABLE bool setFilter(const QString &filter)
DBUS interface function.
Definition: align.cpp:3186
Q_SCRIPTABLE Q_NOREPLY void setSolverMode(int mode)
DBUS interface function.
Definition: align.cpp:716
virtual bool event(QEvent *event) override
void syncCameraControls()
syncCCDControls Update camera controls like gain, offset, ISO..etc.
Definition: align.cpp:1148
Q_SCRIPTABLE Q_NOREPLY void setFOVTelescopeType(int index)
DBUS interface function.
Definition: align.cpp:3124
void processNumber(INumberVectorProperty *nvp)
Process updated device properties.
Definition: align.cpp:2674
void processData(const QSharedPointer< FITSData > &data)
Process new FITS received from CCD.
Definition: align.cpp:1852
void checkCamera(int CCDNum=-1)
Check CCD and make sure information is updated and FOV is re-calculated.
Definition: align.cpp:779
bool addCamera(ISD::Camera *device)
Add Camera to the list of available Cameras.
Definition: align.cpp:823
Q_SCRIPTABLE Q_NOREPLY void setTargetCoords(double ra0, double de0)
DBUS interface function.
Definition: align.cpp:3822
static QStringList generateRemoteOptions(const QVariantMap &optionsMap)
generateOptions Generate astrometry.net option given the supplied map
Definition: align.cpp:1396
void SlewToTarget()
Sync the telescope to the solved alignment coordinate, and then slew to the target coordinate.
Definition: align.cpp:2971
bool loadAndSlew(const QByteArray &image, const QString &extension)
DBUS interface function.
Definition: align.cpp:3076
Q_SCRIPTABLE Ekos::AlignState status()
DBUS interface function.
Definition: align.h:162
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:2954
bool addRotator(ISD::Rotator *device)
Add new Rotator.
Definition: align.cpp:3491
void setAstrometryDevice(ISD::GenericDevice *device)
setAstrometryDevice
Definition: align.cpp:3478
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:1243
subclass of SkyObject specialized for stars.
Definition: starobject.h:32
Q_SCRIPTABLE Q_NOREPLY void clearTarget()
Clear the target, make it invalid.
Definition: align.h:481
@ CAPTURE_IDLE
Definition: ekos.h:93
QStringList generateRemoteArgs(const QSharedPointer< FITSData > &imageData)
Generate arguments we pass to the remote solver.
Definition: align.cpp:1486
void processSwitch(ISwitchVectorProperty *svp)
Process updated device properties.
Definition: align.cpp:2645
CaptureState
Capture states.
Definition: ekos.h:91
bool isParserOK()
Does our parser exist in the system?
Definition: align.cpp:685
void refreshAlignOptions()
refreshAlignOptions is called when settings are updated in OpsAlign.
Definition: align.cpp:3505
void suspend()
Suspend aligning, recovery handled by the align module itself.
Definition: align.h:430
QString join(const QString &separator) const const
void checkCameraExposureProgress(ISD::CameraChip *targetChip, double remaining, IPState state)
checkCameraExposureProgress Track the progress of CCD exposure
Definition: align.cpp:3272
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:2148
Q_SCRIPTABLE Q_NOREPLY void setBinningIndex(int binIndex)
DBUS interface function.
Definition: align.cpp:3103
QStringList getStellarSolverProfiles()
getStellarSolverProfiles
Definition: align.cpp:3950
void updateTargetCoords()
If the target is valid (see m_targetCoordValid), simply return.
Definition: align.cpp:3935
Q_SCRIPTABLE Q_NOREPLY void abort()
DBUS interface function.
Definition: align.h:422
bool syncTelescopeInfo()
We received new telescope info, process them and update FOV.
Definition: align.cpp:998
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:2923
void setTelescopeInfo(double primaryFocalLength, double primaryAperture, double guideFocalLength, double guideAperture)
Set telescope and guide scope info.
Definition: align.cpp:1077
void checkFilter(int filterNum=-1)
Check Filter and make sure information is updated accordingly.
Definition: align.cpp:3203
Q_SCRIPTABLE Q_NOREPLY void startSolving()
DBUS interface function.
Definition: align.cpp:1955
void setTarget(const SkyPoint &targetCoord)
Set the alignment target where the mount is expected to point at.
Definition: align.cpp:3831
void syncCameraInfo()
CCD information is updated, sync them.
Definition: align.cpp:1103
Q_SCRIPTABLE int getLoadAndSlewStatus()
DBUS interface function.
Definition: align.h:170
void solverFailed()
Process solver failure.
Definition: align.cpp:2474
void getFOVScale(double &fov_w, double &fov_h, double &fov_scale)
getFOVScale Returns calculated FOV values
Definition: align.cpp:1209
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.