mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 04:50:29 -04:00 
			
		
		
		
	New devices handling (1)
This commit is contained in:
		
							parent
							
								
									21ba11d90e
								
							
						
					
					
						commit
						55ad76f43c
					
				| @ -45,7 +45,7 @@ set(sdrbase_SOURCES | ||||
| 
 | ||||
|     device/devicesourceapi.cpp | ||||
|     device/devicesinkapi.cpp | ||||
| #    device/deviceenumerator.cpp | ||||
|     device/deviceenumerator.cpp | ||||
| 
 | ||||
|     settings/preferences.cpp | ||||
|     settings/preset.cpp | ||||
| @ -127,7 +127,7 @@ set(sdrbase_HEADERS | ||||
| 
 | ||||
|     device/devicesourceapi.h | ||||
|     device/devicesinkapi.h | ||||
| #    device/deviceenumerator.h | ||||
|     device/deviceenumerator.h | ||||
| 
 | ||||
|     plugin/plugininstancegui.h | ||||
|     plugin/plugininterface.h | ||||
|  | ||||
							
								
								
									
										179
									
								
								sdrbase/device/deviceenumerator.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										179
									
								
								sdrbase/device/deviceenumerator.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,179 @@ | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| // Copyright (C) 2016 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          //
 | ||||
| // the Free Software Foundation as version 3 of the License, or                  //
 | ||||
| //                                                                               //
 | ||||
| // This program is distributed in the hope that it will be useful,               //
 | ||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | ||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | ||||
| // GNU General Public License V3 for more details.                               //
 | ||||
| //                                                                               //
 | ||||
| // You should have received a copy of the GNU General Public License             //
 | ||||
| // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| #include <QGlobalStatic> | ||||
| 
 | ||||
| #include "plugin/pluginmanager.h" | ||||
| #include "deviceenumerator.h" | ||||
| 
 | ||||
| Q_GLOBAL_STATIC(DeviceEnumerator, deviceEnumerator) | ||||
| DeviceEnumerator *DeviceEnumerator::instance() | ||||
| { | ||||
|     return deviceEnumerator; | ||||
| } | ||||
| 
 | ||||
| DeviceEnumerator::DeviceEnumerator() | ||||
| {} | ||||
| 
 | ||||
| DeviceEnumerator::~DeviceEnumerator() | ||||
| {} | ||||
| 
 | ||||
| void DeviceEnumerator::enumerateRxDevices(PluginManager *pluginManager) | ||||
| { | ||||
|     m_rxEnumeration.clear(); | ||||
|     PluginAPI::SamplingDeviceRegistrations& rxDeviceRegistrations = pluginManager->getSourceDeviceRegistrations(); | ||||
|     int index = 0; | ||||
| 
 | ||||
|     for (int i = 0; i < rxDeviceRegistrations.count(); i++) | ||||
|     { | ||||
|         PluginInterface::SamplingDevices samplingDevices = rxDeviceRegistrations[i].m_plugin->enumSampleSources(); | ||||
| 
 | ||||
|         for (int j = 0; j < samplingDevices.count(); j++) | ||||
|         { | ||||
|             m_rxEnumeration.push_back( | ||||
|                 DeviceEnumeration( | ||||
|                     samplingDevices[j], | ||||
|                     rxDeviceRegistrations[i].m_plugin, | ||||
|                     index | ||||
|                 ) | ||||
|             ); | ||||
|             index++; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::enumerateTxDevices(PluginManager *pluginManager) | ||||
| { | ||||
|     m_txEnumeration.clear(); | ||||
|     PluginAPI::SamplingDeviceRegistrations& txDeviceRegistrations = pluginManager->getSinkDeviceRegistrations(); | ||||
|     int index = 0; | ||||
| 
 | ||||
|     for (int i = 0; i < txDeviceRegistrations.count(); i++) | ||||
|     { | ||||
|         PluginInterface::SamplingDevices samplingDevices = txDeviceRegistrations[i].m_plugin->enumSampleSources(); | ||||
| 
 | ||||
|         for (int j = 0; j < samplingDevices.count(); j++) | ||||
|         { | ||||
|             m_rxEnumeration.push_back( | ||||
|                 DeviceEnumeration( | ||||
|                     samplingDevices[j], | ||||
|                     txDeviceRegistrations[i].m_plugin, | ||||
|                     index | ||||
|                 ) | ||||
|             ); | ||||
|             index++; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::listRxDeviceNames(QList<QString>& list, std::vector<int>& indexes) const | ||||
| { | ||||
|     for (DevicesEnumeration::const_iterator it = m_rxEnumeration.begin(); it != m_rxEnumeration.end(); ++it) | ||||
|     { | ||||
|         if ((it->m_samplingDevice.claimed < 0) || (it->m_samplingDevice.type == PluginInterface::SamplingDevice::BuiltInDevice)) | ||||
|         { | ||||
|             list.append(it->m_samplingDevice.displayedName); | ||||
|             indexes.push_back(it->m_index); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::listTxDeviceNames(QList<QString>& list, std::vector<int>& indexes) const | ||||
| { | ||||
|     for (DevicesEnumeration::const_iterator it = m_txEnumeration.begin(); it != m_txEnumeration.end(); ++it) | ||||
|     { | ||||
|         if ((it->m_samplingDevice.claimed < 0) || (it->m_samplingDevice.type == PluginInterface::SamplingDevice::BuiltInDevice)) | ||||
|         { | ||||
|             list.append(it->m_samplingDevice.displayedName); | ||||
|             indexes.push_back(it->m_index); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::changeRxSelection(int tabIndex, int deviceIndex) | ||||
| { | ||||
|     for (DevicesEnumeration::iterator it = m_rxEnumeration.begin(); it != m_rxEnumeration.end(); ++it) | ||||
|     { | ||||
|         if (it->m_samplingDevice.claimed == tabIndex) { | ||||
|             it->m_samplingDevice.claimed = -1; | ||||
|         } | ||||
|         if (it->m_index == deviceIndex) { | ||||
|             it->m_samplingDevice.claimed = tabIndex; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::changeTxSelection(int tabIndex, int deviceIndex) | ||||
| { | ||||
|     for (DevicesEnumeration::iterator it = m_txEnumeration.begin(); it != m_txEnumeration.end(); ++it) | ||||
|     { | ||||
|         if (it->m_samplingDevice.claimed == tabIndex) { | ||||
|             it->m_samplingDevice.claimed = -1; | ||||
|         } | ||||
|         if (it->m_index == deviceIndex) { | ||||
|             it->m_samplingDevice.claimed = tabIndex; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| int DeviceEnumerator::getFileSourceDeviceIndex() const | ||||
| { | ||||
|     for (DevicesEnumeration::const_iterator it = m_rxEnumeration.begin(); it != m_rxEnumeration.end(); ++it) | ||||
|     { | ||||
|         if (it->m_samplingDevice.id == PluginManager::getFileSourceDeviceId()) { | ||||
|             return it->m_index; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return -1; | ||||
| } | ||||
| 
 | ||||
| int DeviceEnumerator::getFileSinkDeviceIndex() const | ||||
| { | ||||
|     for (DevicesEnumeration::const_iterator it = m_txEnumeration.begin(); it != m_txEnumeration.end(); ++it) | ||||
|     { | ||||
|         if (it->m_samplingDevice.id == PluginManager::getFileSinkDeviceId()) { | ||||
|             return it->m_index; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return -1; | ||||
| } | ||||
| 
 | ||||
| int DeviceEnumerator::getRxSamplingDeviceIndex(const QString& deviceId, int sequence) | ||||
| { | ||||
|     for (DevicesEnumeration::iterator it = m_rxEnumeration.begin(); it != m_rxEnumeration.end(); ++it) | ||||
|     { | ||||
|         if ((it->m_samplingDevice.id == deviceId) && (it->m_samplingDevice.sequence == sequence)) { | ||||
|             return it->m_index; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return -1; | ||||
| } | ||||
| 
 | ||||
| int DeviceEnumerator::getTxSamplingDeviceIndex(const QString& deviceId, int sequence) | ||||
| { | ||||
|     for (DevicesEnumeration::iterator it = m_txEnumeration.begin(); it != m_txEnumeration.end(); ++it) | ||||
|     { | ||||
|         if ((it->m_samplingDevice.id == deviceId) && (it->m_samplingDevice.sequence == sequence)) { | ||||
|             return it->m_index; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return -1; | ||||
| } | ||||
| 
 | ||||
							
								
								
									
										69
									
								
								sdrbase/device/deviceenumerator.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								sdrbase/device/deviceenumerator.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,69 @@ | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| // Copyright (C) 2016 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          //
 | ||||
| // the Free Software Foundation as version 3 of the License, or                  //
 | ||||
| //                                                                               //
 | ||||
| // This program is distributed in the hope that it will be useful,               //
 | ||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | ||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | ||||
| // GNU General Public License V3 for more details.                               //
 | ||||
| //                                                                               //
 | ||||
| // You should have received a copy of the GNU General Public License             //
 | ||||
| // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| #ifndef SDRBASE_DEVICE_DEVICEENUMERATOR_H_ | ||||
| #define SDRBASE_DEVICE_DEVICEENUMERATOR_H_ | ||||
| 
 | ||||
| #include <vector> | ||||
| 
 | ||||
| #include "plugin/plugininterface.h" | ||||
| 
 | ||||
| class PluginManager; | ||||
| 
 | ||||
| class DeviceEnumerator | ||||
| { | ||||
| public: | ||||
|     DeviceEnumerator(); | ||||
|     ~DeviceEnumerator(); | ||||
| 
 | ||||
|     static DeviceEnumerator *instance(); | ||||
| 
 | ||||
|     void enumerateRxDevices(PluginManager *pluginManager); | ||||
|     void enumerateTxDevices(PluginManager *pluginManager); | ||||
|     void listRxDeviceNames(QList<QString>& list, std::vector<int>& indexes) const; | ||||
|     void listTxDeviceNames(QList<QString>& list, std::vector<int>& indexes) const; | ||||
|     void changeRxSelection(int tabIndex, int deviceIndex); | ||||
|     void changeTxSelection(int tabIndex, int deviceIndex); | ||||
|     PluginInterface::SamplingDevice getRxSamplingDevice(int deviceIndex) const { return m_rxEnumeration[deviceIndex].m_samplingDevice; } | ||||
|     PluginInterface::SamplingDevice getTxSamplingDevice(int deviceIndex) const { return m_txEnumeration[deviceIndex].m_samplingDevice; } | ||||
|     PluginInterface *getRxPluginInterface(int deviceIndex) { return m_rxEnumeration[deviceIndex].m_pluginInterface; } | ||||
|     PluginInterface *getTxPluginInterface(int deviceIndex) { return m_txEnumeration[deviceIndex].m_pluginInterface; } | ||||
|     int getFileSourceDeviceIndex() const; | ||||
|     int getFileSinkDeviceIndex() const; | ||||
|     int getRxSamplingDeviceIndex(const QString& deviceId, int sequence); | ||||
|     int getTxSamplingDeviceIndex(const QString& deviceId, int sequence); | ||||
| 
 | ||||
| private: | ||||
|     struct DeviceEnumeration | ||||
|     { | ||||
|         PluginInterface::SamplingDevice m_samplingDevice; | ||||
|         PluginInterface *m_pluginInterface; | ||||
|         int m_index; | ||||
| 
 | ||||
|         DeviceEnumeration(const PluginInterface::SamplingDevice& samplingDevice, PluginInterface *pluginInterface, int index) : | ||||
|             m_samplingDevice(samplingDevice), | ||||
|             m_pluginInterface(pluginInterface), | ||||
|             m_index(index) | ||||
|         {} | ||||
|     }; | ||||
| 
 | ||||
|     typedef std::vector<DeviceEnumeration> DevicesEnumeration; | ||||
| 
 | ||||
|     DevicesEnumeration m_rxEnumeration; | ||||
|     DevicesEnumeration m_txEnumeration; | ||||
| }; | ||||
| 
 | ||||
| #endif /* SDRBASE_DEVICE_DEVICEENUMERATOR_H_ */ | ||||
| @ -17,6 +17,18 @@ class SDRANGEL_API PluginAPI : public QObject { | ||||
| 	Q_OBJECT | ||||
| 
 | ||||
| public: | ||||
|     struct SamplingDeviceRegistration //!< This is the device registration
 | ||||
|     { | ||||
|         QString m_deviceId; | ||||
|         PluginInterface* m_plugin; | ||||
|         SamplingDeviceRegistration(const QString& deviceId, PluginInterface* plugin) : | ||||
|             m_deviceId(deviceId), | ||||
|             m_plugin(plugin) | ||||
|         { } | ||||
|     }; | ||||
| 
 | ||||
|     typedef QList<SamplingDeviceRegistration> SamplingDeviceRegistrations; | ||||
| 
 | ||||
|     struct ChannelRegistration | ||||
|     { | ||||
|         QString m_channelId;       //!< Channel or device type ID
 | ||||
|  | ||||
| @ -24,6 +24,7 @@ | ||||
| #include <plugin/plugininstancegui.h> | ||||
| #include "device/devicesourceapi.h" | ||||
| #include "device/devicesinkapi.h" | ||||
| #include "device/deviceenumerator.h" | ||||
| #include "settings/preset.h" | ||||
| #include "util/message.h" | ||||
| #include "dsp/dspdevicesourceengine.h" | ||||
| @ -71,9 +72,8 @@ void PluginManager::loadPlugins() | ||||
| 		it->pluginInterface->initPlugin(&m_pluginAPI); | ||||
| 	} | ||||
| 
 | ||||
| 	// TODO: enumerate with DeviceEnumerator
 | ||||
| 	updateSampleSourceDevices(); | ||||
| 	updateSampleSinkDevices(); | ||||
| 	DeviceEnumerator::instance()->enumerateRxDevices(this); | ||||
| 	DeviceEnumerator::instance()->enumerateTxDevices(this); | ||||
| } | ||||
| 
 | ||||
| void PluginManager::registerRxChannel(const QString& channelName, PluginInterface* plugin) | ||||
| @ -100,7 +100,7 @@ void PluginManager::registerSampleSource(const QString& sourceName, PluginInterf | ||||
| 			<< plugin->getPluginDescriptor().displayedName.toStdString().c_str() | ||||
| 			<< " with source name " << sourceName.toStdString().c_str(); | ||||
| 
 | ||||
| 	m_sampleSourceRegistrations.append(SamplingDeviceRegistration(sourceName, plugin)); | ||||
| 	m_sampleSourceRegistrations.append(PluginAPI::SamplingDeviceRegistration(sourceName, plugin)); | ||||
| } | ||||
| 
 | ||||
| void PluginManager::registerSampleSink(const QString& sinkName, PluginInterface* plugin) | ||||
| @ -109,418 +109,7 @@ void PluginManager::registerSampleSink(const QString& sinkName, PluginInterface* | ||||
| 			<< plugin->getPluginDescriptor().displayedName.toStdString().c_str() | ||||
| 			<< " with sink name " << sinkName.toStdString().c_str(); | ||||
| 
 | ||||
| 	m_sampleSinkRegistrations.append(SamplingDeviceRegistration(sinkName, plugin)); | ||||
| } | ||||
| 
 | ||||
| void PluginManager::updateSampleSourceDevices() | ||||
| { | ||||
| 	m_sampleSourceDevices.clear(); | ||||
| 
 | ||||
| 	for(int i = 0; i < m_sampleSourceRegistrations.count(); ++i) | ||||
| 	{ | ||||
| 		PluginInterface::SamplingDevices ssd = m_sampleSourceRegistrations[i].m_plugin->enumSampleSources(); | ||||
| 
 | ||||
| 		for(int j = 0; j < ssd.count(); ++j) | ||||
| 		{ | ||||
| 			m_sampleSourceDevices.append(SamplingDevice(m_sampleSourceRegistrations[i].m_plugin, | ||||
| 					ssd[j].displayedName, | ||||
|                     ssd[j].hardwareId, | ||||
| 					ssd[j].id, | ||||
| 					ssd[j].serial, | ||||
| 					ssd[j].sequence)); | ||||
|             qDebug("PluginManager::updateSampleSourceDevices: %s %s %s %s %d", | ||||
|                     qPrintable(ssd[j].displayedName), | ||||
|                     qPrintable(ssd[j].hardwareId), | ||||
|                     qPrintable(ssd[j].id), | ||||
|                     qPrintable(ssd[j].serial), | ||||
|                     ssd[j].sequence); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void PluginManager::updateSampleSinkDevices() | ||||
| { | ||||
| 	m_sampleSinkDevices.clear(); | ||||
| 
 | ||||
| 	for(int i = 0; i < m_sampleSinkRegistrations.count(); ++i) | ||||
| 	{ | ||||
| 		PluginInterface::SamplingDevices ssd = m_sampleSinkRegistrations[i].m_plugin->enumSampleSinks(); | ||||
| 
 | ||||
| 		for(int j = 0; j < ssd.count(); ++j) | ||||
| 		{ | ||||
| 			m_sampleSinkDevices.append(SamplingDevice(m_sampleSinkRegistrations[i].m_plugin, | ||||
| 					ssd[j].displayedName, | ||||
| 					ssd[j].hardwareId, | ||||
|                     ssd[j].id, | ||||
| 					ssd[j].serial, | ||||
| 					ssd[j].sequence)); | ||||
|             qDebug("PluginManager::updateSampleSinkDevices: %s %s %s %s %d", | ||||
|                     qPrintable(ssd[j].displayedName), | ||||
|                     qPrintable(ssd[j].hardwareId), | ||||
|                     qPrintable(ssd[j].id), | ||||
|                     qPrintable(ssd[j].serial), | ||||
|                     ssd[j].sequence); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void PluginManager::duplicateLocalSampleSourceDevices(uint deviceUID) | ||||
| { | ||||
|     if (deviceUID == 0) { | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     SamplingDevice *sdrDaemonSSD0 = 0; | ||||
|     SamplingDevice *fileSourceSSD0 = 0; | ||||
|     bool duplicateSDRDaemon = true; | ||||
|     bool duplicateFileSource = true; | ||||
| 
 | ||||
|     for(int i = 0; i < m_sampleSourceDevices.count(); ++i) | ||||
|     { | ||||
|         if (m_sampleSourceDevices[i].m_deviceId == m_sdrDaemonSourceDeviceTypeID) // SDRdaemon
 | ||||
|         { | ||||
|             if (m_sampleSourceDevices[i].m_deviceSequence == 0) { // reference to device 0
 | ||||
|                 sdrDaemonSSD0 = &m_sampleSourceDevices[i]; | ||||
|             } | ||||
|             else if (m_sampleSourceDevices[i].m_deviceSequence == deviceUID) { // already there
 | ||||
|                 duplicateSDRDaemon = false; | ||||
|             } | ||||
|         } | ||||
|         else if (m_sampleSourceDevices[i].m_deviceId == m_fileSourceDeviceTypeID) // File Source
 | ||||
|         { | ||||
|             if (m_sampleSourceDevices[i].m_deviceSequence == 0) { // reference to device 0
 | ||||
|                 fileSourceSSD0 = &m_sampleSourceDevices[i]; | ||||
|             } | ||||
|             else if (m_sampleSourceDevices[i].m_deviceSequence == deviceUID) { // already there
 | ||||
|                 duplicateFileSource = false; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (sdrDaemonSSD0 && duplicateSDRDaemon) // append item for a new instance
 | ||||
|     { | ||||
|         m_sampleSourceDevices.append( | ||||
|             SamplingDevice( | ||||
|                 sdrDaemonSSD0->m_plugin, | ||||
|                 QString("SDRdaemonSource[%1]").arg(deviceUID), | ||||
|                 sdrDaemonSSD0->m_hadrwareId, | ||||
|                 sdrDaemonSSD0->m_deviceId, | ||||
|                 sdrDaemonSSD0->m_deviceSerial, | ||||
|                 deviceUID | ||||
|             ) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     if (fileSourceSSD0 && duplicateFileSource) // append item for a new instance
 | ||||
|     { | ||||
|         m_sampleSourceDevices.append( | ||||
|             SamplingDevice( | ||||
|                 fileSourceSSD0->m_plugin, | ||||
|                 QString("FileSource[%1]").arg(deviceUID), | ||||
|                 fileSourceSSD0->m_hadrwareId, | ||||
|                 fileSourceSSD0->m_deviceId, | ||||
|                 fileSourceSSD0->m_deviceSerial, | ||||
|                 deviceUID | ||||
|             ) | ||||
|         ); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void PluginManager::duplicateLocalSampleSinkDevices(uint deviceUID) | ||||
| { | ||||
|     if (deviceUID == 0) { | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     SamplingDevice *fileSinkSSD0 = 0; | ||||
|     bool duplicateFileSink = true; | ||||
| 
 | ||||
|     for(int i = 0; i < m_sampleSinkDevices.count(); ++i) | ||||
|     { | ||||
|         if (m_sampleSinkDevices[i].m_deviceId == m_fileSinkDeviceTypeID) // File Sink
 | ||||
|         { | ||||
|             if (m_sampleSinkDevices[i].m_deviceSequence == 0) { // reference to device 0
 | ||||
|             	fileSinkSSD0 = &m_sampleSinkDevices[i]; | ||||
|             } | ||||
|             else if (m_sampleSinkDevices[i].m_deviceSequence == deviceUID) { // already there
 | ||||
|                 duplicateFileSink = false; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (fileSinkSSD0 && duplicateFileSink) // append item for a new instance
 | ||||
|     { | ||||
|     	m_sampleSinkDevices.append( | ||||
|             SamplingDevice( | ||||
|             	fileSinkSSD0->m_plugin, | ||||
|                 QString("FileSink[%1]").arg(deviceUID), | ||||
|                 fileSinkSSD0->m_hadrwareId, | ||||
| 				fileSinkSSD0->m_deviceId, | ||||
| 				fileSinkSSD0->m_deviceSerial, | ||||
|                 deviceUID | ||||
|             ) | ||||
|         ); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void PluginManager::fillSampleSourceSelector( | ||||
|         QComboBox* comboBox __attribute__((unused)), | ||||
|         uint deviceUID __attribute__((unused))) | ||||
| { | ||||
| //	comboBox->clear();
 | ||||
| //
 | ||||
| //	for(int i = 0; i < m_sampleSourceDevices.count(); i++)
 | ||||
| //	{
 | ||||
| //	    // For "local" devices show only ones that concern this device set
 | ||||
| //	    if ((m_sampleSourceDevices[i].m_deviceId == m_sdrDaemonSourceDeviceTypeID)
 | ||||
| //	            || (m_sampleSourceDevices[i].m_deviceId == m_fileSourceDeviceTypeID))
 | ||||
| //	    {
 | ||||
| //	        if (deviceUID != m_sampleSourceDevices[i].m_deviceSequence) {
 | ||||
| //	            continue;
 | ||||
| //	        }
 | ||||
| //	    }
 | ||||
| //
 | ||||
| //		comboBox->addItem(m_sampleSourceDevices[i].m_displayName, qVariantFromValue((void *) &m_sampleSourceDevices[i]));
 | ||||
| //	}
 | ||||
| } | ||||
| 
 | ||||
| void PluginManager::fillSampleSinkSelector( | ||||
|         QComboBox* comboBox __attribute__((unused)), | ||||
|         uint deviceUID __attribute__((unused))) | ||||
| { | ||||
| //	comboBox->clear();
 | ||||
| //
 | ||||
| //	for(int i = 0; i < m_sampleSinkDevices.count(); i++)
 | ||||
| //	{
 | ||||
| //	    // For "local" devices show only ones that concern this device set
 | ||||
| //	    if (m_sampleSinkDevices[i].m_deviceId == m_fileSinkDeviceTypeID)
 | ||||
| //	    {
 | ||||
| //	        if (deviceUID != m_sampleSinkDevices[i].m_deviceSequence) {
 | ||||
| //	            continue;
 | ||||
| //	        }
 | ||||
| //	    }
 | ||||
| //
 | ||||
| //		comboBox->addItem(m_sampleSinkDevices[i].m_displayName, qVariantFromValue((void *) &m_sampleSinkDevices[i]));
 | ||||
| //	}
 | ||||
| } | ||||
| 
 | ||||
| int PluginManager::selectSampleSourceByIndex(int index, DeviceSourceAPI *deviceAPI) | ||||
| { | ||||
| 	qDebug("PluginManager::selectSampleSourceByIndex: index: %d", index); | ||||
| 
 | ||||
| 	if (m_sampleSourceDevices.count() == 0) | ||||
| 	{ | ||||
| 		return -1; | ||||
| 	} | ||||
| 
 | ||||
| 	if (index < 0) | ||||
| 	{ | ||||
| 		return -1; | ||||
| 	} | ||||
| 
 | ||||
| 	if (index >= m_sampleSourceDevices.count()) | ||||
| 	{ | ||||
| 		index = 0; | ||||
| 	} | ||||
| 
 | ||||
|     qDebug() << "PluginManager::selectSampleSourceByIndex: m_sampleSource at index " << index | ||||
|             << " hid: " << m_sampleSourceDevices[index].m_hadrwareId.toStdString().c_str() | ||||
|             << " id: " << m_sampleSourceDevices[index].m_deviceId.toStdString().c_str() | ||||
|             << " ser: " << m_sampleSourceDevices[index].m_deviceSerial.toStdString().c_str() | ||||
|             << " seq: " << m_sampleSourceDevices[index].m_deviceSequence; | ||||
| 
 | ||||
|     deviceAPI->stopAcquisition(); | ||||
| 
 | ||||
|     deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_deviceSequence); | ||||
|     deviceAPI->setHardwareId(m_sampleSourceDevices[index].m_hadrwareId); | ||||
|     deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_deviceId); | ||||
|     deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_deviceSerial); | ||||
|     deviceAPI->setSampleSourceDisplayName(m_sampleSourceDevices[index].m_displayName); | ||||
|     deviceAPI->setSampleSourcePluginInterface(m_sampleSourceDevices[index].m_plugin); | ||||
| 
 | ||||
| 	return index; | ||||
| } | ||||
| 
 | ||||
| int PluginManager::selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, uint32_t sourceSequence, DeviceSourceAPI *deviceAPI) | ||||
| { | ||||
| 	qDebug("PluginManager::selectSampleSourceBySequence by sequence: id: %s ser: %s seq: %d", qPrintable(sourceId), qPrintable(sourceSerial), sourceSequence); | ||||
| 
 | ||||
| 	int index = -1; | ||||
| 	int index_matchingSequence = -1; | ||||
| 	int index_firstOfKind = -1; | ||||
| 
 | ||||
| 	for (int i = 0; i < m_sampleSourceDevices.count(); i++) | ||||
| 	{ | ||||
| 		if (m_sampleSourceDevices[i].m_deviceId == sourceId) | ||||
| 		{ | ||||
| 			index_firstOfKind = i; | ||||
| 
 | ||||
| 			if (m_sampleSourceDevices[i].m_deviceSerial == sourceSerial) | ||||
| 			{ | ||||
| 				index = i; // exact match
 | ||||
| 				break; | ||||
| 			} | ||||
| 
 | ||||
| 			if (m_sampleSourceDevices[i].m_deviceSequence == sourceSequence) | ||||
| 			{ | ||||
| 				index_matchingSequence = i; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if(index == -1) // no exact match
 | ||||
| 	{ | ||||
| 		if (index_matchingSequence == -1) // no matching sequence
 | ||||
| 		{ | ||||
| 			if (index_firstOfKind == -1) // no matching device type
 | ||||
| 			{ | ||||
| 				if(m_sampleSourceDevices.count() > 0) // take first if any
 | ||||
| 				{ | ||||
| 					index = 0; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					return -1; // return if no device attached
 | ||||
| 				} | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				index = index_firstOfKind; // take first that matches device type
 | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			index = index_matchingSequence; // take the one that matches the sequence in the device type
 | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|     qDebug() << "PluginManager::selectSampleSourceBySequence: m_sampleSource at index " << index | ||||
|             << " hid: " << m_sampleSourceDevices[index].m_hadrwareId.toStdString().c_str() | ||||
|             << " id: " << m_sampleSourceDevices[index].m_deviceId.toStdString().c_str() | ||||
|             << " ser: " << m_sampleSourceDevices[index].m_deviceSerial.toStdString().c_str() | ||||
|             << " seq: " << m_sampleSourceDevices[index].m_deviceSequence; | ||||
| 
 | ||||
|     deviceAPI->stopAcquisition(); | ||||
| 
 | ||||
| 	//	m_sampleSourcePluginGUI = pluginGUI;
 | ||||
|     deviceAPI->setSampleSourceSequence(m_sampleSourceDevices[index].m_deviceSequence); | ||||
|     deviceAPI->setHardwareId(m_sampleSourceDevices[index].m_hadrwareId); | ||||
|     deviceAPI->setSampleSourceId(m_sampleSourceDevices[index].m_deviceId); | ||||
|     deviceAPI->setSampleSourceSerial(m_sampleSourceDevices[index].m_deviceSerial); | ||||
|     deviceAPI->setSampleSourceDisplayName(m_sampleSourceDevices[index].m_displayName); | ||||
|     deviceAPI->setSampleSourcePluginInterface(m_sampleSourceDevices[index].m_plugin); | ||||
| 
 | ||||
| 	return index; | ||||
| } | ||||
| 
 | ||||
| int PluginManager::selectSampleSinkBySerialOrSequence(const QString& sinkId, const QString& sinkSerial, uint32_t sinkSequence, DeviceSinkAPI *deviceAPI) | ||||
| { | ||||
| 	qDebug("PluginManager::selectSampleSinkBySerialOrSequence by sequence: id: %s ser: %s seq: %d", qPrintable(sinkId), qPrintable(sinkSerial), sinkSequence); | ||||
| 
 | ||||
| 	int index = -1; | ||||
| 	int index_matchingSequence = -1; | ||||
| 	int index_firstOfKind = -1; | ||||
| 
 | ||||
| 	for (int i = 0; i < m_sampleSinkDevices.count(); i++) | ||||
| 	{ | ||||
| 		if (m_sampleSinkDevices[i].m_deviceId == sinkId) | ||||
| 		{ | ||||
| 			index_firstOfKind = i; | ||||
| 
 | ||||
| 			if (m_sampleSinkDevices[i].m_deviceSerial == sinkSerial) | ||||
| 			{ | ||||
| 				index = i; // exact match
 | ||||
| 				break; | ||||
| 			} | ||||
| 
 | ||||
| 			if (m_sampleSinkDevices[i].m_deviceSequence == sinkSequence) | ||||
| 			{ | ||||
| 				index_matchingSequence = i; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if(index == -1) // no exact match
 | ||||
| 	{ | ||||
| 		if (index_matchingSequence == -1) // no matching sequence
 | ||||
| 		{ | ||||
| 			if (index_firstOfKind == -1) // no matching device type
 | ||||
| 			{ | ||||
| 				if(m_sampleSinkDevices.count() > 0) // take first if any
 | ||||
| 				{ | ||||
| 					index = 0; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					return -1; // return if no device attached
 | ||||
| 				} | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				index = index_firstOfKind; // take first that matches device type
 | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			index = index_matchingSequence; // take the one that matches the sequence in the device type
 | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|     qDebug() << "PluginManager::selectSampleSinkBySerialOrSequence: m_sampleSink at index " << index | ||||
|             << " hid: " << m_sampleSinkDevices[index].m_hadrwareId.toStdString().c_str() | ||||
|             << " id: " << m_sampleSinkDevices[index].m_deviceId.toStdString().c_str() | ||||
|             << " ser: " << m_sampleSinkDevices[index].m_deviceSerial.toStdString().c_str() | ||||
|             << " seq: " << m_sampleSinkDevices[index].m_deviceSequence; | ||||
| 
 | ||||
|     deviceAPI->stopGeneration(); | ||||
| 
 | ||||
| 	//	m_sampleSourcePluginGUI = pluginGUI;
 | ||||
|     deviceAPI->setSampleSinkSequence(m_sampleSinkDevices[index].m_deviceSequence); | ||||
|     deviceAPI->setHardwareId(m_sampleSinkDevices[index].m_hadrwareId); | ||||
|     deviceAPI->setSampleSinkId(m_sampleSinkDevices[index].m_deviceId); | ||||
|     deviceAPI->setSampleSinkSerial(m_sampleSinkDevices[index].m_deviceSerial); | ||||
|     deviceAPI->setSampleSinkDisplayName(m_sampleSinkDevices[index].m_displayName); | ||||
|     deviceAPI->setSampleSinkPluginInterface(m_sampleSinkDevices[index].m_plugin); | ||||
| 
 | ||||
| 	return index; | ||||
| } | ||||
| 
 | ||||
| void PluginManager::selectSampleSourceByDevice(void *devicePtr, DeviceSourceAPI *deviceAPI) | ||||
| { | ||||
|     SamplingDevice *sampleSourceDevice = (SamplingDevice *) devicePtr; | ||||
| 
 | ||||
|     qDebug() << "PluginManager::selectSampleSourceByDevice: " | ||||
|             << " hid: " << sampleSourceDevice->m_hadrwareId.toStdString().c_str() | ||||
|             << " id: " << sampleSourceDevice->m_deviceId.toStdString().c_str() | ||||
|             << " ser: " << sampleSourceDevice->m_deviceSerial.toStdString().c_str() | ||||
|             << " seq: " << sampleSourceDevice->m_deviceSequence; | ||||
| 
 | ||||
|     //  m_sampleSourcePluginGUI = pluginGUI;
 | ||||
|     deviceAPI->setSampleSourceSequence(sampleSourceDevice->m_deviceSequence); | ||||
|     deviceAPI->setHardwareId(sampleSourceDevice->m_hadrwareId); | ||||
|     deviceAPI->setSampleSourceId(sampleSourceDevice->m_deviceId); | ||||
|     deviceAPI->setSampleSourceSerial(sampleSourceDevice->m_deviceSerial); | ||||
|     deviceAPI->setSampleSourceDisplayName(sampleSourceDevice->m_displayName); | ||||
|     deviceAPI->setSampleSourcePluginInterface(sampleSourceDevice->m_plugin); | ||||
| } | ||||
| 
 | ||||
| void PluginManager::selectSampleSinkByDevice(void *devicePtr, DeviceSinkAPI *deviceAPI) | ||||
| { | ||||
|     SamplingDevice *sampleSinkDevice = (SamplingDevice *) devicePtr; | ||||
| 
 | ||||
|     qDebug() << "PluginManager::selectSampleSinkByDevice: " | ||||
|             << " hid: " << sampleSinkDevice->m_hadrwareId.toStdString().c_str() | ||||
|             << " id: " << sampleSinkDevice->m_deviceId.toStdString().c_str() | ||||
|             << " ser: " << sampleSinkDevice->m_deviceSerial.toStdString().c_str() | ||||
|             << " seq: " << sampleSinkDevice->m_deviceSequence; | ||||
| 
 | ||||
|     //  m_sampleSourcePluginGUI = pluginGUI;
 | ||||
|     deviceAPI->setSampleSinkSequence(sampleSinkDevice->m_deviceSequence); | ||||
|     deviceAPI->setHardwareId(sampleSinkDevice->m_hadrwareId); | ||||
|     deviceAPI->setSampleSinkId(sampleSinkDevice->m_deviceId); | ||||
|     deviceAPI->setSampleSinkSerial(sampleSinkDevice->m_deviceSerial); | ||||
|     deviceAPI->setSampleSinkDisplayName(sampleSinkDevice->m_displayName); | ||||
|     deviceAPI->setSampleSinkPluginInterface(sampleSinkDevice->m_plugin); | ||||
| 	m_sampleSinkRegistrations.append(PluginAPI::SamplingDeviceRegistration(sinkName, plugin)); | ||||
| } | ||||
| 
 | ||||
| void PluginManager::loadPlugins(const QDir& dir) | ||||
| @ -566,15 +155,6 @@ void PluginManager::loadPlugins(const QDir& dir) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| PluginInterface* PluginManager::getPluginInterfaceAt(int index) | ||||
| { | ||||
|     if (index < m_sampleSourceDevices.size()) { | ||||
|         return m_sampleSourceDevices[index].m_plugin; | ||||
|     } else { | ||||
|         return 0; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void PluginManager::listTxChannels(QList<QString>& list) | ||||
| { | ||||
|     list.clear(); | ||||
|  | ||||
| @ -51,45 +51,21 @@ public: | ||||
| 	void registerTxChannel(const QString& channelName, PluginInterface* plugin); | ||||
| 	void registerSampleSink(const QString& sourceName, PluginInterface* plugin); | ||||
| 
 | ||||
| 	PluginAPI::SamplingDeviceRegistrations& getSourceDeviceRegistrations() { return m_sampleSourceRegistrations; } | ||||
| 	PluginAPI::SamplingDeviceRegistrations& getSinkDeviceRegistrations() { return m_sampleSinkRegistrations; } | ||||
| 	PluginAPI::ChannelRegistrations *getRxChannelRegistrations() { return &m_rxChannelRegistrations; } | ||||
| 	PluginAPI::ChannelRegistrations *getTxChannelRegistrations() { return &m_txChannelRegistrations; } | ||||
| 
 | ||||
| 	void updateSampleSourceDevices(); | ||||
| 	void duplicateLocalSampleSourceDevices(uint deviceUID); | ||||
| 	void fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID); | ||||
| 
 | ||||
| 	void updateSampleSinkDevices(); | ||||
| 	void duplicateLocalSampleSinkDevices(uint deviceUID); | ||||
| 	void fillSampleSinkSelector(QComboBox* comboBox, uint deviceUID); | ||||
| 
 | ||||
| 	int selectSampleSourceByIndex(int index, DeviceSourceAPI *deviceAPI); | ||||
| 	int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, uint32_t sourceSequence, DeviceSourceAPI *deviceAPI); | ||||
| 	void selectSampleSourceByDevice(void *devicePtr, DeviceSourceAPI *deviceAPI); | ||||
| 
 | ||||
| 	int selectSampleSinkBySerialOrSequence(const QString& sinkId, const QString& sinkSerial, uint32_t sinkSequence, DeviceSinkAPI *deviceAPI); | ||||
| 	void selectSampleSinkByDevice(void *devicePtr, DeviceSinkAPI *deviceAPI); | ||||
| 
 | ||||
| 	PluginInterface* getPluginInterfaceAt(int index); | ||||
| 
 | ||||
|     void createRxChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet); | ||||
|     void listRxChannels(QList<QString>& list); | ||||
| 
 | ||||
| 	void createTxChannelInstance(int channelPluginIndex, DeviceUISet *deviceUISet); | ||||
| 	void listTxChannels(QList<QString>& list); | ||||
| 
 | ||||
| 	static const QString& getFileSourceDeviceId() { return m_fileSourceDeviceTypeID; } | ||||
| 	static const QString& getFileSinkDeviceId() { return m_fileSinkDeviceTypeID; } | ||||
| 
 | ||||
| private: | ||||
| 	struct SamplingDeviceRegistration //!< This is the channel registration
 | ||||
| 	{ | ||||
| 		QString m_deviceId; | ||||
| 		PluginInterface* m_plugin; | ||||
| 		SamplingDeviceRegistration(const QString& deviceId, PluginInterface* plugin) : | ||||
| 			m_deviceId(deviceId), | ||||
| 			m_plugin(plugin) | ||||
| 		{ } | ||||
| 	}; | ||||
| 
 | ||||
| 	typedef QList<SamplingDeviceRegistration> SamplingDeviceRegistrations; | ||||
| 
 | ||||
| 	struct SamplingDevice { //!< This is the device registration
 | ||||
| 		PluginInterface* m_plugin; | ||||
| 		QString m_displayName; | ||||
| @ -118,13 +94,11 @@ private: | ||||
| 	PluginAPI m_pluginAPI; | ||||
| 	Plugins m_plugins; | ||||
| 
 | ||||
| 	PluginAPI::ChannelRegistrations m_rxChannelRegistrations; //!< Channel plugins register here
 | ||||
| 	SamplingDeviceRegistrations m_sampleSourceRegistrations;  //!< Input source plugins (one per device kind) register here
 | ||||
| 	SamplingDevices m_sampleSourceDevices;                    //!< Instances of input sources present in the system
 | ||||
| 	PluginAPI::ChannelRegistrations m_rxChannelRegistrations;           //!< Channel plugins register here
 | ||||
| 	PluginAPI::SamplingDeviceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
 | ||||
| 
 | ||||
| 	PluginAPI::ChannelRegistrations m_txChannelRegistrations; //!< Channel plugins register here
 | ||||
| 	SamplingDeviceRegistrations m_sampleSinkRegistrations;    //!< Output sink plugins (one per device kind) register here
 | ||||
| 	SamplingDevices m_sampleSinkDevices;                      //!< Instances of output sinks present in the system
 | ||||
| 	PluginAPI::ChannelRegistrations m_txChannelRegistrations;         //!< Channel plugins register here
 | ||||
| 	PluginAPI::SamplingDeviceRegistrations m_sampleSinkRegistrations; //!< Output sink plugins (one per device kind) register here
 | ||||
| 
 | ||||
| 	// "Local" sample source device IDs
 | ||||
|     static const QString m_sdrDaemonSourceHardwareID;   //!< SDRdaemon source hardware ID
 | ||||
|  | ||||
| @ -25,6 +25,8 @@ public: | ||||
| 	Preset* getWorkingPreset() { return &m_workingPreset; } | ||||
| 	int getSourceIndex() const { return m_preferences.getSourceIndex(); } | ||||
| 	void setSourceIndex(int value) { m_preferences.setSourceIndex(value); } | ||||
| 	const QString& getSourceDeviceId() const { return m_preferences.getSourceDevice(); } | ||||
| 	void setSourceDeviceId(const QString& deviceId) { m_preferences.setSourceDevice(deviceId); } | ||||
| 
 | ||||
| 	void setLatitude(float latitude) { m_preferences.setLatitude(latitude); } | ||||
| 	void setLongitude(float longitude) { m_preferences.setLongitude(longitude); } | ||||
|  | ||||
| @ -29,6 +29,7 @@ set(sdrgui_SOURCES | ||||
|     gui/presetitem.cpp | ||||
|     gui/rollupwidget.cpp | ||||
|     gui/samplingdevicecontrol.cpp | ||||
|     gui/samplingdevicedialog.cpp | ||||
|     gui/scale.cpp | ||||
|     gui/scaleengine.cpp | ||||
|     gui/transverterbutton.cpp | ||||
| @ -75,6 +76,7 @@ set(sdrgui_HEADERS | ||||
|     gui/presetitem.h | ||||
|     gui/rollupwidget.h | ||||
|     gui/samplingdevicecontrol.h | ||||
|     gui/samplingdevicedialog.h | ||||
|     gui/scale.h | ||||
|     gui/scaleengine.h | ||||
|     gui/transverterbutton.h | ||||
| @ -111,6 +113,7 @@ set(sdrgui_FORMS | ||||
|     gui/pluginsdialog.ui | ||||
|     gui/audiodialog.ui | ||||
|     gui/samplingdevicecontrol.ui | ||||
|     gui/samplingdevicedialog.ui | ||||
|     gui/myposdialog.ui | ||||
|     gui/transverterdialog.ui | ||||
| ) | ||||
|  | ||||
| @ -32,7 +32,7 @@ | ||||
| 
 | ||||
| #include "deviceuiset.h" | ||||
| 
 | ||||
| DeviceUISet::DeviceUISet(int tabIndex, QTimer& timer) | ||||
| DeviceUISet::DeviceUISet(int tabIndex, bool rxElseTx, QTimer& timer) | ||||
| { | ||||
|     m_spectrum = new GLSpectrum; | ||||
|     m_spectrumVis = new SpectrumVis(m_spectrum); | ||||
| @ -40,7 +40,7 @@ DeviceUISet::DeviceUISet(int tabIndex, QTimer& timer) | ||||
|     m_spectrumGUI = new GLSpectrumGUI; | ||||
|     m_spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, m_spectrum); | ||||
|     m_channelWindow = new ChannelWindow; | ||||
|     m_samplingDeviceControl = new SamplingDeviceControl(tabIndex); | ||||
|     m_samplingDeviceControl = new SamplingDeviceControl(tabIndex, rxElseTx); | ||||
|     m_deviceSourceEngine = 0; | ||||
|     m_deviceSourceAPI = 0; | ||||
|     m_deviceSinkEngine = 0; | ||||
|  | ||||
| @ -45,7 +45,7 @@ struct DeviceUISet | ||||
|     DeviceSinkAPI *m_deviceSinkAPI; | ||||
|     QByteArray m_mainWindowState; | ||||
| 
 | ||||
|     DeviceUISet(int tabIndex, QTimer& timer); | ||||
|     DeviceUISet(int tabIndex, bool rxElseTx, QTimer& timer); | ||||
|     ~DeviceUISet(); | ||||
| 
 | ||||
|     GLSpectrum *getSpectrum() { return m_spectrum; }     //!< Direct spectrum getter
 | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| // Copyright (C) 2015 Edouard Griffiths, F4EXB                                   //
 | ||||
| // Copyright (C) 2015-2017 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          //
 | ||||
| @ -14,17 +14,20 @@ | ||||
| // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| #include "gui/samplingdevicecontrol.h" | ||||
| #include "gui/pluginsdialog.h" | ||||
| #include "samplingdevicecontrol.h" | ||||
| #include "samplingdevicedialog.h" | ||||
| #include "plugin/pluginmanager.h" | ||||
| #include "device/deviceenumerator.h" | ||||
| #include "ui_samplingdevicecontrol.h" | ||||
| 
 | ||||
| 
 | ||||
| SamplingDeviceControl::SamplingDeviceControl(int tabIndex, QWidget* parent) : | ||||
| SamplingDeviceControl::SamplingDeviceControl(int tabIndex, bool rxElseTx, QWidget* parent) : | ||||
|     QWidget(parent), | ||||
|     ui(new Ui::SamplingDeviceControl), | ||||
|     m_pluginManager(0), | ||||
|     m_deviceTabIndex(tabIndex) | ||||
|     m_deviceTabIndex(tabIndex), | ||||
|     m_rxElseTx(rxElseTx), | ||||
|     m_selectedDeviceIndex(-1) | ||||
| { | ||||
|     ui->setupUi(this); | ||||
| } | ||||
| @ -34,14 +37,40 @@ SamplingDeviceControl::~SamplingDeviceControl() | ||||
|     delete ui; | ||||
| } | ||||
| 
 | ||||
| QComboBox *SamplingDeviceControl::getDeviceSelector() | ||||
| void SamplingDeviceControl::on_deviceChange_clicked() | ||||
| { | ||||
|     return ui->deviceSelect; | ||||
|     SamplingDeviceDialog dialog(m_rxElseTx, m_deviceTabIndex, this); | ||||
|     dialog.exec(); | ||||
| 
 | ||||
|     if (dialog.getSelectedDeviceIndex() >= 0) | ||||
|     { | ||||
|         m_selectedDeviceIndex = dialog.getSelectedDeviceIndex(); | ||||
|         setSelectedDeviceIndex(m_selectedDeviceIndex); | ||||
|         emit changed(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| QPushButton *SamplingDeviceControl::getDeviceSelectionConfirm() | ||||
| void SamplingDeviceControl::on_deviceReload_clicked() | ||||
| { | ||||
|     return ui->deviceConfirm; | ||||
|     if (m_selectedDeviceIndex >= 0) { | ||||
|         emit changed(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SamplingDeviceControl::setSelectedDeviceIndex(int index) | ||||
| { | ||||
|     if (m_rxElseTx) | ||||
|     { | ||||
|         PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(index); | ||||
|         ui->deviceSelectedText->setText(samplingDevice.displayedName); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(index); | ||||
|         ui->deviceSelectedText->setText(samplingDevice.displayedName); | ||||
|     } | ||||
| 
 | ||||
|     m_selectedDeviceIndex = index; | ||||
| } | ||||
| 
 | ||||
| QComboBox *SamplingDeviceControl::getChannelSelector() | ||||
|  | ||||
| @ -37,19 +37,29 @@ class SDRANGEL_API SamplingDeviceControl : public QWidget { | ||||
|     Q_OBJECT | ||||
| 
 | ||||
| public: | ||||
|     explicit SamplingDeviceControl(int tabIndex, QWidget* parent = 0); | ||||
|     explicit SamplingDeviceControl(int tabIndex, bool rxElseTx, QWidget* parent = 0); | ||||
|     ~SamplingDeviceControl(); | ||||
| 
 | ||||
|     int getSelectedDeviceIndex() const { return m_selectedDeviceIndex; } | ||||
|     void setSelectedDeviceIndex(int index); | ||||
| 
 | ||||
|     void setPluginManager(PluginManager *pluginManager) { m_pluginManager = pluginManager; } | ||||
|     QComboBox *getDeviceSelector(); | ||||
|     QPushButton *getDeviceSelectionConfirm(); | ||||
|     QComboBox *getChannelSelector(); | ||||
|     QPushButton *getAddChannelButton(); | ||||
| 
 | ||||
| private slots: | ||||
|     void on_deviceChange_clicked(); | ||||
|     void on_deviceReload_clicked(); | ||||
| 
 | ||||
| private: | ||||
|     Ui::SamplingDeviceControl* ui; | ||||
|     PluginManager *m_pluginManager; | ||||
|     int m_deviceTabIndex; | ||||
|     bool m_rxElseTx; | ||||
|     int m_selectedDeviceIndex; | ||||
| 
 | ||||
| signals: | ||||
|     void changed(); | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -35,20 +35,29 @@ | ||||
|    <property name="spacing"> | ||||
|     <number>3</number> | ||||
|    </property> | ||||
|    <property name="margin"> | ||||
|    <property name="leftMargin"> | ||||
|     <number>2</number> | ||||
|    </property> | ||||
|    <property name="topMargin"> | ||||
|     <number>2</number> | ||||
|    </property> | ||||
|    <property name="rightMargin"> | ||||
|     <number>2</number> | ||||
|    </property> | ||||
|    <property name="bottomMargin"> | ||||
|     <number>2</number> | ||||
|    </property> | ||||
|    <item> | ||||
|     <layout class="QHBoxLayout" name="deviceSelectLayout"> | ||||
|      <item> | ||||
|       <widget class="QComboBox" name="deviceSelect"> | ||||
|        <property name="toolTip"> | ||||
|         <string>Select sampling device</string> | ||||
|       <widget class="QLabel" name="deviceSelectedText"> | ||||
|        <property name="text"> | ||||
|         <string>Device</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QPushButton" name="deviceConfirm"> | ||||
|       <widget class="QPushButton" name="deviceChange"> | ||||
|        <property name="minimumSize"> | ||||
|         <size> | ||||
|          <width>24</width> | ||||
| @ -62,14 +71,34 @@ | ||||
|         </size> | ||||
|        </property> | ||||
|        <property name="toolTip"> | ||||
|         <string>Confirm and change sampling device</string> | ||||
|         <string>Change sampling device</string> | ||||
|        </property> | ||||
|        <property name="text"> | ||||
|         <string/> | ||||
|        </property> | ||||
|        <property name="icon"> | ||||
|         <iconset resource="../resources/res.qrc"> | ||||
|          <normaloff>:/checkmark.png</normaloff>:/checkmark.png</iconset> | ||||
|          <normaloff>:/choose.png</normaloff>:/choose.png</iconset> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QPushButton" name="deviceReload"> | ||||
|        <property name="maximumSize"> | ||||
|         <size> | ||||
|          <width>24</width> | ||||
|          <height>16777215</height> | ||||
|         </size> | ||||
|        </property> | ||||
|        <property name="toolTip"> | ||||
|         <string>Reload sampling device</string> | ||||
|        </property> | ||||
|        <property name="text"> | ||||
|         <string/> | ||||
|        </property> | ||||
|        <property name="icon"> | ||||
|         <iconset resource="../resources/res.qrc"> | ||||
|          <normaloff>:/recycle.png</normaloff>:/recycle.png</iconset> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|  | ||||
							
								
								
									
										63
									
								
								sdrgui/gui/samplingdevicedialog.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								sdrgui/gui/samplingdevicedialog.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,63 @@ | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| // Copyright (C) 2017 F4EXB                                                      //
 | ||||
| // written by Edouard Griffiths                                                  //
 | ||||
| //                                                                               //
 | ||||
| // OpenGL interface modernization.                                               //
 | ||||
| // See: http://doc.qt.io/qt-5/qopenglshaderprogram.html                          //
 | ||||
| //                                                                               //
 | ||||
| // 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          //
 | ||||
| // the Free Software Foundation as version 3 of the License, or                  //
 | ||||
| //                                                                               //
 | ||||
| // This program is distributed in the hope that it will be useful,               //
 | ||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | ||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | ||||
| // GNU General Public License V3 for more details.                               //
 | ||||
| //                                                                               //
 | ||||
| // You should have received a copy of the GNU General Public License             //
 | ||||
| // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| #include "samplingdevicedialog.h" | ||||
| #include "ui_samplingdevicedialog.h" | ||||
| #include "device/deviceenumerator.h" | ||||
| 
 | ||||
| 
 | ||||
| SamplingDeviceDialog::SamplingDeviceDialog(bool rxElseTx, int deviceTabIndex, QWidget* parent) : | ||||
|     QDialog(parent), | ||||
|     ui(new Ui::SamplingDeviceDialog), | ||||
|     m_rxElseTx(rxElseTx), | ||||
|     m_deviceTabIndex(deviceTabIndex), | ||||
|     m_selectedDeviceIndex(-1) | ||||
| { | ||||
|     ui->setupUi(this); | ||||
| 
 | ||||
|     QList<QString> deviceDisplayNames; | ||||
| 
 | ||||
|     if (m_rxElseTx) { | ||||
|         DeviceEnumerator::instance()->listRxDeviceNames(deviceDisplayNames, m_deviceIndexes); | ||||
|     } else { | ||||
|         DeviceEnumerator::instance()->listTxDeviceNames(deviceDisplayNames, m_deviceIndexes); | ||||
|     } | ||||
| 
 | ||||
|     QStringList devicesNamesList(deviceDisplayNames); | ||||
|     ui->deviceSelect->addItems(devicesNamesList); | ||||
| } | ||||
| 
 | ||||
| SamplingDeviceDialog::~SamplingDeviceDialog() | ||||
| { | ||||
|     delete ui; | ||||
| } | ||||
| 
 | ||||
| void SamplingDeviceDialog::accept() | ||||
| { | ||||
|     m_selectedDeviceIndex = m_deviceIndexes[ui->deviceSelect->currentIndex()]; | ||||
| 
 | ||||
|     if (m_rxElseTx) { | ||||
|         DeviceEnumerator::instance()->changeRxSelection(m_deviceTabIndex, m_selectedDeviceIndex); | ||||
|     } else { | ||||
|         DeviceEnumerator::instance()->changeTxSelection(m_deviceTabIndex, m_selectedDeviceIndex); | ||||
|     } | ||||
| 
 | ||||
|     QDialog::accept(); | ||||
| } | ||||
							
								
								
									
										50
									
								
								sdrgui/gui/samplingdevicedialog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								sdrgui/gui/samplingdevicedialog.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,50 @@ | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| // Copyright (C) 2017 F4EXB                                                      //
 | ||||
| // written by Edouard Griffiths                                                  //
 | ||||
| //                                                                               //
 | ||||
| // OpenGL interface modernization.                                               //
 | ||||
| // See: http://doc.qt.io/qt-5/qopenglshaderprogram.html                          //
 | ||||
| //                                                                               //
 | ||||
| // 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          //
 | ||||
| // the Free Software Foundation as version 3 of the License, or                  //
 | ||||
| //                                                                               //
 | ||||
| // This program is distributed in the hope that it will be useful,               //
 | ||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | ||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | ||||
| // GNU General Public License V3 for more details.                               //
 | ||||
| //                                                                               //
 | ||||
| // You should have received a copy of the GNU General Public License             //
 | ||||
| // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| #ifndef SDRGUI_GUI_SAMPLINGDEVICEDIALOG_H_ | ||||
| #define SDRGUI_GUI_SAMPLINGDEVICEDIALOG_H_ | ||||
| 
 | ||||
| #include <QDialog> | ||||
| #include <vector> | ||||
| 
 | ||||
| namespace Ui { | ||||
|     class SamplingDeviceDialog; | ||||
| } | ||||
| 
 | ||||
| class SamplingDeviceDialog : public QDialog { | ||||
|     Q_OBJECT | ||||
| 
 | ||||
| public: | ||||
|     explicit SamplingDeviceDialog(bool rxElseTx, int deviceTabIndex, QWidget* parent = 0); | ||||
|     ~SamplingDeviceDialog(); | ||||
|     int getSelectedDeviceIndex() const { return m_selectedDeviceIndex; } | ||||
| 
 | ||||
| private: | ||||
|     Ui::SamplingDeviceDialog* ui; | ||||
|     bool m_rxElseTx; | ||||
|     int m_deviceTabIndex; | ||||
|     int m_selectedDeviceIndex; | ||||
|     std::vector<int> m_deviceIndexes; | ||||
| 
 | ||||
| private slots: | ||||
|     void accept(); | ||||
| }; | ||||
| 
 | ||||
| #endif /* SDRGUI_GUI_SAMPLINGDEVICEDIALOG_H_ */ | ||||
							
								
								
									
										91
									
								
								sdrgui/gui/samplingdevicedialog.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								sdrgui/gui/samplingdevicedialog.ui
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,91 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <ui version="4.0"> | ||||
|  <class>SamplingDeviceDialog</class> | ||||
|  <widget class="QDialog" name="SamplingDeviceDialog"> | ||||
|   <property name="geometry"> | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>324</width> | ||||
|     <height>139</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="font"> | ||||
|    <font> | ||||
|     <family>Sans Serif</family> | ||||
|     <pointsize>9</pointsize> | ||||
|    </font> | ||||
|   </property> | ||||
|   <property name="windowTitle"> | ||||
|    <string>Select sampling device</string> | ||||
|   </property> | ||||
|   <layout class="QVBoxLayout" name="verticalLayout"> | ||||
|    <item> | ||||
|     <widget class="QGroupBox" name="groupBox"> | ||||
|      <property name="maximumSize"> | ||||
|       <size> | ||||
|        <width>16777215</width> | ||||
|        <height>70</height> | ||||
|       </size> | ||||
|      </property> | ||||
|      <property name="title"> | ||||
|       <string>Select from list</string> | ||||
|      </property> | ||||
|      <layout class="QFormLayout" name="formLayout"> | ||||
|       <item row="0" column="1"> | ||||
|        <widget class="QComboBox" name="deviceSelect"/> | ||||
|       </item> | ||||
|      </layout> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QDialogButtonBox" name="buttonBox"> | ||||
|      <property name="orientation"> | ||||
|       <enum>Qt::Horizontal</enum> | ||||
|      </property> | ||||
|      <property name="standardButtons"> | ||||
|       <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|   </layout> | ||||
|  </widget> | ||||
|  <tabstops> | ||||
|   <tabstop>buttonBox</tabstop> | ||||
|  </tabstops> | ||||
|  <resources/> | ||||
|  <connections> | ||||
|   <connection> | ||||
|    <sender>buttonBox</sender> | ||||
|    <signal>accepted()</signal> | ||||
|    <receiver>SamplingDeviceDialog</receiver> | ||||
|    <slot>accept()</slot> | ||||
|    <hints> | ||||
|     <hint type="sourcelabel"> | ||||
|      <x>257</x> | ||||
|      <y>194</y> | ||||
|     </hint> | ||||
|     <hint type="destinationlabel"> | ||||
|      <x>157</x> | ||||
|      <y>203</y> | ||||
|     </hint> | ||||
|    </hints> | ||||
|   </connection> | ||||
|   <connection> | ||||
|    <sender>buttonBox</sender> | ||||
|    <signal>rejected()</signal> | ||||
|    <receiver>SamplingDeviceDialog</receiver> | ||||
|    <slot>reject()</slot> | ||||
|    <hints> | ||||
|     <hint type="sourcelabel"> | ||||
|      <x>314</x> | ||||
|      <y>194</y> | ||||
|     </hint> | ||||
|     <hint type="destinationlabel"> | ||||
|      <x>286</x> | ||||
|      <y>203</y> | ||||
|     </hint> | ||||
|    </hints> | ||||
|   </connection> | ||||
|  </connections> | ||||
| </ui> | ||||
| @ -30,6 +30,7 @@ | ||||
| #include "device/devicesourceapi.h" | ||||
| #include "device/devicesinkapi.h" | ||||
| #include "device/deviceuiset.h" | ||||
| #include "device/deviceenumerator.h" | ||||
| #include "audio/audiodeviceinfo.h" | ||||
| #include "gui/indicator.h" | ||||
| #include "gui/presetitem.h" | ||||
| @ -138,37 +139,43 @@ MainWindow::MainWindow(QWidget* parent) : | ||||
| 
 | ||||
| 	qDebug() << "MainWindow::MainWindow: select SampleSource from settings..."; | ||||
| 
 | ||||
| 	int sampleSourceIndex = m_settings.getSourceIndex(); | ||||
| 	sampleSourceIndex = m_pluginManager->selectSampleSourceByIndex(sampleSourceIndex, m_deviceUIs.back()->m_deviceSourceAPI); | ||||
| 	int deviceIndex = DeviceEnumerator::instance()->getRxSamplingDeviceIndex(m_settings.getSourceDeviceId(), m_settings.getSourceIndex()); | ||||
| 
 | ||||
| 	if (sampleSourceIndex < 0) | ||||
| 	if (deviceIndex >= 0) | ||||
| 	{ | ||||
| 	    qCritical("MainWindow::MainWindow: no sample source. Exit"); | ||||
|         exit(0); | ||||
|         // delete previous plugin GUI
 | ||||
|         m_deviceUIs.back()->m_deviceSourceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceGUI( | ||||
|                 m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourcePluginInstanceGUI()); | ||||
|         m_deviceUIs.back()->m_deviceSourceAPI->resetSampleSourceId(); | ||||
|         m_deviceUIs.back()->m_deviceSourceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput( | ||||
|                 m_deviceUIs.back()->m_deviceSourceAPI->getSampleSource()); | ||||
|         m_deviceUIs.back()->m_deviceSourceAPI->clearBuddiesLists(); // clear old API buddies lists
 | ||||
| 
 | ||||
|         m_deviceUIs.back()->m_samplingDeviceControl->setSelectedDeviceIndex(deviceIndex); | ||||
| 
 | ||||
| 	    PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex); | ||||
| 	    m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourceSequence(samplingDevice.sequence); | ||||
| 	    m_deviceUIs.back()->m_deviceSourceAPI->setHardwareId(samplingDevice.hardwareId); | ||||
| 	    m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourceId(samplingDevice.id); | ||||
| 	    m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourceSerial(samplingDevice.serial); | ||||
| 	    m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourceDisplayName(samplingDevice.displayedName); | ||||
| 	    m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourcePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceIndex)); | ||||
| 
 | ||||
| 	    DeviceSampleSource *source = m_deviceUIs.back()->m_deviceSourceAPI->getPluginInterface()->createSampleSourcePluginInstanceInput( | ||||
|                 m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourceId(), m_deviceUIs.back()->m_deviceSourceAPI); | ||||
|         m_deviceUIs.back()->m_deviceSourceAPI->setSampleSource(source); | ||||
|         QWidget *gui; | ||||
|         PluginInstanceGUI *pluginGUI = m_deviceUIs.back()->m_deviceSourceAPI->getPluginInterface()->createSampleSourcePluginInstanceGUI( | ||||
|                 m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourceId(), | ||||
|                 &gui, | ||||
|                 m_deviceUIs.back()); | ||||
|         m_deviceUIs.back()->m_deviceSourceAPI->getSampleSource()->setMessageQueueToGUI(pluginGUI->getInputMessageQueue()); | ||||
|         m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourcePluginInstanceGUI(pluginGUI); | ||||
|         setDeviceGUI(0, gui, m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourceDisplayName()); | ||||
| 	} | ||||
| 
 | ||||
| 	// delete previous plugin GUI
 | ||||
| 	m_deviceUIs.back()->m_deviceSourceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceGUI( | ||||
| 	        m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourcePluginInstanceGUI()); | ||||
| 
 | ||||
| 	DeviceSampleSource *source = m_deviceUIs.back()->m_deviceSourceAPI->getPluginInterface()->createSampleSourcePluginInstanceInput( | ||||
| 	        m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourceId(), m_deviceUIs.back()->m_deviceSourceAPI); | ||||
| 	m_deviceUIs.back()->m_deviceSourceAPI->setSampleSource(source); | ||||
|     QWidget *gui; | ||||
|     PluginInstanceGUI *pluginGUI = m_deviceUIs.back()->m_deviceSourceAPI->getPluginInterface()->createSampleSourcePluginInstanceGUI( | ||||
|             m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourceId(), | ||||
|             &gui, | ||||
|             m_deviceUIs.back()); | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->getSampleSource()->setMessageQueueToGUI(pluginGUI->getInputMessageQueue()); | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourcePluginInstanceGUI(pluginGUI); | ||||
|     setDeviceGUI(0, gui, m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourceDisplayName()); | ||||
| 
 | ||||
| 	m_deviceUIs.back()->m_deviceSourceAPI->setBuddyLeader(true); // the first device is always the leader
 | ||||
| 
 | ||||
|     bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true); | ||||
|     m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->setCurrentIndex(sampleSourceIndex); | ||||
|     m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked); | ||||
| 
 | ||||
| 	qDebug() << "MainWindow::MainWindow: load current preset settings..."; | ||||
| 
 | ||||
| 	loadPresetSettings(m_settings.getWorkingPreset(), 0); | ||||
| @ -205,7 +212,7 @@ void MainWindow::addSourceDevice() | ||||
|     sprintf(uidCStr, "UID:%d", dspDeviceSourceEngineUID); | ||||
| 
 | ||||
|     int deviceTabIndex = m_deviceUIs.size(); | ||||
|     m_deviceUIs.push_back(new DeviceUISet(deviceTabIndex, m_masterTimer)); | ||||
|     m_deviceUIs.push_back(new DeviceUISet(deviceTabIndex, true, m_masterTimer)); | ||||
|     m_deviceUIs.back()->m_deviceSourceEngine = dspDeviceSourceEngine; | ||||
| 
 | ||||
|     char tabNameCStr[16]; | ||||
| @ -227,24 +234,28 @@ void MainWindow::addSourceDevice() | ||||
|     ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, tabNameCStr); | ||||
|     ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr); | ||||
| 
 | ||||
|     bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true); | ||||
|     m_pluginManager->duplicateLocalSampleSourceDevices(dspDeviceSourceEngineUID); | ||||
|     // FIXME: replace with the device selection dialog based on static enumeration
 | ||||
|     m_pluginManager->fillSampleSourceSelector(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector(), dspDeviceSourceEngineUID); | ||||
|     connect(m_deviceUIs.back()->m_samplingDeviceControl, SIGNAL(changed()), this, SLOT(on_sampleSource_changed())); | ||||
| 
 | ||||
|     connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelectionConfirm(), SIGNAL(clicked(bool)), this, SLOT(on_sampleSource_confirmClicked(bool))); | ||||
| 
 | ||||
|     m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked); | ||||
|     ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_samplingDeviceControl, tabNameCStr); | ||||
|     ui->tabInputsSelect->setTabToolTip(deviceTabIndex, QString(uidCStr)); | ||||
| 
 | ||||
|     // Create a file source instance by default
 | ||||
|     m_pluginManager->selectSampleSourceBySerialOrSequence("sdrangel.samplesource.filesource", "0", 0, m_deviceUIs.back()->m_deviceSourceAPI); | ||||
|     int fileSourceDeviceIndex = DeviceEnumerator::instance()->getFileSourceDeviceIndex(); | ||||
|     PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(fileSourceDeviceIndex); | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourceSequence(samplingDevice.sequence); | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->setHardwareId(samplingDevice.hardwareId); | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourceId(samplingDevice.id); | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourceSerial(samplingDevice.serial); | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourceDisplayName(samplingDevice.displayedName); | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourcePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(fileSourceDeviceIndex)); | ||||
| 
 | ||||
|     m_deviceUIs.back()->m_samplingDeviceControl->setSelectedDeviceIndex(fileSourceDeviceIndex); | ||||
| 
 | ||||
|     // delete previous plugin GUI
 | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceGUI( | ||||
|             m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourcePluginInstanceGUI()); | ||||
| 
 | ||||
| 
 | ||||
|     DeviceSampleSource *source = m_deviceUIs.back()->m_deviceSourceAPI->getPluginInterface()->createSampleSourcePluginInstanceInput( | ||||
|             m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourceId(), m_deviceUIs.back()->m_deviceSourceAPI); | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->setSampleSource(source); | ||||
| @ -256,7 +267,6 @@ void MainWindow::addSourceDevice() | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->getSampleSource()->setMessageQueueToGUI(pluginGUI->getInputMessageQueue()); | ||||
|     m_deviceUIs.back()->m_deviceSourceAPI->setSampleSourcePluginInstanceGUI(pluginGUI); | ||||
|     setDeviceGUI(deviceTabIndex, gui, m_deviceUIs.back()->m_deviceSourceAPI->getSampleSourceDisplayName()); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void MainWindow::addSinkDevice() | ||||
| @ -269,7 +279,7 @@ void MainWindow::addSinkDevice() | ||||
|     sprintf(uidCStr, "UID:%d", dspDeviceSinkEngineUID); | ||||
| 
 | ||||
|     int deviceTabIndex = m_deviceUIs.size(); | ||||
|     m_deviceUIs.push_back(new DeviceUISet(deviceTabIndex, m_masterTimer)); | ||||
|     m_deviceUIs.push_back(new DeviceUISet(deviceTabIndex, false, m_masterTimer)); | ||||
|     m_deviceUIs.back()->m_deviceSourceEngine = 0; | ||||
|     m_deviceUIs.back()->m_deviceSinkEngine = dspDeviceSinkEngine; | ||||
| 
 | ||||
| @ -293,19 +303,22 @@ void MainWindow::addSinkDevice() | ||||
|     ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, tabNameCStr); | ||||
|     ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr); | ||||
| 
 | ||||
|     bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true); | ||||
|     m_pluginManager->duplicateLocalSampleSinkDevices(dspDeviceSinkEngineUID); | ||||
|     // FIXME: replace with the device selection dialog based on static enumeration
 | ||||
|     m_pluginManager->fillSampleSinkSelector(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector(), dspDeviceSinkEngineUID); | ||||
|     connect(m_deviceUIs.back()->m_samplingDeviceControl, SIGNAL(changed()), this, SLOT(on_sampleSink_changed())); | ||||
| 
 | ||||
|     connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelectionConfirm(), SIGNAL(clicked(bool)), this, SLOT(on_sampleSink_confirmClicked(bool))); | ||||
| 
 | ||||
|     m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked); | ||||
|     ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_samplingDeviceControl, tabNameCStr); | ||||
|     ui->tabInputsSelect->setTabToolTip(deviceTabIndex, QString(uidCStr)); | ||||
| 
 | ||||
|     // create a file sink by default
 | ||||
|     m_pluginManager->selectSampleSinkBySerialOrSequence("sdrangel.samplesink.filesink", "0", 0, m_deviceUIs.back()->m_deviceSinkAPI); | ||||
|     int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileSinkDeviceIndex(); | ||||
|     PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex); | ||||
|     m_deviceUIs.back()->m_deviceSinkAPI->setSampleSinkSequence(samplingDevice.sequence); | ||||
|     m_deviceUIs.back()->m_deviceSinkAPI->setHardwareId(samplingDevice.hardwareId); | ||||
|     m_deviceUIs.back()->m_deviceSinkAPI->setSampleSinkId(samplingDevice.id); | ||||
|     m_deviceUIs.back()->m_deviceSinkAPI->setSampleSinkSerial(samplingDevice.serial); | ||||
|     m_deviceUIs.back()->m_deviceSinkAPI->setSampleSinkDisplayName(samplingDevice.displayedName); | ||||
|     m_deviceUIs.back()->m_deviceSinkAPI->setSampleSinkPluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex)); | ||||
| 
 | ||||
|     m_deviceUIs.back()->m_samplingDeviceControl->setSelectedDeviceIndex(fileSinkDeviceIndex); | ||||
| 
 | ||||
|     // delete previous plugin GUI if it exists
 | ||||
|     m_deviceUIs.back()->m_deviceSinkAPI->getPluginInterface()->deleteSampleSourcePluginInstanceGUI( | ||||
| @ -862,7 +875,7 @@ void MainWindow::on_action_DV_Serial_triggered(bool checked) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void MainWindow::on_sampleSource_confirmClicked(bool checked __attribute__((unused))) | ||||
| void MainWindow::on_sampleSource_changed() | ||||
| { | ||||
|     // Do it in the currently selected source tab
 | ||||
|     int currentSourceTabIndex = ui->tabInputsSelect->currentIndex(); | ||||
| @ -872,8 +885,6 @@ void MainWindow::on_sampleSource_confirmClicked(bool checked __attribute__((unus | ||||
|         qDebug("MainWindow::on_sampleSource_confirmClicked: tab at %d", currentSourceTabIndex); | ||||
|         DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex]; | ||||
|         deviceUI->m_deviceSourceAPI->saveSourceSettings(m_settings.getWorkingPreset()); // save old API settings
 | ||||
|         int selectedComboIndex = deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(); | ||||
|         void *devicePtr = deviceUI->m_samplingDeviceControl->getDeviceSelector()->itemData(selectedComboIndex).value<void *>(); | ||||
|         deviceUI->m_deviceSourceAPI->stopAcquisition(); | ||||
| 
 | ||||
|         // deletes old UI and input object
 | ||||
| @ -885,7 +896,13 @@ void MainWindow::on_sampleSource_confirmClicked(bool checked __attribute__((unus | ||||
|                 deviceUI->m_deviceSourceAPI->getSampleSource()); | ||||
|         deviceUI->m_deviceSourceAPI->clearBuddiesLists(); // clear old API buddies lists
 | ||||
| 
 | ||||
|         m_pluginManager->selectSampleSourceByDevice(devicePtr, deviceUI->m_deviceSourceAPI); // sets the new API
 | ||||
|         PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()); | ||||
|         deviceUI->m_deviceSourceAPI->setSampleSourceSequence(samplingDevice.sequence); | ||||
|         deviceUI->m_deviceSourceAPI->setHardwareId(samplingDevice.hardwareId); | ||||
|         deviceUI->m_deviceSourceAPI->setSampleSourceId(samplingDevice.id); | ||||
|         deviceUI->m_deviceSourceAPI->setSampleSourceSerial(samplingDevice.serial); | ||||
|         deviceUI->m_deviceSourceAPI->setSampleSourceDisplayName(samplingDevice.displayedName); | ||||
|         deviceUI->m_deviceSourceAPI->setSampleSourcePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex())); | ||||
| 
 | ||||
|         // add to buddies list
 | ||||
|         std::vector<DeviceUISet*>::iterator it = m_deviceUIs.begin(); | ||||
| @ -936,14 +953,15 @@ void MainWindow::on_sampleSource_confirmClicked(bool checked __attribute__((unus | ||||
| 
 | ||||
|         deviceUI->m_deviceSourceAPI->loadSourceSettings(m_settings.getWorkingPreset()); // load new API settings
 | ||||
| 
 | ||||
|         if (currentSourceTabIndex == 0) | ||||
|         if (currentSourceTabIndex == 0) // save as default starting device
 | ||||
|         { | ||||
|             m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex()); | ||||
|             m_settings.setSourceIndex(samplingDevice.sequence); | ||||
|             m_settings.setSourceDeviceId(samplingDevice.id); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void MainWindow::on_sampleSink_confirmClicked(bool checked __attribute__((unused))) | ||||
| void MainWindow::on_sampleSink_changed() | ||||
| { | ||||
|     // Do it in the currently selected source tab
 | ||||
|     int currentSinkTabIndex = ui->tabInputsSelect->currentIndex(); | ||||
| @ -953,8 +971,6 @@ void MainWindow::on_sampleSink_confirmClicked(bool checked __attribute__((unused | ||||
|         qDebug("MainWindow::on_sampleSink_confirmClicked: tab at %d", currentSinkTabIndex); | ||||
|         DeviceUISet *deviceUI = m_deviceUIs[currentSinkTabIndex]; | ||||
|         deviceUI->m_deviceSinkAPI->saveSinkSettings(m_settings.getWorkingPreset()); // save old API settings
 | ||||
|         int selectedComboIndex = deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(); | ||||
|         void *devicePtr = deviceUI->m_samplingDeviceControl->getDeviceSelector()->itemData(selectedComboIndex).value<void *>(); | ||||
|         deviceUI->m_deviceSinkAPI->stopGeneration(); | ||||
| 
 | ||||
|         // deletes old UI and output object
 | ||||
| @ -966,7 +982,13 @@ void MainWindow::on_sampleSink_confirmClicked(bool checked __attribute__((unused | ||||
|                 deviceUI->m_deviceSinkAPI->getSampleSink()); | ||||
|         deviceUI->m_deviceSinkAPI->clearBuddiesLists(); // clear old API buddies lists
 | ||||
| 
 | ||||
|         m_pluginManager->selectSampleSinkByDevice(devicePtr, deviceUI->m_deviceSinkAPI); // sets the new API
 | ||||
|         PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()); | ||||
|         deviceUI->m_deviceSinkAPI->setSampleSinkSequence(samplingDevice.sequence); | ||||
|         deviceUI->m_deviceSinkAPI->setHardwareId(samplingDevice.hardwareId); | ||||
|         deviceUI->m_deviceSinkAPI->setSampleSinkId(samplingDevice.id); | ||||
|         deviceUI->m_deviceSinkAPI->setSampleSinkSerial(samplingDevice.serial); | ||||
|         deviceUI->m_deviceSinkAPI->setSampleSinkDisplayName(samplingDevice.displayedName); | ||||
|         deviceUI->m_deviceSinkAPI->setSampleSinkPluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex())); | ||||
| 
 | ||||
|         // add to buddies list
 | ||||
|         std::vector<DeviceUISet*>::iterator it = m_deviceUIs.begin(); | ||||
| @ -1043,7 +1065,6 @@ void MainWindow::on_channel_addClicked(bool checked __attribute__((unused))) | ||||
|             m_pluginManager->createTxChannelInstance(deviceUI->m_samplingDeviceControl->getChannelSelector()->currentIndex(), deviceUI); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void MainWindow::on_action_About_triggered() | ||||
| @ -1074,62 +1095,6 @@ void MainWindow::on_action_reloadDevices_triggered() | ||||
| { | ||||
|     QMessageBox::information(this, tr("Message"), tr("Not implemented")); | ||||
|     return; | ||||
| 
 | ||||
| //    // all devices must be stopped
 | ||||
| //    std::vector<DeviceUISet*>::iterator it = m_deviceUIs.begin();
 | ||||
| //    for (; it != m_deviceUIs.end(); ++it)
 | ||||
| //    {
 | ||||
| //        if ((*it)->m_deviceSourceEngine) // it is a source device
 | ||||
| //        {
 | ||||
| //            if ((*it)->m_deviceSourceEngine->state() == DSPDeviceSourceEngine::StRunning)
 | ||||
| //            {
 | ||||
| //                QMessageBox::information(this, tr("Message"), tr("Stop all devices for reload to take effect"));
 | ||||
| //                return;
 | ||||
| //            }
 | ||||
| //        }
 | ||||
| //
 | ||||
| //        if ((*it)->m_deviceSinkEngine) // it is a sink device
 | ||||
| //        {
 | ||||
| //            if ((*it)->m_deviceSinkEngine->state() == DSPDeviceSinkEngine::StRunning)
 | ||||
| //            {
 | ||||
| //                QMessageBox::information(this, tr("Message"), tr("Stop all devices for reload to take effect"));
 | ||||
| //                return;
 | ||||
| //            }
 | ||||
| //        }
 | ||||
| //    }
 | ||||
| //
 | ||||
| //    // re-scan devices
 | ||||
| //    m_pluginManager->updateSampleSourceDevices();
 | ||||
| //    m_pluginManager->updateSampleSinkDevices();
 | ||||
| //
 | ||||
| //    // re-populate device selectors keeping the same selection
 | ||||
| //    it = m_deviceUIs.begin();
 | ||||
| //    for (; it != m_deviceUIs.end(); ++it)
 | ||||
| //    {
 | ||||
| //        if ((*it)->m_deviceSourceEngine) // it is a source device
 | ||||
| //        {
 | ||||
| //            QComboBox *deviceSelectorComboBox = (*it)->m_samplingDeviceControl->getDeviceSelector();
 | ||||
| //            bool sampleSourceSignalsBlocked = deviceSelectorComboBox->blockSignals(true);
 | ||||
| //            uint dspDeviceSourceEngineUID = (*it)->m_deviceSourceEngine->getUID();
 | ||||
| //            m_pluginManager->duplicateLocalSampleSourceDevices(dspDeviceSourceEngineUID);
 | ||||
| //            m_pluginManager->fillSampleSourceSelector(deviceSelectorComboBox, dspDeviceSourceEngineUID);
 | ||||
| //            int newIndex = m_pluginManager->getSampleSourceSelectorIndex(deviceSelectorComboBox, (*it)->m_deviceSourceAPI);
 | ||||
| //            deviceSelectorComboBox->setCurrentIndex(newIndex);
 | ||||
| //            deviceSelectorComboBox->blockSignals(sampleSourceSignalsBlocked);
 | ||||
| //        }
 | ||||
| //
 | ||||
| //        if ((*it)->m_deviceSinkEngine) // it is a sink device
 | ||||
| //        {
 | ||||
| //            QComboBox *deviceSelectorComboBox = (*it)->m_samplingDeviceControl->getDeviceSelector();
 | ||||
| //            bool sampleSinkSignalsBlocked = deviceSelectorComboBox->blockSignals(true);
 | ||||
| //            uint dspDeviceSinkEngineUID = (*it)->m_deviceSinkEngine->getUID();
 | ||||
| //            m_pluginManager->duplicateLocalSampleSinkDevices(dspDeviceSinkEngineUID);
 | ||||
| //            m_pluginManager->fillSampleSinkSelector(deviceSelectorComboBox, dspDeviceSinkEngineUID);
 | ||||
| //            int newIndex = m_pluginManager->getSampleSinkSelectorIndex(deviceSelectorComboBox, (*it)->m_deviceSinkAPI);
 | ||||
| //            deviceSelectorComboBox->setCurrentIndex(newIndex);
 | ||||
| //            deviceSelectorComboBox->blockSignals(sampleSinkSignalsBlocked);
 | ||||
| //        }
 | ||||
| //    }
 | ||||
| } | ||||
| 
 | ||||
| void MainWindow::on_action_Exit_triggered() | ||||
|  | ||||
| @ -140,8 +140,8 @@ private slots: | ||||
| 	void on_action_Audio_triggered(); | ||||
| 	void on_action_DV_Serial_triggered(bool checked); | ||||
| 	void on_action_My_Position_triggered(); | ||||
| 	void on_sampleSource_confirmClicked(bool checked); | ||||
| 	void on_sampleSink_confirmClicked(bool checked); | ||||
| 	void on_sampleSource_changed(); | ||||
| 	void on_sampleSink_changed(); | ||||
|     void on_channel_addClicked(bool checked); | ||||
| 	void on_action_Loaded_Plugins_triggered(); | ||||
| 	void on_action_About_triggered(); | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								sdrgui/resources/choose.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								sdrgui/resources/choose.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 602 B | 
| @ -79,5 +79,6 @@ | ||||
|         <file>stream.png</file> | ||||
|         <file>antenna.png</file> | ||||
|         <file>link.png</file> | ||||
|         <file>choose.png</file> | ||||
|     </qresource> | ||||
| </RCC> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user