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.
SWGAMModReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGAMModReport.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  channel_power_db = 0.0f;
37 }
38 
40  this->cleanup();
41 }
42 
43 void
45  channel_power_db = 0.0f;
51 }
52 
53 void
55 
56 
57 
58 }
59 
61 SWGAMModReport::fromJson(QString &json) {
62  QByteArray array (json.toStdString().c_str());
63  QJsonDocument doc = QJsonDocument::fromJson(array);
64  QJsonObject jsonObject = doc.object();
65  this->fromJsonObject(jsonObject);
66  return this;
67 }
68 
69 void
70 SWGAMModReport::fromJsonObject(QJsonObject &pJson) {
71  ::SWGSDRangel::setValue(&channel_power_db, pJson["channelPowerDB"], "float", "");
72 
73  ::SWGSDRangel::setValue(&audio_sample_rate, pJson["audioSampleRate"], "qint32", "");
74 
75  ::SWGSDRangel::setValue(&channel_sample_rate, pJson["channelSampleRate"], "qint32", "");
76 
77 }
78 
79 QString
81 {
82  QJsonObject* obj = this->asJsonObject();
83 
84  QJsonDocument doc(*obj);
85  QByteArray bytes = doc.toJson();
86  delete obj;
87  return QString(bytes);
88 }
89 
90 QJsonObject*
92  QJsonObject* obj = new QJsonObject();
94  obj->insert("channelPowerDB", QJsonValue(channel_power_db));
95  }
97  obj->insert("audioSampleRate", QJsonValue(audio_sample_rate));
98  }
100  obj->insert("channelSampleRate", QJsonValue(channel_sample_rate));
101  }
102 
103  return obj;
104 }
105 
106 float
108  return channel_power_db;
109 }
110 void
112  this->channel_power_db = channel_power_db;
113  this->m_channel_power_db_isSet = true;
114 }
115 
116 qint32
118  return audio_sample_rate;
119 }
120 void
122  this->audio_sample_rate = audio_sample_rate;
123  this->m_audio_sample_rate_isSet = true;
124 }
125 
126 qint32
128  return channel_sample_rate;
129 }
130 void
132  this->channel_sample_rate = channel_sample_rate;
133  this->m_channel_sample_rate_isSet = true;
134 }
135 
136 
137 bool
139  bool isObjectUpdated = false;
140  do{
141  if(m_channel_power_db_isSet){ isObjectUpdated = true; break;}
142  if(m_audio_sample_rate_isSet){ isObjectUpdated = true; break;}
143  if(m_channel_sample_rate_isSet){ isObjectUpdated = true; break;}
144  }while(false);
145  return isObjectUpdated;
146 }
147 }
148 
void setAudioSampleRate(qint32 audio_sample_rate)
virtual QString asJson() override
void setChannelPowerDb(float channel_power_db)
virtual void fromJsonObject(QJsonObject &json) override
void setChannelSampleRate(qint32 channel_sample_rate)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual QJsonObject * asJsonObject() override
virtual bool isSet() override
virtual SWGAMModReport * fromJson(QString &jsonString) override