SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
RemoteDataReadQueue Class Reference

#include <remotedatareadqueue.h>

+ Collaboration diagram for RemoteDataReadQueue:

Public Member Functions

 RemoteDataReadQueue ()
 
 ~RemoteDataReadQueue ()
 
void push (RemoteDataBlock *dataBlock)
 push block on the queue More...
 
RemoteDataBlockpop ()
 Pop block from the queue. More...
 
void readSample (Sample &s, bool scaleForTx=false)
 Read sample from queue possibly scaling to Tx size. More...
 
uint32_t length () const
 Returns queue length. More...
 
uint32_t size () const
 Returns queue size (max length) More...
 
void setSize (uint32_t size)
 Sets the queue size (max length) More...
 
uint32_t readSampleCount () const
 Returns the absolute number of samples read. More...
 

Static Public Attributes

static const uint32_t MinimumMaxSize = 10
 

Private Member Functions

void convertDataToSample (Sample &s, uint32_t blockIndex, uint32_t sampleIndex, bool scaleForTx)
 

Private Attributes

QQueue< RemoteDataBlock * > m_dataReadQueue
 
RemoteDataBlockm_dataBlock
 
uint32_t m_maxSize
 
uint32_t m_blockIndex
 
uint32_t m_sampleIndex
 
uint32_t m_sampleCount
 use a counter capped below 2^31 as it is going to be converted to an int in the web interface More...
 
bool m_full
 full condition was hit More...
 

Detailed Description

Definition at line 35 of file remotedatareadqueue.h.

Constructor & Destructor Documentation

◆ RemoteDataReadQueue()

RemoteDataReadQueue::RemoteDataReadQueue ( )

Definition at line 30 of file remotedatareadqueue.cpp.

30  :
31  m_dataBlock(0),
33  m_blockIndex(1),
34  m_sampleIndex(0),
35  m_sampleCount(0),
36  m_full(false)
37 {}
uint32_t m_sampleCount
use a counter capped below 2^31 as it is going to be converted to an int in the web interface ...
bool m_full
full condition was hit
RemoteDataBlock * m_dataBlock
static const uint32_t MinimumMaxSize

◆ ~RemoteDataReadQueue()

RemoteDataReadQueue::~RemoteDataReadQueue ( )

Definition at line 39 of file remotedatareadqueue.cpp.

References pop().

40 {
41  RemoteDataBlock* data;
42 
43  while ((data = pop()) != 0)
44  {
45  qDebug("RemoteDataReadQueue::~RemoteDataReadQueue: data block was still in queue");
46  delete data;
47  }
48 }
RemoteDataBlock * pop()
Pop block from the queue.
+ Here is the call graph for this function:

Member Function Documentation

◆ convertDataToSample()

void RemoteDataReadQueue::convertDataToSample ( Sample s,
uint32_t  blockIndex,
uint32_t  sampleIndex,
bool  scaleForTx 
)
inlineprivate

Definition at line 60 of file remotedatareadqueue.h.

References RemoteProtectedBlock::buf, RemoteSuperBlock::m_header, RemoteSuperBlock::m_protectedBlock, RemoteHeader::m_sampleBits, RemoteHeader::m_sampleBytes, RemoteDataBlock::m_superBlocks, SDR_RX_SAMP_SZ, SDR_TX_SAMP_SZ, Sample::setImag(), and Sample::setReal().

Referenced by readSample().

