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

KDE's Doxygen guidelines are available online.