1 /*
2     SPDX-FileCopyrightText: 2016 Jasem Mutlaq <mutlaqja@ikarustech.com>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "profileinfo.h"
8 
ProfileInfo(int id,const QString & name)9 ProfileInfo::ProfileInfo(int id, const QString &name)
10 {
11     this->name = name;
12     this->id   = id;
13     port = INDIWebManagerPort = guiderport = -1;
14 }
15 
mount() const16 QString ProfileInfo::mount() const
17 {
18     if (drivers.contains("Mount"))
19         return drivers["Mount"];
20     else
21         return QString();
22 }
23 
ccd() const24 QString ProfileInfo::ccd() const
25 {
26     if (drivers.contains("CCD"))
27         return drivers["CCD"];
28     else
29         return QString();
30 }
31 
guider() const32 QString ProfileInfo::guider() const
33 {
34     if (drivers.contains("Guider"))
35         return drivers["Guider"];
36     else
37         return QString();
38 }
39 
focuser() const40 QString ProfileInfo::focuser() const
41 {
42     if (drivers.contains("Focuser"))
43         return drivers["Focuser"];
44     else
45         return QString();
46 }
47 
filter() const48 QString ProfileInfo::filter() const
49 {
50     if (drivers.contains("Filter"))
51         return drivers["Filter"];
52     else
53         return QString();
54 }
55 
dome() const56 QString ProfileInfo::dome() const
57 {
58     if (drivers.contains("Dome"))
59         return drivers["Dome"];
60     else
61         return QString();
62 }
63 
weather() const64 QString ProfileInfo::weather() const
65 {
66     if (drivers.contains("Weather"))
67         return drivers["Weather"];
68     else
69         return QString();
70 }
71 
ao() const72 QString ProfileInfo::ao() const
73 {
74     if (drivers.contains("AO"))
75         return drivers["AO"];
76     else
77         return QString();
78 }
79 
aux1() const80 QString ProfileInfo::aux1() const
81 {
82     if (drivers.contains("Aux1"))
83         return drivers["Aux1"];
84     else
85         return QString();
86 }
87 
aux2() const88 QString ProfileInfo::aux2() const
89 {
90     if (drivers.contains("Aux2"))
91         return drivers["Aux2"];
92     else
93         return QString();
94 }
95 
aux3() const96 QString ProfileInfo::aux3() const
97 {
98     if (drivers.contains("Aux3"))
99         return drivers["Aux3"];
100     else
101         return QString();
102 }
103 
aux4() const104 QString ProfileInfo::aux4() const
105 {
106     if (drivers.contains("Aux4"))
107         return drivers["Aux4"];
108     else
109         return QString();
110 }
111 
toJson() const112 QJsonObject ProfileInfo::toJson() const
113 {
114     return
115     {
116         {"name", name},
117         {"auto_connect", autoConnect},
118         {"port_selector", portSelector},
119         {"mode", host.isEmpty() ? "local" : "remote"},
120         {"remote_host", host},
121         {"remote_port", port},
122         {"indihub", indihub},
123         {"guiding", guidertype},
124         {"remote_guiding_host", guiderhost},
125         {"remote_guiding_port", guiderport},
126         {"use_web_manager", INDIWebManagerPort != -1},
127         {"primary_scope", primaryscope},
128         {"guide_scope", guidescope},
129         {"mount", mount()},
130         {"ccd", ccd()},
131         {"guider", guider()},
132         {"focuser", focuser()},
133         {"filter", filter()},
134         {"ao", ao()},
135         {"dome", dome()},
136         {"weather", weather()},
137         {"aux1", aux1()},
138         {"aux2", aux2()},
139         {"aux3", aux3()},
140         {"aux4", aux4()},
141         {"remote", remotedrivers},
142     };
143 }
144