mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-07 08:24:43 -04:00
Sonar fixes
This commit is contained in:
@@ -40,7 +40,7 @@ MESSAGE_CLASS_DEFINITION(Bladerf1Input::MsgStartStop, Message)
|
||||
Bladerf1Input::Bladerf1Input(DeviceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_settings(),
|
||||
m_dev(0),
|
||||
m_dev(nullptr),
|
||||
m_bladerfThread(nullptr),
|
||||
m_deviceDescription("BladeRFInput"),
|
||||
m_running(false)
|
||||
@@ -70,11 +70,11 @@ Bladerf1Input::~Bladerf1Input()
|
||||
delete m_networkManager;
|
||||
|
||||
if (m_running) {
|
||||
stop();
|
||||
Bladerf1Input::stop();
|
||||
}
|
||||
|
||||
closeDevice();
|
||||
m_deviceAPI->setBuddySharedPtr(0);
|
||||
m_deviceAPI->setBuddySharedPtr(nullptr);
|
||||
}
|
||||
|
||||
void Bladerf1Input::destroy()
|
||||
@@ -84,7 +84,7 @@ void Bladerf1Input::destroy()
|
||||
|
||||
bool Bladerf1Input::openDevice()
|
||||
{
|
||||
if (m_dev != 0)
|
||||
if (m_dev != nullptr)
|
||||
{
|
||||
closeDevice();
|
||||
}
|
||||
@@ -97,24 +97,24 @@ bool Bladerf1Input::openDevice()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_deviceAPI->getSinkBuddies().size() > 0)
|
||||
if (!m_deviceAPI->getSinkBuddies().empty())
|
||||
{
|
||||
DeviceAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0];
|
||||
DeviceBladeRF1Params *buddySharedParams = (DeviceBladeRF1Params *) sinkBuddy->getBuddySharedPtr();
|
||||
const DeviceAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0];
|
||||
const DeviceBladeRF1Params *buddySharedParams = (DeviceBladeRF1Params *) sinkBuddy->getBuddySharedPtr();
|
||||
|
||||
if (buddySharedParams == 0)
|
||||
if (buddySharedParams == nullptr)
|
||||
{
|
||||
qCritical("BladerfInput::openDevice: could not get shared parameters from buddy");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buddySharedParams->m_dev == 0) // device is not opened by buddy
|
||||
if (buddySharedParams->m_dev == nullptr) // device is not opened by buddy
|
||||
{
|
||||
qCritical("BladerfInput::openDevice: could not get BladeRF handle from buddy");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_sharedParams = *(buddySharedParams); // copy parameters from buddy
|
||||
m_sharedParams = *buddySharedParams; // copy parameters from buddy
|
||||
m_dev = m_sharedParams.m_dev; // get BladeRF handle
|
||||
}
|
||||
else
|
||||
@@ -128,7 +128,6 @@ bool Bladerf1Input::openDevice()
|
||||
m_sharedParams.m_dev = m_dev;
|
||||
}
|
||||
|
||||
// TODO: adjust USB transfer data according to sample rate
|
||||
if ((res = bladerf_sync_config(m_dev, BLADERF_RX_X1, BLADERF_FORMAT_SC16_Q11, 64, 8192, 32, 10000)) < 0)
|
||||
{
|
||||
qCritical("BladerfInput::start: bladerf_sync_config with return code %d", res);
|
||||
@@ -182,7 +181,7 @@ void Bladerf1Input::closeDevice()
|
||||
{
|
||||
int res;
|
||||
|
||||
if (m_dev == 0) { // was never open
|
||||
if (m_dev == nullptr) { // was never open
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -191,7 +190,7 @@ void Bladerf1Input::closeDevice()
|
||||
qCritical("BladerfInput::stop: bladerf_enable_module with return code %d", res);
|
||||
}
|
||||
|
||||
if (m_deviceAPI->getSinkBuddies().size() == 0)
|
||||
if (m_deviceAPI->getSinkBuddies().empty())
|
||||
{
|
||||
qDebug("BladerfInput::closeDevice: closing device since Tx side is not open");
|
||||
|
||||
@@ -286,7 +285,7 @@ bool Bladerf1Input::handleMessage(const Message& message)
|
||||
{
|
||||
if (MsgConfigureBladerf1::match(message))
|
||||
{
|
||||
MsgConfigureBladerf1& conf = (MsgConfigureBladerf1&) message;
|
||||
auto& conf = (const MsgConfigureBladerf1&) message;
|
||||
qDebug() << "Bladerf1Input::handleMessage: MsgConfigureBladerf1";
|
||||
|
||||
if (!applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce())) {
|
||||
@@ -297,7 +296,7 @@ bool Bladerf1Input::handleMessage(const Message& message)
|
||||
}
|
||||
else if (MsgStartStop::match(message))
|
||||
{
|
||||
MsgStartStop& cmd = (MsgStartStop&) message;
|
||||
auto& cmd = (const MsgStartStop&) message;
|
||||
qDebug() << "BladerfInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
||||
|
||||
if (cmd.getStartStop())
|
||||
@@ -326,126 +325,107 @@ bool Bladerf1Input::handleMessage(const Message& message)
|
||||
bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||
{
|
||||
bool forwardChange = false;
|
||||
// QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
qDebug() << "BladerfInput::applySettings: force: " << force << settings.getDebugString(settingsKeys, force);
|
||||
|
||||
if ((settingsKeys.contains("dcBlock")) ||
|
||||
settingsKeys.contains("iqCorrection") || force)
|
||||
settingsKeys.contains("iqCorrection") || force)
|
||||
{
|
||||
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("lnaGain") || force)
|
||||
if ((m_dev != nullptr) && (settingsKeys.contains("lnaGain") || force))
|
||||
{
|
||||
if (m_dev != 0)
|
||||
{
|
||||
if(bladerf_set_lna_gain(m_dev, getLnaGain(settings.m_lnaGain)) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_set_lna_gain() failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: LNA gain set to " << getLnaGain(settings.m_lnaGain);
|
||||
}
|
||||
}
|
||||
if(bladerf_set_lna_gain(m_dev, getLnaGain(settings.m_lnaGain)) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_set_lna_gain() failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: LNA gain set to " << getLnaGain(settings.m_lnaGain);
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("vga1") || force)
|
||||
if ((m_dev != nullptr) && (settingsKeys.contains("vga1") || force))
|
||||
{
|
||||
if (m_dev != 0)
|
||||
{
|
||||
if(bladerf_set_rxvga1(m_dev, settings.m_vga1) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_set_rxvga1() failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: VGA1 gain set to " << settings.m_vga1;
|
||||
}
|
||||
}
|
||||
if(bladerf_set_rxvga1(m_dev, settings.m_vga1) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_set_rxvga1() failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: VGA1 gain set to " << settings.m_vga1;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("vga2") || force)
|
||||
if ((m_dev != nullptr) && (settingsKeys.contains("vga2") || force))
|
||||
{
|
||||
if(m_dev != 0)
|
||||
{
|
||||
if(bladerf_set_rxvga2(m_dev, settings.m_vga2) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_set_rxvga2() failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: VGA2 gain set to " << settings.m_vga2;
|
||||
}
|
||||
}
|
||||
if(bladerf_set_rxvga2(m_dev, settings.m_vga2) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_set_rxvga2() failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: VGA2 gain set to " << settings.m_vga2;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("xb200") || force)
|
||||
if ((m_dev != nullptr) && (settingsKeys.contains("xb200") || force))
|
||||
{
|
||||
if (m_dev != 0)
|
||||
{
|
||||
bool changeSettings;
|
||||
bool changeSettings;
|
||||
|
||||
if (m_deviceAPI->getSinkBuddies().size() > 0)
|
||||
{
|
||||
DeviceAPI *buddy = m_deviceAPI->getSinkBuddies()[0];
|
||||
if (!m_deviceAPI->getSinkBuddies().empty())
|
||||
{
|
||||
DeviceAPI *buddy = m_deviceAPI->getSinkBuddies()[0];
|
||||
|
||||
if (buddy->getDeviceSinkEngine()->state() == DSPDeviceSinkEngine::StRunning) { // Tx side running
|
||||
changeSettings = false;
|
||||
} else {
|
||||
changeSettings = true;
|
||||
}
|
||||
}
|
||||
else // No Tx open
|
||||
{
|
||||
if (buddy->getDeviceSinkEngine()->state() == DSPDeviceSinkEngine::State::StRunning) { // Tx side running
|
||||
changeSettings = false;
|
||||
} else {
|
||||
changeSettings = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // No Tx open
|
||||
{
|
||||
changeSettings = true;
|
||||
}
|
||||
|
||||
if (changeSettings)
|
||||
{
|
||||
if (settings.m_xb200)
|
||||
{
|
||||
if (bladerf_expansion_attach(m_dev, BLADERF_XB_200) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_expansion_attach(xb200) failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: Attach XB200";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bladerf_expansion_attach(m_dev, BLADERF_XB_NONE) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_expansion_attach(none) failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: Detach XB200";
|
||||
}
|
||||
}
|
||||
if (changeSettings)
|
||||
{
|
||||
if (settings.m_xb200)
|
||||
{
|
||||
if (bladerf_expansion_attach(m_dev, BLADERF_XB_200) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_expansion_attach(xb200) failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: Attach XB200";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bladerf_expansion_attach(m_dev, BLADERF_XB_NONE) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_expansion_attach(none) failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: Detach XB200";
|
||||
}
|
||||
}
|
||||
|
||||
m_sharedParams.m_xb200Attached = settings.m_xb200;
|
||||
}
|
||||
}
|
||||
m_sharedParams.m_xb200Attached = settings.m_xb200;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("xb200Path") || force)
|
||||
if ((m_dev != nullptr) && (settingsKeys.contains("xb200Path") || force))
|
||||
{
|
||||
if (m_dev != 0)
|
||||
{
|
||||
if(bladerf_xb200_set_path(m_dev, BLADERF_MODULE_RX, settings.m_xb200Path) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_xb200_set_path(BLADERF_MODULE_RX) failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: set xb200 path to " << settings.m_xb200Path;
|
||||
}
|
||||
}
|
||||
if(bladerf_xb200_set_path(m_dev, BLADERF_MODULE_RX, settings.m_xb200Path) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_xb200_set_path(BLADERF_MODULE_RX) failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: set xb200 path to " << settings.m_xb200Path;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("xb200Filter") || force)
|
||||
if ((m_dev != nullptr) && (settingsKeys.contains("xb200Filter") || force))
|
||||
{
|
||||
if (m_dev != 0)
|
||||
{
|
||||
if(bladerf_xb200_set_filterbank(m_dev, BLADERF_MODULE_RX, settings.m_xb200Filter) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_xb200_set_filterbank(BLADERF_MODULE_RX) failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: set xb200 filter to " << settings.m_xb200Filter;
|
||||
}
|
||||
}
|
||||
if(bladerf_xb200_set_filterbank(m_dev, BLADERF_MODULE_RX, settings.m_xb200Filter) != 0) {
|
||||
qDebug("BladerfInput::applySettings: bladerf_xb200_set_filterbank(BLADERF_MODULE_RX) failed");
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: set xb200 filter to " << settings.m_xb200Filter;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("devSampleRate") || force)
|
||||
{
|
||||
forwardChange = true;
|
||||
|
||||
if (m_dev != 0)
|
||||
if (m_dev != nullptr)
|
||||
{
|
||||
unsigned int actualSamplerate;
|
||||
|
||||
@@ -457,27 +437,21 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, const Q
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("bandwidth") || force)
|
||||
if ((m_dev != nullptr) && (settingsKeys.contains("bandwidth") || force))
|
||||
{
|
||||
if(m_dev != 0)
|
||||
{
|
||||
unsigned int actualBandwidth;
|
||||
unsigned int actualBandwidth;
|
||||
|
||||
if( bladerf_set_bandwidth(m_dev, BLADERF_MODULE_RX, settings.m_bandwidth, &actualBandwidth) < 0) {
|
||||
qCritical("BladerfInput::applySettings: could not set bandwidth: %d", settings.m_bandwidth);
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: bladerf_set_bandwidth(BLADERF_MODULE_RX) actual bandwidth is " << actualBandwidth;
|
||||
}
|
||||
}
|
||||
if( bladerf_set_bandwidth(m_dev, BLADERF_MODULE_RX, settings.m_bandwidth, &actualBandwidth) < 0) {
|
||||
qCritical("BladerfInput::applySettings: could not set bandwidth: %d", settings.m_bandwidth);
|
||||
} else {
|
||||
qDebug() << "BladerfInput::applySettings: bladerf_set_bandwidth(BLADERF_MODULE_RX) actual bandwidth is " << actualBandwidth;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("fcPos") || force)
|
||||
if (m_bladerfThread && (settingsKeys.contains("fcPos") || force))
|
||||
{
|
||||
if (m_bladerfThread)
|
||||
{
|
||||
m_bladerfThread->setFcPos((int) settings.m_fcPos);
|
||||
qDebug() << "BladerfInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos;
|
||||
}
|
||||
m_bladerfThread->setFcPos((int) settings.m_fcPos);
|
||||
qDebug() << "BladerfInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos;
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("log2Decim") || force)
|
||||
@@ -491,11 +465,9 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, const Q
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("iqOrder") || force)
|
||||
if (m_bladerfThread && (settingsKeys.contains("iqOrder") || force))
|
||||
{
|
||||
if (m_bladerfThread) {
|
||||
m_bladerfThread->setIQOrder(settings.m_iqOrder);
|
||||
}
|
||||
m_bladerfThread->setIQOrder(settings.m_iqOrder);
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("centerFrequency")
|
||||
@@ -514,7 +486,7 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, const Q
|
||||
|
||||
forwardChange = true;
|
||||
|
||||
if (m_dev != 0)
|
||||
if (m_dev != nullptr)
|
||||
{
|
||||
if (bladerf_set_frequency( m_dev, BLADERF_MODULE_RX, deviceCenterFrequency ) != 0) {
|
||||
qWarning("BladerfInput::applySettings: bladerf_set_frequency(%lld) failed", settings.m_centerFrequency);
|
||||
@@ -527,7 +499,7 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, const Q
|
||||
if (forwardChange)
|
||||
{
|
||||
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Decim);
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, settings.m_centerFrequency);
|
||||
auto *notif = new DSPSignalNotification(sampleRate, settings.m_centerFrequency);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
}
|
||||
|
||||
@@ -549,7 +521,7 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, const Q
|
||||
return true;
|
||||
}
|
||||
|
||||
bladerf_lna_gain Bladerf1Input::getLnaGain(int lnaGain)
|
||||
bladerf_lna_gain Bladerf1Input::getLnaGain(int lnaGain) const
|
||||
{
|
||||
if (lnaGain == 2) {
|
||||
return BLADERF_LNA_GAIN_MAX;
|
||||
@@ -656,7 +628,7 @@ void Bladerf1Input::webapiUpdateDeviceSettings(
|
||||
settings.m_fcPos = static_cast<BladeRF1InputSettings::fcPos_t>(response.getBladeRf1InputSettings()->getFcPos());
|
||||
}
|
||||
if (deviceSettingsKeys.contains("xb200")) {
|
||||
settings.m_xb200 = response.getBladeRf1InputSettings()->getXb200() == 0 ? 0 : 1;
|
||||
settings.m_xb200 = response.getBladeRf1InputSettings()->getXb200() == 0 ? false : true;
|
||||
}
|
||||
if (deviceSettingsKeys.contains("xb200Path")) {
|
||||
settings.m_xb200Path = static_cast<bladerf_xb200_path>(response.getBladeRf1InputSettings()->getXb200Path());
|
||||
@@ -677,10 +649,10 @@ void Bladerf1Input::webapiUpdateDeviceSettings(
|
||||
settings.m_reverseAPIAddress = *response.getBladeRf1InputSettings()->getReverseApiAddress();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIPort")) {
|
||||
settings.m_reverseAPIPort = response.getBladeRf1InputSettings()->getReverseApiPort();
|
||||
settings.m_reverseAPIPort = (uint16_t) response.getBladeRf1InputSettings()->getReverseApiPort();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
||||
settings.m_reverseAPIDeviceIndex = response.getBladeRf1InputSettings()->getReverseApiDeviceIndex();
|
||||
settings.m_reverseAPIDeviceIndex = (uint16_t) response.getBladeRf1InputSettings()->getReverseApiDeviceIndex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,7 +686,7 @@ int Bladerf1Input::webapiRun(
|
||||
|
||||
void Bladerf1Input::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const BladeRF1InputSettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
auto *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
||||
swgDeviceSettings->setDeviceHwType(new QString("BladeRF1"));
|
||||
@@ -773,8 +745,8 @@ void Bladerf1Input::webapiReverseSendSettings(const QList<QString>& deviceSettin
|
||||
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
||||
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QBuffer *buffer = new QBuffer();
|
||||
buffer->open((QBuffer::ReadWrite));
|
||||
auto *buffer = new QBuffer();
|
||||
buffer->open(QBuffer::ReadWrite);
|
||||
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
||||
buffer->seek(0);
|
||||
|
||||
@@ -787,7 +759,7 @@ void Bladerf1Input::webapiReverseSendSettings(const QList<QString>& deviceSettin
|
||||
|
||||
void Bladerf1Input::webapiReverseSendStartStop(bool start)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
auto *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
||||
swgDeviceSettings->setDeviceHwType(new QString("BladeRF1"));
|
||||
@@ -799,8 +771,8 @@ void Bladerf1Input::webapiReverseSendStartStop(bool start)
|
||||
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
||||
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QBuffer *buffer = new QBuffer();
|
||||
buffer->open((QBuffer::ReadWrite));
|
||||
auto *buffer = new QBuffer();
|
||||
buffer->open(QBuffer::ReadWrite);
|
||||
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
||||
buffer->seek(0);
|
||||
QNetworkReply *reply;
|
||||
@@ -815,7 +787,7 @@ void Bladerf1Input::webapiReverseSendStartStop(bool start)
|
||||
delete swgDeviceSettings;
|
||||
}
|
||||
|
||||
void Bladerf1Input::networkManagerFinished(QNetworkReply *reply)
|
||||
void Bladerf1Input::networkManagerFinished(QNetworkReply *reply) const
|
||||
{
|
||||
QNetworkReply::NetworkError replyError = reply->error();
|
||||
|
||||
|
||||
@@ -76,62 +76,62 @@ public:
|
||||
return new MsgStartStop(startStop);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
bool m_startStop;
|
||||
|
||||
MsgStartStop(bool startStop) :
|
||||
explicit MsgStartStop(bool startStop) :
|
||||
Message(),
|
||||
m_startStop(startStop)
|
||||
{ }
|
||||
};
|
||||
|
||||
Bladerf1Input(DeviceAPI *deviceAPI);
|
||||
virtual ~Bladerf1Input();
|
||||
virtual void destroy();
|
||||
explicit Bladerf1Input(DeviceAPI *deviceAPI);
|
||||
~Bladerf1Input() final;
|
||||
void destroy() final;
|
||||
|
||||
virtual void init();
|
||||
virtual bool start();
|
||||
virtual void stop();
|
||||
void init() final;
|
||||
bool start() final;
|
||||
void stop() final;
|
||||
|
||||
virtual QByteArray serialize() const;
|
||||
virtual bool deserialize(const QByteArray& data);
|
||||
QByteArray serialize() const final;
|
||||
bool deserialize(const QByteArray& data) final;
|
||||
|
||||
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
|
||||
virtual const QString& getDeviceDescription() const;
|
||||
virtual int getSampleRate() const;
|
||||
virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
|
||||
virtual quint64 getCenterFrequency() const;
|
||||
virtual void setCenterFrequency(qint64 centerFrequency);
|
||||
void setMessageQueueToGUI(MessageQueue *queue) final { m_guiMessageQueue = queue; }
|
||||
const QString& getDeviceDescription() const final;
|
||||
int getSampleRate() const final;
|
||||
void setSampleRate(int sampleRate) final { (void) sampleRate; }
|
||||
quint64 getCenterFrequency() const final;
|
||||
void setCenterFrequency(qint64 centerFrequency) final;
|
||||
|
||||
virtual bool handleMessage(const Message& message);
|
||||
bool handleMessage(const Message& message) final;
|
||||
|
||||
virtual int webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage);
|
||||
int webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage) final;
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage);
|
||||
int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage) final;
|
||||
|
||||
virtual int webapiRunGet(
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
int webapiRunGet(
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage) final;
|
||||
|
||||
virtual int webapiRun(
|
||||
bool run,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
int webapiRun(
|
||||
bool run,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage) final;
|
||||
|
||||
static void webapiFormatDeviceSettings(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
const BladeRF1InputSettings& settings);
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
const BladeRF1InputSettings& settings);
|
||||
|
||||
static void webapiUpdateDeviceSettings(
|
||||
BladeRF1InputSettings& settings,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response);
|
||||
BladeRF1InputSettings& settings,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response);
|
||||
|
||||
private:
|
||||
DeviceAPI *m_deviceAPI;
|
||||
@@ -148,12 +148,12 @@ private:
|
||||
bool openDevice();
|
||||
void closeDevice();
|
||||
bool applySettings(const BladeRF1InputSettings& settings, const QList<QString>& settingsKeys, bool force);
|
||||
bladerf_lna_gain getLnaGain(int lnaGain);
|
||||
bladerf_lna_gain getLnaGain(int lnaGain) const;
|
||||
void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const BladeRF1InputSettings& settings, bool force);
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
private slots:
|
||||
void networkManagerFinished(QNetworkReply *reply);
|
||||
void networkManagerFinished(QNetworkReply *reply) const;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_BLADERFINPUT_H
|
||||
|
||||
@@ -61,21 +61,8 @@ MESSAGE_CLASS_DEFINITION(SigMFFileInput::MsgReportTotalSamplesCheck, Message)
|
||||
|
||||
SigMFFileInput::SigMFFileInput(DeviceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_running(false),
|
||||
m_settings(),
|
||||
m_trackMode(false),
|
||||
m_currentTrackIndex(0),
|
||||
m_recordOpen(false),
|
||||
m_crcAvailable(false),
|
||||
m_crcOK(false),
|
||||
m_recordLengthOK(false),
|
||||
m_fileInputWorker(nullptr),
|
||||
m_deviceDescription("SigMFFileInput"),
|
||||
m_sampleRate(48000),
|
||||
m_sampleBytes(1),
|
||||
m_centerFrequency(0),
|
||||
m_recordLength(0),
|
||||
m_startingTimeStamp(0)
|
||||
m_deviceDescription("SigMFFileInput")
|
||||
{
|
||||
m_sampleFifo.setLabel(m_deviceDescription);
|
||||
m_deviceAPI->setNbSourceStreams(1);
|
||||
@@ -104,7 +91,7 @@ SigMFFileInput::~SigMFFileInput()
|
||||
);
|
||||
delete m_networkManager;
|
||||
|
||||
stop();
|
||||
SigMFFileInput::stop();
|
||||
}
|
||||
|
||||
void SigMFFileInput::destroy()
|
||||
@@ -156,8 +143,8 @@ bool SigMFFileInput::openFileStreams(const QString& fileName)
|
||||
extractCaptures(&metaRecord);
|
||||
m_metaInfo.m_totalTimeMs = m_captures.back().m_cumulativeTime + ((m_captures.back().m_length * 1000)/m_captures.back().m_sampleRate);
|
||||
|
||||
uint64_t centerFrequency = (m_captures.size() > 0) ? m_captures.at(0).m_centerFrequency : 0;
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(m_metaInfo.m_coreSampleRate, centerFrequency);
|
||||
uint64_t centerFrequency = (!m_captures.empty()) ? m_captures.at(0).m_centerFrequency : 0;
|
||||
auto *notif = new DSPSignalNotification((int) m_metaInfo.m_coreSampleRate, centerFrequency);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
|
||||
if (getMessageQueueToGUI())
|
||||
@@ -244,14 +231,13 @@ void SigMFFileInput::extractMeta(
|
||||
m_metaInfo.m_arch = QString::fromStdString(metaRecord->global.access<sdrangel::GlobalT>().arch);
|
||||
m_metaInfo.m_os = QString::fromStdString(metaRecord->global.access<sdrangel::GlobalT>().os);
|
||||
// lists
|
||||
m_metaInfo.m_nbCaptures = metaRecord->captures.size();
|
||||
m_metaInfo.m_nbAnnotations = metaRecord->annotations.size();
|
||||
m_metaInfo.m_nbCaptures = (unsigned int) metaRecord->captures.size();
|
||||
m_metaInfo.m_nbAnnotations = (unsigned int) metaRecord->annotations.size();
|
||||
// correct sample bits if sdrangel
|
||||
if (m_metaInfo.m_sdrAngelVersion.size() > 0)
|
||||
if ((m_metaInfo.m_sdrAngelVersion.size() > 0)
|
||||
&& (m_metaInfo.m_dataType.m_sampleBits == 32))
|
||||
{
|
||||
if (m_metaInfo.m_dataType.m_sampleBits == 32) {
|
||||
m_metaInfo.m_dataType.m_sampleBits = 24;
|
||||
}
|
||||
m_metaInfo.m_dataType.m_sampleBits = 24;
|
||||
}
|
||||
// negative sample rate means inversion
|
||||
m_metaInfo.m_dataType.m_swapIQ = m_metaInfo.m_coreSampleRate < 0;
|
||||
@@ -270,8 +256,7 @@ void SigMFFileInput::extractCaptures(
|
||||
std::regex datetime_reg("(\\d{4})-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(\\.\\d+)?(([+-]\\d\\d:\\d\\d)|Z)?");
|
||||
std::smatch datetime_match;
|
||||
|
||||
sigmf::SigMFVector<sigmf::Capture<core::DescrT, sdrangel::DescrT>>::iterator it =
|
||||
metaRecord->captures.begin();
|
||||
auto it = metaRecord->captures.begin();
|
||||
uint64_t lastSampleStart = 0;
|
||||
unsigned int i = 0;
|
||||
uint64_t cumulativeTime = 0;
|
||||
@@ -279,7 +264,7 @@ void SigMFFileInput::extractCaptures(
|
||||
for (; it != metaRecord->captures.end(); ++it, i++)
|
||||
{
|
||||
m_captures.push_back(SigMFFileCapture());
|
||||
m_captures.back().m_centerFrequency = it->get<core::DescrT>().frequency;
|
||||
m_captures.back().m_centerFrequency = (uint64_t) it->get<core::DescrT>().frequency;
|
||||
m_captures.back().m_sampleStart = it->get<core::DescrT>().sample_start;
|
||||
m_captureStarts.push_back(m_captures.back().m_sampleStart);
|
||||
m_captures.back().m_cumulativeTime = cumulativeTime;
|
||||
@@ -287,7 +272,7 @@ void SigMFFileInput::extractCaptures(
|
||||
double globalSampleRate = metaRecord->global.access<core::GlobalT>().sample_rate;
|
||||
|
||||
if (sdrangelSampleRate == 0) {
|
||||
m_captures.back().m_sampleRate = globalSampleRate < 0 ? -globalSampleRate : globalSampleRate;
|
||||
m_captures.back().m_sampleRate = (unsigned int) (globalSampleRate < 0 ? -globalSampleRate : globalSampleRate);
|
||||
} else {
|
||||
m_captures.back().m_sampleRate = sdrangelSampleRate;
|
||||
}
|
||||
@@ -326,7 +311,7 @@ void SigMFFileInput::extractCaptures(
|
||||
dateTime = QDateTime::currentDateTimeUtc();
|
||||
}
|
||||
|
||||
double seconds = dateTime.toSecsSinceEpoch();
|
||||
auto seconds = (double) dateTime.toSecsSinceEpoch();
|
||||
// the subsecond part can be milli (strict ISO-8601) or micro or nano (RFC-3339). This will take any width
|
||||
if (datetime_match.size() > 7)
|
||||
{
|
||||
@@ -335,13 +320,13 @@ void SigMFFileInput::extractCaptures(
|
||||
double fractionalSecs = boost::lexical_cast<double>(datetime_match[7]);
|
||||
seconds += fractionalSecs;
|
||||
}
|
||||
catch (const boost::bad_lexical_cast &e)
|
||||
catch (const boost::bad_lexical_cast&)
|
||||
{
|
||||
qDebug("SigMFFileInput::extractCaptures: invalid fractional seconds");
|
||||
}
|
||||
}
|
||||
|
||||
m_captures.back().m_tsms = seconds * 1000.0;
|
||||
m_captures.back().m_tsms = (uint64_t) (seconds * 1000.0);
|
||||
}
|
||||
|
||||
m_captures.back().m_length = it->get<core::DescrT>().length;
|
||||
@@ -390,7 +375,7 @@ void SigMFFileInput::analyzeDataType(const std::string& dataTypeString, SigMFFil
|
||||
{
|
||||
dataType.m_sampleBits = boost::lexical_cast<int>(dataType_match[3]);
|
||||
}
|
||||
catch(const boost::bad_lexical_cast &e)
|
||||
catch(const boost::bad_lexical_cast&)
|
||||
{
|
||||
qDebug("SigMFFileInput::analyzeDataType: invalid sample bits. Assume 32");
|
||||
dataType.m_sampleBits = 32;
|
||||
@@ -414,7 +399,7 @@ uint64_t SigMFFileInput::getTrackSampleStart(unsigned int trackIndex)
|
||||
int SigMFFileInput::getTrackIndex(uint64_t sampleIndex)
|
||||
{
|
||||
auto it = std::upper_bound(m_captureStarts.begin(), m_captureStarts.end(), sampleIndex);
|
||||
return (it - m_captureStarts.begin()) - 1;
|
||||
return (int) ((it - m_captureStarts.begin()) - 1);
|
||||
}
|
||||
|
||||
void SigMFFileInput::seekFileStream(uint64_t sampleIndex)
|
||||
@@ -441,7 +426,7 @@ void SigMFFileInput::seekFileMillis(int seekMillis)
|
||||
|
||||
void SigMFFileInput::init()
|
||||
{
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
|
||||
auto *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
}
|
||||
|
||||
@@ -596,13 +581,13 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
{
|
||||
if (MsgConfigureSigMFFileInput::match(message))
|
||||
{
|
||||
MsgConfigureSigMFFileInput& conf = (MsgConfigureSigMFFileInput&) message;
|
||||
auto& conf = (const MsgConfigureSigMFFileInput&) message;
|
||||
applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce());
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureTrackIndex::match(message))
|
||||
{
|
||||
MsgConfigureTrackIndex& conf = (MsgConfigureTrackIndex&) message;
|
||||
auto& conf = (const MsgConfigureTrackIndex&) message;
|
||||
m_currentTrackIndex = conf.getTrackIndex();
|
||||
qDebug("SigMFFileInput::handleMessage MsgConfigureTrackIndex: m_currentTrackIndex: %d", m_currentTrackIndex);
|
||||
seekTrackMillis(0);
|
||||
@@ -623,7 +608,7 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
);
|
||||
|
||||
if (working) {
|
||||
startWorker();
|
||||
startWorker();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,7 +616,7 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
}
|
||||
else if (MsgConfigureTrackWork::match(message))
|
||||
{
|
||||
MsgConfigureTrackWork& conf = (MsgConfigureTrackWork&) message;
|
||||
auto& conf = (const MsgConfigureTrackWork&) message;
|
||||
bool working = conf.isWorking();
|
||||
m_trackMode = true;
|
||||
|
||||
@@ -653,7 +638,7 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
}
|
||||
else if (MsgConfigureTrackSeek::match(message))
|
||||
{
|
||||
MsgConfigureTrackSeek& conf = (MsgConfigureTrackSeek&) message;
|
||||
auto& conf = (const MsgConfigureTrackSeek&) message;
|
||||
int seekMillis = conf.getMillis();
|
||||
seekTrackMillis(seekMillis);
|
||||
|
||||
@@ -669,7 +654,7 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
m_captures[m_currentTrackIndex].m_sampleStart + ((m_captures[m_currentTrackIndex].m_length*seekMillis)/1000UL));
|
||||
|
||||
if (working) {
|
||||
startWorker();
|
||||
startWorker();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,7 +662,7 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
}
|
||||
else if (MsgConfigureFileSeek::match(message))
|
||||
{
|
||||
MsgConfigureFileSeek& conf = (MsgConfigureFileSeek&) message;
|
||||
auto& conf = (const MsgConfigureFileSeek&) message;
|
||||
int seekMillis = conf.getMillis();
|
||||
seekFileStream(seekMillis);
|
||||
uint64_t sampleCount = (m_metaInfo.m_totalSamples*seekMillis)/1000UL;
|
||||
@@ -695,7 +680,7 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
m_fileInputWorker->setSamplesCount(sampleCount);
|
||||
|
||||
if (working) {
|
||||
startWorker();
|
||||
startWorker();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,7 +688,7 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
}
|
||||
else if (MsgConfigureFileWork::match(message))
|
||||
{
|
||||
MsgConfigureFileWork& conf = (MsgConfigureFileWork&) message;
|
||||
auto& conf = (const MsgConfigureFileWork&) message;
|
||||
bool working = conf.isWorking();
|
||||
m_trackMode = false;
|
||||
|
||||
@@ -724,27 +709,24 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
}
|
||||
else if (MsgConfigureFileInputStreamTiming::match(message))
|
||||
{
|
||||
if (m_fileInputWorker)
|
||||
if (m_fileInputWorker && getMessageQueueToGUI())
|
||||
{
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
quint64 totalSamplesCount = m_fileInputWorker->getSamplesCount();
|
||||
quint64 trackSamplesCount = totalSamplesCount - m_captures[m_currentTrackIndex].m_sampleStart;
|
||||
MsgReportFileInputStreamTiming *report = MsgReportFileInputStreamTiming::create(
|
||||
totalSamplesCount,
|
||||
trackSamplesCount,
|
||||
m_captures[m_currentTrackIndex].m_cumulativeTime,
|
||||
m_currentTrackIndex
|
||||
);
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
quint64 totalSamplesCount = m_fileInputWorker->getSamplesCount();
|
||||
quint64 trackSamplesCount = totalSamplesCount - m_captures[m_currentTrackIndex].m_sampleStart;
|
||||
MsgReportFileInputStreamTiming *report = MsgReportFileInputStreamTiming::create(
|
||||
totalSamplesCount,
|
||||
trackSamplesCount,
|
||||
m_captures[m_currentTrackIndex].m_cumulativeTime,
|
||||
m_currentTrackIndex
|
||||
);
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgStartStop::match(message))
|
||||
{
|
||||
MsgStartStop& cmd = (MsgStartStop&) message;
|
||||
auto& cmd = (const MsgStartStop&) message;
|
||||
qDebug() << "FileInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
||||
|
||||
if (cmd.getStartStop())
|
||||
@@ -798,7 +780,7 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
}
|
||||
else if (SigMFFileInputWorker::MsgReportTrackChange::match(message))
|
||||
{
|
||||
SigMFFileInputWorker::MsgReportTrackChange& report = (SigMFFileInputWorker::MsgReportTrackChange&) message;
|
||||
auto& report = (const SigMFFileInputWorker::MsgReportTrackChange&) message;
|
||||
m_currentTrackIndex = report.getTrackIndex();
|
||||
qDebug("SigMFFileInput::handleMessage MsgReportTrackChange: m_currentTrackIndex: %d", m_currentTrackIndex);
|
||||
int sampleRate = m_captures.at(m_currentTrackIndex).m_sampleRate;
|
||||
@@ -806,7 +788,7 @@ bool SigMFFileInput::handleMessage(const Message& message)
|
||||
|
||||
if ((m_sampleRate != sampleRate) || (m_centerFrequency != centerFrequency))
|
||||
{
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, centerFrequency);
|
||||
auto *notif = new DSPSignalNotification(sampleRate, centerFrequency);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
|
||||
m_sampleRate = sampleRate;
|
||||
@@ -831,18 +813,15 @@ bool SigMFFileInput::applySettings(const SigMFFileInputSettings& settings, const
|
||||
{
|
||||
qDebug() << "SigMFFileInput::applySettings: force: " << force << settings.getDebugString(settingsKeys, force);
|
||||
|
||||
if (settingsKeys.contains("accelerationFactor") || force)
|
||||
if (m_fileInputWorker && (settingsKeys.contains("accelerationFactor") || force))
|
||||
{
|
||||
if (m_fileInputWorker)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
if (!m_sampleFifo.setSize(m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample))) {
|
||||
qCritical("SigMFFileInput::applySettings: could not reallocate sample FIFO size to %lu",
|
||||
m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample));
|
||||
}
|
||||
|
||||
m_fileInputWorker->setAccelerationFactor(settings.m_accelerationFactor); // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
if (!m_sampleFifo.setSize(m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample))) {
|
||||
qCritical("SigMFFileInput::applySettings: could not reallocate sample FIFO size to %lu",
|
||||
m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample));
|
||||
}
|
||||
|
||||
m_fileInputWorker->setAccelerationFactor(settings.m_accelerationFactor); // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("fileName")) {
|
||||
@@ -925,10 +904,10 @@ void SigMFFileInput::webapiUpdateDeviceSettings(
|
||||
settings.m_reverseAPIAddress = *response.getSigMfFileInputSettings()->getReverseApiAddress();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIPort")) {
|
||||
settings.m_reverseAPIPort = response.getSigMfFileInputSettings()->getReverseApiPort();
|
||||
settings.m_reverseAPIPort = (uint16_t) response.getSigMfFileInputSettings()->getReverseApiPort();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
||||
settings.m_reverseAPIDeviceIndex = response.getSigMfFileInputSettings()->getReverseApiDeviceIndex();
|
||||
settings.m_reverseAPIDeviceIndex = (uint16_t) response.getSigMfFileInputSettings()->getReverseApiDeviceIndex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1080,7 +1059,11 @@ void SigMFFileInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& resp
|
||||
response.getSigMfFileInputReport()->setSampleFormat(m_metaInfo.m_dataType.m_floatingPoint ? 1 : 0);
|
||||
response.getSigMfFileInputReport()->setSampleSigned(m_metaInfo.m_dataType.m_signed ? 1 : 0);
|
||||
response.getSigMfFileInputReport()->setSampleSwapIq(m_metaInfo.m_dataType.m_swapIQ ? 1 : 0);
|
||||
response.getSigMfFileInputReport()->setCrcStatus(!m_crcAvailable ? 0 : m_crcOK ? 1 : 2);
|
||||
if (!m_crcAvailable) {
|
||||
response.getSigMfFileInputReport()->setCrcStatus(0);
|
||||
} else {
|
||||
response.getSigMfFileInputReport()->setCrcStatus(m_crcOK ? 1 : 2);
|
||||
}
|
||||
response.getSigMfFileInputReport()->setTotalBytesStatus(m_recordLengthOK);
|
||||
response.getSigMfFileInputReport()->setTrackNumber(m_currentTrackIndex);
|
||||
QList<SigMFFileCapture>::const_iterator it = m_captures.begin();
|
||||
@@ -1124,7 +1107,7 @@ void SigMFFileInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& resp
|
||||
posRatio = (float) totalSamplesCount / (float) m_metaInfo.m_totalSamples;
|
||||
response.getSigMfFileInputReport()->setRecordSamplesRatio(posRatio);
|
||||
|
||||
if (m_captures.size() > 0 )
|
||||
if (!m_captures.empty() )
|
||||
{
|
||||
uint64_t totalTimeMs = m_captures.back().m_cumulativeTime + ((m_captures.back().m_length * 1000) / m_captures.back().m_sampleRate);
|
||||
response.getSigMfFileInputReport()->setRecordDurationMs(totalTimeMs);
|
||||
@@ -1137,7 +1120,7 @@ void SigMFFileInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& resp
|
||||
|
||||
void SigMFFileInput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const SigMFFileInputSettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
auto *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
||||
swgDeviceSettings->setDeviceHwType(new QString("SigMFFileInput"));
|
||||
@@ -1166,8 +1149,8 @@ void SigMFFileInput::webapiReverseSendSettings(const QList<QString>& deviceSetti
|
||||
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
||||
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QBuffer *buffer = new QBuffer();
|
||||
buffer->open((QBuffer::ReadWrite));
|
||||
auto *buffer = new QBuffer();
|
||||
buffer->open(QBuffer::ReadWrite);
|
||||
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
||||
buffer->seek(0);
|
||||
|
||||
@@ -1180,7 +1163,7 @@ void SigMFFileInput::webapiReverseSendSettings(const QList<QString>& deviceSetti
|
||||
|
||||
void SigMFFileInput::webapiReverseSendStartStop(bool start)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
auto *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
||||
swgDeviceSettings->setDeviceHwType(new QString("SigMFFileInput"));
|
||||
@@ -1192,8 +1175,8 @@ void SigMFFileInput::webapiReverseSendStartStop(bool start)
|
||||
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
||||
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QBuffer *buffer = new QBuffer();
|
||||
buffer->open((QBuffer::ReadWrite));
|
||||
auto *buffer = new QBuffer();
|
||||
buffer->open(QBuffer::ReadWrite);
|
||||
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
||||
buffer->seek(0);
|
||||
QNetworkReply *reply;
|
||||
@@ -1208,7 +1191,7 @@ void SigMFFileInput::webapiReverseSendStartStop(bool start)
|
||||
delete swgDeviceSettings;
|
||||
}
|
||||
|
||||
void SigMFFileInput::networkManagerFinished(QNetworkReply *reply)
|
||||
void SigMFFileInput::networkManagerFinished(QNetworkReply *reply) const
|
||||
{
|
||||
QNetworkReply::NetworkError replyError = reply->error();
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
private:
|
||||
bool m_working;
|
||||
|
||||
MsgConfigureTrackWork(bool working) :
|
||||
explicit MsgConfigureTrackWork(bool working) :
|
||||
Message(),
|
||||
m_working(working)
|
||||
{ }
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
private:
|
||||
bool m_working;
|
||||
|
||||
MsgConfigureFileWork(bool working) :
|
||||
explicit MsgConfigureFileWork(bool working) :
|
||||
Message(),
|
||||
m_working(working)
|
||||
{ }
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
private:
|
||||
int m_trackIndex;
|
||||
|
||||
MsgConfigureTrackIndex(int trackIndex) :
|
||||
explicit MsgConfigureTrackIndex(int trackIndex) :
|
||||
Message(),
|
||||
m_trackIndex(trackIndex)
|
||||
{ }
|
||||
@@ -152,10 +152,10 @@ public:
|
||||
return new MsgConfigureTrackSeek(seekMillis);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
int m_seekMillis; //!< millis of seek position from the beginning 0..1000
|
||||
|
||||
MsgConfigureTrackSeek(int seekMillis) :
|
||||
explicit MsgConfigureTrackSeek(int seekMillis) :
|
||||
Message(),
|
||||
m_seekMillis(seekMillis)
|
||||
{ }
|
||||
@@ -175,10 +175,10 @@ public:
|
||||
return new MsgConfigureFileSeek(seekMillis);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
int m_seekMillis; //!< millis of seek position from the beginning 0..1000
|
||||
|
||||
MsgConfigureFileSeek(int seekMillis) :
|
||||
explicit MsgConfigureFileSeek(int seekMillis) :
|
||||
Message(),
|
||||
m_seekMillis(seekMillis)
|
||||
{ }
|
||||
@@ -217,10 +217,10 @@ public:
|
||||
return new MsgStartStop(startStop);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
bool m_startStop;
|
||||
|
||||
MsgStartStop(bool startStop) :
|
||||
explicit MsgStartStop(bool startStop) :
|
||||
Message(),
|
||||
m_startStop(startStop)
|
||||
{ }
|
||||
@@ -240,10 +240,10 @@ public:
|
||||
return new MsgReportStartStop(startStop);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
bool m_startStop;
|
||||
|
||||
MsgReportStartStop(bool startStop) :
|
||||
explicit MsgReportStartStop(bool startStop) :
|
||||
Message(),
|
||||
m_startStop(startStop)
|
||||
{ }
|
||||
@@ -257,13 +257,13 @@ public:
|
||||
|
||||
public:
|
||||
const SigMFFileMetaInfo& getMetaInfo() const { return m_metaInfo; }
|
||||
const QList<SigMFFileCapture>& getCaptures() { return m_captures; }
|
||||
const QList<SigMFFileCapture>& getCaptures() const { return m_captures; }
|
||||
|
||||
static MsgReportMetaData* create(const SigMFFileMetaInfo& metaInfo, const QList<SigMFFileCapture>& captures) {
|
||||
return new MsgReportMetaData(metaInfo, captures);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
SigMFFileMetaInfo m_metaInfo;
|
||||
QList<SigMFFileCapture> m_captures;
|
||||
|
||||
@@ -288,7 +288,7 @@ public:
|
||||
|
||||
private:
|
||||
int m_trackIndex;
|
||||
MsgReportTrackChange(int trackIndex) :
|
||||
explicit MsgReportTrackChange(int trackIndex) :
|
||||
Message(),
|
||||
m_trackIndex(trackIndex)
|
||||
{ }
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
quint64 m_samplesCount;
|
||||
quint64 m_trackSamplesCount;
|
||||
quint64 m_trackTimeStart;
|
||||
@@ -354,10 +354,10 @@ public:
|
||||
return new MsgReportCRC(ok);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
bool m_ok;
|
||||
|
||||
MsgReportCRC(bool ok) :
|
||||
explicit MsgReportCRC(bool ok) :
|
||||
Message(),
|
||||
m_ok(ok)
|
||||
{ }
|
||||
@@ -376,98 +376,98 @@ public:
|
||||
return new MsgReportTotalSamplesCheck(ok);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
bool m_ok;
|
||||
|
||||
MsgReportTotalSamplesCheck(bool ok) :
|
||||
explicit MsgReportTotalSamplesCheck(bool ok) :
|
||||
Message(),
|
||||
m_ok(ok)
|
||||
{ }
|
||||
};
|
||||
|
||||
SigMFFileInput(DeviceAPI *deviceAPI);
|
||||
virtual ~SigMFFileInput();
|
||||
virtual void destroy();
|
||||
explicit SigMFFileInput(DeviceAPI *deviceAPI);
|
||||
~SigMFFileInput() final;
|
||||
void destroy() final;
|
||||
|
||||
virtual void init();
|
||||
virtual bool start();
|
||||
virtual void stop();
|
||||
void init() final;
|
||||
bool start() final;
|
||||
void stop() final;
|
||||
|
||||
virtual QByteArray serialize() const;
|
||||
virtual bool deserialize(const QByteArray& data);
|
||||
QByteArray serialize() const final;
|
||||
bool deserialize(const QByteArray& data) final;
|
||||
|
||||
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
|
||||
virtual const QString& getDeviceDescription() const;
|
||||
virtual int getSampleRate() const;
|
||||
virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
|
||||
virtual quint64 getCenterFrequency() const;
|
||||
virtual void setCenterFrequency(qint64 centerFrequency);
|
||||
void setMessageQueueToGUI(MessageQueue *queue) final { m_guiMessageQueue = queue; }
|
||||
const QString& getDeviceDescription() const final;
|
||||
int getSampleRate() const final;
|
||||
void setSampleRate(int sampleRate) final { (void) sampleRate; }
|
||||
quint64 getCenterFrequency() const final;
|
||||
void setCenterFrequency(qint64 centerFrequency) final;
|
||||
quint64 getStartingTimeStamp() const;
|
||||
|
||||
virtual bool handleMessage(const Message& message);
|
||||
bool handleMessage(const Message& message) final;
|
||||
|
||||
virtual int webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage);
|
||||
int webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage) final;
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage);
|
||||
int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage) final;
|
||||
|
||||
virtual int webapiRunGet(
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
int webapiRunGet(
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage) final;
|
||||
|
||||
virtual int webapiActionsPost(
|
||||
const QStringList& deviceActionsKeys,
|
||||
SWGSDRangel::SWGDeviceActions& query,
|
||||
QString& errorMessage);
|
||||
int webapiActionsPost(
|
||||
const QStringList& deviceActionsKeys,
|
||||
SWGSDRangel::SWGDeviceActions& query,
|
||||
QString& errorMessage) final;
|
||||
|
||||
virtual int webapiRun(
|
||||
bool run,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
int webapiRun(
|
||||
bool run,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage) final;
|
||||
|
||||
virtual int webapiReportGet(
|
||||
SWGSDRangel::SWGDeviceReport& response,
|
||||
QString& errorMessage);
|
||||
int webapiReportGet(
|
||||
SWGSDRangel::SWGDeviceReport& response,
|
||||
QString& errorMessage) final;
|
||||
|
||||
static void webapiFormatDeviceSettings(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
const SigMFFileInputSettings& settings);
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
const SigMFFileInputSettings& settings);
|
||||
|
||||
static void webapiUpdateDeviceSettings(
|
||||
SigMFFileInputSettings& settings,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response);
|
||||
SigMFFileInputSettings& settings,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response);
|
||||
|
||||
private:
|
||||
DeviceAPI *m_deviceAPI;
|
||||
QMutex m_mutex;
|
||||
bool m_running;
|
||||
bool m_running = false;
|
||||
SigMFFileInputSettings m_settings;
|
||||
std::ifstream m_metaStream;
|
||||
std::ifstream m_dataStream;
|
||||
SigMFFileMetaInfo m_metaInfo;
|
||||
QList<SigMFFileCapture> m_captures;
|
||||
std::vector<uint64_t> m_captureStarts;
|
||||
bool m_trackMode;
|
||||
int m_currentTrackIndex;
|
||||
bool m_recordOpen;
|
||||
bool m_crcAvailable;
|
||||
bool m_crcOK;
|
||||
bool m_recordLengthOK;
|
||||
bool m_trackMode = false;
|
||||
int m_currentTrackIndex = 0;
|
||||
bool m_recordOpen = false;
|
||||
bool m_crcAvailable = false;
|
||||
bool m_crcOK = false;
|
||||
bool m_recordLengthOK = false;
|
||||
QString m_recordSummary;
|
||||
SigMFFileInputWorker* m_fileInputWorker;
|
||||
SigMFFileInputWorker* m_fileInputWorker = nullptr;
|
||||
QThread m_fileInputWorkerThread;
|
||||
QString m_deviceDescription;
|
||||
int m_sampleRate;
|
||||
unsigned int m_sampleBytes;
|
||||
quint64 m_centerFrequency;
|
||||
quint64 m_recordLength; //!< record length in seconds computed from file size
|
||||
quint64 m_startingTimeStamp;
|
||||
int m_sampleRate = 48000;
|
||||
unsigned int m_sampleBytes = 1;
|
||||
quint64 m_centerFrequency = 0;
|
||||
quint64 m_recordLength = 0; //!< record length in seconds computed from file size
|
||||
quint64 m_startingTimeStamp = 0;
|
||||
QTimer m_masterTimer;
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
QNetworkRequest m_networkRequest;
|
||||
@@ -498,7 +498,7 @@ private:
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
private slots:
|
||||
void networkManagerFinished(QNetworkReply *reply);
|
||||
void networkManagerFinished(QNetworkReply *reply) const;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_SIGMFFILEINPUT_H
|
||||
|
||||
Reference in New Issue
Block a user