mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 21:54:55 -04:00
MIMO: test MI source: implemented file record
This commit is contained in:
@@ -49,11 +49,9 @@ TestMI::TestMI(DeviceAPI *deviceAPI) :
|
||||
m_running(false),
|
||||
m_masterTimer(deviceAPI->getMasterTimer())
|
||||
{
|
||||
m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
|
||||
m_deviceAPI->setNbSourceStreams(2);
|
||||
m_deviceAPI->addSourceStream(true); // Add a new source stream data set in the engine - asynchronous handling of FIFOs
|
||||
m_deviceAPI->addSourceStream(true); // Add a new source stream data set in the engine - asynchronous handling of FIFOs
|
||||
//m_deviceAPI->addAncillarySink(m_fileSink); TODO: implement when active
|
||||
m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4));
|
||||
m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4));
|
||||
m_networkManager = new QNetworkAccessManager();
|
||||
@@ -69,10 +67,17 @@ TestMI::~TestMI()
|
||||
stop();
|
||||
}
|
||||
|
||||
m_deviceAPI->removeAncillarySink(m_fileSink);
|
||||
std::vector<FileRecord*>::iterator it = m_fileSinks.begin();
|
||||
int istream = 0;
|
||||
|
||||
for (; it != m_fileSinks.end(); ++it, istream++)
|
||||
{
|
||||
m_deviceAPI->removeAncillarySink(*it, istream);
|
||||
delete *it;
|
||||
}
|
||||
|
||||
m_deviceAPI->removeLastSourceStream(); // Remove the last source stream data set in the engine
|
||||
m_deviceAPI->removeLastSourceStream(); // Remove the last source stream data set in the engine
|
||||
delete m_fileSink;
|
||||
}
|
||||
|
||||
void TestMI::destroy()
|
||||
@@ -82,6 +87,11 @@ void TestMI::destroy()
|
||||
|
||||
void TestMI::init()
|
||||
{
|
||||
m_fileSinks.push_back(new FileRecord(QString("test_0_%1.sdriq").arg(m_deviceAPI->getDeviceUID())));
|
||||
m_fileSinks.push_back(new FileRecord(QString("test_1_%1.sdriq").arg(m_deviceAPI->getDeviceUID())));
|
||||
m_deviceAPI->addAncillarySink(m_fileSinks[0], 0);
|
||||
m_deviceAPI->addAncillarySink(m_fileSinks[1], 1);
|
||||
|
||||
applySettings(m_settings, true);
|
||||
}
|
||||
|
||||
@@ -216,20 +226,21 @@ bool TestMI::handleMessage(const Message& message)
|
||||
{
|
||||
MsgFileRecord& conf = (MsgFileRecord&) message;
|
||||
qDebug() << "TestMI::handleMessage: MsgFileRecord: " << conf.getStartStop();
|
||||
int istream = conf.getStreamIndex();
|
||||
|
||||
if (conf.getStartStop())
|
||||
{
|
||||
if (m_settings.m_fileRecordName.size() != 0) {
|
||||
m_fileSink->setFileName(m_settings.m_fileRecordName);
|
||||
m_fileSinks[istream]->setFileName(m_settings.m_fileRecordName + "_0.sdriq");
|
||||
} else {
|
||||
m_fileSink->genUniqueFileName(m_deviceAPI->getDeviceUID());
|
||||
m_fileSinks[istream]->genUniqueFileName(m_deviceAPI->getDeviceUID(), istream);
|
||||
}
|
||||
|
||||
m_fileSink->startRecording();
|
||||
m_fileSinks[istream]->startRecording();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fileSink->stopRecording();
|
||||
m_fileSinks[istream]->stopRecording();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -421,7 +432,7 @@ bool TestMI::applySettings(const TestMISettings& settings, bool force)
|
||||
{
|
||||
int sampleRate = settings.m_streams[istream].m_sampleRate/(1<<settings.m_streams[istream].m_log2Decim);
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, settings.m_streams[istream].m_centerFrequency);
|
||||
m_fileSink->handleMessage(*notif); // forward to file sink
|
||||
m_fileSinks[istream]->handleMessage(*notif); // forward to file sink
|
||||
DSPDeviceMIMOEngine::SignalNotification *engineNotif = new DSPDeviceMIMOEngine::SignalNotification(
|
||||
sampleRate, settings.m_streams[istream].m_centerFrequency, true, 0);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(engineNotif);
|
||||
@@ -820,3 +831,12 @@ void TestMI::networkManagerFinished(QNetworkReply *reply)
|
||||
answer.chop(1); // remove last \n
|
||||
qDebug("TestMI::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
||||
}
|
||||
|
||||
bool TestMI::isRecording(unsigned int istream) const
|
||||
{
|
||||
if (istream < m_fileSinks.size()) {
|
||||
return m_fileSinks[istream]->isRecording();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -63,17 +63,20 @@ public:
|
||||
|
||||
public:
|
||||
bool getStartStop() const { return m_startStop; }
|
||||
int getStreamIndex() const { return m_streamIndex; }
|
||||
|
||||
static MsgFileRecord* create(bool startStop) {
|
||||
return new MsgFileRecord(startStop);
|
||||
static MsgFileRecord* create(bool startStop, int streamIndex) {
|
||||
return new MsgFileRecord(startStop, streamIndex);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool m_startStop;
|
||||
int m_streamIndex;
|
||||
|
||||
MsgFileRecord(bool startStop) :
|
||||
MsgFileRecord(bool startStop, int streamIndex) :
|
||||
Message(),
|
||||
m_startStop(startStop)
|
||||
m_startStop(startStop),
|
||||
m_streamIndex(streamIndex)
|
||||
{ }
|
||||
};
|
||||
|
||||
@@ -141,6 +144,8 @@ public:
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
|
||||
bool isRecording(unsigned int istream) const;
|
||||
|
||||
private:
|
||||
struct DeviceSettingsKeys
|
||||
{
|
||||
@@ -149,7 +154,7 @@ private:
|
||||
};
|
||||
|
||||
DeviceAPI *m_deviceAPI;
|
||||
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
||||
std::vector<FileRecord *> m_fileSinks; //!< File sinks to record device I/Q output
|
||||
QMutex m_mutex;
|
||||
TestMISettings m_settings;
|
||||
std::vector<TestMIThread*> m_testSourceThreads;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 //
|
||||
@@ -145,6 +145,7 @@ void TestMIGui::on_startStop_toggled(bool checked)
|
||||
void TestMIGui::on_streamIndex_currentIndexChanged(int index)
|
||||
{
|
||||
m_streamIndex = index;
|
||||
updateFileRecordStatus();
|
||||
displaySettings();
|
||||
}
|
||||
|
||||
@@ -296,7 +297,7 @@ void TestMIGui::on_record_toggled(bool checked)
|
||||
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
}
|
||||
|
||||
TestMI::MsgFileRecord* message = TestMI::MsgFileRecord::create(checked);
|
||||
TestMI::MsgFileRecord* message = TestMI::MsgFileRecord::create(checked, m_streamIndex);
|
||||
m_sampleMIMO->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
@@ -376,6 +377,15 @@ void TestMIGui::updateFrequencyShiftLimit()
|
||||
ui->frequencyShift->setValueRange(false, 7, -sampleRate, sampleRate);
|
||||
}
|
||||
|
||||
void TestMIGui::updateFileRecordStatus()
|
||||
{
|
||||
if (((TestMI*) m_sampleMIMO)->isRecording(m_streamIndex)) {
|
||||
ui->record->setStyleSheet("QToolButton { background-color : red; }");
|
||||
} else {
|
||||
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
}
|
||||
}
|
||||
|
||||
void TestMIGui::displaySettings()
|
||||
{
|
||||
blockApplySettings(true);
|
||||
|
||||
@@ -77,6 +77,7 @@ private:
|
||||
void updateAmpCoarseLimit();
|
||||
void updateAmpFineLimit();
|
||||
void updateFrequencyShiftLimit();
|
||||
void updateFileRecordStatus();
|
||||
|
||||
private slots:
|
||||
void handleInputMessages();
|
||||
|
||||
Reference in New Issue
Block a user