mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 13:00:26 -04:00 
			
		
		
		
	LimeSDR input: moved FileRecord out of the GUI
This commit is contained in:
		
							parent
							
								
									9da26ad8b3
								
							
						
					
					
						commit
						175fd69014
					
				| @ -23,6 +23,7 @@ | |||||||
| #include "device/devicesourceapi.h" | #include "device/devicesourceapi.h" | ||||||
| #include "device/devicesinkapi.h" | #include "device/devicesinkapi.h" | ||||||
| #include "dsp/dspcommands.h" | #include "dsp/dspcommands.h" | ||||||
|  | #include "dsp/filerecord.h" | ||||||
| #include "limesdrinput.h" | #include "limesdrinput.h" | ||||||
| #include "limesdrinputthread.h" | #include "limesdrinputthread.h" | ||||||
| #include "limesdr/devicelimesdrparam.h" | #include "limesdr/devicelimesdrparam.h" | ||||||
| @ -35,7 +36,7 @@ MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgGetDeviceInfo, Message) | |||||||
| MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgSetReferenceConfig, Message) | MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgSetReferenceConfig, Message) | ||||||
| MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportLimeSDRToGUI, Message) | MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportLimeSDRToGUI, Message) | ||||||
| MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportStreamInfo, Message) | MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportStreamInfo, Message) | ||||||
| 
 | MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgFileRecord, Message) | ||||||
| 
 | 
 | ||||||
| LimeSDRInput::LimeSDRInput(DeviceSourceAPI *deviceAPI) : | LimeSDRInput::LimeSDRInput(DeviceSourceAPI *deviceAPI) : | ||||||
|     m_deviceAPI(deviceAPI), |     m_deviceAPI(deviceAPI), | ||||||
| @ -49,11 +50,18 @@ LimeSDRInput::LimeSDRInput(DeviceSourceAPI *deviceAPI) : | |||||||
|     suspendBuddies(); |     suspendBuddies(); | ||||||
|     openDevice(); |     openDevice(); | ||||||
|     resumeBuddies(); |     resumeBuddies(); | ||||||
|  | 
 | ||||||
