SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
SWGKiwiSDRSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGKiwiSDRSettings.h"
15 
16 #include "SWGHelpers.h"
17 
18 #include <QJsonDocument>
19 #include <QJsonArray>
20 #include <QObject>
21 #include <QDebug>
22 
23 namespace SWGSDRangel {
24 
26  init();
27  this->fromJson(*json);
28 }
29 
31  gain = 0;
32  m_gain_isSet = false;
33  use_agc = 0;
34  m_use_agc_isSet = false;
35  dc_block = 0;
36  m_dc_block_isSet = false;
37  center_frequency = 0L;
39  server_address = nullptr;
40  m_server_address_isSet = false;
41  file_record_name = nullptr;
43  use_reverse_api = 0;
45  reverse_api_address = nullptr;
47  reverse_api_port = 0;
51 }
52 
54  this->cleanup();
55 }
56 
57 void
59  gain = 0;
60  m_gain_isSet = false;
61  use_agc = 0;
62  m_use_agc_isSet = false;
63  dc_block = 0;
64  m_dc_block_isSet = false;
65  center_frequency = 0L;
67  server_address = new QString("");
68  m_server_address_isSet = false;
69  file_record_name = new QString("");
71  use_reverse_api = 0;
73  reverse_api_address = new QString("");
75  reverse_api_port = 0;
79 }
80 
81 void
83 
84 
85 
86 
87  if(server_address != nullptr) {
88  delete server_address;
89  }
90  if(file_record_name != nullptr) {
91  delete file_record_name;
92  }
93 
94  if(reverse_api_address != nullptr) {
95  delete reverse_api_address;
96  }
97 
98 
99 }
100 
103  QByteArray array (json.toStdString().c_str());
104  QJsonDocument doc = QJsonDocument::fromJson(array);
105  QJsonObject jsonObject = doc.object();
106  this->fromJsonObject(jsonObject);
107  return this;
108 }
109 
110 void
112  ::SWGSDRangel::setValue(&gain, pJson["gain"], "qint32", "");
113 
114  ::SWGSDRangel::setValue(&use_agc, pJson["useAGC"], "qint32", "");
115 
116  ::SWGSDRangel::setValue(&dc_block, pJson["dcBlock"], "qint32", "");
117 
118  ::SWGSDRangel::setValue(&center_frequency, pJson["centerFrequency"], "qint64", "");
119 
120  ::SWGSDRangel::setValue(&server_address, pJson["serverAddress"], "QString", "QString");
121 
122  ::SWGSDRangel::setValue(&file_record_name, pJson["fileRecordName"], "QString", "QString");
123 
124  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
125 
126  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
127 
128  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
129 
130  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
131 
132 }
133 
134 QString
136 {
137  QJsonObject* obj = this->asJsonObject();
138 
139  QJsonDocument doc(*obj);
140  QByteArray bytes = doc.toJson();
141  delete obj;
142  return QString(bytes);
143 }
144 
145 QJsonObject*
147  QJsonObject* obj = new QJsonObject();
148  if(m_gain_isSet){
149  obj->insert("gain", QJsonValue(gain));
150  }
151  if(m_use_agc_isSet){
152  obj->insert("useAGC", QJsonValue(use_agc));
153  }
154  if(m_dc_block_isSet){
155  obj->insert("dcBlock", QJsonValue(dc_block));
156  }
158  obj->insert("centerFrequency", QJsonValue(center_frequency));
159  }
160  if(server_address != nullptr && *server_address != QString("")){
161  toJsonValue(QString("serverAddress"), server_address, obj, QString("QString"));
162  }
163  if(file_record_name != nullptr && *file_record_name != QString("")){
164  toJsonValue(QString("fileRecordName"), file_record_name, obj, QString("QString"));
165  }
167  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
168  }
169  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
170  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
171  }
173  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
174  }
176  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
177  }
178 
179  return obj;
180 }
181 
182 qint32
184  return gain;
185 }
186 void
188  this->gain = gain;
189  this->m_gain_isSet = true;
190 }
191 
192 qint32
194  return use_agc;
195 }
196 void
198  this->use_agc = use_agc;
199  this->m_use_agc_isSet = true;
200 }
201 
202 qint32
204  return dc_block;
205 }
206 void
208  this->dc_block = dc_block;
209  this->m_dc_block_isSet = true;
210 }
211 
212 qint64
214  return center_frequency;
215 }
216 void
218  this->center_frequency = center_frequency;
219  this->m_center_frequency_isSet = true;
220 }
221 
222 QString*
224  return server_address;
225 }
226 void
228  this->server_address = server_address;
229  this->m_server_address_isSet = true;
230 }
231 
232 QString*
234  return file_record_name;
235 }
236 void
238  this->file_record_name = file_record_name;
239  this->m_file_record_name_isSet = true;
240 }
241 
242 qint32
244  return use_reverse_api;
245 }
246 void
248  this->use_reverse_api = use_reverse_api;
249  this->m_use_reverse_api_isSet = true;
250 }
251 
252 QString*
254  return reverse_api_address;
255 }
256 void
258  this->reverse_api_address = reverse_api_address;
259  this->m_reverse_api_address_isSet = true;
260 }
261 
262 qint32
264  return reverse_api_port;
265 }
266 void
268  this->reverse_api_port = reverse_api_port;
269  this->m_reverse_api_port_isSet = true;
270 }
271 
272 qint32
275 }
276 void
278  this->reverse_api_device_index = reverse_api_device_index;
280 }
281 
282 
283 bool
285  bool isObjectUpdated = false;
286  do{
287  if(m_gain_isSet){ isObjectUpdated = true; break;}
288  if(m_use_agc_isSet){ isObjectUpdated = true; break;}
289  if(m_dc_block_isSet){ isObjectUpdated = true; break;}
290  if(m_center_frequency_isSet){ isObjectUpdated = true; break;}
291  if(server_address != nullptr && *server_address != QString("")){ isObjectUpdated = true; break;}
292  if(file_record_name != nullptr && *file_record_name != QString("")){ isObjectUpdated = true; break;}
293  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
294  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
295  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
296  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
297  }while(false);
298  return isObjectUpdated;
299 }
300 }
301 
void setReverseApiPort(qint32 reverse_api_port)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setCenterFrequency(qint64 center_frequency)
virtual QJsonObject * asJsonObject() override
void setServerAddress(QString *server_address)
void setFileRecordName(QString *file_record_name)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setUseReverseApi(qint32 use_reverse_api)
virtual void fromJsonObject(QJsonObject &json) override
virtual QString asJson() override
void setReverseApiAddress(QString *reverse_api_address)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual SWGKiwiSDRSettings * fromJson(QString &jsonString) override