mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 13:00:26 -04:00 
			
		
		
		
	Multi device support: Aligned SDRDaemon plugin
This commit is contained in:
		
							parent
							
								
									b399cc0dd4
								
							
						
					
					
						commit
						8885f9bcdd
					
				| @ -195,9 +195,9 @@ void FileSourceGui::handleSourceMessages() | ||||
| 
 | ||||
| void FileSourceGui::updateSampleRateAndFrequency() | ||||
| { | ||||
|     m_pluginAPI->getSpectrum()->setSampleRate(m_sampleRate); | ||||
|     m_pluginAPI->getSpectrum()->setSampleRate(m_deviceSampleRate); | ||||
|     m_pluginAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); | ||||
|     ui->deviceRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000)); | ||||
|     ui->deviceRateText->setText(tr("%1k").arg((float)m_deviceSampleRate / 1000)); | ||||
| } | ||||
| 
 | ||||
| void FileSourceGui::displaySettings() | ||||
|  | ||||
| @ -32,7 +32,10 @@ | ||||
| #include "ui_sdrdaemongui.h" | ||||
| #include "plugin/pluginapi.h" | ||||
| #include "gui/colormapper.h" | ||||
| #include "gui/glspectrum.h" | ||||
| #include "dsp/dspengine.h" | ||||
| #include "dsp/dspcommands.h" | ||||
| #include "dsp/filesink.h" | ||||
| #include "mainwindow.h" | ||||
| #include "util/simpleserializer.h" | ||||
| 
 | ||||
| @ -92,10 +95,19 @@ SDRdaemonGui::SDRdaemonGui(PluginAPI* pluginAPI, QWidget* parent) : | ||||
| 	displaySettings(); | ||||
| 	ui->applyButton->setEnabled(false); | ||||
| 	ui->sendButton->setEnabled(false); | ||||
| 
 | ||||
|     char recFileNameCStr[30]; | ||||
|     sprintf(recFileNameCStr, "test_%d.sdriq", m_pluginAPI->getDeviceUID()); | ||||
|     m_fileSink = new FileSink(std::string(recFileNameCStr)); | ||||
|     m_pluginAPI->addSink(m_fileSink); | ||||
| 
 | ||||
|     connect(m_pluginAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection); | ||||
| } | ||||
| 
 | ||||
| SDRdaemonGui::~SDRdaemonGui() | ||||
| { | ||||
|     m_pluginAPI->removeSink(m_fileSink); | ||||
|     delete m_fileSink; | ||||
| 	delete ui; | ||||
| } | ||||
| 
 | ||||