|  |     char recFileNameCStr[30]; | ||||||
|  |     sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID()); | ||||||
|  |     m_fileSink = new FileRecord(std::string(recFileNameCStr)); | ||||||
|  |     m_deviceAPI->addSink(m_fileSink); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| LimeSDRInput::~LimeSDRInput() | LimeSDRInput::~LimeSDRInput() | ||||||
| { | { | ||||||
|     if (m_running) stop(); |     if (m_running) stop(); | ||||||
|  |     m_deviceAPI->removeSink(m_fileSink); | ||||||
|  |     delete m_fileSink; | ||||||
|     suspendBuddies(); |     suspendBuddies(); | ||||||
|     closeDevice(); |     closeDevice(); | ||||||
|     resumeBuddies(); |     resumeBuddies(); | ||||||
| @ -483,6 +491,19 @@ bool LimeSDRInput::handleMessage(const Message& message) | |||||||
| 
 | 
 | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |     else if (MsgFileRecord::match(message)) | ||||||
|  |     { | ||||||
|  |         MsgFileRecord& conf = (MsgFileRecord&) message; | ||||||
|  |         qDebug() << "LimeSDRInput::handleMessage: MsgFileRecord: " << conf.getStartStop(); | ||||||
|  | 
 | ||||||
|  |         if (conf.getStartStop()) { | ||||||
|  |             m_fileSink->startRecording(); | ||||||
|  |         } else { | ||||||
|  |             m_fileSink->stopRecording(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         return false; |         return false; | ||||||
| @ -1100,6 +1121,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc | |||||||
|         int ncoShift = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0; |         int ncoShift = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0; | ||||||
|         DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency + ncoShift); |         DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency + ncoShift); | ||||||
|         m_deviceAPI->getDeviceInputMessageQueue()->push(notif); |         m_deviceAPI->getDeviceInputMessageQueue()->push(notif); | ||||||
|  |         m_fileSink->handleMessage(*notif); // forward to file sink
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     qDebug() << "LimeSDRInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz" |     qDebug() << "LimeSDRInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz" | ||||||
|  | |||||||
| @ -27,6 +27,7 @@ | |||||||
| class DeviceSourceAPI; | class DeviceSourceAPI; | ||||||
| class LimeSDRInputThread; | class LimeSDRInputThread; | ||||||
| struct DeviceLimeSDRParams; | struct DeviceLimeSDRParams; | ||||||
|  | class FileRecord; | ||||||
| 
 | 
 | ||||||
| class LimeSDRInput : public DeviceSampleSource | class LimeSDRInput : public DeviceSampleSource | ||||||
| { | { | ||||||
| @ -208,6 +209,25 @@ public: | |||||||
|         { } |         { } | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  |     class MsgFileRecord : public Message { | ||||||
|  |         MESSAGE_CLASS_DECLARATION | ||||||
|  | 
 | ||||||
|  |     public: | ||||||
|  |         bool getStartStop() const { return m_startStop; } | ||||||
|  | 
 | ||||||
|  |         static MsgFileRecord* create(bool startStop) { | ||||||
|  |             return new MsgFileRecord(startStop); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |     protected: | ||||||
|  |         bool m_startStop; | ||||||
|  | 
 | ||||||
|  |         MsgFileRecord(bool startStop) : | ||||||
|  |             Message(), | ||||||
|  |             m_startStop(startStop) | ||||||
|  |         { } | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|     LimeSDRInput(DeviceSourceAPI *deviceAPI); |     LimeSDRInput(DeviceSourceAPI *deviceAPI); | ||||||
|     virtual ~LimeSDRInput(); |     virtual ~LimeSDRInput(); | ||||||
| 
 | 
 | ||||||
| @ -235,8 +255,8 @@ private: | |||||||
|     bool m_running; |     bool m_running; | ||||||
|     DeviceLimeSDRShared m_deviceShared; |     DeviceLimeSDRShared m_deviceShared; | ||||||
|     bool m_firstConfig; |     bool m_firstConfig; | ||||||
| 
 |  | ||||||
|     lms_stream_t m_streamId; |     lms_stream_t m_streamId; | ||||||
|  |     FileRecord *m_fileSink; //!< File sink to record device I/Q output
 | ||||||
| 
 | 
 | ||||||
|     bool openDevice(); |     bool openDevice(); | ||||||
|     void closeDevice(); |     void closeDevice(); | ||||||
|  | |||||||
| @ -27,7 +27,6 @@ | |||||||
| #include "dsp/dspengine.h" | #include "dsp/dspengine.h" | ||||||
| #include "dsp/dspcommands.h" | #include "dsp/dspcommands.h" | ||||||
| #include "device/devicesourceapi.h" | #include "device/devicesourceapi.h" | ||||||
| #include "dsp/filerecord.h" |  | ||||||
| 
 | 
 | ||||||
| LimeSDRInputGUI::LimeSDRInputGUI(DeviceSourceAPI *deviceAPI, QWidget* parent) : | LimeSDRInputGUI::LimeSDRInputGUI(DeviceSourceAPI *deviceAPI, QWidget* parent) : | ||||||
|     QWidget(parent), |     QWidget(parent), | ||||||
| @ -77,18 +76,11 @@ LimeSDRInputGUI::LimeSDRInputGUI(DeviceSourceAPI *deviceAPI, QWidget* parent) : | |||||||
| 
 | 
 | ||||||
|     displaySettings(); |     displaySettings(); | ||||||
| 
 | 
 | ||||||
|     char recFileNameCStr[30]; |  | ||||||
|     sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID()); |  | ||||||
|     m_fileSink = new FileRecord(std::string(recFileNameCStr)); |  | ||||||
|     m_deviceAPI->addSink(m_fileSink); |  | ||||||
| 
 |  | ||||||
|     connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleMessagesToGUI()), Qt::QueuedConnection); |     connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleMessagesToGUI()), Qt::QueuedConnection); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| LimeSDRInputGUI::~LimeSDRInputGUI() | LimeSDRInputGUI::~LimeSDRInputGUI() | ||||||
| { | { | ||||||
|     m_deviceAPI->removeSink(m_fileSink); |  | ||||||
|     delete m_fileSink; |  | ||||||
|     delete m_sampleSource; // Valgrind memcheck
 |     delete m_sampleSource; // Valgrind memcheck
 | ||||||
|     delete ui; |     delete ui; | ||||||
| } | } | ||||||
| @ -166,7 +158,6 @@ void LimeSDRInputGUI::handleMessagesToGUI() | |||||||
|             m_deviceCenterFrequency = notif->getCenterFrequency(); |             m_deviceCenterFrequency = notif->getCenterFrequency(); | ||||||
|             qDebug("LimeSDRInputGUI::handleMessagesToGUI: SampleRate: %d, CenterFrequency: %llu", notif->getSampleRate(), notif->getCenterFrequency()); |             qDebug("LimeSDRInputGUI::handleMessagesToGUI: SampleRate: %d, CenterFrequency: %llu", notif->getSampleRate(), notif->getCenterFrequency()); | ||||||
|             updateSampleRateAndFrequency(); |             updateSampleRateAndFrequency(); | ||||||
|             m_fileSink->handleMessage(*notif); // forward to file sink
 |  | ||||||
| 
 | 
 | ||||||
|             delete message; |             delete message; | ||||||
|         } |         } | ||||||
| @ -418,16 +409,14 @@ void LimeSDRInputGUI::on_startStop_toggled(bool checked) | |||||||
| 
 | 
 | ||||||