61  {
62  int sampleSize = m_dataBlock->m_superBlocks[blockIndex].m_header.m_sampleBytes * 2; // I/Q sample size in data block
63  int samplebits = m_dataBlock->m_superBlocks[blockIndex].m_header.m_sampleBits; // I or Q sample size in bits
64  int32_t iconv, qconv;
65 
66  if ((sizeof(Sample) == 4) && (sampleSize == 8)) // generally 24->16 bits
67  {
68  iconv = ((int32_t*) &(m_dataBlock->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize]))[0];
69  qconv = ((int32_t*) &(m_dataBlock->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+4]))[0];
70  iconv >>= scaleForTx ? (SDR_TX_SAMP_SZ-SDR_RX_SAMP_SZ) : (samplebits-SDR_RX_SAMP_SZ);
71  qconv >>= scaleForTx ? (SDR_TX_SAMP_SZ-SDR_RX_SAMP_SZ) : (samplebits-SDR_RX_SAMP_SZ);
72  s.setReal(iconv);
73  s.setImag(qconv);
74  }
75  else if ((sizeof(Sample) == 8) && (sampleSize == 4)) // generally 16->24 bits
76  {
77  iconv = ((int16_t*) &(m_dataBlock->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize]))[0];
78  qconv = ((int16_t*) &(m_dataBlock->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize+2]))[0];
79  iconv <<= scaleForTx ? (SDR_TX_SAMP_SZ-samplebits) : (SDR_RX_SAMP_SZ-samplebits);
80  qconv <<= scaleForTx ? (SDR_TX_SAMP_SZ-samplebits) : (SDR_RX_SAMP_SZ-samplebits);
81  s.setReal(iconv);
82  s.setImag(qconv);
83  }
84  else if ((sampleSize == 4) || (sampleSize == 8)) // generally 16->16 or 24->24 bits
85  {
86  s = *((Sample*) &(m_dataBlock->m_superBlocks[blockIndex].m_protectedBlock.buf[sampleIndex*sampleSize]));
87  }
88  else // invalid size
89  {
90  s = Sample{0, 0};
91  }
92  }
short int16_t
Definition: rtptypes_win.h:43
RemoteSuperBlock * m_superBlocks
RemoteProtectedBlock m_protectedBlock
#define SDR_RX_SAMP_SZ
Definition: dsptypes.h:32
uint8_t buf[RemoteNbBytesPerBlock]
uint8_t m_sampleBytes
number of bytes per sample (2 or 4) for this block
void setImag(FixReal v)
Definition: dsptypes.h:59
int int32_t
Definition: rtptypes_win.h:45
#define SDR_TX_SAMP_SZ
Definition: dsptypes.h:38
RemoteHeader m_header
void setReal(FixReal v)
Definition: dsptypes.h:58
RemoteDataBlock * m_dataBlock
uint8_t m_sampleBits
number of bits per sample
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ length()

uint32_t RemoteDataReadQueue::length ( ) const
inline

Returns queue length.

Definition at line 44 of file remotedatareadqueue.h.

Referenced by RemoteSource::handleMessage(), push(), readSample(), and RemoteSource::webapiFormatChannelReport().

+ Here is the caller graph for this function:

◆ pop()

RemoteDataBlock * RemoteDataReadQueue::pop ( )

Pop block from the queue.

Definition at line 69 of file remotedatareadqueue.cpp.

References m_blockIndex, m_dataReadQueue, and m_sampleIndex.

Referenced by ~RemoteDataReadQueue().

70 {
71  if (m_dataReadQueue.isEmpty())
72  {
73  return 0;
74  }
75  else
76  {
77  m_blockIndex = 1;
78  m_sampleIndex = 0;
79 
80  return m_dataReadQueue.takeFirst();
81  }
82 }
QQueue< RemoteDataBlock * > m_dataReadQueue
+ Here is the caller graph for this function:

◆ push()

void RemoteDataReadQueue::push ( RemoteDataBlock dataBlock)

push block on the queue

Definition at line 50 of file remotedatareadqueue.cpp.

References length(), m_dataReadQueue, m_full, and m_maxSize.

51 {
52  if (length() >= m_maxSize)
53  {
54  qWarning("RemoteDataReadQueue::push: queue is full");
55  m_full = true; // stop filling the queue
56  RemoteDataBlock *data = m_dataReadQueue.takeLast();
57  delete data;
58  }
59 
60  if (m_full) {
61  m_full = (length() > m_maxSize/2); // do not fill queue again before queue is half size
62  }
63 
64  if (!m_full) {
65  m_dataReadQueue.append(dataBlock);
66  }
67 }
bool m_full
full condition was hit
uint32_t length() const
Returns queue length.
QQueue< RemoteDataBlock * > m_dataReadQueue
+ Here is the call graph for this function:

◆ readSample()

void RemoteDataReadQueue::readSample ( Sample s,
bool  scaleForTx = false 
)

Read sample from queue possibly scaling to Tx size.

Definition at line 91 of file remotedatareadqueue.cpp.

References convertDataToSample(), length(), m_blockIndex, m_dataBlock, m_dataReadQueue, RemoteSuperBlock::m_header, m_maxSize, RemoteHeader::m_sampleBytes, m_sampleCount, m_sampleIndex, and RemoteDataBlock::m_superBlocks.

Referenced by RemoteSource::pull().

