Kstars

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

KDE's Doxygen guidelines are available online.