| void LimeSDRInputGUI::on_record_toggled(bool checked) | void LimeSDRInputGUI::on_record_toggled(bool checked) | ||||||
| { | { | ||||||
|     if (checked) |     if (checked) { | ||||||
|     { |  | ||||||
|         ui->record->setStyleSheet("QToolButton { background-color : red; }"); |         ui->record->setStyleSheet("QToolButton { background-color : red; }"); | ||||||
|         m_fileSink->startRecording(); |     } else { | ||||||
|     } |  | ||||||
|     else |  | ||||||
|     { |  | ||||||
|         ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); |         ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | ||||||
|         m_fileSink->stopRecording(); |  | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     LimeSDRInput::MsgFileRecord* message = LimeSDRInput::MsgFileRecord::create(checked); | ||||||
|  |     m_sampleSource->getInputMessageQueue()->push(message); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void LimeSDRInputGUI::on_centerFrequency_changed(quint64 value) | void LimeSDRInputGUI::on_centerFrequency_changed(quint64 value) | ||||||
|  | |||||||
| @ -24,7 +24,6 @@ | |||||||
| #include "limesdrinput.h" | #include "limesdrinput.h" | ||||||
| 
 | 
 | ||||||
| class DeviceSourceAPI; | class DeviceSourceAPI; | ||||||
| class FileRecord; |  | ||||||
| 
 | 
 | ||||||
| namespace Ui { | namespace Ui { | ||||||
|     class LimeSDRInputGUI; |     class LimeSDRInputGUI; | ||||||
| @ -57,7 +56,6 @@ private: | |||||||
|     QTimer m_updateTimer; |     QTimer m_updateTimer; | ||||||
|     QTimer m_statusTimer; |     QTimer m_statusTimer; | ||||||
|     DeviceSampleSource* m_sampleSource; |     DeviceSampleSource* m_sampleSource; | ||||||
|     FileRecord *m_fileSink; //!< File sink to record device I/Q output
 |  | ||||||
|     int m_sampleRate; |     int m_sampleRate; | ||||||
|     quint64 m_deviceCenterFrequency; //!< Center frequency in device
 |     quint64 m_deviceCenterFrequency; //!< Center frequency in device
 | ||||||
|     int m_lastEngineState; |     int m_lastEngineState; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user