File indexing completed on 2024-04-21 14:47:26
0001 /* 0002 KStars UI tests for meridian flip 0003 0004 SPDX-FileCopyrightText: 2020 Wolfgang Reissenberger <sterne-jaeger@openfuture.de> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include "config-kstars.h" 0012 #include "test_ekos_debug.h" 0013 0014 #if defined(HAVE_INDI) 0015 0016 #include <QObject> 0017 #include <QPushButton> 0018 #include <QQuickItem> 0019 #include <QTest> 0020 #include <QQueue> 0021 0022 #include "ekos/align/align.h" 0023 #include "ekos/guide/guide.h" 0024 #include "ekos/mount/mount.h" 0025 #include "ekos/scheduler/scheduler.h" 0026 #include "ekos/profileeditor.h" 0027 0028 #include "test_ekos_simulator.h" 0029 #include "test_ekos_capture.h" 0030 #include "test_ekos_capture_helper.h" 0031 0032 class TestEkosMeridianFlipBase : public QObject 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 explicit TestEkosMeridianFlipBase(QObject *parent = nullptr); 0038 explicit TestEkosMeridianFlipBase(QString guider, QObject *parent = nullptr); 0039 0040 protected: 0041 /** 0042 * @brief Start a test EKOS profile. 0043 */ 0044 bool startEkosProfile(); 0045 0046 /** 0047 * @brief Shutdown the current test EKOS profile. 0048 */ 0049 bool shutdownEkosProfile(); 0050 0051 /** 0052 * @brief Enable the meridian flip on the mount tab 0053 * @param delay seconds delay of the meridian flip 0054 */ 0055 bool enableMeridianFlip(double delay); 0056 0057 /** 0058 * @brief Position the mount so that the meridian will be reached in certain timeframe 0059 * @param secsToMF seconds until the meridian will be crossed 0060 * @param fast use sync for fast positioning 0061 */ 0062 bool positionMountForMF(int secsToMF, bool fast = true); 0063 0064 /** 0065 * @brief Check if meridian flip has been started 0066 * @param startDelay upper limit for expected time in seconds that are expected the flip to start 0067 */ 0068 bool checkMFStarted (int startDelay); 0069 0070 /** 0071 * @brief Check if meridian flip runs and completes 0072 * @param startDelay upper limit for expected time in seconds that are expected the flip to start 0073 */ 0074 bool checkMFExecuted(int startDelay); 0075 0076 /** 0077 * @brief Determine the number of seconds until the meridian flip should take place by reading 0078 * the displayed meridian flip status. 0079 */ 0080 int secondsToMF(); 0081 0082 /** 0083 * @brief Determine the target close to the meridian 0084 * @param secsToMF seconds to meridian flip 0085 * @param set to true if a sync close to the target should be executed 0086 */ 0087 void findMFTestTarget(int secsToMF, bool fast); 0088 0089 /** 0090 * @brief General preparations used both for pure capturing test cases as well as those with the scheduler. 0091 * @param guideDeviation select "Abort if Guide Deviation" 0092 * @param initialGuideDeviation select "Only Start if Guide Deviation <" 0093 */ 0094 bool prepareMFTestcase(bool guideDeviation, bool initialGuideDeviation); 0095 0096 /** 0097 * @brief Helper function that reads capture sequence test data, creates entries in the capture module, 0098 * executes upfront focusing if necessary and positions the mount close to the meridian. 0099 * @param secsToMF seconds until the meridian will be crossed 0100 * @param guideDeviation select "Abort if Guide Deviation" 0101 * @param initialGuideDeviation select "Only Start if Guide Deviation <" 0102 */ 0103 bool prepareCaptureTestcase(int secsToMF, bool guideDeviation, bool initialGuideDeviation); 0104 0105 /** 0106 * @brief Prepare the scheduler with a single based upon the capture sequences filled 0107 * by @see prepareCaptureTestcase(int,bool,bool,bool) 0108 * @param secsToMF seconds until the meridian will be crossed 0109 * @param useAlign use alignment for the scheduler job 0110 * @param completionCondition completion condition for the scheduler 0111 * @param iterations number of iterations to be executed (only relevant if completionCondition == FINISH_REPEAT) 0112 * @return true iff preparation was successful 0113 */ 0114 bool prepareSchedulerTestcase(int secsToMF, bool useAlign, Ekos::CompletionCondition completionCondition, int iterations); 0115 0116 /** 0117 * @brief Prepare test data iterating over all combination of parameters. 0118 * @param exptime exposure time of the test frames 0119 * @param locationList variants of locations 0120 * @param culminationList variants of upper or lower culmination (upper = true) 0121 * @param filterList variants of filter parameter tests 0122 * @param focusList variants with/without the focus after flip option selected ( 0=no, 1=refocus, 2=HFR autofocus, 3=after meridian flip) 0123 * @param guideList variants with/without guiding tests 0124 * @param ditherList variants with/without dithering tests 0125 */ 0126 void prepareTestData(double exptime, QList<QString> locationList, QList<bool> culminationList, QList<std::pair<QString, int> > filterList, 0127 QList<int> focusList, QList<bool> guideList, QList<bool> ditherList); 0128 0129 /** 0130 * @brief Check if guiding and dithering is restarted if required. 0131 */ 0132 bool checkDithering(); 0133 0134 /** 0135 * @brief Check if re-focusing is issued if required. 0136 */ 0137 bool checkRefocusing(); 0138 0139 /** 0140 * @brief Helper function for start of alignment 0141 * @param exposure time 0142 */ 0143 bool executeAlignment(double expTime); 0144 0145 /** 0146 * @brief Helper function to stop guiding 0147 */ 0148 bool stopAligning(); 0149 0150 /** 0151 * @brief Helper function for start of capturing 0152 */ 0153 bool startCapturing(); 0154 0155 /** 0156 * @brief Helper function to stop capturing 0157 */ 0158 bool stopCapturing(); 0159 0160 /** 0161 * @brief Helper function for starting the scheduler 0162 */ 0163 bool startScheduler(); 0164 0165 /** 0166 * @brief Helper function for stopping the scheduler 0167 */ 0168 bool stopScheduler(); 0169 0170 /** @brief Check if after a meridian flip all features work as expected: capturing, aligning, guiding and focusing */ 0171 bool checkPostMFBehavior(); 0172 0173 // helper class 0174 TestEkosCaptureHelper *m_CaptureHelper = nullptr; 0175 0176 // target position 0177 SkyPoint *target; 0178 0179 // initial focuser position 0180 int initialFocusPosition = -1; 0181 0182 // focus after meridian flip selected? 0183 bool refocus_checked = false; 0184 // aligning used? 0185 bool use_aligning = false; 0186 // regular dithering on? 0187 bool dithering_checked = false; 0188 // astrometry files available? 0189 bool astrometry_available = true; 0190 0191 protected slots: 0192 void initTestCase(); 0193 void cleanupTestCase(); 0194 0195 void init(); 0196 void cleanup(); 0197 }; 0198 0199 #endif // HAVE_INDI 0200