Kstars

focus.h
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ui_focus.h"
10#include "focusfourierpower.h"
11#include "ekos/ekos.h"
12#include "parameters.h"
13#include "ekos/auxiliary/filtermanager.h"
14
15#include "indi/indicamera.h"
16#include "indi/indifocuser.h"
17#include "indi/indistd.h"
18#include "indi/indiweather.h"
19#include "indi/indimount.h"
20
21#include "opsfocussettings.h"
22#include "opsfocusprocess.h"
23#include "opsfocusmechanics.h"
24#include "ui_cfz.h"
25#include "focusutils.h"
26
27class FocusProfilePlot;
28class FITSData;
29class FITSView;
30class FITSViewer;
31
32namespace Ekos
33{
34
35class DarkProcessor;
36class FocusAlgorithmInterface;
37class FocusFWHM;
38#if defined(HAVE_OPENCV)
39class FocusBlurriness;
40#endif
41class PolynomialFit;
42class AdaptiveFocus;
43class FocusAdvisor;
44class StellarSolverProfileEditor;
45
46/**
47 * @class Focus
48 * @short Supports manual focusing and auto focusing using relative and absolute INDI focusers.
49 *
50 * @author Jasem Mutlaq
51 * @version 1.5
52 */
53class Focus : public QWidget, public Ui::Focus
54{
56 Q_CLASSINFO("D-Bus Interface", "org.kde.kstars.Ekos.Focus")
57 Q_PROPERTY(Ekos::FocusState status READ status NOTIFY newStatus)
58 Q_PROPERTY(QString opticalTrain READ opticalTrain WRITE setOpticalTrain)
59 Q_PROPERTY(QString camera READ camera)
60 Q_PROPERTY(QString focuser READ focuser)
61 Q_PROPERTY(QString filterWheel READ filterWheel)
62 Q_PROPERTY(QString filter READ filter WRITE setFilter)
63 Q_PROPERTY(double HFR READ getHFR NOTIFY newHFR)
64 Q_PROPERTY(double exposure READ exposure WRITE setExposure)
65
66 // AdaptiveFocus and FocusAdvisor are friend classes so they can access methods in Focus
67 friend class AdaptiveFocus;
68 friend class FocusAdvisor;
69 friend class FocusModule;
70
71 public:
72 Focus(int id = 0);
73 ~Focus();
74
75 typedef enum { FOCUS_NONE, FOCUS_IN, FOCUS_OUT } Direction;
76 typedef enum { FOCUS_MANUAL, FOCUS_AUTO } Type;
77 typedef enum { FOCUS_ITERATIVE, FOCUS_POLYNOMIAL, FOCUS_LINEAR, FOCUS_LINEAR1PASS } Algorithm;
78 typedef enum { FOCUS_CFZ_CLASSIC, FOCUS_CFZ_WAVEFRONT, FOCUS_CFZ_GOLD } CFZAlgorithm;
79 typedef enum { FOCUS_STAR_HFR, FOCUS_STAR_HFR_ADJ, FOCUS_STAR_FWHM, FOCUS_STAR_NUM_STARS, FOCUS_STAR_FOURIER_POWER, FOCUS_STAR_STDDEV, FOCUS_STAR_SOBEL, FOCUS_STAR_LAPLASSIAN, FOCUS_STAR_CANNY } StarMeasure;
80 typedef enum { FOCUS_STAR_GAUSSIAN, FOCUS_STAR_MOFFAT } StarPSF;
81 typedef enum { FOCUS_UNITS_PIXEL, FOCUS_UNITS_ARCSEC } StarUnits;
82 typedef enum { FOCUS_WALK_CLASSIC, FOCUS_WALK_FIXED_STEPS, FOCUS_WALK_CFZ_SHUFFLE } FocusWalk;
83 typedef enum { FOCUS_MASK_NONE, FOCUS_MASK_RING, FOCUS_MASK_MOSAIC } ImageMaskType;
84
85 /** @defgroup FocusDBusInterface Ekos DBus Interface - Focus Module
86 * Ekos::Focus interface provides advanced scripting capabilities to perform manual and automatic focusing operations.
87 */
88
89 /*@{*/
90
91 /** DBUS interface function.
92 * select the CCD device from the available CCD drivers.
93 * @param device The CCD device name
94 * @return Returns true if CCD device is found and set, false otherwise.
95 */
96 Q_SCRIPTABLE QString camera();
97
98 /** DBUS interface function.
99 * select the focuser device from the available focuser drivers. The focuser device can be the same as the CCD driver if the focuser functionality was embedded within the driver.
100 * @param device The focuser device name
101 * @return Returns true if focuser device is found and set, false otherwise.
102 */
103 Q_SCRIPTABLE QString focuser();
104
105 /** DBUS interface function.
106 * 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.
107 * @param device The filter device name
108 * @return Returns true if filter device is found and set, false otherwise.
109 */
110 Q_SCRIPTABLE QString filterWheel();
111
112 /** DBUS interface function.
113 * select the filter from the available filters.
114 * @param filter The filter name
115 * @return Returns true if filter is found and set, false otherwise.
116 */
117 Q_SCRIPTABLE bool setFilter(const QString &filter);
118 Q_SCRIPTABLE QString filter();
119
120 /** DBUS interface function.
121 * @return Returns True if current focuser supports auto-focusing
122 */
123 Q_SCRIPTABLE bool canAutoFocus()
124 {
125 return (m_FocusType == FOCUS_AUTO);
126 }
127
128 /** DBUS interface function.
129 * @return Returns Half-Flux-Radius in pixels.
130 */
131 Q_SCRIPTABLE double getHFR()
132 {
133 return currentHFR;
134 }
135
136 /** DBUS interface function.
137 * Set CCD exposure value
138 * @param value exposure value in seconds.
139 */
140 Q_SCRIPTABLE Q_NOREPLY void setExposure(double value);
141 Q_SCRIPTABLE double exposure()
142 {
143 return focusExposure->value();
144 }
145
146 /** DBUS interface function.
147 * Set CCD binning
148 * @param binX horizontal binning
149 * @param binY vertical binning
150 */
151 Q_SCRIPTABLE Q_NOREPLY void setBinning(int binX, int binY);
152
153 /** DBUS interface function.
154 * Set Auto Focus options. The options must be set before starting the autofocus operation. If no options are set, the options loaded from the user configuration are used.
155 * @param enable If true, Ekos will attempt to automatically select the best focus star in the frame. If it fails to select a star, the user will be asked to select a star manually.
156 */
157 Q_SCRIPTABLE Q_NOREPLY void setAutoStarEnabled(bool enable);
158
159 /** DBUS interface function.
160 * Set Auto Focus options. The options must be set before starting the autofocus operation. If no options are set, the options loaded from the user configuration are used.
161 * @param enable if true, Ekos will capture a subframe around the selected focus star. The subframe size is determined by the boxSize parameter.
162 */
163 Q_SCRIPTABLE Q_NOREPLY void setAutoSubFrameEnabled(bool enable);
164
165 /** DBUS interface function.
166 * Set Autofocus parameters
167 * @param boxSize the box size around the focus star in pixels. The boxsize is used to subframe around the focus star.
168 * @param stepSize the initial step size to be commanded to the focuser. If the focuser is absolute, the step size is in ticks. For relative focusers, the focuser will be commanded to focus inward for stepSize milliseconds initially.
169 * @param maxTravel the maximum steps permitted before the autofocus operation aborts.
170 * @param tolerance Measure of how accurate the autofocus algorithm is. If the difference between the current HFR and minimum measured HFR is less than %tolerance after the focuser traversed both ends of the V-curve, then the focusing operation
171 * is deemed successful. Otherwise, the focusing operation will continue.
172 */
173 Q_SCRIPTABLE Q_NOREPLY void setAutoFocusParameters(int boxSize, int stepSize, int maxTravel, double tolerance);
174
175 /** DBUS interface function.
176 * resetFrame Resets the CCD frame to its full native resolution.
177 */
178 Q_SCRIPTABLE Q_NOREPLY void resetFrame();
179
180 /** DBUS interface function.
181 * Return state of Focuser module (Ekos::FocusState)
182 */
183
184 Q_SCRIPTABLE Ekos::FocusState status()
185 {
186 return m_state;
187 }
188
189 /** @}*/
190
191 /**
192 * @brief Add CCD to the list of available CCD.
193 * @param newCCD pointer to CCD device.
194 * @return True if added successfully, false if duplicate or failed to add.
195 */
196 bool setCamera(ISD::Camera *device);
197
198 /**
199 * @brief addFocuser Add focuser to the list of available focusers.
200 * @param newFocuser pointer to focuser device.
201 * @return True if added successfully, false if duplicate or failed to add.
202 */
203 bool setFocuser(ISD::Focuser *device);
204
205 /**
206 * @brief reconnectFocuser Add focuser to the list of available focusers.
207 * @param focuser name of the focuser.
208 */
209 void reconnectFocuser(const QString &focuser);
210
211 /**
212 * @brief addFilter Add filter to the list of available filters.
213 * @param newFilter pointer to filter device.
214 * @return True if added successfully, false if duplicate or failed to add.
215 */
216 bool setFilterWheel(ISD::FilterWheel *device);
217
218 /**
219 * @brief setImageMask Select the currently active image mask filtering
220 * the stars relevant for focusing
221 */
222 void selectImageMask();
223
224 /**
225 * @brief updateTemperatureSources Update list of available temperature sources.
226 * @param temperatureSources Devices with temperature reporting capability
227 * @return True if updated successfully
228 */
230
231 /**
232 * @brief removeDevice Remove device from Focus module
233 * @param deviceRemoved pointer to device
234 */
235 void removeDevice(const QSharedPointer<ISD::GenericDevice> &deviceRemoved);
236
237 const QSharedPointer<FilterManager> &filterManager() const
238 {
239 return m_FilterManager;
240 }
241 void setupFilterManager();
242 void connectFilterManager();
243
244 // Settings
245 QVariantMap getAllSettings() const;
246 void setAllSettings(const QVariantMap &settings);
247
248 const QString &opsDialogName() const
249 {
250 return m_opsDialogName;
251 }
252
253public slots:
254
255 /** \addtogroup FocusDBusInterface
256 * @{
257 */
258
259 /* Focus */
260 /** DBUS interface function.
261 * Start the autofocus operation.
262 */
263 Q_SCRIPTABLE Q_NOREPLY void start();
264
265 /** DBUS interface function.
266 * Abort the autofocus operation.
267 */
268 Q_SCRIPTABLE Q_NOREPLY void abort();
269
270 /** DBUS interface function.
271 * Capture a focus frame.
272 * @param settleTime if > 0 wait for the given time in seconds before starting to capture
273 */
274 Q_SCRIPTABLE Q_NOREPLY void capture(double settleTime = 0.0);
275
276 /** DBUS interface function.
277 * Focus inward
278 * @param ms If set, focus inward for ms ticks (Absolute Focuser), or ms milliseconds (Relative Focuser). If not set, it will use the value specified in the options.
279 */
280 Q_SCRIPTABLE bool focusIn(int ms = -1);
281
282 /** DBUS interface function.
283 * Focus outward
284 * @param ms If set, focus outward for ms ticks (Absolute Focuser), or ms milliseconds (Relative Focuser). If not set, it will use the value specified in the options.
285 */
286 Q_SCRIPTABLE bool focusOut(int ms = -1);
287
288 /**
289 * @brief checkFocus Given the minimum required HFR, check focus and calculate HFR. If current HFR exceeds required HFR, start autofocus process, otherwise do nothing.
290 * @param requiredHFR Minimum HFR to trigger autofocus process.
291 */
292 Q_SCRIPTABLE Q_NOREPLY void checkFocus(double requiredHFR);
293
294 /** @}*/
295
296 /**
297 * @brief Run the autofocus process for the currently selected filter
298 * @param The reason Autofocus has been called.
299 */
300 void runAutoFocus(const AutofocusReason autofocusReason, const QString &reasonInfo);
301
302 /**
303 * @brief startFraming Begins continuous capture of the CCD and calculates HFR every frame.
304 */
305 void startFraming();
306
307 /**
308 * @brief Move the focuser to the initial focus position.
309 */
310 void resetFocuser();
311
312 /**
313 * @brief checkStopFocus Perform checks before stopping the autofocus operation. Some checks are necessary for in-sequence focusing.
314 * @param abort true iff focusing should be aborted, false if it should only be stopped and marked as failed
315 */
316 void checkStopFocus(bool abort);
317
318 /**
319 * @brief React when a meridian flip has been started
320 */
321 void meridianFlipStarted();
322
323 /**
324 * @brief Check CCD and make sure information is updated accordingly. This simply calls syncCameraInfo for the current CCD.
325 * @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.
326 * CCDNum is the index of the CCD in the dropdown menu.
327 */
328 void checkCamera();
329
330 /**
331 * @brief syncCameraInfo Read current CCD information and update settings accordingly.
332 */
333 void syncCameraInfo();
334
335 /**
336 * @brief Update camera controls like Gain, ISO, Offset...etc
337 */
338 void syncCCDControls();
339
340 /**
341 * @brief Check Focuser and make sure information is updated accordingly.
342 * @param FocuserNum By default, we check the already selected focuser in the dropdown menu. If FocuserNum is specified, the check is made against this specific focuser in the dropdown menu.
343 * FocuserNum is the index of the focuser in the dropdown menu.
344 */
345 void checkFocuser();
346
347 /**
348 * @brief Check Filter and make sure information is updated accordingly.
349 * @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.
350 * filterNum is the index of the filter in the dropdown menu.
351 */
352 void checkFilter();
353
354 /**
355 * @brief Check temperature source and make sure information is updated accordingly.
356 * @param name Name of temperature source, if empty then use current source.
357 */
358 void checkTemperatureSource(const QString &name = QString());
359
360 /**
361 * @brief clearDataPoints Remove all data points from HFR plots
362 */
363 void clearDataPoints();
364
365 /**
366 * @brief focusStarSelected The user selected a focus star, save its coordinates and subframe it if subframing is enabled.
367 * @param x X coordinate
368 * @param y Y coordinate
369 */
370 void focusStarSelected(int x, int y);
371
372 /**
373 * @brief selectFocusStarFraction Select the focus star based by fraction of the overall size.
374 * It calls focusStarSelected after multiplying the fractions (0.0 to 1.0) with the focus view width and height.
375 * @param x final x = x * focusview_width
376 * @param y final y = y * focusview_height
377 */
378 void selectFocusStarFraction(double x, double y);
379
380 /**
381 * @brief newFITS A new FITS blob is received by the CCD driver.
382 * @param bp pointer to blob data
383 */
384 void processData(const QSharedPointer<FITSData> &data);
385
386 /**
387 * @brief updateProperty Read focus number properties of interest as they arrive from the focuser driver and process them accordingly.
388 * @param prop INDI Property
389 */
390 void updateProperty(INDI::Property prop);
391
392 /**
393 * @brief processTemperatureSource Updates focus temperature source.
394 * @param nvp pointer to updated focuser number property.
395 */
396 void processTemperatureSource(INDI::Property prop);
397
398 /**
399 * @brief setFocusStatus Upon completion of the focusing process, set its status (fail or pass) and reset focus process to clean state.
400 * @param status If true, the focus process finished successfully. Otherwise, it failed.
401 */
402 //void setAutoFocusResult(bool status);
403 // Logging
404 void appendLogText(const QString &logtext);
405 void appendFocusLogText(const QString &text);
406
407 // Adjust focuser offset, relative or absolute
408 void adjustFocusOffset(int value, bool useAbsoluteOffset);
409
410 // Update Mount module status
411 void setMountStatus(ISD::Mount::Status newState);
412
413 // Update Altitude From Mount
414 void setMountCoords(const SkyPoint &position, ISD::Mount::PierSide pierSide, const dms &ha);
415
416 /**
417 * @brief toggleVideo Turn on and off video streaming if supported by the camera.
418 * @param enabled Set to true to start video streaming, false to stop it if active.
419 */
420 void toggleVideo(bool enabled);
421
422 /**
423 * @brief setWeatherData Updates weather data that could be used to extract focus temperature from observatory
424 * in case focus native temperature is not available.
425 */
426 //void setWeatherData(const std::vector<ISD::Weather::WeatherData> &data);
427
428 /**
429 * @brief loadOptionsProfiles Load StellarSolver Profile
430 */
432
433 /**
434 * @brief getStellarSolverProfiles
435 * @return list of StellarSolver profile names
436 */
438
439 QString opticalTrain() const
440 {
441 return opticalTrainCombo->currentText();
442 }
443 void setOpticalTrain(const QString &value)
444 {
445 opticalTrainCombo->setCurrentText(value);
446 }
447
448 /**
449 * @brief adaptiveFocus moves the focuser between subframes to stay at focus
450 */
451 void adaptiveFocus();
452
453 protected:
454 void addPlotPosition(int pos, double hfr, bool plot = true);
455
456 private slots:
457 /**
458 * @brief toggleSubframe Process enabling and disabling subfrag.
459 * @param enable If true, subframing is enabled. If false, subframing is disabled. Even if subframing is enabled, it must be supported by the CCD driver.
460 */
461 void toggleSubframe(bool enable);
462
463 void checkAutoStarTimeout();
464
465 void setAbsoluteFocusTicks();
466
467 void updateBoxSize(int value);
468
469 void processCaptureTimeout();
470
471 void processCaptureErrorDefault();
472 void processCaptureError(ISD::Camera::ErrorType type);
473
474 void setCaptureComplete();
475
476 void showFITSViewer();
477
478 void toggleFocusingWidgetFullScreen();
479
480 void setVideoStreamEnabled(bool enabled);
481
482 void starDetectionFinished();
483 void setCurrentMeasure();
484 void startAbIns();
485 void manualStart();
486
487 signals:
488 void newLog(const QString &text);
489 void newFocusLog(const QString &text);
490 void newStatus(Ekos::FocusState state, const QString &trainname);
491 void newHFR(double hfr, int position, bool inAutofocus, const QString &trainname);
492 void newFocusTemperatureDelta(double delta, double absTemperature, const QString &trainname);
493 void inSequenceAF(bool requested, const QString &trainname);
494
495 void absolutePositionChanged(int value);
496 void focusPositionAdjusted();
497 void focusAdaptiveComplete(bool success, const QString &trainname);
498
499 void trainChanged();
500 void focuserChanged(int id, bool isValid);
501
502 void suspendGuiding();
503 void resumeGuiding();
504 void newImage(const QSharedPointer<FITSView> &view);
505 void newStarPixmap(QPixmap &);
506 void settingsUpdated(const QVariantMap &settings);
507
508 // Signals for Analyze.
509 void autofocusStarting(double temperature, const QString &filter, AutofocusReason reason, const QString &reasonInfo);
510 void autofocusComplete(double temperature, const QString &filter, const QString &points, const bool useWeights,
511 const QString &curve = "", const QString &title = "");
512 void autofocusAborted(const QString &filter, const QString &points, const bool useWeights,
513 const AutofocusFailReason failCode, const QString &failCodeInfo);
514
515 // Focus Advisor
516 void newFocusAdvisorStage(int stage);
517 void newFocusAdvisorMessage(QString name);
518
519 /**
520 * @brief Signal Analyze that an Adaptive Focus iteration is complete
521 * @param Active filter
522 * @param temperature
523 * @param tempTicks is the number of ticks movement due to temperature change
524 * @param altitude
525 * @param altTicks is the number of ticks movement due to altitude change
526 * @param prevPosError is the position error at the previous adaptive focus iteration
527 * @param thisPosError is the position error for the current adaptive focus iteration
528 * @param totalTicks is the total tick movement for this adaptive focus iteration
529 * @param position is the current focuser position
530 * @param focuserMoved indicates whether totalTicks > minimum focuser movement
531 */
532 void adaptiveFocusComplete(const QString &filter, double temperature, double tempTicks, double altitude, double altTicks,
533 int prevPosError, int thisPosError, int totalTicks, int position, bool focuserMoved);
534
535 // HFR V curve plot events
536 /**
537 * @brief initialize the HFR V plot
538 * @param showPosition show focuser position (true) or count focus iterations (false)
539 * @param yAxisLabel is the label to display
540 * @param starUnits the units multiplier to display the pixel data
541 * @param minimum whether the curve shape is a minimum or maximum
542 * @param useWeights whether or not to display weights on the graph
543 * @param showPosition show focuser position (true) or show focusing iteration number (false)
544 */
545 void initHFRPlot(QString str, double starUnits, bool minimum, bool useWeights, bool showPosition);
546
547 /**
548 * @brief new HFR plot position with sigma
549 * @param pos focuser position with associated error (sigma)
550 * @param hfr measured star HFR value
551 * @param sigma is the standard deviation of star HFRs
552 * @param pulseDuration Pulse duration in ms for relative focusers that only support timers,
553 * or the number of ticks in a relative or absolute focuser
554 * */
555 void newHFRPlotPosition(double pos, double hfr, double sigma, bool outlier, int pulseDuration, bool plot = true);
556
557 /**
558 * @brief draw the approximating polynomial into the HFR V-graph
559 * @param poly pointer to the polynomial approximation
560 * @param isVShape has the solution a V shape?
561 * @param activate make the graph visible?
562 */
563 void drawPolynomial(PolynomialFit *poly, bool isVShape, bool activate, bool plot = true);
564
565 /**
566 * @brief draw the curve into the HFR V-graph
567 * @param poly pointer to the polynomial approximation
568 * @param isVShape has the solution a V shape?
569 * @param activate make the graph visible?
570 */
571 void drawCurve(CurveFitting *curve, bool isVShape, bool activate, bool plot = true);
572
573 /**
574 * @brief Focus solution with minimal HFR found
575 * @param solutionPosition focuser position
576 * @param solutionValue HFR value
577 */
578 void minimumFound(double solutionPosition, double solutionValue, bool plot = true);
579
580 /**
581 * @brief Draw Critical Focus Zone on graph
582 * @param solutionPosition focuser position
583 * @param solutionValue HFR value
584 * @param m_cfzSteps the size of the CFZ
585 * @param plt - whether to plot the CFZ
586 */
587 void drawCFZ(double minPosition, double minValue, int m_cfzSteps, bool plt);
588
589 /**
590 * @brief redraw the entire HFR plot
591 * @param poly pointer to the polynomial approximation
592 * @param solutionPosition solution focuser position
593 * @param solutionValue solution HFR value
594 */
595 void redrawHFRPlot(PolynomialFit *poly, double solutionPosition, double solutionValue);
596
597 /**
598 * @brief draw a title on the focus plot
599 * @param title the title
600 */
601 void setTitle(const QString &title, bool plot = true);
602
603 /**
604 * @brief final updates after focus run comopletes on the focus plot
605 * @param title
606 * @param plot
607 */
608 void finalUpdates(const QString &title, bool plot = true);
609
610 /**
611 * @brief focuserTimedout responding to requests
612 * @param focuser
613 */
614 void focuserTimedout(const QString &focuser);
615
616 private:
617
618 QList<SSolver::Parameters> m_StellarSolverProfiles;
619 QString savedOptionsProfiles;
620 StellarSolverProfileEditor *optionsProfileEditor { nullptr };
621
622 // Connections
623 void initConnections();
624
625 // Settings
626
627 /**
628 * @brief Connect GUI elements to sync settings once updated.
629 */
630 void connectSyncSettings();
631 /**
632 * @brief Stop updating settings when GUI elements are updated.
633 */
634 void disconnectSyncSettings();
635 /**
636 * @brief loadSettings Load setting from Options and set them accordingly.
637 */
638 void loadGlobalSettings();
639
640 /**
641 * @brief checkMosaicMaskLimits Check if the maximum values configured
642 * for the aberration style mosaic tile sizes fit into the CCD frame size.
643 */
644 void checkMosaicMaskLimits();
645
646 /**
647 * @brief syncSettings When checkboxes, comboboxes, or spin boxes are updated, save their values in the
648 * global and per-train settings.
649 */
650 void syncSettings();
651
652 /**
653 * @brief syncControl Sync setting to widget. The value depends on the widget type.
654 * @param settings Map of all settings
655 * @param key name of widget to sync
656 * @param widget pointer of widget to set
657 * @return True if sync successful, false otherwise
658 */
659 bool syncControl(const QVariantMap &settings, const QString &key, QWidget * widget);
660
661 /**
662 * @brief settleSettings Run this function after timeout from debounce timer to update database
663 * and emit settingsChanged signal. This is required so we don't overload output.
664 */
665 void settleSettings();
666
667 /**
668 * @brief prepareGUI Perform once only GUI prep processing
669 */
670 void prepareGUI();
671
672 /**
673 * @brief setUseWeights sets the useWeights checkbox
674 */
675 void setUseWeights();
676
677 /**
678 * @brief setDenoise sets the focusDenoise checkbox
679 */
680 void setDenoise();
681
682 /**
683 * @brief setDonutBuster sets the donutBuster checkbox
684 */
685 void setDonutBuster();
686
687 /**
688 * @brief setScanForStartPos sets the scanForStartPos checkbox
689 */
690 void setScanForStartPos();
691
692 /**
693 * @brief addMissingStellarSolverProfiles
694 * @param profile to add
695 * @param profilePath file pathname
696 */
697 void addMissingStellarSolverProfile(const QString profilesPath, const QString profile);
698
699 /**
700 * @brief Perform the processing to abort an in-flight focus procedure
701 */
702 void processAbort();
703
704 // HFR Plot
705 void initPlots();
706
707 // Positions
708 void getAbsFocusPosition();
709 bool autoFocusChecks();
710 void autoFocusAbs();
711 void autoFocusLinear();
712 void autoFocusRel();
713
714 // Linear does plotting differently from the rest.
715 void plotLinearFocus();
716
717 // Linear final updates to the curve
718 void plotLinearFinalUpdates();
719
720 // Launch the Aberation Inspector popup
721 void startAberrationInspector();
722
723 // Get the curve fitting goal based on how the algorithm is progressing
724 CurveFitting::FittingGoal getGoal(int numSteps);
725
726 /** @brief Helper function determining whether the focuser behaves like a position
727 * based one (vs. a timer based)
728 */
729 bool isPositionBased()
730 {
731 return (canAbsMove || canRelMove || (m_FocusAlgorithm == FOCUS_LINEAR) || (m_FocusAlgorithm == FOCUS_LINEAR1PASS));
732 }
733 void resetButtons();
734
735 /**
736 * @brief returns whether the Aberration Inspector can be used or not
737 * @return can / cant be started
738 */
739 bool canAbInsStart();
740 void stop(FocusState completionState = FOCUS_ABORTED);
741
742 void initView();
743 void initHelperObjects();
744
745 /** @brief Sets the plot vectors for Analyze after Autofocus. Used by Linear and Linear1Pass
746 */
747 void updatePlotPosition();
748
749 /** @brief Build the data string to send to Analyze
750 */
751 QString getAnalyzeData();
752
753 /**
754 * @brief prepareCapture Set common settings for capture for focus module
755 * @param targetChip target Chip
756 */
757 void prepareCapture(ISD::CameraChip *targetChip);
758
759 // HFR / FWHM
760 void setHFRComplete();
761
762 // Sets the star algorithm and enables/disables various UI inputs.
763 void setFocusDetection(StarAlgorithm starAlgorithm);
764
765 // Sets the algorithm and enables/disables various UI inputs.
766 void setFocusAlgorithm(Algorithm algorithm);
767
768 // Set the Auto Star & Box widgets
769 void setAutoStarAndBox();
770
771 void setCurveFit(CurveFitting::CurveFit curvefit);
772
773 void setStarMeasure(StarMeasure starMeasure);
774 void setStarPSF(StarPSF starPSF);
775 void setStarUnits(StarUnits starUnits);
776 void setWalk(FocusWalk focusWalk);
777 double calculateStarWeight(const bool useWeights, const std::vector<double> values);
778 bool boxOverlap(const QPair<int, int> b1Start, const QPair<int, int> b1End, const QPair<int, int> b2Start,
779 const QPair<int, int> b2End);
780 double getStarUnits(const StarMeasure starMeasure, const StarUnits starUnits);
781 // Calculate the CFZ of the current focus camera
782 double calcCameraCFZ();
783
784 // Calculate the CFZ from the screen parameters
785 void calcCFZ();
786
787 // Static data for filter's midpoint wavelength changed so update CFZ
788 void wavelengthChanged();
789
790 // Reset the CFZ parameters from the current Optical Train
791 void resetCFZToOT();
792
793 // Move the focuser in (negative) or out (positive amount).
794 bool changeFocus(int amount, bool updateDir = true);
795
796 // Start up capture, or occasionally move focuser again, after current focus-move accomplished.
797 void autoFocusProcessPositionChange(IPState state);
798
799 // For the Linear algorithm, which always scans in (from higher position to lower position)
800 // if we notice the new position is higher than the current position (that is, it is the start
801 // of a new scan), we adjust the new position to be several steps further out than requested
802 // and set focuserAdditionalMovement to the extra motion, so that after this motion completes
803 // we will then scan back in (back to the originally requested position). This "overscan dance" is done
804 // to reduce backlash on such movement changes and so that we've always focused in before capture.
805 int adjustLinearPosition(int position, int newPosition, int overscan, bool updateDir);
806
807 // Are we using a Star Measure that assumes a star field that requires star detection
808 bool isStarMeasureStarBased();
809
810 // Process the image to get star FWHMs
811 void getFWHM(const QList<Edge *> &stars, double *FWHM, double *weight);
812
813 // Process the image to get the Fourier Transform Power
814 // If tile = -1 use the whole image; if mosaicTile is specified use just that
815 void getFourierPower(double *fourierPower, double *weight, const int mosaicTile = -1);
816
817 // Process the image to get the blurryness factor
818 // If tile = -1 use the whole image; if mosaicTile is specified use just that
819 void getBlurriness(const StarMeasure starMeasure, const bool denoise, double *blurriness, double *weight,
820 const QRect &roi, const int mosaicTile = -1);
821
822 /**
823 * @brief syncTrackingBoxPosition Sync the tracking box to the current selected star center
824 */
825 void syncTrackingBoxPosition();
826
827 /** @internal Search for stars using the method currently configured, and return the consolidated HFR.
828 * @param image_data is the FITS frame to work with.
829 * @return the HFR of the star or field of stars in the frame, depending on the consolidation method, or -1 if it cannot be estimated.
830 */
831 void analyzeSources();
832
833 /** @internal Add a new star measure (HFR, FWHM, etc) for the current focuser position.
834 * @param newMeasure is the new measure (e.g. HFR, FWHM, etc) to consider for the current focuser position.
835 * @return true if a new sample is required, else false.
836 */
837 bool appendMeasure(double newMeasure);
838
839 /**
840 * @brief completeAutofocusProcedure finishes off autofocus and emits a message for other modules.
841 */
842 void completeFocusProcedure(FocusState completionState, AutofocusFailReason failCode, QString failCodeInfo = "",
843 bool plot = true);
844
845 /**
846 * @brief activities to be executed after the configured settling time
847 * @param completionState state the focuser completed with
848 * @param autoFocusUsed is autofocus running?
849 * @param buildOffsetsUsed is autofocus running as a result of build offsets
850 * @param failCode is the reason for the Autofocus failure
851 * @param failCodeInfo contains extra info about failCode
852 */
853 void settle(const FocusState completionState, const bool autoFocusUsed,
854 const bool buildOffsetsUsed, const AutofocusFailReason failCode, const QString failCodeInfo);
855
856 void setLastFocusTemperature();
857 void setLastFocusAlt();
858 bool findTemperatureElement(const QSharedPointer<ISD::GenericDevice> &device);
859
860 /**
861 * @brief reset Adaptive Focus parameters
862 * @param Adaptive Focus enabled
863 */
864 void resetAdaptiveFocus(bool enabled);
865
866 void setupOpticalTrainManager();
867 void refreshOpticalTrain();
868
869 /**
870 * @brief set member valiables for the scope attached to the current Optical Train
871 * @param Optical Train scope parameters
872 * @param Optical Train reducer
873 */
874 void setScopeDetails(const QJsonObject &scope, const double reducer);
875
876 /**
877 * @brief handleFocusMotionTimeout When focuser is command to go to a target position, we expect to receive a notification
878 * that it arrived at the desired destination. If not, we command it again.
879 */
880 void handleFocusMotionTimeout();
881
882 /**
883 * @brief returns axis label based on measure selected
884 * @param starMeasure the star measure beuing used
885 */
886 QString getyAxisLabel(StarMeasure starMeasure);
887
888 /**
889 * @brief disable input widgets at the start of an AF run
890 * @param the widget to disable
891 * @param whether to disable at the widget level or disable all the children
892 */
893 void AFDisable(QWidget * widget, const bool children);
894
895 /**
896 * @brief returns whether the Gain input field is enabled outside of autofocus and
897 * whether logically is should be enabled during AF even though all input widgets are disabled
898 */
899 bool isFocusGainEnabled();
900
901 /**
902 * @brief returns whether the ISO input field is enabled outside of autofocus and
903 * whether logically is should be enabled during AF even though all input widgets are disabled
904 */
905 bool isFocusISOEnabled();
906
907 /**
908 * @brief returns whether the SubFrame input field is enabled outside of autofocus and
909 * whether logically is should be enabled during AF even though all input widgets are disabled
910 */
911 bool isFocusSubFrameEnabled();
912
913 /**
914 * @brief Save the focus frame for later dubugging
915 */
916 void saveFocusFrame();
917
918 /**
919 * @brief Initialise donut processing
920 */
921 void initDonutProcessing();
922
923 /**
924 * @brief Setup Linear Focuser
925 * @param initialPosition of the focuser
926 */
927 void setupLinearFocuser(int initialPosition);
928
929 /**
930 * @brief Initialise the Scan Start Position algorithm
931 * @param force Scan Start Pos
932 * @param startPosition
933 * @return whether Scan for Start Position was initiated
934 */
935 bool initScanStartPos(const bool force, const int initialPosition);
936
937 /**
938 * @brief Process the scan for the Autofocus starting position
939 */
940 void scanStartPos();
941
942 /**
943 * @brief Reset donut processing
944 */
945 void resetDonutProcessing();
946
947 /**
948 * @brief Adjust Autofocus capture exposure based on user settings when using Donut Buster
949 */
950 void donutTimeDilation();
951
952 /// Focuser device needed for focus operation
953 ISD::Focuser *m_Focuser { nullptr };
954 int m_focuserId;
955 /// CCD device needed for focus operation
956 ISD::Camera *m_Camera { nullptr };
957 /// Optional device filter
958 ISD::FilterWheel *m_FilterWheel { nullptr };
959 /// Optional temperature source element
960 INumber *currentTemperatureSourceElement {nullptr};
961
962 /// Current filter position
963 int currentFilterPosition { -1 };
964 int fallbackFilterPosition { -1 };
965 /// True if we need to change filter position and wait for result before continuing capture
966 bool filterPositionPending { false };
967 bool fallbackFilterPending { false };
968
969 /// They're generic GDInterface because they could be either ISD::Camera or ISD::FilterWheel or ISD::Weather
970 QList<QSharedPointer<ISD::GenericDevice>> m_TemperatureSources;
971
972 /// Last Focus direction. Used by Iterative and Polynomial. NOTE: this does not take account of overscan
973 /// so, e.g. an outward move will always by FOCUS_OUT even though overscan will move back in
974 Direction m_LastFocusDirection { FOCUS_NONE };
975 /// Keep track of the last requested steps
976 uint32_t m_LastFocusSteps {0};
977 /// What type of focusing are we doing right now?
978 Type m_FocusType { FOCUS_MANUAL };
979 /// Focus HFR & Centeroid algorithms
980 StarAlgorithm m_FocusDetection { ALGORITHM_SEP };
981 /// Focus Process Algorithm
982 Algorithm m_FocusAlgorithm { FOCUS_LINEAR1PASS };
983 /// Curve fit
984 CurveFitting::CurveFit m_CurveFit { CurveFitting::FOCUS_HYPERBOLA };
985 /// Star measure to use
986 StarMeasure m_StarMeasure { FOCUS_STAR_HFR };
987 /// PSF to use
988 StarPSF m_StarPSF { FOCUS_STAR_GAUSSIAN };
989 /// Units to use when displaying HFR or FWHM
990 StarUnits m_StarUnits { FOCUS_UNITS_PIXEL };
991 /// Units to use when displaying HFR or FWHM
992 FocusWalk m_FocusWalk { FOCUS_WALK_FIXED_STEPS };
993 /// Are we minimising or maximising?
994 CurveFitting::OptimisationDirection m_OptDir { CurveFitting::OPTIMISATION_MINIMISE };
995 /// The type of statistics to use
996 Mathematics::RobustStatistics::ScaleCalculation m_ScaleCalc { Mathematics::RobustStatistics::SCALE_SESTIMATOR };
997
998 /******************************************
999 * "Measure" variables, HFR, FWHM, numStars
1000 ******************************************/
1001
1002 /// Current HFR value just fetched from FITS file
1003 double currentHFR { INVALID_STAR_MEASURE };
1004 double currentFWHM { INVALID_STAR_MEASURE };
1005 double currentNumStars { INVALID_STAR_MEASURE };
1006 double currentFourierPower { INVALID_STAR_MEASURE };
1007 double currentBlurriness { INVALID_STAR_MEASURE };
1008 double currentMeasure { INVALID_STAR_MEASURE };
1009 double currentWeight { 0 };
1010 /// Last HFR value recorded
1011 double lastHFR { 0 };
1012 /// If (currentHFR > deltaHFR) we start the autofocus process.
1013 double minimumRequiredHFR { INVALID_STAR_MEASURE };
1014 /// Maximum HFR recorded
1015 double maxHFR { 1 };
1016 /// Is HFR increasing? We're going away from the sweet spot! If HFRInc=1, we re-capture just to make sure HFR calculations are correct, if HFRInc > 1, we switch directions
1017 int HFRInc { 0 };
1018 /// If HFR decreasing? Well, good job. Once HFR start decreasing, we can start calculating HFR slope and estimating our next move.
1019 int HFRDec { 0 };
1020
1021 /****************************
1022 * Absolute position focusers
1023 ****************************/
1024 /// Absolute focus position
1025 int currentPosition { 0 };
1026 /// Motion state of the absolute focuser
1027 IPState currentPositionState {IPS_IDLE};
1028 /// flag if position or state has changed (to avoid too much logging)
1029 bool logPositionAndState {true};
1030 /// What was our position before we started the focus process?
1031 int initialFocuserAbsPosition { -1 };
1032 /// Pulse duration in ms for relative focusers that only support timers, or the number of ticks in a relative or absolute focuser
1033 int pulseDuration { 1000 };
1034 /// Does the focuser support absolute motion?
1035 bool canAbsMove { false };
1036 /// Does the focuser support relative motion?
1037 bool canRelMove { false };
1038 /// Does the focuser support timer-based motion?
1039 bool canTimerMove { false };
1040 /// Maximum range of motion for our lovely absolute focuser
1041 double absMotionMax { 0 };
1042 /// Minimum range of motion for our lovely absolute focuser
1043 double absMotionMin { 0 };
1044 /// How many iterations have we completed now in our absolute autofocus algorithm? We can't go forever
1045 int absIterations { 0 };
1046 /// Current image mask
1047 ImageMaskType m_currentImageMask = FOCUS_MASK_NONE;
1048
1049 /****************************
1050 * Misc. variables
1051 ****************************/
1052
1053 /// Are we tring to abort Autofocus?
1054 bool m_abortInProgress { false };
1055 /// Are we in the process of capturing an image?
1056 bool m_captureInProgress { false };
1057 /// Are we in the process of star detection?
1058 bool m_starDetectInProgress { false };
1059 // Was the frame modified by us? Better keep track since we need to return it to its previous state once we are done with the focus operation.
1060 //bool frameModified;
1061 /// Was the modified frame subFramed?
1062 bool subFramed { false };
1063 /// If the autofocus process fails, let's not ruin the capture session probably taking place in the next tab. Instead, we should restart it and try again, but we keep count until we hit MAXIMUM_RESET_ITERATIONS
1064 /// and then we truly give up.
1065 int resetFocusIteration { 0 };
1066 /// Which filter must we use once the autofocus process kicks in?
1067 int lockedFilterIndex { -1 };
1068 /// Keep track of what we're doing right now
1069 bool inAutoFocus { false };
1070 bool inFocusLoop { false };
1071 bool inScanStartPos { false };
1072 //bool inSequenceFocus { false };
1073 /// Keep track of request to retry or abort an AutoFocus run after focus position has been reset
1074 /// RESTART_NONE = normal operation, no restart
1075 /// RESTART_NOW = restart the autofocus routine
1076 /// RESTART_ABORT = when autofocus has been tried MAXIMUM_RESET_ITERATIONS times, abort the routine
1077 typedef enum { RESTART_NONE = 0, RESTART_NOW, RESTART_ABORT } FocusRestartState;
1078 FocusRestartState m_RestartState { RESTART_NONE };
1079 /// Did we reverse direction?
1080 bool reverseDir { false };
1081 /// Did the user or the auto selection process finish selecting our focus star?
1082 bool starSelected { false };
1083 /// Adjust the focus position to a target value
1084 bool inAdjustFocus { false };
1085 /// Build offsets is a special case of the Autofocus run
1086 bool inBuildOffsets { false };
1087 // Target frame dimensions
1088 //int fx,fy,fw,fh;
1089 /// If HFR=-1 which means no stars detected, we need to decide how many times should the re-capture process take place before we give up or reverse direction.
1090 int noStarCount { 0 };
1091 /// 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
1092 ISD::Camera::UploadMode rememberUploadMode { ISD::Camera::UPLOAD_CLIENT };
1093 /// Star measure (e.g. HFR, FWHM, etc) values for captured frames before averages
1094 QVector<double> starMeasureFrames;
1095 // Camera Fast Exposure
1096 bool m_RememberCameraFastExposure = { false };
1097 // Future Watch
1098 QFutureWatcher<bool> m_StarFinderWatcher;
1099 // R2 as a measure of how well the curve fits the datapoints. Passed to the V-curve graph for display
1100 double R2 = 0;
1101 // Counter to retry the auto focus run if the R2Limit has not been reached
1102 int R2Retries = 0;
1103 // Counter to retry starting focus operation (autofocus, adjust focus, etc) if the focuser is still active
1104 int m_StartRetries = 0;
1105 // Reason code for the Autofocus run - passed to Analyze
1106 AutofocusReason m_AutofocusReason = AutofocusReason::FOCUS_NONE;
1107 // Extra information about m_AutofocusReason
1108 QString m_AutofocusReasonInfo;
1109 // Autofocus run number - to help with debugging logs
1110 int m_AFRun = 0;
1111 // Rerun flag indicating a rerun due to AF failing
1112 bool m_AFRerun = false;
1113
1114 ITextVectorProperty *filterName { nullptr };
1115 INumberVectorProperty *filterSlot { nullptr };
1116
1117 // Holds the superset of text values in combo-boxes that can have restricted options
1118 QStringList m_StarMeasureText;
1119 QStringList m_CurveFitText;
1120 QStringList m_FocusWalkText;
1121
1122 // Holds the enabled state of widgets that is used to active functionality in focus
1123 // during Autofocus when the input interface is disabled
1124 bool m_FocusGainAFEnabled { false };
1125 bool m_FocusISOAFEnabled { false };
1126 bool m_FocusSubFrameAFEnabled { false };
1127
1128 /****************************
1129 * Plot variables
1130 ****************************/
1131
1132 /// Plot minimum positions
1133 double minPos { 1e6 };
1134 /// Plot maximum positions
1135 double maxPos { 0 };
1136 /// V curve plot points
1137 QVector<double> plot_position, plot_value, plot_weight;
1138 QVector<bool> plot_outlier;
1139 bool isVShapeSolution = false;
1140
1141 /// State
1142 FocusState m_state { Ekos::FOCUS_IDLE };
1143 FocusState m_pendingState { Ekos::FOCUS_IDLE };
1144 FocusState state() const
1145 {
1146 return m_state;
1147 }
1148 void setState(FocusState newState);
1149
1150 bool isBusy()
1151 {
1152 return m_state == FOCUS_WAITING || m_state == FOCUS_PROGRESS || m_state == FOCUS_FRAMING
1153 || m_state == FOCUS_CHANGING_FILTER;
1154 }
1155
1156 /// CCD Chip frame settings
1158
1159 /// Selected star coordinates
1160 QVector3D starCenter;
1161
1162 // Remember last star center coordinates in case of timeout in manual select mode
1163 QVector3D rememberStarCenter;
1164
1165 /// Focus Frame
1166 QSharedPointer<FITSView> m_FocusView;
1167
1168 /// Star Select Timer
1169 QTimer waitStarSelectTimer;
1170
1171 /// FITS Viewer in case user want to display in it instead of internal view
1173
1174 /// Track star position and HFR to know if we're detecting bogus stars due to detection algorithm false positive results
1175 QVector<QVector3D> starsHFR;
1176
1177 /// Relative Profile
1178 FocusProfilePlot *profilePlot { nullptr };
1179 QDialog *profileDialog { nullptr };
1180
1181 /// Polynomial fitting.
1182 std::unique_ptr<PolynomialFit> polynomialFit;
1183
1184 // Curve fitting for focuser movement.
1185 std::unique_ptr<CurveFitting> curveFitting;
1186
1187 // Curve fitting for stars.
1188 std::unique_ptr<CurveFitting> starFitting;
1189
1190 // FWHM processing.
1191 std::unique_ptr<FocusFWHM> focusFWHM;
1192
1193 // Fourier Transform power processing.
1194 std::unique_ptr<FocusFourierPower> focusFourierPower;
1195
1196#if defined(HAVE_OPENCV)
1197 // Blurriness processing.
1198 std::unique_ptr<FocusBlurriness> focusBlurriness;
1199#endif
1200
1201 // Adaptive Focus processing.
1202 std::unique_ptr<AdaptiveFocus> adaptFocus;
1203
1204 // Focus Advisor processing.
1205 std::unique_ptr<FocusAdvisor> focusAdvisor;
1206
1207 // Capture timers
1208 QTimer captureTimer;
1209 QTimer captureTimeout;
1210 uint8_t captureTimeoutCounter { 0 };
1211 uint8_t m_MissingCameraCounter { 0 };
1212 uint8_t captureFailureCounter { 0 };
1213
1214 // Gain Control
1215 double GainSpinSpecialValue { INVALID_VALUE };
1216
1217 // Focus motion timer.
1218 QTimer m_FocusMotionTimer;
1219 uint8_t m_FocusMotionTimerCounter { 0 };
1220
1221 // Focuser reconnect counter
1222 uint8_t m_FocuserReconnectCounter { 0 };
1223
1224 // Set m_DebugFocuser = true to simulate a focuser failure
1225 bool m_DebugFocuser { false };
1226 uint16_t m_DebugFocuserCounter { 0 };
1227
1228 // Guide Suspend
1229 bool m_GuidingSuspended { false };
1230
1231 // Data
1232 QSharedPointer<FITSData> m_ImageData;
1233
1234 // Linear focuser.
1235 std::unique_ptr<FocusAlgorithmInterface> linearFocuser;
1236 int focuserAdditionalMovement { 0 };
1237 bool focuserAdditionalMovementUpdateDir { true };
1238 int linearRequestedPosition { 0 };
1239
1240 bool hasDeviation { false };
1241
1242 //double observatoryTemperature { INVALID_VALUE };
1243 double m_LastSourceAutofocusTemperature { INVALID_VALUE };
1244 QSharedPointer<ISD::GenericDevice> m_LastSourceDeviceAutofocusTemperature;
1245 //TemperatureSource lastFocusTemperatureSource { NO_TEMPERATURE };
1246 double m_LastSourceAutofocusAlt { INVALID_VALUE };
1247
1248 // Mount altitude value for logging
1249 double mountAlt { INVALID_VALUE };
1250
1251 static constexpr uint8_t MAXIMUM_FLUCTUATIONS {10};
1252
1253 QVariantMap m_Settings;
1254 QVariantMap m_GlobalSettings;
1255
1256 // Dark Processor
1257 QPointer<DarkProcessor> m_DarkProcessor;
1258
1259 QSharedPointer<FilterManager> m_FilterManager;
1260
1261 // Maintain a list of disabled widgets when Autofocus is running that can be restored at the end of the run
1262 QVector <QWidget *> disabledWidgets;
1263
1264 // Scope parameters of the active optical train
1265 double m_Aperture = 0.0f;
1266 double m_FocalLength = 0.0f;
1267 double m_FocalRatio = 0.0f;
1268 double m_Reducer = 0.0f;
1269 double m_CcdPixelSizeX = 0.0f;
1270 int m_CcdWidth = 0;
1271 int m_CcdHeight = 0;
1272 QString m_ScopeType;
1273
1274 QString m_opsDialogName;
1275
1276 // Settings popup
1277 //std::unique_ptr<Ui::Settings> m_SettingsUI;
1278 //QPointer<QDialog> m_SettingsDialog;
1279 OpsFocusSettings *m_OpsFocusSettings { nullptr };
1280
1281 // Process popup
1282 //std::unique_ptr<Ui::Process> m_ProcessUI;
1283 //QPointer<QDialog> m_ProcessDialog;
1284 OpsFocusProcess *m_OpsFocusProcess { nullptr };
1285
1286 // Mechanics popup
1287 //std::unique_ptr<Ui::Mechanics> m_MechanicsUI;
1288 //QPointer<QDialog> m_MechanicsDialog;
1289 OpsFocusMechanics *m_OpsFocusMechanics { nullptr };
1290
1291 // CFZ popup
1292 std::unique_ptr<Ui::focusCFZDialog> m_CFZUI;
1293 QPointer<QDialog> m_CFZDialog;
1294
1295 // CFZ
1296 double m_cfzSteps = 0.0f;
1297
1298 // Aberration Inspector
1299 void calculateAbInsData();
1300 bool m_abInsOn = false;
1301 int m_abInsRun = 0;
1302 QVector<int> m_abInsPosition;
1303 QVector<QVector<double>> m_abInsMeasure;
1304 QVector<QVector<double>> m_abInsWeight;
1305 QVector<QVector<int>> m_abInsNumStars;
1306 QVector<QPoint> m_abInsTileCenterOffset;
1307
1308 QTimer m_DebounceTimer;
1309
1310 // Donut Buster
1311 double m_donutOrigExposure = 0.0;
1312 QVector<int> m_scanPosition;
1313 QVector<double> m_scanMeasure;
1314 QString m_AFfilter = NULL_FILTER;
1315};
1316
1317}
Supports manual focusing and auto focusing using relative and absolute INDI focusers.
Definition focus.h:54
void drawPolynomial(PolynomialFit *poly, bool isVShape, bool activate, bool plot=true)
draw the approximating polynomial into the HFR V-graph
void toggleVideo(bool enabled)
toggleVideo Turn on and off video streaming if supported by the camera.
Definition focus.cpp:5492
void checkTemperatureSource(const QString &name=QString())
Check temperature source and make sure information is updated accordingly.
Definition focus.cpp:567
Q_SCRIPTABLE bool setFilter(const QString &filter)
DBUS interface function.
Definition focus.cpp:655
void startFraming()
startFraming Begins continuous capture of the CCD and calculates HFR every frame.
Definition focus.cpp:4552
void newHFRPlotPosition(double pos, double hfr, double sigma, bool outlier, int pulseDuration, bool plot=true)
new HFR plot position with sigma
void redrawHFRPlot(PolynomialFit *poly, double solutionPosition, double solutionValue)
redraw the entire HFR plot
Q_SCRIPTABLE double getHFR()
DBUS interface function.
Definition focus.h:131
void loadStellarSolverProfiles()
setWeatherData Updates weather data that could be used to extract focus temperature from observatory ...
Definition focus.cpp:247
Q_SCRIPTABLE Q_NOREPLY void setBinning(int binX, int binY)
DBUS interface function.
Definition focus.cpp:5040
void clearDataPoints()
clearDataPoints Remove all data points from HFR plots
Definition focus.cpp:3114
Q_SCRIPTABLE Q_NOREPLY void setAutoStarEnabled(bool enable)
DBUS interface function.
Definition focus.cpp:5046
void runAutoFocus(const AutofocusReason autofocusReason, const QString &reasonInfo)
Run the autofocus process for the currently selected filter.
Definition focus.cpp:1012
void updateProperty(INDI::Property prop)
updateProperty Read focus number properties of interest as they arrive from the focuser driver and pr...
Definition focus.cpp:4161
void focusStarSelected(int x, int y)
focusStarSelected The user selected a focus star, save its coordinates and subframe it if subframing ...
Definition focus.cpp:4766
void reconnectFocuser(const QString &focuser)
reconnectFocuser Add focuser to the list of available focusers.
Definition focus.cpp:1884
bool setFocuser(ISD::Focuser *device)
addFocuser Add focuser to the list of available focusers.
Definition focus.cpp:705
void resetFocuser()
Move the focuser to the initial focus position.
Definition focus.cpp:2525
void processData(const QSharedPointer< FITSData > &data)
newFITS A new FITS blob is received by the CCD driver.
Definition focus.cpp:1910
void focuserTimedout(const QString &focuser)
focuserTimedout responding to requests
void initHFRPlot(QString str, double starUnits, bool minimum, bool useWeights, bool showPosition)
initialize the HFR V plot
void selectFocusStarFraction(double x, double y)
selectFocusStarFraction Select the focus star based by fraction of the overall size.
Definition focus.cpp:4753
void appendLogText(const QString &logtext)
setFocusStatus Upon completion of the focusing process, set its status (fail or pass) and reset focus...
Definition focus.cpp:4537
void adaptiveFocus()
adaptiveFocus moves the focuser between subframes to stay at focus
Definition focus.cpp:986
Q_SCRIPTABLE Q_NOREPLY void resetFrame()
DBUS interface function.
Definition focus.cpp:314
void meridianFlipStarted()
React when a meridian flip has been started.
Definition focus.cpp:1397
Q_SCRIPTABLE QString filterWheel()
DBUS interface function.
void processTemperatureSource(INDI::Property prop)
processTemperatureSource Updates focus temperature source.
Definition focus.cpp:919
void removeDevice(const QSharedPointer< ISD::GenericDevice > &deviceRemoved)
removeDevice Remove device from Focus module
Definition focus.cpp:5263
void syncCameraInfo()
syncCameraInfo Read current CCD information and update settings accordingly.
Definition focus.cpp:469
void checkFilter()
Check Filter and make sure information is updated accordingly.
Definition focus.cpp:671
void drawCFZ(double minPosition, double minValue, int m_cfzSteps, bool plt)
Draw Critical Focus Zone on graph.
Q_SCRIPTABLE QString focuser()
DBUS interface function.
void finalUpdates(const QString &title, bool plot=true)
final updates after focus run comopletes on the focus plot
void minimumFound(double solutionPosition, double solutionValue, bool plot=true)
Focus solution with minimal HFR found.
void checkStopFocus(bool abort)
checkStopFocus Perform checks before stopping the autofocus operation.
Definition focus.cpp:1351
void checkFocuser()
Check Focuser and make sure information is updated accordingly.
Definition focus.cpp:743
Q_SCRIPTABLE Q_NOREPLY void setExposure(double value)
DBUS interface function.
Definition focus.cpp:5035
void setTitle(const QString &title, bool plot=true)
draw a title on the focus plot
void drawCurve(CurveFitting *curve, bool isVShape, bool activate, bool plot=true)
draw the curve into the HFR V-graph
QStringList getStellarSolverProfiles()
getStellarSolverProfiles
Definition focus.cpp:298
Q_SCRIPTABLE Q_NOREPLY void setAutoFocusParameters(int boxSize, int stepSize, int maxTravel, double tolerance)
DBUS interface function.
Definition focus.cpp:5056
Q_SCRIPTABLE Ekos::FocusState status()
DBUS interface function.
Definition focus.h:184
bool setFilterWheel(ISD::FilterWheel *device)
addFilter Add filter to the list of available filters.
Definition focus.cpp:507
Q_SCRIPTABLE bool canAutoFocus()
DBUS interface function.
Definition focus.h:123
void updateTemperatureSources(const QList< QSharedPointer< ISD::GenericDevice > > &temperatureSources)
updateTemperatureSources Update list of available temperature sources.
Definition focus.cpp:548
Q_SCRIPTABLE QString camera()
DBUS interface function.
Q_SCRIPTABLE Q_NOREPLY void setAutoSubFrameEnabled(bool enable)
DBUS interface function.
Definition focus.cpp:5051
bool setCamera(ISD::Camera *device)
Add CCD to the list of available CCD.
Definition focus.cpp:849
void syncCCDControls()
Update camera controls like Gain, ISO, Offset...etc.
Definition focus.cpp:417
void checkCamera()
Check CCD and make sure information is updated accordingly.
Definition focus.cpp:358
void selectImageMask()
setImageMask Select the currently active image mask filtering the stars relevant for focusing
Definition focus.cpp:1847
void adaptiveFocusComplete(const QString &filter, double temperature, double tempTicks, double altitude, double altTicks, int prevPosError, int thisPosError, int totalTicks, int position, bool focuserMoved)
Signal Analyze that an Adaptive Focus iteration is complete.
Primary window to view monochrome and color FITS images.
Definition fitsviewer.h:54
CameraChip class controls a particular chip in camera.
Camera class controls an INDI Camera device.
Definition indicamera.h:45
Focuser class handles control of INDI focuser devices.
Definition indifocuser.h:21
The sky coordinates of a point in the sky.
Definition skypoint.h:45
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
Q_SCRIPTABLE Q_NOREPLY void checkFocus(double requiredHFR)
checkFocus Given the minimum required HFR, check focus and calculate HFR.
Definition focus.cpp:4904
Q_SCRIPTABLE Q_NOREPLY void capture(double settleTime=0.0)
DBUS interface function.
Definition focus.cpp:1505
Q_SCRIPTABLE bool focusOut(int ms=-1)
DBUS interface function.
Definition focus.cpp:1699
Q_SCRIPTABLE Q_NOREPLY void start()
DBUS interface function.
Definition focus.cpp:1006
Q_SCRIPTABLE Q_NOREPLY void abort()
DBUS interface function.
Definition focus.cpp:1411
Q_SCRIPTABLE bool focusIn(int ms=-1)
DBUS interface function.
Definition focus.cpp:1679
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
Q_CLASSINFO(Name, Value)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
const QObjectList & children() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 3 2025 11:47:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.