mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 16:08:39 -05:00
SDRdaemon plugin: added counters for data received from UDP
This commit is contained in:
parent
13d698a940
commit
ca7d8de81e
@ -1,67 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
||||
// written by Christian Daniel //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_SCOPEWINDOW_H
|
||||
#define INCLUDE_SCOPEWINDOW_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "dsp/dsptypes.h"
|
||||
#include "util/export.h"
|
||||
|
||||
class DSPEngine;
|
||||
|
||||
namespace Ui {
|
||||
class ScopeWindow;
|
||||
}
|
||||
|
||||
class SDRANGEL_API ScopeWindow : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ScopeWindow(DSPEngine* dspEngine, QWidget* parent = NULL);
|
||||
~ScopeWindow();
|
||||
|
||||
void setSampleRate(int sampleRate);
|
||||
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
|
||||
private slots:
|
||||
void on_amp_valueChanged(int value);
|
||||
void on_scope_traceSizeChanged(int value);
|
||||
void on_time_valueChanged(int value);
|
||||
void on_timeOfs_valueChanged(int value);
|
||||
void on_displayMode_currentIndexChanged(int index);
|
||||
|
||||
void on_horizView_clicked();
|
||||
void on_vertView_clicked();
|
||||
|
||||
private:
|
||||
Ui::ScopeWindow *ui;
|
||||
int m_sampleRate;
|
||||
|
||||
qint32 m_displayData;
|
||||
qint32 m_displayOrientation;
|
||||
qint32 m_timeBase;
|
||||
qint32 m_timeOffset;
|
||||
qint32 m_amplification;
|
||||
|
||||
void applySettings();
|
||||
};
|
||||
|
||||
#endif // INCLUDE_SCOPEWINDOW_H
|
@ -35,7 +35,9 @@ SDRdaemonBuffer::SDRdaemonBuffer(std::size_t blockSize) :
|
||||
m_sampleRate(1000000),
|
||||
m_sampleBytes(2),
|
||||
m_sampleBits(12),
|
||||
m_rawBuffer(0)
|
||||
m_rawBuffer(0),
|
||||
m_bytesInBlock(0),
|
||||
m_nbBlocks(0)
|
||||
{
|
||||
m_currentMeta.init();
|
||||
}
|
||||
@ -55,10 +57,12 @@ bool SDRdaemonBuffer::readMeta(char *array, std::size_t length)
|
||||
{
|
||||
assert(length >= sizeof(MetaData) + 8);
|
||||
MetaData *metaData = (MetaData *) array;
|
||||
updateBlockCounts(length);
|
||||
|
||||
if (m_crc64.calculate_crc((uint8_t *)array, sizeof(MetaData) - 8) == metaData->m_crc)
|
||||
{
|
||||
memcpy((void *) &m_dataCRC, (const void *) &array[sizeof(MetaData)], 8);
|
||||
m_nbBlocks = 0;
|
||||
|
||||
if (!(m_currentMeta == *metaData))
|
||||
{
|
||||
@ -222,6 +226,12 @@ void SDRdaemonBuffer::updateBufferSize(uint32_t frameSize)
|
||||
m_rawBuffer = new uint8_t[nbFrames * frameSize];
|
||||
}
|
||||
|
||||
void SDRdaemonBuffer::updateBlockCounts(uint32_t nbBytesReceived)
|
||||
{
|
||||
m_nbBlocks += m_bytesInBlock + nbBytesReceived > m_blockSize ? 1 : 0;
|
||||
m_bytesInBlock = m_bytesInBlock + nbBytesReceived > m_blockSize ? nbBytesReceived : m_bytesInBlock + nbBytesReceived;
|
||||
}
|
||||
|
||||
void SDRdaemonBuffer::printMeta(MetaData *metaData)
|
||||
{
|
||||
std::cerr
|
||||
|
@ -73,6 +73,7 @@ private:
|
||||
void writeDataLZ4(char *array, std::size_t length);
|
||||
void writeDataUncompressed(char *array, std::size_t length);
|
||||
void updateBufferSize(uint32_t frameSize);
|
||||
void updateBlockCounts(uint32_t nbBytesReceived);
|
||||
void printMeta(MetaData *metaData);
|
||||
|
||||
std::size_t m_blockSize; //!< UDP block (payload) size
|
||||
@ -98,6 +99,8 @@ private:
|
||||
|
||||
uint32_t m_rawCount; //!< Current position in the raw samples buffer
|
||||
uint8_t *m_rawBuffer; //!< Buffer for raw samples obtained from UDP (I/Q not in a formal I/Q structure)
|
||||
uint32_t m_bytesInBlock; //!< Number of bytes received in the current UDP block
|
||||
uint32_t m_nbBlocks; //!< Number of UDP blocks received in the current frame
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,192 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
||||
// written by Christian Daniel //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "gui/scopewindow.h"
|
||||
#include "ui_scopewindow.h"
|
||||
#include "util/simpleserializer.h"
|
||||
|
||||
ScopeWindow::ScopeWindow(DSPEngine* dspEngine, QWidget* parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ScopeWindow),
|
||||
m_sampleRate(0),
|
||||
m_timeBase(1)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->scope->setDSPEngine(dspEngine);
|
||||
}
|
||||
|
||||
ScopeWindow::~ScopeWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ScopeWindow::setSampleRate(int sampleRate)
|
||||
{
|
||||
m_sampleRate = sampleRate;
|
||||
on_scope_traceSizeChanged(0);
|
||||
}
|
||||
|
||||
void ScopeWindow::resetToDefaults()
|
||||
{
|
||||
m_displayData = GLScope::ModeIQ;
|
||||
m_displayOrientation = Qt::Horizontal;
|
||||
m_timeBase = 1;
|
||||
m_timeOffset = 0;
|
||||
m_amplification = 0;
|
||||
applySettings();
|
||||
}
|
||||
|
||||
QByteArray ScopeWindow::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
#if 0
|
||||
s.writeS32(1, m_displayData);
|
||||
s.writeS32(2, m_displayOrientation);
|
||||
s.writeS32(3, m_timeBase);
|
||||
s.writeS32(4, m_timeOffset);
|
||||
s.writeS32(5, m_amplification);
|
||||
#endif
|
||||
return s.final();
|
||||
}
|
||||
|
||||
bool ScopeWindow::deserialize(const QByteArray& data)
|
||||
{
|
||||
#if 0
|
||||
SimpleDeserializer d(data);
|
||||
|
||||
if(!d.isValid()) {
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(d.getVersion() == 1) {
|
||||
d.readS32(1, &m_displayData, GLScope::ModeIQ);
|
||||
d.readS32(2, &m_displayOrientation, Qt::Horizontal);
|
||||
d.readS32(3, &m_timeBase, 1);
|
||||
d.readS32(4, &m_timeOffset, 0);
|
||||
d.readS32(5, &m_amplification, 0);
|
||||
if(m_timeBase < 0)
|
||||
m_timeBase = 1;
|
||||
applySettings();
|
||||
return true;
|
||||
} else {
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
resetToDefaults();
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScopeWindow::on_amp_valueChanged(int value)
|
||||
{
|
||||
static qreal amps[11] = { 0.2, 0.1, 0.05, 0.02, 0.01, 0.005, 0.002, 0.001, 0.0005, 0.0002, 0.0001 };
|
||||
ui->ampText->setText(tr("%1\n/div").arg(amps[value], 0, 'f', 4));
|
||||
ui->scope->setAmp(0.2 / amps[value]);
|
||||
m_amplification = value;
|
||||
}
|
||||
|
||||
void ScopeWindow::on_scope_traceSizeChanged(int)
|
||||
{
|
||||
qreal t = (ui->scope->getTraceSize() * 0.1 / m_sampleRate) / (qreal)m_timeBase;
|
||||
if(t < 0.000001)
|
||||
ui->timeText->setText(tr("%1\nns/div").arg(t * 1000000000.0));
|
||||
else if(t < 0.001)
|
||||
ui->timeText->setText(tr("%1\nµs/div").arg(t * 1000000.0));
|
||||
else if(t < 1.0)
|
||||
ui->timeText->setText(tr("%1\nms/div").arg(t * 1000.0));
|
||||
else ui->timeText->setText(tr("%1\ns/div").arg(t * 1.0));
|
||||
}
|
||||
|
||||
void ScopeWindow::on_time_valueChanged(int value)
|
||||
{
|
||||
m_timeBase = value;
|
||||
on_scope_traceSizeChanged(0);
|
||||
ui->scope->setTimeBase(m_timeBase);
|
||||
}
|
||||
|
||||
void ScopeWindow::on_timeOfs_valueChanged(int value)
|
||||
{
|
||||
m_timeOffset = value;
|
||||
ui->scope->setTimeOfsProMill(value);
|
||||
}
|
||||
|
||||
void ScopeWindow::on_displayMode_currentIndexChanged(int index)
|
||||
{
|
||||
m_displayData = index;
|
||||
switch(index) {
|
||||
case 0: // i+q
|
||||
ui->scope->setMode(GLScope::ModeIQ);
|
||||
break;
|
||||
case 1: // mag(lin)+pha
|
||||
ui->scope->setMode(GLScope::ModeMagLinPha);
|
||||
break;
|
||||
case 2: // mag(dB)+pha
|
||||
ui->scope->setMode(GLScope::ModeMagdBPha);
|
||||
break;
|
||||
case 3: // derived1+derived2
|
||||
ui->scope->setMode(GLScope::ModeDerived12);
|
||||
break;
|
||||
case 4: // clostationary
|
||||
ui->scope->setMode(GLScope::ModeCyclostationary);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ScopeWindow::on_horizView_clicked()
|
||||
{
|
||||
m_displayOrientation = Qt::Horizontal;
|
||||
if(ui->horizView->isChecked()) {
|
||||
ui->vertView->setChecked(false);
|
||||
ui->scope->setOrientation(Qt::Horizontal);
|
||||
} else {
|
||||
ui->horizView->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ScopeWindow::on_vertView_clicked()
|
||||
{
|
||||
m_displayOrientation = Qt::Vertical;
|
||||
if(ui->vertView->isChecked()) {
|
||||
ui->horizView->setChecked(false);
|
||||
ui->scope->setOrientation(Qt::Vertical);
|
||||
} else {
|
||||
ui->vertView->setChecked(true);
|
||||
ui->scope->setOrientation(Qt::Vertical);
|
||||
}
|
||||
}
|
||||
|
||||
void ScopeWindow::applySettings()
|
||||
{
|
||||
ui->displayMode->setCurrentIndex(m_displayData);
|
||||
if(m_displayOrientation == Qt::Horizontal) {
|
||||
ui->scope->setOrientation(Qt::Horizontal);
|
||||
ui->horizView->setChecked(true);
|
||||
ui->vertView->setChecked(false);
|
||||
} else {
|
||||
ui->scope->setOrientation(Qt::Vertical);
|
||||
ui->horizView->setChecked(false);
|
||||
ui->vertView->setChecked(true);
|
||||
}
|
||||
ui->time->setValue(m_timeBase);
|
||||
ui->timeOfs->setValue(m_timeOffset);
|
||||
ui->amp->setValue(m_amplification);
|
||||
}
|
Loading…
Reference in New Issue
Block a user