| @ -319,6 +331,28 @@ bool SDRdaemonGui::handleMessage(const Message& message) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void SDRdaemonGui::handleDSPMessages() | ||||
| { | ||||
|     Message* message; | ||||
| 
 | ||||
|     while ((message = m_pluginAPI->getDeviceOutputMessageQueue()->pop()) != 0) | ||||
|     { | ||||
|         qDebug("SDRdaemonGui::handleDSPMessages: message: %s", message->getIdentifier()); | ||||
| 
 | ||||
|         if (DSPSignalNotification::match(*message)) | ||||
|         { | ||||
|             DSPSignalNotification* notif = (DSPSignalNotification*) message; | ||||
|             m_deviceSampleRate = notif->getSampleRate(); | ||||
|             m_deviceCenterFrequency = notif->getCenterFrequency(); | ||||
|             qDebug("SDRdaemonGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); | ||||
|             updateSampleRateAndFrequency(); | ||||
|             m_fileSink->handleMessage(*notif); // forward to file sink
 | ||||
| 
 | ||||
|             delete message; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SDRdaemonGui::handleSourceMessages() | ||||
| { | ||||
| 	Message* message; | ||||
| @ -334,6 +368,13 @@ void SDRdaemonGui::handleSourceMessages() | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void SDRdaemonGui::updateSampleRateAndFrequency() | ||||
| { | ||||
|     m_pluginAPI->getSpectrum()->setSampleRate(m_deviceSampleRate); | ||||
|     m_pluginAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); | ||||
|     ui->deviceRateText->setText(tr("%1k").arg((float)m_deviceSampleRate / 1000)); | ||||
| } | ||||
| 
 | ||||
| void SDRdaemonGui::displaySettings() | ||||
| { | ||||
| 	ui->address->setText(m_address); | ||||
| @ -557,6 +598,20 @@ void SDRdaemonGui::on_startStop_toggled(bool checked) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SDRdaemonGui::on_record_toggled(bool checked) | ||||
| { | ||||
|     if (checked) | ||||
|     { | ||||
|         ui->record->setStyleSheet("QToolButton { background-color : red; }"); | ||||
|         m_fileSink->startRecording(); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | ||||
|         m_fileSink->stopRecording(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SDRdaemonGui::configureUDPLink() | ||||
| { | ||||
| 	qDebug() << "SDRdaemonGui::configureUDPLink: " << m_address.toStdString().c_str() | ||||
|  | ||||
| @ -24,6 +24,7 @@ | ||||
| #include "sdrdaemoninput.h" | ||||
| 
 | ||||
| class PluginAPI; | ||||
| class FileSink; | ||||
| 
 | ||||
| namespace Ui { | ||||
| 	class SDRdaemonGui; | ||||
| @ -55,6 +56,9 @@ private: | ||||
| 	QTimer m_statusTimer; | ||||
| 	SampleSource* m_sampleSource; | ||||
|     bool m_acquisition; | ||||
|     FileSink *m_fileSink; //!< File sink to record device I/Q output
 | ||||
|     int m_deviceSampleRate; | ||||
|     quint64 m_deviceCenterFrequency; //!< Center frequency in device
 | ||||
|     int m_lastEngineState; | ||||
| 
 | ||||
| 	int m_sampleRate; | ||||
| @ -103,8 +107,10 @@ private: | ||||
| 	void updateWithStreamData(); | ||||
| 	void updateWithStreamTime(); | ||||
| 	void sendConfiguration(); | ||||
|     void updateSampleRateAndFrequency(); | ||||
| 
 | ||||
| private slots: | ||||
|     void handleDSPMessages(); | ||||
| 	void handleSourceMessages(); | ||||
| 	void on_applyButton_clicked(bool checked); | ||||
| 	void on_dcOffset_toggled(bool checked); | ||||
| @ -122,6 +128,7 @@ private slots: | ||||
| 	void on_decim_currentIndexChanged(int index); | ||||
| 	void on_fcPos_currentIndexChanged(int index); | ||||
| 	void on_startStop_toggled(bool checked); | ||||
|     void on_record_toggled(bool checked); | ||||
| 	void updateStatus(); | ||||
| 	void tick(); | ||||
| }; | ||||
|  | ||||
| @ -35,19 +35,58 @@ | ||||
|    <item> | ||||
|     <layout class="QHBoxLayout" name="horizontalLayout_freq"> | ||||
|      <item> | ||||
|       <widget class="ButtonSwitch" name="startStop"> | ||||
|        <property name="toolTip"> | ||||
|         <string>start/stop acquisition</string> | ||||
|        </property> | ||||
|        <property name="text"> | ||||
|         <string/> | ||||
|        </property> | ||||
|        <property name="icon"> | ||||
|         <iconset resource="../../../sdrbase/resources/res.qrc"> | ||||
|          <normaloff>:/play.png</normaloff> | ||||
|          <normalon>:/stop.png</normalon>:/play.png</iconset> | ||||
|        </property> | ||||
|       </widget> | ||||
|        <layout class="QVBoxLayout" name="deviceUILayout"> | ||||
|          <item> | ||||
|            <layout class="QHBoxLayout" name="deviceButtonsLayout"> | ||||
|              <item> | ||||
|               <widget class="ButtonSwitch" name="startStop"> | ||||
|                <property name="toolTip"> | ||||
|                 <string>start/stop acquisition</string> | ||||
|                </property> | ||||
|                <property name="text"> | ||||
|                 <string/> | ||||
|                </property> | ||||
|                <property name="icon"> | ||||
|                 <iconset resource="../../../sdrbase/resources/res.qrc"> | ||||
|                  <normaloff>:/play.png</normaloff> | ||||
|                  <normalon>:/stop.png</normalon>:/play.png</iconset> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|              <item> | ||||
|               <widget class="ButtonSwitch" name="record"> | ||||
|                <property name="toolTip"> | ||||
|                 <string>Toggle record I/Q samples from device</string> | ||||
|                </property> | ||||
|                <property name="text"> | ||||
|                 <string/> | ||||
|                </property> | ||||
|                <property name="icon"> | ||||
|                 <iconset resource="../../../sdrbase/resources/res.qrc"> | ||||
|                  <normaloff>:/record_off.png</normaloff>:/record_off.png</iconset> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item>              | ||||
|            </layout> | ||||
|          </item> | ||||
|          <item> | ||||
|             <layout class="QHBoxLayout" name="deviceRateLayout"> | ||||
|              <item> | ||||
|               <widget class="QLabel" name="deviceRateText"> | ||||
|                <property name="toolTip"> | ||||
|                 <string>I/Q sample rate kS/s</string> | ||||
|                </property> | ||||
|                <property name="text"> | ||||
|                 <string>00000k</string> | ||||
|                </property> | ||||
|                <property name="alignment"> | ||||
|                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|             </layout>          | ||||
|          </item> | ||||
|        </layout> | ||||
|      </item> | ||||
|      <item> | ||||
|       <spacer name="freqLeftSpacer"> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user