1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-24 17:08:36 -05:00

DeviceGUI: removed destroy method. Part of #2159

This commit is contained in:
f4exb 2024-09-07 21:50:42 +02:00
parent 5d0fa7fa67
commit 37e06de0ed
10 changed files with 270 additions and 293 deletions

View File

@ -84,6 +84,7 @@ WDSPRx::WDSPRx(DeviceAPI *deviceAPI) :
WDSPRx::~WDSPRx() WDSPRx::~WDSPRx()
{ {
qDebug("WDSPRx::~WDSPRx");
QObject::disconnect( QObject::disconnect(
m_networkManager, m_networkManager,
&QNetworkAccessManager::finished, &QNetworkAccessManager::finished,
@ -94,7 +95,8 @@ WDSPRx::~WDSPRx()
m_deviceAPI->removeChannelSinkAPI(this); m_deviceAPI->removeChannelSinkAPI(this);
m_deviceAPI->removeChannelSink(this); m_deviceAPI->removeChannelSink(this);
stop(); WDSPRx::stop();
qDebug("WDSPRx::~WDSPRx: emd");
} }
void WDSPRx::setDeviceAPI(DeviceAPI *deviceAPI) void WDSPRx::setDeviceAPI(DeviceAPI *deviceAPI)
@ -196,7 +198,7 @@ bool WDSPRx::handleMessage(const Message& cmd)
{ {
if (MsgConfigureWDSPRx::match(cmd)) if (MsgConfigureWDSPRx::match(cmd))
{ {
MsgConfigureWDSPRx& cfg = (MsgConfigureWDSPRx&) cmd; auto& cfg = (const MsgConfigureWDSPRx&) cmd;
qDebug("WDSPRx::handleMessage: MsgConfigureWDSPRx"); qDebug("WDSPRx::handleMessage: MsgConfigureWDSPRx");
applySettings(cfg.getSettings(), cfg.getForce()); applySettings(cfg.getSettings(), cfg.getForce());
@ -206,7 +208,7 @@ bool WDSPRx::handleMessage(const Message& cmd)
else if (DSPSignalNotification::match(cmd)) else if (DSPSignalNotification::match(cmd))
{ {
qDebug() << "WDSPRx::handleMessage: DSPSignalNotification"; qDebug() << "WDSPRx::handleMessage: DSPSignalNotification";
DSPSignalNotification& notif = (DSPSignalNotification&) cmd; auto& notif = (const DSPSignalNotification&) cmd;
m_basebandSampleRate = notif.getSampleRate(); m_basebandSampleRate = notif.getSampleRate();
// Forward to the sink // Forward to the sink
if (m_running) { if (m_running) {
@ -235,7 +237,7 @@ bool WDSPRx::handleMessage(const Message& cmd)
void WDSPRx::setCenterFrequency(qint64 frequency) void WDSPRx::setCenterFrequency(qint64 frequency)
{ {
WDSPRxSettings settings = m_settings; WDSPRxSettings settings = m_settings;
settings.m_inputFrequencyOffset = frequency; settings.m_inputFrequencyOffset = (qint32) frequency;
applySettings(settings, false); applySettings(settings, false);
if (m_guiMessageQueue) // forward to GUI if any if (m_guiMessageQueue) // forward to GUI if any
@ -360,7 +362,7 @@ void WDSPRx::applySettings(const WDSPRxSettings& settings, bool force)
QList<ObjectPipe*> pipes; QList<ObjectPipe*> pipes;
MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes); MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes);
if (pipes.size() > 0) { if (!pipes.empty()) {
sendChannelSettings(pipes, reverseAPIKeys, settings, force); sendChannelSettings(pipes, reverseAPIKeys, settings, force);
} }
@ -389,12 +391,12 @@ bool WDSPRx::deserialize(const QByteArray& data)
} }
} }
void WDSPRx::sendSampleRateToDemodAnalyzer() void WDSPRx::sendSampleRateToDemodAnalyzer() const
{ {
QList<ObjectPipe*> pipes; QList<ObjectPipe*> pipes;
MainCore::instance()->getMessagePipes().getMessagePipes(this, "reportdemod", pipes); MainCore::instance()->getMessagePipes().getMessagePipes(this, "reportdemod", pipes);
if (pipes.size() > 0) if (!pipes.empty())
{ {
for (const auto& pipe: pipes) for (const auto& pipe: pipes)
{ {
@ -463,7 +465,7 @@ void WDSPRx::webapiUpdateChannelSettings(
SWGSDRangel::SWGChannelSettings& response) SWGSDRangel::SWGChannelSettings& response)
{ {
if (channelSettingsKeys.contains("inputFrequencyOffset")) { if (channelSettingsKeys.contains("inputFrequencyOffset")) {
settings.m_inputFrequencyOffset = response.getWdspRxSettings()->getInputFrequencyOffset(); settings.m_inputFrequencyOffset = (qint32) response.getWdspRxSettings()->getInputFrequencyOffset();
} }
if (channelSettingsKeys.contains("profileIndex")) { if (channelSettingsKeys.contains("profileIndex")) {
settings.m_profileIndex = response.getWdspRxSettings()->getProfileIndex(); settings.m_profileIndex = response.getWdspRxSettings()->getProfileIndex();
@ -669,13 +671,13 @@ void WDSPRx::webapiUpdateChannelSettings(
settings.m_reverseAPIAddress = *response.getWdspRxSettings()->getReverseApiAddress(); settings.m_reverseAPIAddress = *response.getWdspRxSettings()->getReverseApiAddress();
} }
if (channelSettingsKeys.contains("reverseAPIPort")) { if (channelSettingsKeys.contains("reverseAPIPort")) {
settings.m_reverseAPIPort = response.getWdspRxSettings()->getReverseApiPort(); settings.m_reverseAPIPort = (uint16_t) response.getWdspRxSettings()->getReverseApiPort();
} }
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) { if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getWdspRxSettings()->getReverseApiDeviceIndex(); settings.m_reverseAPIDeviceIndex = (uint16_t) response.getWdspRxSettings()->getReverseApiDeviceIndex();
} }
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) { if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
settings.m_reverseAPIChannelIndex = response.getWdspRxSettings()->getReverseApiChannelIndex(); settings.m_reverseAPIChannelIndex = (uint16_t) response.getWdspRxSettings()->getReverseApiChannelIndex();
} }
if (settings.m_spectrumGUI && channelSettingsKeys.contains("spectrumConfig")) { if (settings.m_spectrumGUI && channelSettingsKeys.contains("spectrumConfig")) {
settings.m_spectrumGUI->updateFrom(channelSettingsKeys, response.getWdspRxSettings()->getSpectrumConfig()); settings.m_spectrumGUI->updateFrom(channelSettingsKeys, response.getWdspRxSettings()->getSpectrumConfig());
@ -717,11 +719,11 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon
response.getWdspRxSettings()->setDnb(settings.m_dnb ? 1 : 0); response.getWdspRxSettings()->setDnb(settings.m_dnb ? 1 : 0);
response.getWdspRxSettings()->setNbScheme((int) settings.m_nbScheme); response.getWdspRxSettings()->setNbScheme((int) settings.m_nbScheme);
response.getWdspRxSettings()->setNb2Mode((int) settings.m_nb2Mode); response.getWdspRxSettings()->setNb2Mode((int) settings.m_nb2Mode);
response.getWdspRxSettings()->setNbSlewTime(settings.m_nbSlewTime); response.getWdspRxSettings()->setNbSlewTime((float) settings.m_nbSlewTime);
response.getWdspRxSettings()->setNbLeadTime(settings.m_nbLeadTime); response.getWdspRxSettings()->setNbLeadTime((float) settings.m_nbLeadTime);
response.getWdspRxSettings()->setNbLagTime(settings.m_nbLagTime); response.getWdspRxSettings()->setNbLagTime((float) settings.m_nbLagTime);
response.getWdspRxSettings()->setNbThreshold(settings.m_nbThreshold); response.getWdspRxSettings()->setNbThreshold(settings.m_nbThreshold);
response.getWdspRxSettings()->setNbAvgTime(settings.m_nbAvgTime); response.getWdspRxSettings()->setNbAvgTime((float) settings.m_nbAvgTime);
response.getWdspRxSettings()->setDnr(settings.m_dnr ? 1 : 0); response.getWdspRxSettings()->setDnr(settings.m_dnr ? 1 : 0);
response.getWdspRxSettings()->setAnf(settings.m_anf ? 1 : 0); response.getWdspRxSettings()->setAnf(settings.m_anf ? 1 : 0);
response.getWdspRxSettings()->setNrScheme((int) settings.m_nrScheme); response.getWdspRxSettings()->setNrScheme((int) settings.m_nrScheme);
@ -731,22 +733,22 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon
response.getWdspRxSettings()->setNr2ArtifactReduction(settings.m_nr2ArtifactReduction ? 1 : 0); response.getWdspRxSettings()->setNr2ArtifactReduction(settings.m_nr2ArtifactReduction ? 1 : 0);
response.getWdspRxSettings()->setAmFadeLevel(settings.m_amFadeLevel ? 1 : 0); response.getWdspRxSettings()->setAmFadeLevel(settings.m_amFadeLevel ? 1 : 0);
response.getWdspRxSettings()->setCwPeaking(settings.m_cwPeaking ? 1 : 0); response.getWdspRxSettings()->setCwPeaking(settings.m_cwPeaking ? 1 : 0);
response.getWdspRxSettings()->setCwPeakFrequency(settings.m_cwPeakFrequency); response.getWdspRxSettings()->setCwPeakFrequency((float) settings.m_cwPeakFrequency);
response.getWdspRxSettings()->setCwBandwidth(settings.m_cwBandwidth); response.getWdspRxSettings()->setCwBandwidth((float) settings.m_cwBandwidth);
response.getWdspRxSettings()->setCwGain(settings.m_cwGain); response.getWdspRxSettings()->setCwGain((float) settings.m_cwGain);
response.getWdspRxSettings()->setFmDeviation(settings.m_fmDeviation); response.getWdspRxSettings()->setFmDeviation((float) settings.m_fmDeviation);
response.getWdspRxSettings()->setFmAfLow(settings.m_fmAFLow); response.getWdspRxSettings()->setFmAfLow((float) settings.m_fmAFLow);
response.getWdspRxSettings()->setFmAfHigh(settings.m_fmAFHigh); response.getWdspRxSettings()->setFmAfHigh((float) settings.m_fmAFHigh);
response.getWdspRxSettings()->setFmAfLimiter(settings.m_fmAFLimiter ? 1 : 0); response.getWdspRxSettings()->setFmAfLimiter(settings.m_fmAFLimiter ? 1 : 0);
response.getWdspRxSettings()->setFmAfLimiterGain(settings.m_fmAFLimiterGain); response.getWdspRxSettings()->setFmAfLimiterGain((float) settings.m_fmAFLimiterGain);
response.getWdspRxSettings()->setFmCtcssNotch(settings.m_fmCTCSSNotch ? 1 : 0); response.getWdspRxSettings()->setFmCtcssNotch(settings.m_fmCTCSSNotch ? 1 : 0);
response.getWdspRxSettings()->setFmCtcssNotchFrequency(settings.m_fmCTCSSNotchFrequency); response.getWdspRxSettings()->setFmCtcssNotchFrequency((float) settings.m_fmCTCSSNotchFrequency);
response.getWdspRxSettings()->setSquelch(settings.m_squelch ? 1 : 0); response.getWdspRxSettings()->setSquelch(settings.m_squelch ? 1 : 0);
response.getWdspRxSettings()->setSquelchThreshold(settings.m_squelchThreshold); response.getWdspRxSettings()->setSquelchThreshold(settings.m_squelchThreshold);
response.getWdspRxSettings()->setSquelchMode((int) settings.m_squelchMode); response.getWdspRxSettings()->setSquelchMode((int) settings.m_squelchMode);
response.getWdspRxSettings()->setSsqlTauMute(settings.m_ssqlTauMute); response.getWdspRxSettings()->setSsqlTauMute((float) settings.m_ssqlTauMute);
response.getWdspRxSettings()->setSsqlTauUnmute(settings.m_ssqlTauUnmute); response.getWdspRxSettings()->setSsqlTauUnmute((float) settings.m_ssqlTauUnmute);
response.getWdspRxSettings()->setAmsqMaxTail(settings.m_amsqMaxTail); response.getWdspRxSettings()->setAmsqMaxTail((float) settings.m_amsqMaxTail);
response.getWdspRxSettings()->setEqualizer(settings.m_equalizer ? 1 : 0); response.getWdspRxSettings()->setEqualizer(settings.m_equalizer ? 1 : 0);
if (!response.getWdspRxSettings()->getEqF()) { if (!response.getWdspRxSettings()->getEqF()) {
@ -770,11 +772,11 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon
} }
response.getWdspRxSettings()->setRit(settings.m_rit ? 1 : 0); response.getWdspRxSettings()->setRit(settings.m_rit ? 1 : 0);
response.getWdspRxSettings()->setRitFrequency(settings.m_ritFrequency); response.getWdspRxSettings()->setRitFrequency((float) settings.m_ritFrequency);
response.getWdspRxSettings()->setSpanLog2(settings.m_profiles[settings.m_profileIndex].m_spanLog2); response.getWdspRxSettings()->setSpanLog2(settings.m_profiles[settings.m_profileIndex].m_spanLog2);
response.getWdspRxSettings()->setRfBandwidth(settings.m_profiles[settings.m_profileIndex].m_highCutoff); response.getWdspRxSettings()->setRfBandwidth(settings.m_profiles[settings.m_profileIndex].m_highCutoff);
response.getWdspRxSettings()->setLowCutoff(settings.m_profiles[settings.m_profileIndex].m_lowCutoff); response.getWdspRxSettings()->setLowCutoff(settings.m_profiles[settings.m_profileIndex].m_lowCutoff);
response.getWdspRxSettings()->setFftWindow((int) settings.m_profiles[settings.m_profileIndex].m_fftWindow); response.getWdspRxSettings()->setFftWindow(settings.m_profiles[settings.m_profileIndex].m_fftWindow);
response.getWdspRxSettings()->setRgbColor(settings.m_rgbColor); response.getWdspRxSettings()->setRgbColor(settings.m_rgbColor);
if (response.getWdspRxSettings()->getTitle()) { if (response.getWdspRxSettings()->getTitle()) {
@ -810,7 +812,7 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon
} }
else else
{ {
SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum(); auto *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum();
settings.m_spectrumGUI->formatTo(swgGLSpectrum); settings.m_spectrumGUI->formatTo(swgGLSpectrum);
response.getWdspRxSettings()->setSpectrumConfig(swgGLSpectrum); response.getWdspRxSettings()->setSpectrumConfig(swgGLSpectrum);
} }
@ -824,7 +826,7 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon
} }
else else
{ {
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker(); auto *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
settings.m_channelMarker->formatTo(swgChannelMarker); settings.m_channelMarker->formatTo(swgChannelMarker);
response.getWdspRxSettings()->setChannelMarker(swgChannelMarker); response.getWdspRxSettings()->setChannelMarker(swgChannelMarker);
} }
@ -838,7 +840,7 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon
} }
else else
{ {
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState(); auto *swgRollupState = new SWGSDRangel::SWGRollupState();
settings.m_rollupState->formatTo(swgRollupState); settings.m_rollupState->formatTo(swgRollupState);
response.getWdspRxSettings()->setRollupState(swgRollupState); response.getWdspRxSettings()->setRollupState(swgRollupState);
} }
@ -847,11 +849,12 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon
void WDSPRx::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) void WDSPRx::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
{ {
double magsqAvg, magsqPeak; double magsqAvg;
double magsqPeak;
int nbMagsqSamples; int nbMagsqSamples;
getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples); getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
response.getSsbDemodReport()->setChannelPowerDb(CalcDb::dbPower(magsqAvg)); response.getSsbDemodReport()->setChannelPowerDb((float) CalcDb::dbPower(magsqAvg));
if (m_running) if (m_running)
{ {
@ -861,9 +864,9 @@ void WDSPRx::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
} }
} }
void WDSPRx::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const WDSPRxSettings& settings, bool force) void WDSPRx::webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const WDSPRxSettings& settings, bool force)
{ {
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings(); auto *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force); webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
@ -874,8 +877,8 @@ void WDSPRx::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, cons
m_networkRequest.setUrl(QUrl(channelSettingsURL)); m_networkRequest.setUrl(QUrl(channelSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer = new QBuffer(); auto *buffer = new QBuffer();
buffer->open((QBuffer::ReadWrite)); buffer->open(QBuffer::ReadWrite);
buffer->write(swgChannelSettings->asJson().toUtf8()); buffer->write(swgChannelSettings->asJson().toUtf8());
buffer->seek(0); buffer->seek(0);
@ -888,9 +891,9 @@ void WDSPRx::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, cons
void WDSPRx::sendChannelSettings( void WDSPRx::sendChannelSettings(
const QList<ObjectPipe*>& pipes, const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys, const QList<QString>& channelSettingsKeys,
const WDSPRxSettings& settings, const WDSPRxSettings& settings,
bool force) bool force) const
{ {
qDebug("WDSPRx::sendChannelSettings: %d pipes", pipes.size()); qDebug("WDSPRx::sendChannelSettings: %d pipes", pipes.size());
@ -900,7 +903,7 @@ void WDSPRx::sendChannelSettings(
if (messageQueue) if (messageQueue)
{ {
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings(); auto *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force); webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create( MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create(
this, this,
@ -914,11 +917,11 @@ void WDSPRx::sendChannelSettings(
} }
void WDSPRx::webapiFormatChannelSettings( void WDSPRx::webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys, const QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings, SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const WDSPRxSettings& settings, const WDSPRxSettings& settings,
bool force bool force
) ) const
{ {
swgChannelSettings->setDirection(0); // Single sink (Rx) swgChannelSettings->setDirection(0); // Single sink (Rx)
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet()); swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
@ -978,19 +981,19 @@ void WDSPRx::webapiFormatChannelSettings(
swgWDSPRxSettings->setNb2Mode((int) settings.m_nb2Mode); swgWDSPRxSettings->setNb2Mode((int) settings.m_nb2Mode);
} }
if (channelSettingsKeys.contains("nbSlewTime")) { if (channelSettingsKeys.contains("nbSlewTime")) {
swgWDSPRxSettings->setNbSlewTime(settings.m_nbSlewTime); swgWDSPRxSettings->setNbSlewTime((float) settings.m_nbSlewTime);
} }
if (channelSettingsKeys.contains("nbLeadTime")) { if (channelSettingsKeys.contains("nbLeadTime")) {
swgWDSPRxSettings->setNbLeadTime(settings.m_nbSlewTime); swgWDSPRxSettings->setNbLeadTime((float) settings.m_nbSlewTime);
} }
if (channelSettingsKeys.contains("nbLagTime")) { if (channelSettingsKeys.contains("nbLagTime")) {
swgWDSPRxSettings->setNbLagTime(settings.m_nbLagTime); swgWDSPRxSettings->setNbLagTime((float) settings.m_nbLagTime);
} }
if (channelSettingsKeys.contains("nbThreshold")) { if (channelSettingsKeys.contains("nbThreshold")) {
swgWDSPRxSettings->setNbThreshold(settings.m_nbThreshold); swgWDSPRxSettings->setNbThreshold(settings.m_nbThreshold);
} }
if (channelSettingsKeys.contains("nbAvgTime")) { if (channelSettingsKeys.contains("nbAvgTime")) {
swgWDSPRxSettings->setNbAvgTime(settings.m_nbAvgTime); swgWDSPRxSettings->setNbAvgTime((float) settings.m_nbAvgTime);
} }
if (channelSettingsKeys.contains("dnr")) { if (channelSettingsKeys.contains("dnr")) {
swgWDSPRxSettings->setDnr(settings.m_dnr ? 1 : 0); swgWDSPRxSettings->setDnr(settings.m_dnr ? 1 : 0);
@ -1020,34 +1023,34 @@ void WDSPRx::webapiFormatChannelSettings(
swgWDSPRxSettings->setCwPeaking(settings.m_cwPeaking ? 1 : 0); swgWDSPRxSettings->setCwPeaking(settings.m_cwPeaking ? 1 : 0);
} }
if (channelSettingsKeys.contains("cwPeakFrequency")) { if (channelSettingsKeys.contains("cwPeakFrequency")) {
swgWDSPRxSettings->setCwPeakFrequency(settings.m_cwPeakFrequency); swgWDSPRxSettings->setCwPeakFrequency((float) settings.m_cwPeakFrequency);
} }
if (channelSettingsKeys.contains("cwBandwidth")) { if (channelSettingsKeys.contains("cwBandwidth")) {
swgWDSPRxSettings->setCwBandwidth(settings.m_cwBandwidth); swgWDSPRxSettings->setCwBandwidth((float) settings.m_cwBandwidth);
} }
if (channelSettingsKeys.contains("cwGain")) { if (channelSettingsKeys.contains("cwGain")) {
swgWDSPRxSettings->setCwGain(settings.m_cwGain); swgWDSPRxSettings->setCwGain((float) settings.m_cwGain);
} }
if (channelSettingsKeys.contains("fmDeviation")) { if (channelSettingsKeys.contains("fmDeviation")) {
swgWDSPRxSettings->setFmDeviation(settings.m_fmDeviation); swgWDSPRxSettings->setFmDeviation((float) settings.m_fmDeviation);
} }
if (channelSettingsKeys.contains("fmAFLow")) { if (channelSettingsKeys.contains("fmAFLow")) {
swgWDSPRxSettings->setFmAfLow(settings.m_fmAFLow); swgWDSPRxSettings->setFmAfLow((float) settings.m_fmAFLow);
} }
if (channelSettingsKeys.contains("fmAFHigh")) { if (channelSettingsKeys.contains("fmAFHigh")) {
swgWDSPRxSettings->setFmAfHigh(settings.m_fmAFHigh); swgWDSPRxSettings->setFmAfHigh((float) settings.m_fmAFHigh);
} }
if (channelSettingsKeys.contains("fmAFLimiter")) { if (channelSettingsKeys.contains("fmAFLimiter")) {
swgWDSPRxSettings->setFmAfLimiter(settings.m_fmAFLimiter ? 1 : 0); swgWDSPRxSettings->setFmAfLimiter(settings.m_fmAFLimiter ? 1 : 0);
} }
if (channelSettingsKeys.contains("fmAFLimiterGain")) { if (channelSettingsKeys.contains("fmAFLimiterGain")) {
swgWDSPRxSettings->setFmAfLimiterGain(settings.m_fmAFLimiterGain); swgWDSPRxSettings->setFmAfLimiterGain((float) settings.m_fmAFLimiterGain);
} }
if (channelSettingsKeys.contains("fmCTCSSNotch")) { if (channelSettingsKeys.contains("fmCTCSSNotch")) {
swgWDSPRxSettings->setFmCtcssNotch(settings.m_fmCTCSSNotch ? 1 : 0); swgWDSPRxSettings->setFmCtcssNotch(settings.m_fmCTCSSNotch ? 1 : 0);
} }
if (channelSettingsKeys.contains("fmCTCSSNotchFrequency")) { if (channelSettingsKeys.contains("fmCTCSSNotchFrequency")) {
swgWDSPRxSettings->setFmCtcssNotchFrequency(settings.m_fmCTCSSNotchFrequency); swgWDSPRxSettings->setFmCtcssNotchFrequency((float) settings.m_fmCTCSSNotchFrequency);
} }
if (channelSettingsKeys.contains("squelch")) { if (channelSettingsKeys.contains("squelch")) {
swgWDSPRxSettings->setSquelch(settings.m_squelch ? 1 : 0); swgWDSPRxSettings->setSquelch(settings.m_squelch ? 1 : 0);
@ -1059,13 +1062,13 @@ void WDSPRx::webapiFormatChannelSettings(
swgWDSPRxSettings->setSquelchMode((int) settings.m_squelchMode); swgWDSPRxSettings->setSquelchMode((int) settings.m_squelchMode);
} }
if (channelSettingsKeys.contains("ssqlTauMute")) { if (channelSettingsKeys.contains("ssqlTauMute")) {
swgWDSPRxSettings->setSsqlTauMute(settings.m_ssqlTauMute); swgWDSPRxSettings->setSsqlTauMute((float) settings.m_ssqlTauMute);
} }
if (channelSettingsKeys.contains("ssqlTauUnmute")) { if (channelSettingsKeys.contains("ssqlTauUnmute")) {
swgWDSPRxSettings->setSsqlTauUnmute(settings.m_ssqlTauUnmute); swgWDSPRxSettings->setSsqlTauUnmute((float) settings.m_ssqlTauUnmute);
} }
if (channelSettingsKeys.contains("amsqMaxTail")) { if (channelSettingsKeys.contains("amsqMaxTail")) {
swgWDSPRxSettings->setAmsqMaxTail(settings.m_amsqMaxTail); swgWDSPRxSettings->setAmsqMaxTail((float) settings.m_amsqMaxTail);
} }
if (channelSettingsKeys.contains("equalizer")) { if (channelSettingsKeys.contains("equalizer")) {
swgWDSPRxSettings->setEqualizer(settings.m_equalizer ? 1 : 0); swgWDSPRxSettings->setEqualizer(settings.m_equalizer ? 1 : 0);
@ -1101,7 +1104,7 @@ void WDSPRx::webapiFormatChannelSettings(
swgWDSPRxSettings->setRit(settings.m_rit ? 1 : 0); swgWDSPRxSettings->setRit(settings.m_rit ? 1 : 0);
} }
if (channelSettingsKeys.contains("ritFrequency")) { if (channelSettingsKeys.contains("ritFrequency")) {
swgWDSPRxSettings->setRit(settings.m_ritFrequency); swgWDSPRxSettings->setRit((qint32) settings.m_ritFrequency);
} }
if (channelSettingsKeys.contains("spanLog2") || force) { if (channelSettingsKeys.contains("spanLog2") || force) {
swgWDSPRxSettings->setSpanLog2(settings.m_profiles[settings.m_profileIndex].m_spanLog2); swgWDSPRxSettings->setSpanLog2(settings.m_profiles[settings.m_profileIndex].m_spanLog2);
@ -1113,7 +1116,7 @@ void WDSPRx::webapiFormatChannelSettings(
swgWDSPRxSettings->setLowCutoff(settings.m_profiles[settings.m_profileIndex].m_lowCutoff); swgWDSPRxSettings->setLowCutoff(settings.m_profiles[settings.m_profileIndex].m_lowCutoff);
} }
if (channelSettingsKeys.contains("fftWindow") || force) { if (channelSettingsKeys.contains("fftWindow") || force) {
swgWDSPRxSettings->setLowCutoff(settings.m_profiles[settings.m_profileIndex].m_fftWindow); swgWDSPRxSettings->setLowCutoff((float) settings.m_profiles[settings.m_profileIndex].m_fftWindow);
} }
if (channelSettingsKeys.contains("rgbColor") || force) { if (channelSettingsKeys.contains("rgbColor") || force) {
swgWDSPRxSettings->setRgbColor(settings.m_rgbColor); swgWDSPRxSettings->setRgbColor(settings.m_rgbColor);
@ -1130,27 +1133,27 @@ void WDSPRx::webapiFormatChannelSettings(
if (settings.m_spectrumGUI && (channelSettingsKeys.contains("spectrunConfig") || force)) if (settings.m_spectrumGUI && (channelSettingsKeys.contains("spectrunConfig") || force))
{ {
SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum(); auto *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum();
settings.m_spectrumGUI->formatTo(swgGLSpectrum); settings.m_spectrumGUI->formatTo(swgGLSpectrum);
swgWDSPRxSettings->setSpectrumConfig(swgGLSpectrum); swgWDSPRxSettings->setSpectrumConfig(swgGLSpectrum);
} }
if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force)) if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force))
{ {
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker(); auto *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
settings.m_channelMarker->formatTo(swgChannelMarker); settings.m_channelMarker->formatTo(swgChannelMarker);
swgWDSPRxSettings->setChannelMarker(swgChannelMarker); swgWDSPRxSettings->setChannelMarker(swgChannelMarker);
} }
if (settings.m_rollupState && (channelSettingsKeys.contains("rollupState") || force)) if (settings.m_rollupState && (channelSettingsKeys.contains("rollupState") || force))
{ {
SWGSDRangel::SWGRollupState *swgRolllupState = new SWGSDRangel::SWGRollupState(); auto *swgRolllupState = new SWGSDRangel::SWGRollupState();
settings.m_rollupState->formatTo(swgRolllupState); settings.m_rollupState->formatTo(swgRolllupState);
swgWDSPRxSettings->setRollupState(swgRolllupState); swgWDSPRxSettings->setRollupState(swgRolllupState);
} }
} }
void WDSPRx::networkManagerFinished(QNetworkReply *reply) void WDSPRx::networkManagerFinished(QNetworkReply *reply) const
{ {
QNetworkReply::NetworkError replyError = reply->error(); QNetworkReply::NetworkError replyError = reply->error();

View File

@ -67,34 +67,34 @@ public:
{ } { }
}; };
WDSPRx(DeviceAPI *deviceAPI); explicit WDSPRx(DeviceAPI *deviceAPI);
virtual ~WDSPRx(); ~WDSPRx() final;
virtual void destroy() { delete this; } void destroy() final { delete this; }
virtual void setDeviceAPI(DeviceAPI *deviceAPI); void setDeviceAPI(DeviceAPI *deviceAPI) final;
virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; } DeviceAPI *getDeviceAPI() final { return m_deviceAPI; }
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
using BasebandSampleSink::feed; using BasebandSampleSink::feed;
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po) final;
virtual void start(); void start() final;
virtual void stop(); void stop() final;
virtual void pushMessage(Message *msg) { m_inputMessageQueue.push(msg); } void pushMessage(Message *msg) final { m_inputMessageQueue.push(msg); }
virtual QString getSinkName() { return objectName(); } QString getSinkName() final { return objectName(); }
virtual void getIdentifier(QString& id) { id = objectName(); } void getIdentifier(QString& id) final { id = objectName(); }
virtual QString getIdentifier() const { return objectName(); } QString getIdentifier() const final { return objectName(); }
virtual void getTitle(QString& title) { title = m_settings.m_title; } void getTitle(QString& title) final { title = m_settings.m_title; }
virtual qint64 getCenterFrequency() const { return m_settings.m_inputFrequencyOffset; } qint64 getCenterFrequency() const final { return m_settings.m_inputFrequencyOffset; }
virtual void setCenterFrequency(qint64 frequency); void setCenterFrequency(qint64 frequency) final;
virtual QByteArray serialize() const; QByteArray serialize() const final;
virtual bool deserialize(const QByteArray& data); bool deserialize(const QByteArray& data) final;
virtual int getNbSinkStreams() const { return 1; } int getNbSinkStreams() const final { return 1; }
virtual int getNbSourceStreams() const { return 0; } int getNbSourceStreams() const final { return 0; }
virtual int getStreamIndex() const { return m_settings.m_streamIndex; } int getStreamIndex() const final { return m_settings.m_streamIndex; }
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const final
{ {
(void) streamIndex; (void) streamIndex;
(void) sinkElseSource; (void) sinkElseSource;
@ -116,23 +116,23 @@ public:
} }
} }
virtual int webapiSettingsGet( int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage); QString& errorMessage) final;
virtual int webapiWorkspaceGet( int webapiWorkspaceGet(
SWGSDRangel::SWGWorkspaceInfo& response, SWGSDRangel::SWGWorkspaceInfo& response,
QString& errorMessage); QString& errorMessage) final;
virtual int webapiSettingsPutPatch( int webapiSettingsPutPatch(
bool force, bool force,
const QStringList& channelSettingsKeys, const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage); QString& errorMessage) final;
virtual int webapiReportGet( int webapiReportGet(
SWGSDRangel::SWGChannelReport& response, SWGSDRangel::SWGChannelReport& response,
QString& errorMessage); QString& errorMessage) final;
static void webapiFormatChannelSettings( static void webapiFormatChannelSettings(
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
@ -161,26 +161,26 @@ private:
QNetworkAccessManager *m_networkManager; QNetworkAccessManager *m_networkManager;
QNetworkRequest m_networkRequest; QNetworkRequest m_networkRequest;
virtual bool handleMessage(const Message& cmd); bool handleMessage(const Message& cmd) final;
void applySettings(const WDSPRxSettings& settings, bool force = false); void applySettings(const WDSPRxSettings& settings, bool force = false);
void sendSampleRateToDemodAnalyzer(); void sendSampleRateToDemodAnalyzer() const;
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response); void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const WDSPRxSettings& settings, bool force); void webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const WDSPRxSettings& settings, bool force);
void sendChannelSettings( void sendChannelSettings(
const QList<ObjectPipe*>& pipes, const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys, const QList<QString>& channelSettingsKeys,
const WDSPRxSettings& settings, const WDSPRxSettings& settings,
bool force bool force
); ) const;
void webapiFormatChannelSettings( void webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys, const QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings, SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const WDSPRxSettings& settings, const WDSPRxSettings& settings,
bool force bool force
); ) const;
private slots: private slots:
void networkManagerFinished(QNetworkReply *reply); void networkManagerFinished(QNetworkReply *reply) const;
void handleIndexInDeviceSetChanged(int index); void handleIndexInDeviceSetChanged(int index);
}; };

View File

@ -53,11 +53,6 @@ WDSPRxGUI* WDSPRxGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas
return gui; return gui;
} }
void WDSPRxGUI::destroy()
{
delete this;
}
void WDSPRxGUI::resetToDefaults() void WDSPRxGUI::resetToDefaults()
{ {
m_settings.resetToDefaults(); m_settings.resetToDefaults();
@ -610,6 +605,7 @@ WDSPRxGUI::WDSPRxGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
WDSPRxGUI::~WDSPRxGUI() WDSPRxGUI::~WDSPRxGUI()
{ {
qDebug("WDSPRxGUI::~WDSPRxGUI");
delete ui; delete ui;
delete m_audioMuteRightClickEnabler; delete m_audioMuteRightClickEnabler;
delete m_agcRightClickEnabler; delete m_agcRightClickEnabler;
@ -620,6 +616,7 @@ WDSPRxGUI::~WDSPRxGUI()
delete m_equalizerRightClickEnabler; delete m_equalizerRightClickEnabler;
delete m_panRightClickEnabler; delete m_panRightClickEnabler;
delete m_demodRightClickEnabler; delete m_demodRightClickEnabler;
qDebug("WDSPRxGUI::~WDSPRxGUI: end");
} }
bool WDSPRxGUI::blockApplySettings(bool block) bool WDSPRxGUI::blockApplySettings(bool block)

View File

@ -56,7 +56,6 @@ class WDSPRxGUI : public ChannelGUI {
public: public:
static WDSPRxGUI* create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel); static WDSPRxGUI* create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel);
virtual void destroy();
void resetToDefaults() final; void resetToDefaults() final;
QByteArray serialize() const final; QByteArray serialize() const final;

View File

@ -43,7 +43,7 @@ RTLSDRGui::RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true), m_forceSettings(true),
m_settings(), m_settings(),
m_sampleRateMode(true), m_sampleRateMode(true),
m_sampleSource(0) m_sampleSource(nullptr)
{ {
m_deviceUISet = deviceUISet; m_deviceUISet = deviceUISet;
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
@ -92,11 +92,6 @@ RTLSDRGui::~RTLSDRGui()
qDebug("RTLSDRGui::~RTLSDRGui: end"); qDebug("RTLSDRGui::~RTLSDRGui: end");
} }
void RTLSDRGui::destroy()
{
delete this;
}
void RTLSDRGui::resetToDefaults() void RTLSDRGui::resetToDefaults()
{ {
m_settings.resetToDefaults(); m_settings.resetToDefaults();
@ -145,7 +140,7 @@ bool RTLSDRGui::handleMessage(const Message& message)
{ {
if (RTLSDRInput::MsgConfigureRTLSDR::match(message)) if (RTLSDRInput::MsgConfigureRTLSDR::match(message))
{ {
const RTLSDRInput::MsgConfigureRTLSDR& cfg = (RTLSDRInput::MsgConfigureRTLSDR&) message; auto& cfg = (const RTLSDRInput::MsgConfigureRTLSDR&) message;
if (cfg.getForce()) { if (cfg.getForce()) {
m_settings = cfg.getSettings(); m_settings = cfg.getSettings();
@ -161,7 +156,7 @@ bool RTLSDRGui::handleMessage(const Message& message)
} }
else if (RTLSDRInput::MsgStartStop::match(message)) else if (RTLSDRInput::MsgStartStop::match(message))
{ {
RTLSDRInput::MsgStartStop& notif = (RTLSDRInput::MsgStartStop&) message; auto& notif = (const RTLSDRInput::MsgStartStop&) message;
blockApplySettings(true); blockApplySettings(true);
ui->startStop->setChecked(notif.getStartStop()); ui->startStop->setChecked(notif.getStartStop());
blockApplySettings(false); blockApplySettings(false);
@ -178,13 +173,13 @@ void RTLSDRGui::handleInputMessages()
{ {
Message* message; Message* message;
while ((message = m_inputMessageQueue.pop()) != 0) while ((message = m_inputMessageQueue.pop()) != nullptr)
{ {
qDebug("RTLSDRGui::handleInputMessages: message: %s", message->getIdentifier()); qDebug("RTLSDRGui::handleInputMessages: message: %s", message->getIdentifier());
if (DSPSignalNotification::match(*message)) if (DSPSignalNotification::match(*message))
{ {
DSPSignalNotification* notif = (DSPSignalNotification*) message; auto* notif = (const DSPSignalNotification*) message;
m_sampleRate = notif->getSampleRate(); m_sampleRate = notif->getSampleRate();
m_deviceCenterFrequency = notif->getCenterFrequency(); m_deviceCenterFrequency = notif->getCenterFrequency();
qDebug("RTLSDRGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); qDebug("RTLSDRGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
@ -213,7 +208,7 @@ void RTLSDRGui::updateFrequencyLimits()
{ {
// values in kHz // values in kHz
qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0; qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0;
qint64 minLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMin : m_sampleSource->m_frequencyHighRangeMin) + deltaFrequency; qint64 minLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMin : m_sampleSource->getFrequencyHighRangeMin()) + deltaFrequency;
qint64 maxLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMax : RTLSDRInput::frequencyHighRangeMax) + deltaFrequency; qint64 maxLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMax : RTLSDRInput::frequencyHighRangeMax) + deltaFrequency;
if (m_settings.m_transverterMode) if (m_settings.m_transverterMode)
@ -233,7 +228,7 @@ void RTLSDRGui::updateFrequencyLimits()
void RTLSDRGui::displayGains() void RTLSDRGui::displayGains()
{ {
if (m_gains.size() > 0) if (!m_gains.empty())
{ {
int dist = abs(m_settings.m_gain - m_gains[0]); int dist = abs(m_settings.m_gain - m_gains[0]);
int pos = 0; int pos = 0;
@ -248,7 +243,7 @@ void RTLSDRGui::displayGains()
} }
ui->gainText->setText(tr("%1.%2").arg(m_gains[pos] / 10).arg(abs(m_gains[pos] % 10))); ui->gainText->setText(tr("%1.%2").arg(m_gains[pos] / 10).arg(abs(m_gains[pos] % 10)));
ui->gain->setMaximum(m_gains.size() - 1); ui->gain->setMaximum((int) (m_gains.size() - 1));
ui->gain->setEnabled(true); ui->gain->setEnabled(true);
ui->gain->setValue(pos); ui->gain->setValue(pos);
} }
@ -280,7 +275,7 @@ void RTLSDRGui::displaySampleRate()
ui->sampleRate->setToolTip("Device to host sample rate (S/s)"); ui->sampleRate->setToolTip("Device to host sample rate (S/s)");
ui->deviceRateText->setToolTip("Baseband sample rate (S/s)"); ui->deviceRateText->setToolTip("Baseband sample rate (S/s)");
uint32_t basebandSampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim); uint32_t basebandSampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
ui->deviceRateText->setText(tr("%1k").arg(QString::number(basebandSampleRate / 1000.0f, 'g', 5))); ui->deviceRateText->setText(tr("%1k").arg(QString::number((float) basebandSampleRate / 1000.0f, 'g', 5)));
} }
else else
{ {
@ -296,7 +291,7 @@ void RTLSDRGui::displaySampleRate()
ui->sampleRate->setValue(m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim)); ui->sampleRate->setValue(m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim));
ui->sampleRate->setToolTip("Baseband sample rate (S/s)"); ui->sampleRate->setToolTip("Baseband sample rate (S/s)");
ui->deviceRateText->setToolTip("Device to host sample rate (S/s)"); ui->deviceRateText->setToolTip("Device to host sample rate (S/s)");
ui->deviceRateText->setText(tr("%1k").arg(QString::number(m_settings.m_devSampleRate / 1000.0f, 'g', 5))); ui->deviceRateText->setText(tr("%1k").arg(QString::number((float) m_settings.m_devSampleRate / 1000.0f, 'g', 5)));
} }
ui->sampleRate->blockSignals(false); ui->sampleRate->blockSignals(false);
@ -310,7 +305,7 @@ void RTLSDRGui::displayFcTooltip()
m_settings.m_devSampleRate, m_settings.m_devSampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD
); );
ui->fcPos->setToolTip(tr("Relative position of device center frequency: %1 kHz").arg(QString::number(fShift / 1000.0f, 'g', 5))); ui->fcPos->setToolTip(tr("Relative position of device center frequency: %1 kHz").arg(QString::number((float) fShift / 1000.0f, 'g', 5)));
} }
void RTLSDRGui::displaySettings() void RTLSDRGui::displaySettings()
@ -363,9 +358,9 @@ void RTLSDRGui::on_decim_currentIndexChanged(int index)
displaySampleRate(); displaySampleRate();
if (m_sampleRateMode) { if (m_sampleRateMode) {
m_settings.m_devSampleRate = ui->sampleRate->getValueNew(); m_settings.m_devSampleRate = (int) ui->sampleRate->getValueNew();
} else { } else {
m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim); m_settings.m_devSampleRate = (int) ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim);
} }
m_settingsKeys.append("log2Decim"); m_settingsKeys.append("log2Decim");
@ -523,9 +518,9 @@ void RTLSDRGui::on_agc_stateChanged(int state)
void RTLSDRGui::on_sampleRate_changed(quint64 value) void RTLSDRGui::on_sampleRate_changed(quint64 value)
{ {
if (m_sampleRateMode) { if (m_sampleRateMode) {
m_settings.m_devSampleRate = value; m_settings.m_devSampleRate = (int) value;
} else { } else {
m_settings.m_devSampleRate = value * (1 << m_settings.m_log2Decim); m_settings.m_devSampleRate = (int) (value * (1 << m_settings.m_log2Decim));
} }
displayFcTooltip(); displayFcTooltip();
@ -542,7 +537,7 @@ void RTLSDRGui::on_offsetTuning_toggled(bool checked)
void RTLSDRGui::on_rfBW_changed(quint64 value) void RTLSDRGui::on_rfBW_changed(quint64 value)
{ {
m_settings.m_rfBandwidth = value * 1000; m_settings.m_rfBandwidth = (quint32) (value * 1000);
m_settingsKeys.append("rfBandwidth"); m_settingsKeys.append("rfBandwidth");
sendSettings(); sendSettings();
} }
@ -554,9 +549,9 @@ void RTLSDRGui::on_lowSampleRate_toggled(bool checked)
displaySampleRate(); displaySampleRate();
if (m_sampleRateMode) { if (m_sampleRateMode) {
m_settings.m_devSampleRate = ui->sampleRate->getValueNew(); m_settings.m_devSampleRate = (int) ui->sampleRate->getValueNew();
} else { } else {
m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim); m_settings.m_devSampleRate = (int) (ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim));
} }
qDebug("RTLSDRGui::on_lowSampleRate_toggled: %d S/s", m_settings.m_devSampleRate); qDebug("RTLSDRGui::on_lowSampleRate_toggled: %d S/s", m_settings.m_devSampleRate);
@ -611,7 +606,7 @@ void RTLSDRGui::displayReplayLength()
if (!replayEnabled) { if (!replayEnabled) {
ui->replayOffset->setMaximum(0); ui->replayOffset->setMaximum(0);
} else { } else {
ui->replayOffset->setMaximum(m_settings.m_replayLength * 10 - 1); ui->replayOffset->setMaximum((int) (m_settings.m_replayLength * 10 - 1));
} }
ui->replayLabel->setEnabled(replayEnabled); ui->replayLabel->setEnabled(replayEnabled);
ui->replayOffset->setEnabled(replayEnabled); ui->replayOffset->setEnabled(replayEnabled);
@ -622,10 +617,10 @@ void RTLSDRGui::displayReplayLength()
void RTLSDRGui::displayReplayOffset() void RTLSDRGui::displayReplayOffset()
{ {
bool replayEnabled = m_settings.m_replayLength > 0.0f; bool replayEnabled = m_settings.m_replayLength > 0.0f;
ui->replayOffset->setValue(m_settings.m_replayOffset * 10); ui->replayOffset->setValue((int) (m_settings.m_replayOffset * 10));
ui->replayOffsetText->setText(QString("%1s").arg(m_settings.m_replayOffset, 0, 'f', 1)); ui->replayOffsetText->setText(QString("%1s").arg(m_settings.m_replayOffset, 0, 'f', 1));
ui->replayNow->setEnabled(replayEnabled && (m_settings.m_replayOffset > 0.0f)); ui->replayNow->setEnabled(replayEnabled && (m_settings.m_replayOffset > 0.0f));
ui->replayPlus->setEnabled(replayEnabled && (std::round(m_settings.m_replayOffset * 10) < ui->replayOffset->maximum())); ui->replayPlus->setEnabled(replayEnabled && (std::round(m_settings.m_replayOffset * 10) < (float) ui->replayOffset->maximum()));
ui->replayMinus->setEnabled(replayEnabled && (m_settings.m_replayOffset > 0.0f)); ui->replayMinus->setEnabled(replayEnabled && (m_settings.m_replayOffset > 0.0f));
} }
@ -647,7 +642,7 @@ void RTLSDRGui::displayReplayStep()
void RTLSDRGui::on_replayOffset_valueChanged(int value) void RTLSDRGui::on_replayOffset_valueChanged(int value)
{ {
m_settings.m_replayOffset = value / 10.0f; m_settings.m_replayOffset = (float) value / 10.0f;
displayReplayOffset(); displayReplayOffset();
m_settingsKeys.append("replayOffset"); m_settingsKeys.append("replayOffset");
sendSettings(); sendSettings();
@ -660,12 +655,12 @@ void RTLSDRGui::on_replayNow_clicked()
void RTLSDRGui::on_replayPlus_clicked() void RTLSDRGui::on_replayPlus_clicked()
{ {
ui->replayOffset->setValue(ui->replayOffset->value() + m_settings.m_replayStep * 10); ui->replayOffset->setValue((int) ((float) ui->replayOffset->value() + m_settings.m_replayStep * 10));
} }
void RTLSDRGui::on_replayMinus_clicked() void RTLSDRGui::on_replayMinus_clicked()
{ {
ui->replayOffset->setValue(ui->replayOffset->value() - m_settings.m_replayStep * 10); ui->replayOffset->setValue((int) ((float) ui->replayOffset->value() - m_settings.m_replayStep * 10));
} }
void RTLSDRGui::on_replaySave_clicked() void RTLSDRGui::on_replaySave_clicked()
@ -675,7 +670,7 @@ void RTLSDRGui::on_replaySave_clicked()
if (fileDialog.exec()) if (fileDialog.exec())
{ {
QStringList fileNames = fileDialog.selectedFiles(); QStringList fileNames = fileDialog.selectedFiles();
if (fileNames.size() > 0) if (!fileNames.empty())
{ {
RTLSDRInput::MsgSaveReplay *message = RTLSDRInput::MsgSaveReplay::create(fileNames[0]); RTLSDRInput::MsgSaveReplay *message = RTLSDRInput::MsgSaveReplay::create(fileNames[0]);
m_sampleSource->getInputMessageQueue()->push(message); m_sampleSource->getInputMessageQueue()->push(message);
@ -692,10 +687,10 @@ void RTLSDRGui::on_replayLoop_toggled(bool checked)
void RTLSDRGui::setReplayTime(float time) void RTLSDRGui::setReplayTime(float time)
{ {
ui->replayOffset->setValue(std::ceil(time * 10.0f)); ui->replayOffset->setValue((int) std::ceil(time * 10.0f));
} }
void RTLSDRGui::makeUIConnections() void RTLSDRGui::makeUIConnections() const
{ {
QObject::connect(ui->centerFrequency, &ValueDial::changed, this, &RTLSDRGui::on_centerFrequency_changed); QObject::connect(ui->centerFrequency, &ValueDial::changed, this, &RTLSDRGui::on_centerFrequency_changed);
QObject::connect(ui->sampleRate, &ValueDial::changed, this, &RTLSDRGui::on_sampleRate_changed); QObject::connect(ui->sampleRate, &ValueDial::changed, this, &RTLSDRGui::on_sampleRate_changed);

View File

@ -42,14 +42,13 @@ class RTLSDRGui : public DeviceGUI {
Q_OBJECT Q_OBJECT
public: public:
explicit RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent = 0); explicit RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent = nullptr);
virtual ~RTLSDRGui(); ~RTLSDRGui() final;
virtual void destroy();
void resetToDefaults(); void resetToDefaults() final;
QByteArray serialize() const; QByteArray serialize() const final;
bool deserialize(const QByteArray& data); bool deserialize(const QByteArray& data) final;
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } MessageQueue *getInputMessageQueue() final { return &m_inputMessageQueue; }
void setReplayTime(float time) override; void setReplayTime(float time) override;
private: private:
@ -79,7 +78,7 @@ private:
void updateFrequencyLimits(); void updateFrequencyLimits();
void blockApplySettings(bool block); void blockApplySettings(bool block);
bool handleMessage(const Message& message); bool handleMessage(const Message& message);
void makeUIConnections(); void makeUIConnections() const;
private slots: private slots:
void handleInputMessages(); void handleInputMessages();

View File

@ -56,7 +56,7 @@ const int RTLSDRInput::sampleRateHighRangeMax = 3200000;
RTLSDRInput::RTLSDRInput(DeviceAPI *deviceAPI) : RTLSDRInput::RTLSDRInput(DeviceAPI *deviceAPI) :
m_deviceAPI(deviceAPI), m_deviceAPI(deviceAPI),
m_settings(), m_settings(),
m_dev(0), m_dev(nullptr),
m_rtlSDRThread(nullptr), m_rtlSDRThread(nullptr),
m_deviceDescription("RTLSDR"), m_deviceDescription("RTLSDR"),
m_tunerType(RTLSDR_TUNER_UNKNOWN), m_tunerType(RTLSDR_TUNER_UNKNOWN),
@ -102,7 +102,7 @@ void RTLSDRInput::destroy()
bool RTLSDRInput::openDevice() bool RTLSDRInput::openDevice()
{ {
if (m_dev != 0) if (m_dev != nullptr)
{ {
closeDevice(); closeDevice();
} }
@ -110,7 +110,6 @@ bool RTLSDRInput::openDevice()
char vendor[256]; char vendor[256];
char product[256]; char product[256];
char serial[256]; char serial[256];
int res;
int numberOfGains; int numberOfGains;
if (!m_sampleFifo.setSize(96000 * 4)) if (!m_sampleFifo.setSize(96000 * 4))
@ -142,7 +141,7 @@ bool RTLSDRInput::openDevice()
return false; return false;
} }
if ((res = rtlsdr_open(&m_dev, device)) < 0) if ((rtlsdr_open(&m_dev, device)) < 0)
{ {
qCritical("RTLSDRInput::openDevice: could not open RTLSDR #%d: %s", device, strerror(errno)); qCritical("RTLSDRInput::openDevice: could not open RTLSDR #%d: %s", device, strerror(errno));
return false; return false;
@ -153,7 +152,7 @@ bool RTLSDRInput::openDevice()
product[0] = '\0'; product[0] = '\0';
serial[0] = '\0'; serial[0] = '\0';
if ((res = rtlsdr_get_usb_strings(m_dev, vendor, product, serial)) < 0) if ((rtlsdr_get_usb_strings(m_dev, vendor, product, serial)) < 0)
{ {
qCritical("RTLSDRInput::openDevice: error accessing USB device"); qCritical("RTLSDRInput::openDevice: error accessing USB device");
stop(); stop();
@ -171,28 +170,28 @@ bool RTLSDRInput::openDevice()
m_frequencyHighRangeMin = 24000UL; m_frequencyHighRangeMin = 24000UL;
} }
if ((res = rtlsdr_set_sample_rate(m_dev, 1152000)) < 0) if ((rtlsdr_set_sample_rate(m_dev, 1152000)) < 0)
{ {
qCritical("RTLSDRInput::openDevice: could not set sample rate: 1024k S/s"); qCritical("RTLSDRInput::openDevice: could not set sample rate: 1024k S/s");
stop(); stop();
return false; return false;
} }
if ((res = rtlsdr_set_tuner_gain_mode(m_dev, 1)) < 0) if ((rtlsdr_set_tuner_gain_mode(m_dev, 1)) < 0)
{ {
qCritical("RTLSDRInput::openDevice: error setting tuner gain mode"); qCritical("RTLSDRInput::openDevice: error setting tuner gain mode");
stop(); stop();
return false; return false;
} }
if ((res = rtlsdr_set_agc_mode(m_dev, 0)) < 0) if ((rtlsdr_set_agc_mode(m_dev, 0)) < 0)
{ {
qCritical("RTLSDRInput::openDevice: error setting agc mode"); qCritical("RTLSDRInput::openDevice: error setting agc mode");
stop(); stop();
return false; return false;
} }
numberOfGains = rtlsdr_get_tuner_gains(m_dev, NULL); numberOfGains = rtlsdr_get_tuner_gains(m_dev, nullptr);
if (numberOfGains < 0) if (numberOfGains < 0)
{ {
@ -214,7 +213,7 @@ bool RTLSDRInput::openDevice()
qDebug() << "RTLSDRInput::openDevice: " << m_gains.size() << "gains"; qDebug() << "RTLSDRInput::openDevice: " << m_gains.size() << "gains";
} }
if ((res = rtlsdr_reset_buffer(m_dev)) < 0) if ((rtlsdr_reset_buffer(m_dev)) < 0)
{ {
qCritical("RTLSDRInput::openDevice: could not reset USB EP buffers: %s", strerror(errno)); qCritical("RTLSDRInput::openDevice: could not reset USB EP buffers: %s", strerror(errno));
stop(); stop();
@ -260,10 +259,10 @@ bool RTLSDRInput::start()
void RTLSDRInput::closeDevice() void RTLSDRInput::closeDevice()
{ {
if (m_dev != 0) if (m_dev != nullptr)
{ {
rtlsdr_close(m_dev); rtlsdr_close(m_dev);
m_dev = 0; m_dev = nullptr;
} }
m_deviceDescription.clear(); m_deviceDescription.clear();
@ -351,7 +350,7 @@ bool RTLSDRInput::handleMessage(const Message& message)
{ {
if (MsgConfigureRTLSDR::match(message)) if (MsgConfigureRTLSDR::match(message))
{ {
MsgConfigureRTLSDR& conf = (MsgConfigureRTLSDR&) message; auto& conf = (const MsgConfigureRTLSDR&) message;
qDebug() << "RTLSDRInput::handleMessage: MsgConfigureRTLSDR"; qDebug() << "RTLSDRInput::handleMessage: MsgConfigureRTLSDR";
bool success = applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce()); bool success = applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce());
@ -365,7 +364,7 @@ bool RTLSDRInput::handleMessage(const Message& message)
} }
else if (MsgStartStop::match(message)) else if (MsgStartStop::match(message))
{ {
MsgStartStop& cmd = (MsgStartStop&) message; auto& cmd = (const MsgStartStop&) message;
qDebug() << "RTLSDRInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop"); qDebug() << "RTLSDRInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
if (cmd.getStartStop()) if (cmd.getStartStop())
@ -387,7 +386,7 @@ bool RTLSDRInput::handleMessage(const Message& message)
} }
else if (MsgSaveReplay::match(message)) else if (MsgSaveReplay::match(message))
{ {
MsgSaveReplay& cmd = (MsgSaveReplay&) message; auto& cmd = (const MsgSaveReplay&) message;
m_replayBuffer.save(cmd.getFilename(), m_settings.m_devSampleRate, getCenterFrequency()); m_replayBuffer.save(cmd.getFilename(), m_settings.m_devSampleRate, getCenterFrequency());
return true; return true;
} }
@ -419,9 +418,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
settings.m_iqImbalance ? "true" : "false"); settings.m_iqImbalance ? "true" : "false");
} }
if (settingsKeys.contains("loPpmCorrection") || force) if ((m_dev != nullptr) && (settingsKeys.contains("loPpmCorrection") || force))
{
if (m_dev != 0)
{ {
if (rtlsdr_set_freq_correction(m_dev, settings.m_loPpmCorrection) < 0) { if (rtlsdr_set_freq_correction(m_dev, settings.m_loPpmCorrection) < 0) {
qCritical("RTLSDRInput::applySettings: could not set LO ppm correction: %d", settings.m_loPpmCorrection); qCritical("RTLSDRInput::applySettings: could not set LO ppm correction: %d", settings.m_loPpmCorrection);
@ -429,13 +426,12 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
qDebug("RTLSDRInput::applySettings: LO ppm correction set to: %d", settings.m_loPpmCorrection); qDebug("RTLSDRInput::applySettings: LO ppm correction set to: %d", settings.m_loPpmCorrection);
} }
} }
}
if (settingsKeys.contains("devSampleRate") || force) if (settingsKeys.contains("devSampleRate") || force)
{ {
forwardChange = true; forwardChange = true;
if(m_dev != 0) if(m_dev != nullptr)
{ {
if( rtlsdr_set_sample_rate(m_dev, settings.m_devSampleRate) < 0) if( rtlsdr_set_sample_rate(m_dev, settings.m_devSampleRate) < 0)
{ {
@ -475,12 +471,9 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
qDebug() << "RTLSDRInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos; qDebug() << "RTLSDRInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos;
} }
if (settingsKeys.contains("iqOrder") || force) if (m_rtlSDRThread && (settingsKeys.contains("iqOrder") || force)) {
{
if (m_rtlSDRThread) {
m_rtlSDRThread->setIQOrder(settings.m_iqOrder); m_rtlSDRThread->setIQOrder(settings.m_iqOrder);
} }
}
if (settingsKeys.contains("centerFrequency") if (settingsKeys.contains("centerFrequency")
|| settingsKeys.contains("fcPos") || settingsKeys.contains("fcPos")
@ -500,9 +493,9 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
forwardChange = true; forwardChange = true;
if (m_dev != 0) if (m_dev != nullptr)
{ {
if (rtlsdr_set_center_freq(m_dev, deviceCenterFrequency) != 0) { if (rtlsdr_set_center_freq(m_dev, (uint32_t) deviceCenterFrequency) != 0) {
qWarning("RTLSDRInput::applySettings: rtlsdr_set_center_freq(%lld) failed", deviceCenterFrequency); qWarning("RTLSDRInput::applySettings: rtlsdr_set_center_freq(%lld) failed", deviceCenterFrequency);
} else { } else {
qDebug("RTLSDRInput::applySettings: rtlsdr_set_center_freq(%lld)", deviceCenterFrequency); qDebug("RTLSDRInput::applySettings: rtlsdr_set_center_freq(%lld)", deviceCenterFrequency);
@ -526,7 +519,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
{ {
m_settings.m_rfBandwidth = settings.m_rfBandwidth; m_settings.m_rfBandwidth = settings.m_rfBandwidth;
if (m_dev != 0) if (m_dev != nullptr)
{ {
if (rtlsdr_set_tuner_bandwidth( m_dev, m_settings.m_rfBandwidth) != 0) { if (rtlsdr_set_tuner_bandwidth( m_dev, m_settings.m_rfBandwidth) != 0) {
qCritical("RTLSDRInput::applySettings: could not set RF bandwidth to %u", m_settings.m_rfBandwidth); qCritical("RTLSDRInput::applySettings: could not set RF bandwidth to %u", m_settings.m_rfBandwidth);
@ -537,9 +530,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
} }
// Reapply offset_tuning setting if bandwidth is changed, otherwise frequency response of filter looks wrong on E4000 // Reapply offset_tuning setting if bandwidth is changed, otherwise frequency response of filter looks wrong on E4000
if (settingsKeys.contains("offsetTuning") || settingsKeys.contains("rfBandwidth") || force) if ((m_dev != nullptr) && (settingsKeys.contains("offsetTuning") || settingsKeys.contains("rfBandwidth") || force))
{
if (m_dev != 0)
{ {
if (rtlsdr_set_offset_tuning(m_dev, m_settings.m_offsetTuning ? 0 : 1) != 0) { if (rtlsdr_set_offset_tuning(m_dev, m_settings.m_offsetTuning ? 0 : 1) != 0) {
qCritical("RTLSDRInput::applySettings: could not set offset tuning to %s", settings.m_offsetTuning ? "on" : "off"); qCritical("RTLSDRInput::applySettings: could not set offset tuning to %s", settings.m_offsetTuning ? "on" : "off");
@ -547,11 +538,8 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
qDebug("RTLSDRInput::applySettings: offset tuning set to %s", settings.m_offsetTuning ? "on" : "off"); qDebug("RTLSDRInput::applySettings: offset tuning set to %s", settings.m_offsetTuning ? "on" : "off");
} }
} }
}
if (settingsKeys.contains("gain") || force) if ((m_dev != nullptr) && (settingsKeys.contains("gain") || force))
{
if(m_dev != 0)
{ {
// Nooelec E4000 SDRs appear to require tuner_gain_mode to be reset to manual before // Nooelec E4000 SDRs appear to require tuner_gain_mode to be reset to manual before
// each call to set_tuner_gain, otherwise tuner AGC seems to be re-enabled // each call to set_tuner_gain, otherwise tuner AGC seems to be re-enabled
@ -565,11 +553,8 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
qDebug("RTLSDRInput::applySettings: rtlsdr_set_tuner_gain() to %d", settings.m_gain); qDebug("RTLSDRInput::applySettings: rtlsdr_set_tuner_gain() to %d", settings.m_gain);
} }
} }
}
if (settingsKeys.contains("biasTee") || force) if ((m_dev != nullptr) && (settingsKeys.contains("biasTee") || force))
{
if(m_dev != 0)
{ {
if (rtlsdr_set_bias_tee(m_dev, settings.m_biasTee ? 1 : 0) != 0) { if (rtlsdr_set_bias_tee(m_dev, settings.m_biasTee ? 1 : 0) != 0) {
qCritical("RTLSDRInput::applySettings: rtlsdr_set_bias_tee() failed"); qCritical("RTLSDRInput::applySettings: rtlsdr_set_bias_tee() failed");
@ -577,7 +562,6 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
qDebug("RTLSDRInput::applySettings: rtlsdr_set_bias_tee() to %d", settings.m_biasTee ? 1 : 0); qDebug("RTLSDRInput::applySettings: rtlsdr_set_bias_tee() to %d", settings.m_biasTee ? 1 : 0);
} }
} }
}
if (settings.m_useReverseAPI) if (settings.m_useReverseAPI)
{ {
@ -599,7 +583,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
} }
if (settingsKeys.contains("replayOffset") || settingsKeys.contains("devSampleRate") || force) { if (settingsKeys.contains("replayOffset") || settingsKeys.contains("devSampleRate") || force) {
m_replayBuffer.setReadOffset(((unsigned)(m_settings.m_replayOffset * m_settings.m_devSampleRate)) * 2); m_replayBuffer.setReadOffset(((unsigned)(m_settings.m_replayOffset * (float) m_settings.m_devSampleRate)) * 2);
} }
if (settingsKeys.contains("replayLoop") || force) { if (settingsKeys.contains("replayLoop") || force) {
@ -609,7 +593,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList<QStr
if (forwardChange) if (forwardChange)
{ {
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim); int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency); auto *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif); m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
} }
@ -729,10 +713,10 @@ void RTLSDRInput::webapiUpdateDeviceSettings(
settings.m_reverseAPIAddress = *response.getRtlSdrSettings()->getReverseApiAddress(); settings.m_reverseAPIAddress = *response.getRtlSdrSettings()->getReverseApiAddress();
} }
if (deviceSettingsKeys.contains("reverseAPIPort")) { if (deviceSettingsKeys.contains("reverseAPIPort")) {
settings.m_reverseAPIPort = response.getRtlSdrSettings()->getReverseApiPort(); settings.m_reverseAPIPort = (uint16_t) response.getRtlSdrSettings()->getReverseApiPort();
} }
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) { if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getRtlSdrSettings()->getReverseApiDeviceIndex(); settings.m_reverseAPIDeviceIndex = (uint16_t) response.getRtlSdrSettings()->getReverseApiDeviceIndex();
} }
} }
@ -807,11 +791,11 @@ int RTLSDRInput::webapiReportGet(
return 200; return 200;
} }
void RTLSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response) void RTLSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response) const
{ {
response.getRtlSdrReport()->setGains(new QList<SWGSDRangel::SWGGain*>); response.getRtlSdrReport()->setGains(new QList<SWGSDRangel::SWGGain*>);
for (std::vector<int>::const_iterator it = getGains().begin(); it != getGains().end(); ++it) for (auto it = getGains().begin(); it != getGains().end(); ++it)
{ {
response.getRtlSdrReport()->getGains()->append(new SWGSDRangel::SWGGain); response.getRtlSdrReport()->getGains()->append(new SWGSDRangel::SWGGain);
response.getRtlSdrReport()->getGains()->back()->setGainCb(*it); response.getRtlSdrReport()->getGains()->back()->setGainCb(*it);
@ -822,7 +806,7 @@ void RTLSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respons
void RTLSDRInput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const RTLSDRSettings& settings, bool force) void RTLSDRInput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const RTLSDRSettings& settings, bool force)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); auto *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setDirection(0); // single Rx swgDeviceSettings->setDirection(0); // single Rx
swgDeviceSettings->setDeviceHwType(new QString("RTLSDR")); swgDeviceSettings->setDeviceHwType(new QString("RTLSDR"));
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex()); swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
@ -890,8 +874,8 @@ void RTLSDRInput::webapiReverseSendSettings(const QList<QString>& deviceSettings
m_networkRequest.setUrl(QUrl(channelSettingsURL)); m_networkRequest.setUrl(QUrl(channelSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer = new QBuffer(); auto *buffer = new QBuffer();
buffer->open((QBuffer::ReadWrite)); buffer->open(QBuffer::ReadWrite);
buffer->write(swgDeviceSettings->asJson().toUtf8()); buffer->write(swgDeviceSettings->asJson().toUtf8());
buffer->seek(0); buffer->seek(0);
@ -904,7 +888,7 @@ void RTLSDRInput::webapiReverseSendSettings(const QList<QString>& deviceSettings
void RTLSDRInput::webapiReverseSendStartStop(bool start) void RTLSDRInput::webapiReverseSendStartStop(bool start)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); auto *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setDirection(0); // single Rx swgDeviceSettings->setDirection(0); // single Rx
swgDeviceSettings->setDeviceHwType(new QString("RTLSDR")); swgDeviceSettings->setDeviceHwType(new QString("RTLSDR"));
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex()); swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
@ -916,8 +900,8 @@ void RTLSDRInput::webapiReverseSendStartStop(bool start)
m_networkRequest.setUrl(QUrl(channelSettingsURL)); m_networkRequest.setUrl(QUrl(channelSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer = new QBuffer(); auto *buffer = new QBuffer();
buffer->open((QBuffer::ReadWrite)); buffer->open(QBuffer::ReadWrite);
buffer->write(swgDeviceSettings->asJson().toUtf8()); buffer->write(swgDeviceSettings->asJson().toUtf8());
buffer->seek(0); buffer->seek(0);
QNetworkReply *reply; QNetworkReply *reply;
@ -932,7 +916,7 @@ void RTLSDRInput::webapiReverseSendStartStop(bool start)
delete swgDeviceSettings; delete swgDeviceSettings;
} }
void RTLSDRInput::networkManagerFinished(QNetworkReply *reply) void RTLSDRInput::networkManagerFinished(QNetworkReply *reply) const
{ {
QNetworkReply::NetworkError replyError = reply->error(); QNetworkReply::NetworkError replyError = reply->error();

View File

@ -75,10 +75,10 @@ public:
return new MsgStartStop(startStop); return new MsgStartStop(startStop);
} }
protected: private:
bool m_startStop; bool m_startStop;
MsgStartStop(bool startStop) : explicit MsgStartStop(bool startStop) :
Message(), Message(),
m_startStop(startStop) m_startStop(startStop)
{ } { }
@ -94,57 +94,57 @@ public:
return new MsgSaveReplay(filename); return new MsgSaveReplay(filename);
} }
protected: private:
QString m_filename; QString m_filename;
MsgSaveReplay(const QString& filename) : explicit MsgSaveReplay(const QString& filename) :
Message(), Message(),
m_filename(filename) m_filename(filename)
{ } { }
}; };
RTLSDRInput(DeviceAPI *deviceAPI); explicit RTLSDRInput(DeviceAPI *deviceAPI);
virtual ~RTLSDRInput(); ~RTLSDRInput() final;
virtual void destroy(); void destroy() final;
virtual void init(); void init() final;
virtual bool start(); bool start() final;
virtual void stop(); void stop() final;
virtual QByteArray serialize() const; QByteArray serialize() const final;
virtual bool deserialize(const QByteArray& data); bool deserialize(const QByteArray& data) final;
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; } void setMessageQueueToGUI(MessageQueue *queue) final { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const; const QString& getDeviceDescription() const final;
virtual int getSampleRate() const; int getSampleRate() const final;
virtual void setSampleRate(int sampleRate) { (void) sampleRate; } void setSampleRate(int sampleRate) final { (void) sampleRate; }
virtual quint64 getCenterFrequency() const; quint64 getCenterFrequency() const final;
virtual void setCenterFrequency(qint64 centerFrequency); void setCenterFrequency(qint64 centerFrequency) final;
virtual bool handleMessage(const Message& message); bool handleMessage(const Message& message) final;
virtual int webapiSettingsGet( int webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response, SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage); QString& errorMessage) final;
virtual int webapiSettingsPutPatch( int webapiSettingsPutPatch(
bool force, bool force,
const QStringList& deviceSettingsKeys, const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage); QString& errorMessage) final;
virtual int webapiReportGet( int webapiReportGet(
SWGSDRangel::SWGDeviceReport& response, SWGSDRangel::SWGDeviceReport& response,
QString& errorMessage); QString& errorMessage) final;
virtual int webapiRunGet( int webapiRunGet(
SWGSDRangel::SWGDeviceState& response, SWGSDRangel::SWGDeviceState& response,
QString& errorMessage); QString& errorMessage) final;
virtual int webapiRun( int webapiRun(
bool run, bool run,
SWGSDRangel::SWGDeviceState& response, SWGSDRangel::SWGDeviceState& response,
QString& errorMessage); QString& errorMessage) final;
static void webapiFormatDeviceSettings( static void webapiFormatDeviceSettings(
SWGSDRangel::SWGDeviceSettings& response, SWGSDRangel::SWGDeviceSettings& response,
@ -159,10 +159,10 @@ public:
rtlsdr_tuner getTunerType() const { return m_tunerType; } rtlsdr_tuner getTunerType() const { return m_tunerType; }
QString getTunerName() const; QString getTunerName() const;
void set_ds_mode(int on); void set_ds_mode(int on);
quint64 getFrequencyHighRangeMin() const { return m_frequencyHighRangeMin; }
static const quint64 frequencyLowRangeMin; static const quint64 frequencyLowRangeMin;
static const quint64 frequencyLowRangeMax; static const quint64 frequencyLowRangeMax;
quint64 m_frequencyHighRangeMin;
static const quint64 frequencyHighRangeMax; static const quint64 frequencyHighRangeMax;
static const int sampleRateLowRangeMin; static const int sampleRateLowRangeMin;
static const int sampleRateLowRangeMax; static const int sampleRateLowRangeMax;
@ -181,17 +181,18 @@ private:
bool m_running; bool m_running;
QNetworkAccessManager *m_networkManager; QNetworkAccessManager *m_networkManager;
QNetworkRequest m_networkRequest; QNetworkRequest m_networkRequest;
quint64 m_frequencyHighRangeMin;
ReplayBuffer<quint8> m_replayBuffer; ReplayBuffer<quint8> m_replayBuffer;
bool openDevice(); bool openDevice();
void closeDevice(); void closeDevice();
bool applySettings(const RTLSDRSettings& settings, const QList<QString>& settingsKeys, bool force); bool applySettings(const RTLSDRSettings& settings, const QList<QString>& settingsKeys, bool force);
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response); void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response) const;
void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const RTLSDRSettings& settings, bool force); void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const RTLSDRSettings& settings, bool force);
void webapiReverseSendStartStop(bool start); void webapiReverseSendStartStop(bool start);
private slots: private slots:
void networkManagerFinished(QNetworkReply *reply); void networkManagerFinished(QNetworkReply *reply) const;
}; };
#endif // INCLUDE_RTLSDRINPUT_H #endif // INCLUDE_RTLSDRINPUT_H

View File

@ -59,9 +59,8 @@ public:
ContextMenuDeviceSettings ContextMenuDeviceSettings
}; };
DeviceGUI(QWidget *parent = nullptr); explicit DeviceGUI(QWidget *parent = nullptr);
virtual ~DeviceGUI(); ~DeviceGUI() override;
virtual void destroy() = 0;
virtual void resetToDefaults() = 0; virtual void resetToDefaults() = 0;
void setWorkspaceIndex(int index); void setWorkspaceIndex(int index);

View File

@ -972,7 +972,7 @@ void MainWindow::removeDeviceSet(int deviceSetIndex)
// deletes old UI and core object // deletes old UI and core object
deviceUISet->freeChannels(); // destroys the channel instances deviceUISet->freeChannels(); // destroys the channel instances
deviceUISet->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI deviceUISet->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI
deviceUISet->m_deviceGUI->destroy(); delete deviceUISet->m_deviceGUI;
deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->resetSamplingDeviceId();
deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
@ -993,7 +993,7 @@ void MainWindow::removeDeviceSet(int deviceSetIndex)
// deletes old UI and output object // deletes old UI and output object
deviceUISet->freeChannels(); deviceUISet->freeChannels();
deviceUISet->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI deviceUISet->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
deviceUISet->m_deviceGUI->destroy(); delete deviceUISet->m_deviceGUI;
deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->resetSamplingDeviceId();
deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
@ -1013,7 +1013,7 @@ void MainWindow::removeDeviceSet(int deviceSetIndex)
// deletes old UI and output object // deletes old UI and output object
deviceUISet->freeChannels(); deviceUISet->freeChannels();
deviceUISet->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI deviceUISet->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
deviceUISet->m_deviceGUI->destroy(); delete deviceUISet->m_deviceGUI;
deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->resetSamplingDeviceId();
@ -1068,7 +1068,7 @@ void MainWindow::removeLastDeviceSet()
// deletes old UI and input object // deletes old UI and input object
m_deviceUIs.back()->freeChannels(); // destroys the channel instances m_deviceUIs.back()->freeChannels(); // destroys the channel instances
m_deviceUIs.back()->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI m_deviceUIs.back()->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI
m_deviceUIs.back()->m_deviceGUI->destroy(); delete m_deviceUIs.back()->m_deviceGUI;
m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId(); m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId();
m_deviceUIs.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists m_deviceUIs.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
@ -1087,7 +1087,7 @@ void MainWindow::removeLastDeviceSet()
// deletes old UI and output object // deletes old UI and output object
m_deviceUIs.back()->freeChannels(); m_deviceUIs.back()->freeChannels();
m_deviceUIs.back()->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI m_deviceUIs.back()->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
m_deviceUIs.back()->m_deviceGUI->destroy(); delete m_deviceUIs.back()->m_deviceGUI;
m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId(); m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId();
m_deviceUIs.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists m_deviceUIs.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
@ -1106,7 +1106,7 @@ void MainWindow::removeLastDeviceSet()
// deletes old UI and output object // deletes old UI and output object
m_deviceUIs.back()->freeChannels(); m_deviceUIs.back()->freeChannels();
m_deviceUIs.back()->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI m_deviceUIs.back()->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
m_deviceUIs.back()->m_deviceGUI->destroy(); delete m_deviceUIs.back()->m_deviceGUI;
m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId(); m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId();
m_dspEngine->removeLastDeviceMIMOEngine(); m_dspEngine->removeLastDeviceMIMOEngine();
@ -2373,7 +2373,7 @@ void MainWindow::sampleSourceChange(int deviceSetIndex, int newDeviceIndex, Work
// deletes old UI and input object // deletes old UI and input object
deviceUISet->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI deviceUISet->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI
deviceUISet->m_deviceGUI->destroy(); delete deviceUISet->m_deviceGUI;
deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->resetSamplingDeviceId();
deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(deviceUISet->m_deviceAPI->getSampleSource()); deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(deviceUISet->m_deviceAPI->getSampleSource());
deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
@ -2405,7 +2405,7 @@ void MainWindow::sampleSinkChange(int deviceSetIndex, int newDeviceIndex, Worksp
// deletes old UI and output object // deletes old UI and output object
deviceUISet->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI deviceUISet->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
m_deviceUIs[deviceSetIndex]->m_deviceGUI->destroy(); delete m_deviceUIs[deviceSetIndex]->m_deviceGUI;
deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->resetSamplingDeviceId();
deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(deviceUISet->m_deviceAPI->getSampleSink()); deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(deviceUISet->m_deviceAPI->getSampleSink());
deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
@ -2437,7 +2437,7 @@ void MainWindow::sampleMIMOChange(int deviceSetIndex, int newDeviceIndex, Worksp
// deletes old UI and output object // deletes old UI and output object
deviceUISet->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI deviceUISet->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
deviceUISet->m_deviceGUI->destroy(); delete deviceUISet->m_deviceGUI;
deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->resetSamplingDeviceId();
deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceMIMO(deviceUISet->m_deviceAPI->getSampleMIMO()); deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceMIMO(deviceUISet->m_deviceAPI->getSampleMIMO());