File indexing completed on 2024-04-28 03:43:08
0001 /* 0002 SPDX-FileCopyrightText: 2022 Jasem Mutlaq <mutlaqja@ikarustech.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QJsonArray> 0010 #include <QObject> 0011 #include <QVariantMap> 0012 0013 namespace Ekos 0014 { 0015 0016 /** 0017 * @brief The OpticalTrainSettings class 0018 * 0019 * General-purpose class to encapsulate OpticalTrain-specific settings in the database. 0020 * 0021 * The settings are stored as QVariant Map. Each element in the array should have the following format. 0022 * { 0023 * "id1": payload1, 0024 * "id2", payload2, 0025 * ... 0026 * } 0027 * 0028 * 1. The ID is a unique number from the Settings enum. 0029 * 2. The Payload is QVariant. 0030 * 0031 * @author Jasem Mutlaq 0032 * @version 1.0 0033 */ 0034 class OpticalTrainSettings : public QObject 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 0040 static OpticalTrainSettings *Instance(); 0041 static void release(); 0042 0043 // Settings 0044 typedef enum 0045 { 0046 Capture, 0047 Focus, 0048 Mount, 0049 Align, 0050 Guide, 0051 Observatory, 0052 Scheduler, 0053 Analyze, 0054 DarkLibrary 0055 } Settings; 0056 0057 /** 0058 * @brief setOpticalTrainID This must be called before calling any settings functions below. 0059 * @param id ID of optical train 0060 */ 0061 void setOpticalTrainID(uint32_t id); 0062 0063 void setOneSetting(Settings id, const QVariant &value); 0064 QVariant getOneSetting(Settings id); 0065 void initSettings(); 0066 void setSettings(const QVariantMap &settings); 0067 const QVariantMap &getSettings() const 0068 { 0069 return m_Settings; 0070 } 0071 0072 signals: 0073 void updated(); 0074 0075 private: 0076 0077 OpticalTrainSettings(QObject *parent = nullptr); 0078 static OpticalTrainSettings *m_Instance; 0079 0080 uint32_t m_TrainID {0}; 0081 QVariantMap m_Settings; 0082 }; 0083 0084 }