kopia lustrzana https://github.com/f4exb/sdrangel
				
				
				
			Multi device support: Aligned Funcube Pro plugin
							rodzic
							
								
									ea1f2208f7
								
							
						
					
					
						commit
						25197faa7a
					
				|  | @ -19,7 +19,10 @@ | |||
| #include "ui_fcdprogui.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 "fcdprogui.h" | ||||
| #include "fcdproconst.h" | ||||
| 
 | ||||
|  | @ -139,10 +142,19 @@ FCDProGui::FCDProGui(PluginAPI* pluginAPI, QWidget* parent) : | |||
| 
 | ||||
| 	m_sampleSource = new FCDProInput(); | ||||
| 	DSPEngine::instance()->setSource(m_sampleSource); | ||||
| 
 | ||||
|     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); | ||||
| } | ||||
| 
 | ||||
| FCDProGui::~FCDProGui() | ||||
| { | ||||
|     m_pluginAPI->removeSink(m_fileSink); | ||||
|     delete m_fileSink; | ||||
| 	delete ui; | ||||
| } | ||||
| 
 | ||||
|  | @ -205,6 +217,35 @@ bool FCDProGui::handleMessage(const Message& message) | |||
| 	return false; | ||||
| } | ||||
| 
 | ||||
| void FCDProGui::handleDSPMessages() | ||||
| { | ||||
|     Message* message; | ||||
| 
 | ||||
|     while ((message = m_pluginAPI->getDeviceOutputMessageQueue()->pop()) != 0) | ||||
|     { | ||||
|         qDebug("FCDProGui::handleDSPMessages: message: %s", message->getIdentifier()); | ||||
| 
 | ||||
|         if (DSPSignalNotification::match(*message)) | ||||
|         { | ||||
|             DSPSignalNotification* notif = (DSPSignalNotification*) message; | ||||
|             m_sampleRate = notif->getSampleRate(); | ||||
|             m_deviceCenterFrequency = notif->getCenterFrequency(); | ||||
|             qDebug("FCDProGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); | ||||
|             updateSampleRateAndFrequency(); | ||||
|             m_fileSink->handleMessage(*notif); // forward to file sink
 | ||||
| 
 | ||||
|             delete message; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void FCDProGui::updateSampleRateAndFrequency() | ||||
| { | ||||
|     m_pluginAPI->getSpectrum()->setSampleRate(m_sampleRate); | ||||
|     m_pluginAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); | ||||
|     ui->deviceRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000)); | ||||
| } | ||||
| 
 | ||||
| void FCDProGui::displaySettings() | ||||
| { | ||||
| 	ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); | ||||
|  | @ -396,6 +437,20 @@ void FCDProGui::on_startStop_toggled(bool checked) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void FCDProGui::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 FCDProGui::updateStatus() | ||||
| { | ||||
|     int state = m_pluginAPI->state(); | ||||
|  |  | |||
|  | @ -23,6 +23,7 @@ | |||
| #include "plugin/plugingui.h" | ||||
| 
 | ||||
| class PluginAPI; | ||||
| class FileSink; | ||||
| 
 | ||||
| namespace Ui { | ||||
| 	class FCDProGui; | ||||
|  | @ -56,12 +57,17 @@ private: | |||
| 	QTimer m_statusTimer; | ||||
| 	std::vector<int> m_gains; | ||||
| 	SampleSource* m_sampleSource; | ||||
|     FileSink *m_fileSink; //!< File sink to record device I/Q output
 | ||||
|     int m_sampleRate; | ||||
|     quint64 m_deviceCenterFrequency; //!< Center frequency in device
 | ||||
| 	int m_lastEngineState; | ||||
| 
 | ||||
| 	void displaySettings(); | ||||
| 	void sendSettings(); | ||||
| 	void updateSampleRateAndFrequency(); | ||||
| 
 | ||||
| private slots: | ||||
|     void handleDSPMessages(); | ||||
| 	void on_centerFrequency_changed(quint64 value); | ||||
| 	void on_ppm_valueChanged(int value); | ||||
| 	void on_dcOffset_toggled(bool checked); | ||||
|  | @ -85,6 +91,7 @@ private slots: | |||
| 	void on_gain6_currentIndexChanged(int index); | ||||
| 	void on_setDefaults_clicked(bool checked); | ||||
| 	void on_startStop_toggled(bool checked); | ||||
| 	void on_record_toggled(bool checked); | ||||
| 	void updateHardware(); | ||||
| 	void updateStatus(); | ||||
| }; | ||||
|  |  | |||
|  | @ -38,16 +38,55 @@ | |||
|    <item> | ||||
|     <layout class="QHBoxLayout" name="layoutFrequency"> | ||||
|      <item> | ||||
|       <widget class="ButtonSwitch" name="startStop"> | ||||
|        <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="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="horizontalSpacer"> | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 f4exb
						f4exb