mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 13:00:26 -04:00 
			
		
		
		
	Merge branch 'f4exb:master' into freq_scanner
This commit is contained in:
		
						commit
						03232b094c
					
				| @ -51,7 +51,7 @@ void DeviceLimeSDR::enumOriginDevices(const QString& hardwareId, PluginInterface | ||||
|             findSerial((const char *) deviceList[i], serial); | ||||
| 
 | ||||
|             DeviceLimeSDRParams limeSDRParams; | ||||
|             limeSDRParams.open(deviceList[i]); | ||||
|             limeSDRParams.open(deviceList[i], false); | ||||
|             limeSDRParams.close(); | ||||
| 
 | ||||
|             QString displayedName(QString("LimeSDR[%1:$1] %2").arg(i).arg(serial.c_str())); | ||||
|  | ||||
| @ -18,7 +18,7 @@ | ||||
| #include <QDebug> | ||||
| #include "devicelimesdrparam.h" | ||||
| 
 | ||||
| bool DeviceLimeSDRParams::open(lms_info_str_t deviceStr) | ||||
| bool DeviceLimeSDRParams::open(lms_info_str_t deviceStr, bool init) | ||||
| { | ||||
|     getHardwareType((const char *) deviceStr); | ||||
| 
 | ||||
| @ -30,10 +30,13 @@ bool DeviceLimeSDRParams::open(lms_info_str_t deviceStr) | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     if (LMS_Init(m_dev) < 0) | ||||
|     if (init)  | ||||
|     { | ||||
|         qCritical() << "DeviceLimeSDRParams::open: cannot init device " << deviceStr; | ||||
|         return false; | ||||
|         if (LMS_Init(m_dev) < 0) | ||||
|         { | ||||
|             qCritical() << "DeviceLimeSDRParams::open: cannot init device " << deviceStr; | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     int n; | ||||
|  | ||||
| @ -96,7 +96,7 @@ struct DEVICES_API DeviceLimeSDRParams | ||||
|     /**
 | ||||
|      * Opens and initialize the device and obtain information (# channels, ranges, ...) | ||||
|      */ | ||||
|     bool open(lms_info_str_t deviceStr); | ||||
|     bool open(lms_info_str_t deviceStr, bool init = true); | ||||
|     void close(); | ||||
|     lms_device_t *getDevice() { return m_dev; } | ||||
| 
 | ||||
|  | ||||
| @ -288,6 +288,8 @@ void SimplePTTGUI::updateDeviceSetLists() | ||||
| 
 | ||||
|     ui->rxDevice->clear(); | ||||
|     ui->txDevice->clear(); | ||||
|     ui->rxDevice->addItem(tr("None"), -1); | ||||
|     ui->txDevice->addItem(tr("None"), -1); | ||||
|     unsigned int deviceIndex = 0; | ||||
|     unsigned int rxIndex = 0; | ||||
|     unsigned int txIndex = 0; | ||||
| @ -296,6 +298,7 @@ void SimplePTTGUI::updateDeviceSetLists() | ||||
|     { | ||||
|         DSPDeviceSourceEngine *deviceSourceEngine =  (*it)->m_deviceSourceEngine; | ||||
|         DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine; | ||||
|         DSPDeviceMIMOEngine *deviceMIMOEngine = (*it)->m_deviceMIMOEngine; | ||||
| 
 | ||||
|         if (deviceSourceEngine) | ||||
|         { | ||||
| @ -307,6 +310,14 @@ void SimplePTTGUI::updateDeviceSetLists() | ||||
|             ui->txDevice->addItem(QString("T%1").arg(deviceIndex), deviceIndex); | ||||
|             txIndex++; | ||||
|         } | ||||
|         else if (deviceMIMOEngine) | ||||
|         { | ||||
|             QString text = QString("M%1").arg(deviceIndex); | ||||
|             ui->rxDevice->addItem(text, deviceIndex); | ||||
|             ui->txDevice->addItem(text, deviceIndex); | ||||
|             rxIndex++; | ||||
|             txIndex++; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     int rxDeviceIndex; | ||||
| @ -314,11 +325,8 @@ void SimplePTTGUI::updateDeviceSetLists() | ||||
| 
 | ||||
|     if (rxIndex > 0) | ||||
|     { | ||||
|         if (m_settings.m_rxDeviceSetIndex < 0) { | ||||
|             ui->rxDevice->setCurrentIndex(0); | ||||
|         } else { | ||||
|             ui->rxDevice->setCurrentIndex(m_settings.m_rxDeviceSetIndex); | ||||
|         } | ||||
|         int index = ui->rxDevice->findData(m_settings.m_rxDeviceSetIndex); | ||||
|         ui->rxDevice->setCurrentIndex(index == -1 ? 0 : index); | ||||
| 
 | ||||
|         rxDeviceIndex = ui->rxDevice->currentData().toInt(); | ||||
|     } | ||||
| @ -330,11 +338,8 @@ void SimplePTTGUI::updateDeviceSetLists() | ||||
| 
 | ||||
|     if (txIndex > 0) | ||||
|     { | ||||
|         if (m_settings.m_txDeviceSetIndex < 0) { | ||||
|             ui->txDevice->setCurrentIndex(0); | ||||
|         } else { | ||||
|             ui->txDevice->setCurrentIndex(m_settings.m_txDeviceSetIndex); | ||||
|         } | ||||
|         int index = ui->txDevice->findData(m_settings.m_txDeviceSetIndex); | ||||
|         ui->txDevice->setCurrentIndex(index == -1 ? 0 : index); | ||||
| 
 | ||||
|         txDeviceIndex = ui->txDevice->currentData().toInt(); | ||||
|     } | ||||
| @ -425,7 +430,7 @@ void SimplePTTGUI::on_rxDevice_currentIndexChanged(int index) | ||||
| { | ||||
|     if (index >= 0) | ||||
|     { | ||||
|         m_settings.m_rxDeviceSetIndex = index; | ||||
|         m_settings.m_rxDeviceSetIndex = ui->rxDevice->currentData().toInt(); | ||||
|         m_settingsKeys.append("rxDeviceSetIndex"); | ||||
|         applySettings(); | ||||
|     } | ||||
| @ -435,7 +440,7 @@ void SimplePTTGUI::on_txDevice_currentIndexChanged(int index) | ||||
| { | ||||
|     if (index >= 0) | ||||
|     { | ||||
|         m_settings.m_txDeviceSetIndex = index; | ||||
|         m_settings.m_txDeviceSetIndex = ui->txDevice->currentData().toInt(); | ||||
|         m_settingsKeys.append("txDeviceSetIndex"); | ||||
|         applySettings(); | ||||
|     } | ||||
|  | ||||
| @ -23,6 +23,7 @@ | ||||
| #include "SWGSuccessResponse.h" | ||||
| #include "SWGErrorResponse.h" | ||||
| 
 | ||||
| #include "maincore.h" | ||||
| #include "webapi/webapiadapterinterface.h" | ||||
| #include "audio/audiodevicemanager.h" | ||||
| #include "dsp/dspengine.h" | ||||
| @ -242,13 +243,31 @@ bool SimplePTTWorker::turnDevice(bool on) | ||||
|     SWGSDRangel::SWGDeviceState response; | ||||
|     SWGSDRangel::SWGErrorResponse error; | ||||
|     int httpCode; | ||||
| 
 | ||||
|     unsigned int deviceSetIndex = m_tx ? m_settings.m_txDeviceSetIndex : m_settings.m_rxDeviceSetIndex; | ||||
|     MainCore *mainCore = MainCore::instance(); | ||||
|     auto deviceSets = mainCore->getDeviceSets(); | ||||
|     if (deviceSetIndex >= deviceSets.size())  | ||||
|     { | ||||
|         qWarning("SimplePTTWorker::turnDevice: deviceSetIndex out of range"); | ||||
|         return false; | ||||
|     } | ||||
|     bool isDeviceMIMO = mainCore->getDeviceSetTypeId(deviceSets[deviceSetIndex]) == 'M'; | ||||
|     if (on) { | ||||
|         httpCode = m_webAPIAdapterInterface->devicesetDeviceRunPost( | ||||
|             m_tx ? m_settings.m_txDeviceSetIndex : m_settings.m_rxDeviceSetIndex, response, error); | ||||
|         if (isDeviceMIMO) { | ||||
|             httpCode = m_webAPIAdapterInterface->devicesetDeviceSubsystemRunPost( | ||||
|                 deviceSetIndex, m_tx ? 1 : 0, response, error); | ||||
|         } else { | ||||
|             httpCode = m_webAPIAdapterInterface->devicesetDeviceRunPost( | ||||
|                 deviceSetIndex, response, error); | ||||
|         } | ||||
|     } else { | ||||
|         httpCode = m_webAPIAdapterInterface->devicesetDeviceRunDelete( | ||||
|             m_tx ? m_settings.m_txDeviceSetIndex : m_settings.m_rxDeviceSetIndex, response, error); | ||||
|         if (isDeviceMIMO) { | ||||
|             httpCode = m_webAPIAdapterInterface->devicesetDeviceSubsystemRunDelete( | ||||
|                 deviceSetIndex, m_tx ? 1 : 0, response, error); | ||||
|         } else { | ||||
|             httpCode = m_webAPIAdapterInterface->devicesetDeviceRunDelete( | ||||
|                 deviceSetIndex, response, error); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (httpCode/100 == 2) | ||||
|  | ||||
| @ -245,95 +245,86 @@ bool DeviceEnumerator::isMIMOEnumerated(const QString& deviceHwId, int deviceSeq | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::enumerateDevices(PluginAPI::SamplingDeviceRegistrations& deviceRegistrations, DevicesEnumeration& enumeration, PluginInterface::SamplingDevice::StreamType type) | ||||
| void DeviceEnumerator::enumerateDevices(std::initializer_list<PluginAPI::SamplingDeviceRegistrations*> deviceRegistrationsList, std::initializer_list<DevicesEnumeration*> enumerations) | ||||
| { | ||||
|     DevicesEnumeration tempEnumeration; | ||||
|     auto enumerationsArray = enumerations.begin(); | ||||
|     PluginInterface::OriginDevices originDevices; | ||||
|     QStringList originDevicesHwIds; | ||||
| 
 | ||||
|     for (int i = 0; i < deviceRegistrations.count(); i++) | ||||
|     { | ||||
|         qDebug("DeviceEnumerator::enumerateDevices: %s", qPrintable(deviceRegistrations[i].m_deviceId)); | ||||
|         emit enumeratingDevices(deviceRegistrations[i].m_deviceId); | ||||
|         deviceRegistrations[i].m_plugin->enumOriginDevices(originDevicesHwIds, originDevices); | ||||
|         PluginInterface::SamplingDevices samplingDevices; | ||||
|         if (type == PluginInterface::SamplingDevice::StreamSingleRx) { | ||||
|             samplingDevices = deviceRegistrations[i].m_plugin->enumSampleSources(originDevices); | ||||
|         } else if (type == PluginInterface::SamplingDevice::StreamSingleTx) { | ||||
|             samplingDevices = deviceRegistrations[i].m_plugin->enumSampleSinks(originDevices); | ||||
|         } else { | ||||
|             samplingDevices = deviceRegistrations[i].m_plugin->enumSampleMIMO(originDevices); | ||||
|         } | ||||
| 
 | ||||
|         for (int j = 0; j < samplingDevices.count(); j++) | ||||
|         { | ||||
|             tempEnumeration.push_back( | ||||
|                 DeviceEnumeration( | ||||
|                     samplingDevices[j], | ||||
|                     deviceRegistrations[i].m_plugin, | ||||
|                     0   // Index will be set when adding to enumeration below
 | ||||
|                 ) | ||||
|             ); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // We don't remove devices that are no-longer found from the enumeration list, in case their
 | ||||
|     // index is referenced in some other object (E.g. DeviceGUI)
 | ||||
|     // Instead we mark as removed. If later re-added, then we re-use the same index
 | ||||
|     for (DevicesEnumeration::iterator it = enumeration.begin(); it != enumeration.end(); ++it) | ||||
|     for(size_t i = 0; i < 3; i++)  | ||||
|     { | ||||
|         bool found = false; | ||||
|         for (DevicesEnumeration::iterator it2 = tempEnumeration.begin(); it2 != tempEnumeration.end(); ++it2) | ||||
|         { | ||||
|             if (it->m_samplingDevice == it2->m_samplingDevice) | ||||
|         if (enumerationsArray[i] != nullptr) { | ||||
|             for(auto &device : *enumerationsArray[i])  | ||||
|             { | ||||
|                 found = true; | ||||
|                 break; | ||||
|                 device.m_samplingDevice.removed = true; | ||||
|             } | ||||
|         } | ||||
|         if (!found) { | ||||
|             it->m_samplingDevice.removed = true; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // Add new entries and update existing (in case re-added or sequence number has changed)
 | ||||
|     int index = enumeration.size(); | ||||
|     for (DevicesEnumeration::iterator it = tempEnumeration.begin(); it != tempEnumeration.end(); ++it) | ||||
|     for (auto const &deviceRegistrations : deviceRegistrationsList) | ||||
|     { | ||||
| 
 | ||||
|         bool found = false; | ||||
|         for (DevicesEnumeration::iterator it2 = enumeration.begin(); it2 != enumeration.end(); ++it2) | ||||
|         for (auto &deviceRegistration : *deviceRegistrations)  | ||||
|         { | ||||
|             if (it->m_samplingDevice == it2->m_samplingDevice) | ||||
|             qDebug("DeviceEnumerator::enumerateDevices: %s", qPrintable(deviceRegistration.m_deviceId)); | ||||
|             emit enumeratingDevices(deviceRegistration.m_deviceId); | ||||
|             deviceRegistration.m_plugin->enumOriginDevices(originDevicesHwIds, originDevices); | ||||
|             auto func = [&](const PluginInterface::SamplingDevices &devices, DevicesEnumeration& enumeration)  | ||||
|             { | ||||
|                 it2->m_samplingDevice.removed = false; | ||||
|                 it2->m_samplingDevice.displayedName = it->m_samplingDevice.displayedName; | ||||
|                 found = true; | ||||
|                 break; | ||||
|                 for (auto &newDevice : devices)  | ||||
|                 { | ||||
|                     auto found = std::find_if(enumeration.begin(), enumeration.end(), [&](const DeviceEnumeration &device)  | ||||
|                     { | ||||
|                         return device.m_samplingDevice == newDevice; | ||||
|                     }); | ||||
|                     if (found == enumeration.end())  | ||||
|                     { | ||||
|                         enumeration.emplace_back(newDevice, deviceRegistration.m_plugin, enumeration.size()); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         found->m_samplingDevice.removed = false; | ||||
|                     } | ||||
|                 } | ||||
|             }; | ||||
|             if (enumerationsArray[PluginInterface::SamplingDevice::StreamType::StreamSingleRx])  | ||||
|             { | ||||
|                 func(deviceRegistration.m_plugin->enumSampleSources(originDevices), *enumerationsArray[PluginInterface::SamplingDevice::StreamType::StreamSingleRx]); | ||||
|             } | ||||
|             if (enumerationsArray[PluginInterface::SamplingDevice::StreamType::StreamSingleTx])  | ||||
|             { | ||||
|                 func(deviceRegistration.m_plugin->enumSampleSinks(originDevices), *enumerationsArray[PluginInterface::SamplingDevice::StreamType::StreamSingleTx]); | ||||
|             } | ||||
|             if (enumerationsArray[PluginInterface::SamplingDevice::StreamType::StreamMIMO])  | ||||
|             { | ||||
|                 func(deviceRegistration.m_plugin->enumSampleMIMO(originDevices), *enumerationsArray[PluginInterface::SamplingDevice::StreamType::StreamMIMO]); | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
|         if (!found) | ||||
|         { | ||||
|             it->m_index = index++; | ||||
|             enumeration.push_back(*it); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::enumerateRxDevices(PluginManager *pluginManager) | ||||
| { | ||||
|     enumerateDevices(pluginManager->getSourceDeviceRegistrations(), m_rxEnumeration, PluginInterface::SamplingDevice::StreamSingleRx); | ||||
|     enumerateDevices({&pluginManager->getSourceDeviceRegistrations()}, { &m_rxEnumeration, nullptr, nullptr }); | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::enumerateTxDevices(PluginManager *pluginManager) | ||||
| { | ||||
|     enumerateDevices(pluginManager->getSinkDeviceRegistrations(), m_txEnumeration, PluginInterface::SamplingDevice::StreamSingleTx); | ||||
|     enumerateDevices({&pluginManager->getSinkDeviceRegistrations()}, { nullptr, &m_txEnumeration, nullptr }); | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::enumerateMIMODevices(PluginManager *pluginManager) | ||||
| { | ||||
|     enumerateDevices(pluginManager->getMIMODeviceRegistrations(), m_mimoEnumeration, PluginInterface::SamplingDevice::StreamMIMO); | ||||
|     enumerateDevices({&pluginManager->getMIMODeviceRegistrations()}, { nullptr, nullptr, &m_mimoEnumeration }); | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::enumerateAllDevices(PluginManager *pluginManager) | ||||
| { | ||||
|     enumerateDevices( | ||||
|         {&pluginManager->getSourceDeviceRegistrations(), &pluginManager->getSinkDeviceRegistrations(), &pluginManager->getMIMODeviceRegistrations()}, | ||||
|         { &m_rxEnumeration, &m_txEnumeration, &m_mimoEnumeration } | ||||
|         ); | ||||
| } | ||||
| 
 | ||||
| void DeviceEnumerator::listRxDeviceNames(QList<QString>& list, std::vector<int>& indexes) const | ||||
|  | ||||
| @ -41,6 +41,7 @@ public: | ||||
|     void enumerateRxDevices(PluginManager *pluginManager); | ||||
|     void enumerateTxDevices(PluginManager *pluginManager); | ||||
|     void enumerateMIMODevices(PluginManager *pluginManager); | ||||
|     void enumerateAllDevices(PluginManager *pluginManager); | ||||
|     void addNonDiscoverableDevices(PluginManager *pluginManager, const DeviceUserArgs& deviceUserArgs); | ||||
|     void listRxDeviceNames(QList<QString>& list, std::vector<int>& indexes) const; | ||||
|     void listTxDeviceNames(QList<QString>& list, std::vector<int>& indexes) const; | ||||
| @ -93,7 +94,7 @@ private: | ||||
|     DevicesEnumeration m_txEnumeration; | ||||
|     DevicesEnumeration m_mimoEnumeration; | ||||
| 
 | ||||
|     void enumerateDevices(PluginAPI::SamplingDeviceRegistrations& deviceRegistrations, DevicesEnumeration& enumeration, PluginInterface::SamplingDevice::StreamType type); | ||||
|     void enumerateDevices(std::initializer_list<PluginAPI::SamplingDeviceRegistrations*>  deviceRegistrations, std::initializer_list<DevicesEnumeration*> enumerations); | ||||
|     PluginInterface *getRxRegisteredPlugin(PluginManager *pluginManager, const QString& deviceHwId); | ||||
|     PluginInterface *getTxRegisteredPlugin(PluginManager *pluginManager, const QString& deviceHwId); | ||||
|     PluginInterface *getMIMORegisteredPlugin(PluginManager *pluginManager, const QString& deviceHwId); | ||||
|  | ||||
| @ -130,9 +130,7 @@ void PluginManager::loadPluginsFinal() | ||||
|         it->pluginInterface->initPlugin(&m_pluginAPI); | ||||
|     } | ||||
| 
 | ||||
|     DeviceEnumerator::instance()->enumerateRxDevices(this); | ||||
|     DeviceEnumerator::instance()->enumerateTxDevices(this); | ||||
|     DeviceEnumerator::instance()->enumerateMIMODevices(this); | ||||
|     DeviceEnumerator::instance()->enumerateAllDevices(this); | ||||
| } | ||||
| 
 | ||||
| void PluginManager::loadPluginsNonDiscoverable(const DeviceUserArgs& deviceUserArgs) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user