1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

SDRDaemon input: use timestamps in milliseconds directly

This commit is contained in:
f4exb 2018-11-13 13:45:55 +01:00
parent ec2bf7a57d
commit 5167aecb6a
7 changed files with 26 additions and 48 deletions

View File

@ -45,6 +45,7 @@ public:
// samples timestamp
uint32_t getTVOutSec() const { return m_tvOut_sec; }
uint32_t getTVOutUsec() const { return m_tvOut_usec; }
uint64_t getTVOutMSec() const { return (m_tvOut_sec * 1000LL) + (m_tvOut_usec/ 1000LL); }
// stats

View File

@ -71,8 +71,7 @@ SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceUISet *deviceUISet, QWidget* parent
m_paletteGreenText.setColor(QPalette::WindowText, Qt::green);
m_paletteWhiteText.setColor(QPalette::WindowText, Qt::white);
m_startingTimeStamp.tv_sec = 0;
m_startingTimeStamp.tv_usec = 0;
m_startingTimeStampms = 0;
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
@ -187,20 +186,17 @@ bool SDRdaemonSourceGui::handleMessage(const Message& message)
}
else if (SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData::match(message))
{
m_startingTimeStamp.tv_sec = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData&)message).get_tv_sec();
m_startingTimeStamp.tv_usec = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData&)message).get_tv_usec();
m_startingTimeStampms = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData&)message).get_tv_msec();
qDebug() << "SDRdaemonSourceGui::handleMessage: SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData: "
<< " : " << m_startingTimeStamp.tv_sec
<< " : " << m_startingTimeStamp.tv_usec;
<< " : " << m_startingTimeStampms << " ms";
updateWithStreamTime();
return true;
}
else if (SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming::match(message))
{
m_startingTimeStamp.tv_sec = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).get_tv_sec();
m_startingTimeStamp.tv_usec = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).get_tv_usec();
m_startingTimeStampms = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).get_tv_msec();
m_framesDecodingStatus = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getFramesDecodingStatus();
m_allBlocksReceived = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).allBlocksReceived();
m_bufferLengthInSecs = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getBufferLengthInSecs();
@ -464,8 +460,7 @@ void SDRdaemonSourceGui::updateWithAcquisition()
void SDRdaemonSourceGui::updateWithStreamTime()
{
bool updateEventCounts = false;
quint64 startingTimeStampMsec = ((quint64) m_startingTimeStamp.tv_sec * 1000LL) + ((quint64) m_startingTimeStamp.tv_usec / 1000LL);
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
QDateTime dt = QDateTime::fromMSecsSinceEpoch(m_startingTimeStampms);
QString s_date = dt.toString("yyyy-MM-dd HH:mm:ss.zzz");
ui->absTimeText->setText(s_date);

View File

@ -17,8 +17,6 @@
#ifndef INCLUDE_SDRDAEMONSOURCEGUI_H
#define INCLUDE_SDRDAEMONSOURCEGUI_H
#include <sys/time.h>
#include <QTimer>
#include <QWidget>
#include <QNetworkRequest>
@ -72,7 +70,7 @@ private:
// int m_sampleRate;
// quint64 m_centerFrequency;
struct timeval m_startingTimeStamp;
uint64_t m_startingTimeStampms;
int m_framesDecodingStatus;
bool m_allBlocksReceived;
float m_bufferLengthInSecs;

View File

@ -355,8 +355,7 @@ void SDRdaemonSourceInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport
response.getSdrDaemonSourceReport()->setSampleRate(m_SDRdaemonUDPHandler->getSampleRate());
response.getSdrDaemonSourceReport()->setBufferRwBalance(m_SDRdaemonUDPHandler->getBufferGauge());
quint64 startingTimeStampMsec = ((quint64) m_SDRdaemonUDPHandler->getTVSec() * 1000LL) + ((quint64) m_SDRdaemonUDPHandler->getTVuSec() / 1000LL);
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
QDateTime dt = QDateTime::fromMSecsSinceEpoch(m_SDRdaemonUDPHandler->getTVmSec());
response.getSdrDaemonSourceReport()->setDaemonTimestamp(new QString(dt.toString("yyyy-MM-dd HH:mm:ss.zzz")));
response.getSdrDaemonSourceReport()->setMinNbBlocks(m_SDRdaemonUDPHandler->getMinNbBlocks());

View File

@ -99,26 +99,23 @@ public:
public:
int getSampleRate() const { return m_sampleRate; }
quint64 getCenterFrequency() const { return m_centerFrequency; }
uint32_t get_tv_sec() const { return m_tv_sec; }
uint32_t get_tv_usec() const { return m_tv_usec; }
uint32_t get_tv_msec() const { return m_tv_msec; }
static MsgReportSDRdaemonSourceStreamData* create(int sampleRate, quint64 centerFrequency, uint32_t tv_sec, uint32_t tv_usec)
static MsgReportSDRdaemonSourceStreamData* create(int sampleRate, quint64 centerFrequency, uint64_t tv_msec)
{
return new MsgReportSDRdaemonSourceStreamData(sampleRate, centerFrequency, tv_sec, tv_usec);
return new MsgReportSDRdaemonSourceStreamData(sampleRate, centerFrequency, tv_msec);
}
protected:
int m_sampleRate;
quint64 m_centerFrequency;
uint32_t m_tv_sec;
uint32_t m_tv_usec;
uint64_t m_tv_msec;
MsgReportSDRdaemonSourceStreamData(int sampleRate, quint64 centerFrequency, uint32_t tv_sec, uint32_t tv_usec) :
MsgReportSDRdaemonSourceStreamData(int sampleRate, quint64 centerFrequency, uint64_t tv_msec) :
Message(),
m_sampleRate(sampleRate),
m_centerFrequency(centerFrequency),
m_tv_sec(tv_sec),
m_tv_usec(tv_usec)
m_tv_msec(tv_msec)
{ }
};
@ -126,8 +123,7 @@ public:
MESSAGE_CLASS_DECLARATION
public:
uint32_t get_tv_sec() const { return m_tv_sec; }
uint32_t get_tv_usec() const { return m_tv_usec; }
uint64_t get_tv_msec() const { return m_tv_msec; }
int getFramesDecodingStatus() const { return m_framesDecodingStatus; }
bool allBlocksReceived() const { return m_allBlocksReceived; }
float getBufferLengthInSecs() const { return m_bufferLenSec; }
@ -143,8 +139,7 @@ public:
int getSampleBits() const { return m_sampleBits; }
int getSampleBytes() const { return m_sampleBytes; }
static MsgReportSDRdaemonSourceStreamTiming* create(uint32_t tv_sec,
uint32_t tv_usec,
static MsgReportSDRdaemonSourceStreamTiming* create(uint64_t tv_msec,
float bufferLenSec,
int32_t bufferGauge,
int framesDecodingStatus,
@ -160,8 +155,7 @@ public:
int sampleBits,
int sampleBytes)
{
return new MsgReportSDRdaemonSourceStreamTiming(tv_sec,
tv_usec,
return new MsgReportSDRdaemonSourceStreamTiming(tv_msec,
bufferLenSec,
bufferGauge,
framesDecodingStatus,
@ -179,8 +173,7 @@ public:
}
protected:
uint32_t m_tv_sec;
uint32_t m_tv_usec;
uint64_t m_tv_msec;
int m_framesDecodingStatus;
bool m_allBlocksReceived;
float m_bufferLenSec;
@ -196,8 +189,7 @@ public:
int m_sampleBits;
int m_sampleBytes;
MsgReportSDRdaemonSourceStreamTiming(uint32_t tv_sec,
uint32_t tv_usec,
MsgReportSDRdaemonSourceStreamTiming(uint64_t tv_msec,
float bufferLenSec,
int32_t bufferGauge,
int framesDecodingStatus,
@ -213,8 +205,7 @@ public:
int sampleBits,
int sampleBytes) :
Message(),
m_tv_sec(tv_sec),
m_tv_usec(tv_usec),
m_tv_msec(tv_msec),
m_framesDecodingStatus(framesDecodingStatus),
m_allBlocksReceived(allBlocksReceived),
m_bufferLenSec(bufferLenSec),

View File

@ -41,8 +41,7 @@ SDRdaemonSourceUDPHandler::SDRdaemonSourceUDPHandler(SampleSinkFifo *sampleFifo,
m_sampleFifo(sampleFifo),
m_samplerate(0),
m_centerFrequency(0),
m_tv_sec(0),
m_tv_usec(0),
m_tv_msec(0),
m_outputMessageQueueToGUI(0),
m_tickCount(0),
m_samplesCount(0),
@ -179,8 +178,7 @@ void SDRdaemonSourceUDPHandler::processData()
const SDRDaemonMetaDataFEC& metaData = m_sdrDaemonBuffer.getCurrentMeta();
bool change = false;
m_tv_sec = m_sdrDaemonBuffer.getTVOutSec();
m_tv_usec = m_sdrDaemonBuffer.getTVOutUsec();
m_tv_msec = m_sdrDaemonBuffer.getTVOutMSec();
if (m_centerFrequency != metaData.m_centerFrequency)
{
@ -206,8 +204,7 @@ void SDRdaemonSourceUDPHandler::processData()
SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData *report = SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData::create(
m_samplerate,
m_centerFrequency * 1000, // Frequency in Hz for the GUI
m_tv_sec,
m_tv_usec);
m_tv_msec);
m_outputMessageQueueToGUI->push(report);
}
@ -343,8 +340,7 @@ void SDRdaemonSourceUDPHandler::tick()
}
SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming *report = SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming::create(
m_tv_sec,
m_tv_usec,
m_tv_msec,
m_sdrDaemonBuffer.getBufferLengthInSecs(),
m_sdrDaemonBuffer.getBufferGauge(),
framesDecodingStatus,

View File

@ -48,8 +48,7 @@ public:
int getSampleRate() const { return m_samplerate; }
int getCenterFrequency() const { return m_centerFrequency * 1000; }
int getBufferGauge() const { return m_sdrDaemonBuffer.getBufferGauge(); }
uint32_t getTVSec() const { return m_tv_sec; }
uint32_t getTVuSec() const { return m_tv_usec; }
uint64_t getTVmSec() const { return m_tv_msec; }
int getMinNbBlocks() { return m_sdrDaemonBuffer.getMinNbBlocks(); }
int getMaxNbRecovery() { return m_sdrDaemonBuffer.getMaxNbRecovery(); }
public slots:
@ -72,8 +71,7 @@ private:
SampleSinkFifo *m_sampleFifo;
uint32_t m_samplerate;
uint32_t m_centerFrequency;
uint32_t m_tv_sec;
uint32_t m_tv_usec;
uint64_t m_tv_msec;
MessageQueue *m_outputMessageQueueToGUI;
uint32_t m_tickCount;
std::size_t m_samplesCount;