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

KDE's Doxygen guidelines are available online.