File indexing completed on 2024-04-21 14:47:17
0001 /* 0002 Tests for scheduler job state machine. 0003 0004 SPDX-FileCopyrightText: 2021 Wolfgang Reissenberger <sterne-jaeger@openfuture.de> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include "ekos/capture/sequencejobstate.h" 0012 #include <QTest> 0013 0014 class TestAdapter; 0015 0016 class TestSequenceJobState : public QObject 0017 { 0018 Q_OBJECT 0019 public: 0020 explicit TestSequenceJobState(); 0021 0022 protected slots: 0023 /** 0024 * @brief Initialization at beginning of the run of the entire test suite. 0025 */ 0026 void initTestCase(); 0027 /** 0028 * @brief Cleanup after the entire test suite has finished. 0029 */ 0030 void cleanupTestCase(); 0031 /** 0032 * @brief Initialisation before each single test case. 0033 */ 0034 void init(); 0035 /** 0036 * @brief Cleanup after the a single test case has finished. 0037 */ 0038 void cleanup(); 0039 0040 private slots: 0041 /** 0042 * @brief Test case with temperature, rotator and guiding 0043 */ 0044 void testPrepareLightFrames(); 0045 0046 /** 0047 * @brief Test data for {@see testPrepareLightFrames()} 0048 */ 0049 void testPrepareLightFrames_data(); 0050 0051 private: 0052 // The state machine 0053 Ekos::SequenceJobState *m_stateMachine; 0054 // the test adapter simulating the EKOS environment 0055 TestAdapter *m_adapter; 0056 // forward signals to the sequence job 0057 void connectAdapter(); 0058 }; 0059 0060 /* ********************************************************************************* 0061 * Test adapter 0062 * ********************************************************************************* */ 0063 0064 class TestAdapter : public QObject 0065 { 0066 Q_OBJECT 0067 public: 0068 explicit TestAdapter(); 0069 0070 double m_ccdtemperature = 0.0, m_rotatorangle = 0.0, m_guiding_dev; 0071 double m_targetccdtemp, m_targetrotatorangle, m_target_guiding_dev; 0072 bool m_isguideractive, m_ispreview; 0073 0074 QTimer *temperatureTimer, *rotatorTimer, *guidingTimer; 0075 0076 // initialize the values 0077 void init(double temp, double angle, double guiding_limit); 0078 0079 // set CCD to preview mode 0080 void setCCDBatchMode(bool m_preview); 0081 // set the current CCD temperature 0082 void setCCDTemperature(double value); 0083 // set the current camera rotator position 0084 void setRotatorAngle(double value); 0085 0086 // flag if capture preparation is completed 0087 bool isCapturePreparationComplete = false; 0088 0089 public slots: 0090 /** 0091 * @brief Slot that reads the requested device state and publishes the corresponding event 0092 * @param state device state that needs to be read directly 0093 */ 0094 void readCurrentState(Ekos::CaptureState state); 0095 0096 /** 0097 * @brief Slot that marks the capture preparation as completed. 0098 */ 0099 void setCapturePreparationComplete() { isCapturePreparationComplete = true; } 0100 0101 signals: 0102 // signals to be forwarded to the state machine 0103 // trigger capture preparation steps 0104 void prepareCapture(CCDFrameType frameType, bool enforceCCDTemp, bool enforceStartGuiderDrift, bool isPreview); 0105 // update the current CCD temperature 0106 void newCCDTemperature(double value); 0107 // update the current camera rotator position 0108 void newRotatorAngle(double value, IPState state); 0109 // update to the current guiding deviation 0110 void newGuiderDrift(double deviation_rms); 0111 };