92 {
93  // depletion/repletion state
94  if (m_dataBlock == 0)
95  {
96  if (length() >= m_maxSize/2)
97  {
98  qDebug("RemoteDataReadQueue::readSample: initial pop new block: queue size: %u", length());
99  m_blockIndex = 1;
100  m_dataBlock = m_dataReadQueue.takeFirst();
102  m_sampleIndex++;
103  m_sampleCount++;
104  }
105  else
106  {
107  s = Sample{0, 0};
108  }
109 
110  return;
111  }
112 
114  uint32_t samplesPerBlock = RemoteNbBytesPerBlock / sampleSize;
115 
116  if (m_sampleIndex < samplesPerBlock)
117  {
119  m_sampleIndex++;
120  m_sampleCount++;
121  }
122  else
123  {
124  m_sampleIndex = 0;
125  m_blockIndex++;
126 
127  if (m_blockIndex < RemoteNbOrginalBlocks)
128  {
130  m_sampleIndex++;
131  m_sampleCount++;
132  }
133  else
134  {
135  delete m_dataBlock;
136  m_dataBlock = 0;
137 
138  if (length() == 0) {
139  qWarning("RemoteDataReadQueue::readSample: try to pop new block but queue is empty");
140  }
141 
142  if (length() > 0)
143  {
144  //qDebug("RemoteDataReadQueue::readSample: pop new block: queue size: %u", length());
145  m_blockIndex = 1;
146  m_dataBlock = m_dataReadQueue.takeFirst();
148  m_sampleIndex++;
149  m_sampleCount++;
150  }
151  else
152  {
153  s = Sample{0, 0};
154  }
155  }
156  }
157 }
RemoteSuperBlock * m_superBlocks
uint32_t m_sampleCount
use a counter capped below 2^31 as it is going to be converted to an int in the web interface ...
unsigned int uint32_t
Definition: rtptypes_win.h:46
uint8_t m_sampleBytes
number of bytes per sample (2 or 4) for this block
uint32_t length() const
Returns queue length.
RemoteHeader m_header
RemoteDataBlock * m_dataBlock
void convertDataToSample(Sample &s, uint32_t blockIndex, uint32_t sampleIndex, bool scaleForTx)
QQueue< RemoteDataBlock * > m_dataReadQueue
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSampleCount()

uint32_t RemoteDataReadQueue::readSampleCount ( ) const
inline

Returns the absolute number of samples read.

Definition at line 47 of file remotedatareadqueue.h.

Referenced by RemoteSource::handleMessage(), and RemoteSource::webapiFormatChannelReport().

+ Here is the caller graph for this function:

◆ setSize()

void RemoteDataReadQueue::setSize ( uint32_t  size)

Sets the queue size (max length)

Definition at line 84 of file remotedatareadqueue.cpp.

References m_maxSize, MinimumMaxSize, and size().

85 {
86  if (size != m_maxSize) {
88  }
89 }
uint32_t size() const
Returns queue size (max length)
static const uint32_t MinimumMaxSize
+ Here is the call graph for this function:

◆ size()

uint32_t RemoteDataReadQueue::size ( ) const
inline

Returns queue size (max length)

Definition at line 45 of file remotedatareadqueue.h.

Referenced by RemoteSource::handleMessage(), setSize(), and RemoteSource::webapiFormatChannelReport().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_blockIndex

uint32_t RemoteDataReadQueue::m_blockIndex
private

Definition at line 55 of file remotedatareadqueue.h.

Referenced by pop(), and readSample().

◆ m_dataBlock

RemoteDataBlock* RemoteDataReadQueue::m_dataBlock
private

Definition at line 53 of file remotedatareadqueue.h.

Referenced by readSample().

◆ m_dataReadQueue

QQueue<RemoteDataBlock*> RemoteDataReadQueue::m_dataReadQueue
private

Definition at line 52 of file remotedatareadqueue.h.

Referenced by pop(), push(), and readSample().

◆ m_full

bool RemoteDataReadQueue::m_full
private

full condition was hit

Definition at line 58 of file remotedatareadqueue.h.

Referenced by push().

◆ m_maxSize

uint32_t RemoteDataReadQueue::m_maxSize
private

Definition at line 54 of file remotedatareadqueue.h.

Referenced by push(), readSample(), and setSize().

◆ m_sampleCount

uint32_t RemoteDataReadQueue::m_sampleCount
private

use a counter capped below 2^31 as it is going to be converted to an int in the web interface

Definition at line 57 of file remotedatareadqueue.h.

Referenced by readSample().

◆ m_sampleIndex

uint32_t RemoteDataReadQueue::m_sampleIndex
private

Definition at line 56 of file remotedatareadqueue.h.

Referenced by pop(), and readSample().

◆ MinimumMaxSize

const uint32_t RemoteDataReadQueue::MinimumMaxSize = 10
static

Definition at line 49 of file remotedatareadqueue.h.

Referenced by setSize().


The documentation for this class was generated from the following files: