File indexing completed on 2024-04-21 14:47:27
0001 /* 0002 Helper class of KStars UI scheduler tests 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 "test_ekos_helper.h" 0012 #include "ekos/scheduler/schedulerjob.h" 0013 0014 class TestEkosSchedulerHelper : public TestEkosHelper 0015 { 0016 public: 0017 struct StartupCondition 0018 { 0019 Ekos::StartupCondition type; 0020 int culminationOffset; 0021 QDateTime atLocalDateTime; // This is in local time, not universal time. 0022 }; 0023 struct CompletionCondition 0024 { 0025 Ekos::CompletionCondition type; 0026 int repeat; 0027 QDateTime atLocalDateTime; // This is in local time, not universal time. 0028 }; 0029 0030 struct ScheduleSteps 0031 { 0032 bool track, focus, align, guide; 0033 }; 0034 0035 struct ShutdownProcedure 0036 { 0037 bool warm_ccd, close_cap, park_mount, park_dome; 0038 }; 0039 0040 struct CaptureJob 0041 { 0042 int exposureTime; 0043 int count; 0044 QString filterName; 0045 QString fitsDirectory; 0046 }; 0047 0048 TestEkosSchedulerHelper(); 0049 0050 // This writes the the scheduler and capture files into the locations given. 0051 static bool writeSimpleSequenceFiles(const QString &eslContents, const QString &eslFile, const QString &esqContents, 0052 const QString &esqFile); 0053 0054 static QString getSchedulerFile(const SkyObject *targetObject, const StartupCondition &startupCondition, 0055 const CompletionCondition &completionCondition, ScheduleSteps steps, 0056 bool enforceTwilight, bool enforceArtificialHorizon, int minAltitude = 30, QString fitsFile = nullptr, 0057 ShutdownProcedure shutdownProcedure = {false, false, true, false}, int errorDelay = 0); 0058 0059 // This is a capture sequence file needed to start up the scheduler. Most fields are ignored by the scheduler, 0060 // and by the Mock capture module as well. 0061 static QString getDefaultEsqContent() 0062 { 0063 return getEsqContent(QVector<CaptureJob>(1, {200, 1, "Red", "."})); 0064 } 0065 0066 /** 0067 * @brief Create a capture sequence file with the given capture jobs 0068 * @param jobs 0069 * @return ESQ string to be handled by Capture 0070 */ 0071 static QString getEsqContent(QVector<CaptureJob> jobs); 0072 0073 // Simple write-string-to-file utility. 0074 static bool writeFile(const QString &filename, const QString &contents); 0075 0076 protected: 0077 0078 };