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.
SWGPlutoSdrInputReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGPlutoSdrInputReport.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  adc_rate = 0;
32  m_adc_rate_isSet = false;
33  rssi = nullptr;
34  m_rssi_isSet = false;
35  gain_db = 0;
36  m_gain_db_isSet = false;
37  temperature = 0.0f;
38  m_temperature_isSet = false;
39 }
40 
42  this->cleanup();
43 }
44 
45 void
47  adc_rate = 0;
48  m_adc_rate_isSet = false;
49  rssi = new QString("");
50  m_rssi_isSet = false;
51  gain_db = 0;
52  m_gain_db_isSet = false;
53  temperature = 0.0f;
54  m_temperature_isSet = false;
55 }
56 
57 void
59 
60  if(rssi != nullptr) {
61  delete rssi;
62  }
63 
64 
65 }
66 
69  QByteArray array (json.toStdString().c_str());
70  QJsonDocument doc = QJsonDocument::fromJson(array);
71  QJsonObject jsonObject = doc.object();
72  this->fromJsonObject(jsonObject);
73  return this;
74 }
75 
76 void
78  ::SWGSDRangel::setValue(&adc_rate, pJson["adcRate"], "qint32", "");
79 
80  ::SWGSDRangel::setValue(&rssi, pJson["rssi"], "QString", "QString");
81 
82  ::SWGSDRangel::setValue(&gain_db, pJson["gainDB"], "qint32", "");
83 
84  ::SWGSDRangel::setValue(&temperature, pJson["temperature"], "float", "");
85 
86 }
87 
88 QString
90 {
91  QJsonObject* obj = this->asJsonObject();
92 
93  QJsonDocument doc(*obj);
94  QByteArray bytes = doc.toJson();
95  delete obj;
96  return QString(bytes);
97 }
98 
99 QJsonObject*
101  QJsonObject* obj = new QJsonObject();
102  if(m_adc_rate_isSet){
103  obj->insert("adcRate", QJsonValue(adc_rate));
104  }
105  if(rssi != nullptr && *rssi != QString("")){
106  toJsonValue(QString("rssi"), rssi, obj, QString("QString"));
107  }
108  if(m_gain_db_isSet){
109  obj->insert("gainDB", QJsonValue(gain_db));
110  }
112  obj->insert("temperature", QJsonValue(temperature));
113  }
114 
115  return obj;
116 }
117 
118 qint32
120  return adc_rate;
121 }
122 void
124  this->adc_rate = adc_rate;
125  this->m_adc_rate_isSet = true;
126 }
127 
128 QString*
130  return rssi;
131 }
132 void
134  this->rssi = rssi;
135  this->m_rssi_isSet = true;
136 }
137 
138 qint32
140  return gain_db;
141 }
142 void
144  this->gain_db = gain_db;
145  this->m_gain_db_isSet = true;
146 }
147 
148 float
150  return temperature;
151 }
152 void
154  this->temperature = temperature;
155  this->m_temperature_isSet = true;
156 }
157 
158 
159 bool
161  bool isObjectUpdated = false;
162  do{
163  if(m_adc_rate_isSet){ isObjectUpdated = true; break;}
164  if(rssi != nullptr && *rssi != QString("")){ isObjectUpdated = true; break;}
165  if(m_gain_db_isSet){ isObjectUpdated = true; break;}
166  if(m_temperature_isSet){ isObjectUpdated = true; break;}
167  }while(false);
168  return isObjectUpdated;
169 }
170 }
171 
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual void fromJsonObject(QJsonObject &json) override
virtual QJsonObject * asJsonObject() override
virtual SWGPlutoSdrInputReport * fromJson(QString &jsonString) override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25