1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 01:18:38 -05:00

Moved device and feature sets add and remove signals where appropriate. Improves #1139

This commit is contained in:
f4exb 2022-03-23 05:53:12 +01:00
parent 90620eed62
commit 8a3f15ba45
11 changed files with 55 additions and 35 deletions

View File

@ -92,40 +92,40 @@ void DeviceSet::deleteChannel(int channelIndex)
}
}
void DeviceSet::addRxChannel(int selectedChannelIndex, PluginAPI *pluginAPI)
ChannelAPI *DeviceSet::addRxChannel(int selectedChannelIndex, PluginAPI *pluginAPI)
{
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations(); // Available channel plugins
ChannelAPI *rxChannel;
(*channelRegistrations)[selectedChannelIndex].m_plugin->createRxChannel(m_deviceAPI, nullptr, &rxChannel);
ChannelAPI *channelAPI = rxChannel;
m_channelInstanceRegistrations.append(channelAPI);
MainCore::instance()->addChannelInstance(this, channelAPI);
m_channelInstanceRegistrations.append(rxChannel);
MainCore::instance()->addChannelInstance(this, rxChannel);
renameChannelInstances();
qDebug("DeviceSet::addRxChannel: %s", qPrintable(rxChannel->getName()));
return rxChannel;
}
void DeviceSet::addTxChannel(int selectedChannelIndex, PluginAPI *pluginAPI)
ChannelAPI *DeviceSet::addTxChannel(int selectedChannelIndex, PluginAPI *pluginAPI)
{
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getTxChannelRegistrations(); // Available channel plugins
ChannelAPI *txChannel;
(*channelRegistrations)[selectedChannelIndex].m_plugin->createTxChannel(m_deviceAPI, nullptr, &txChannel);
ChannelAPI *channelAPI = txChannel;
m_channelInstanceRegistrations.append(channelAPI);
MainCore::instance()->addChannelInstance(this, channelAPI);
m_channelInstanceRegistrations.append(txChannel);
MainCore::instance()->addChannelInstance(this, txChannel);
renameChannelInstances();
qDebug("DeviceSet::addTxChannel: %s", qPrintable(txChannel->getName()));
return txChannel;
}
void DeviceSet::addMIMOChannel(int selectedChannelIndex, PluginAPI *pluginAPI)
ChannelAPI *DeviceSet::addMIMOChannel(int selectedChannelIndex, PluginAPI *pluginAPI)
{
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getMIMOChannelRegistrations(); // Available channel plugins
ChannelAPI *mimoChannel;
(*channelRegistrations)[selectedChannelIndex].m_plugin->createMIMOChannel(m_deviceAPI, nullptr, &mimoChannel);
ChannelAPI *channelAPI = mimoChannel;
m_channelInstanceRegistrations.append(channelAPI);
MainCore::instance()->addChannelInstance(this, channelAPI);
m_channelInstanceRegistrations.append(mimoChannel);
MainCore::instance()->addChannelInstance(this, mimoChannel);
renameChannelInstances();
qDebug("DeviceSet::addMIMOChannel: %s", qPrintable(mimoChannel->getName()));
return mimoChannel;
}
void DeviceSet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI)

View File

@ -61,9 +61,9 @@ public:
void saveTxChannelSettings(Preset* preset);
void loadMIMOChannelSettings(const Preset* preset, PluginAPI *pluginAPI);
void saveMIMOChannelSettings(Preset* preset);
void addRxChannel(int selectedChannelIndex, PluginAPI *pluginAPI);
void addTxChannel(int selectedChannelIndex, PluginAPI *pluginAPI);
void addMIMOChannel(int selectedChannelIndex, PluginAPI *pluginAPI);
ChannelAPI *addRxChannel(int selectedChannelIndex, PluginAPI *pluginAPI);
ChannelAPI *addTxChannel(int selectedChannelIndex, PluginAPI *pluginAPI);
ChannelAPI *addMIMOChannel(int selectedChannelIndex, PluginAPI *pluginAPI);
// slave mode
void addChannelInstance(ChannelAPI *channelAPI);
void removeChannelInstanceAt(int index);

View File

@ -136,7 +136,13 @@ public:
}
int getIndexInFeatureSet() const { return m_indexInFeatureSet; }
void setIndexInFeatureSet(int indexInFeatureSet) { m_indexInFeatureSet = indexInFeatureSet; }
void setIndexInFeatureSet(int indexInFeatureSet)
{
m_indexInFeatureSet = indexInFeatureSet;
emit indexInFeatureSetChanged(m_indexInFeatureSet);
}
uint64_t getUID() const { return m_uid; }
FeatureState getState() const { return m_state; }
const QString& getErrorMessage() const { return m_errorMessage; }
@ -164,6 +170,9 @@ private:
QString m_uri; //!< Unique non modifiable identifier attached to channel type
uint64_t m_uid;
int m_indexInFeatureSet;
signals:
void indexInFeatureSetChanged(int index);
};
#endif // SDRBASE_FETURE_FEATUREAPI_H_

View File

@ -34,7 +34,7 @@ FeatureSet::~FeatureSet()
{
}
void FeatureSet::addFeature(int selectedFeatureIndex, PluginAPI *pluginAPI, WebAPIAdapterInterface *apiAdapter)
Feature *FeatureSet::addFeature(int selectedFeatureIndex, PluginAPI *pluginAPI, WebAPIAdapterInterface *apiAdapter)
{
PluginAPI::FeatureRegistrations *featureRegistrations = pluginAPI->getFeatureRegistrations(); // Available feature plugins
Feature *feature = featureRegistrations->at(selectedFeatureIndex).m_plugin->createFeature(apiAdapter);
@ -43,6 +43,7 @@ void FeatureSet::addFeature(int selectedFeatureIndex, PluginAPI *pluginAPI, WebA
m_featureInstanceRegistrations.append(feature);
MainCore::instance()->addFeatureInstance(this, feature);
renameFeatureInstances();
return feature;
}
void FeatureSet::removeFeatureInstance(Feature* feature)

View File

@ -36,7 +36,7 @@ public:
int getNumberOfFeatures() const { return m_featureInstanceRegistrations.size(); }
int getIndex() const { return m_featureTabIndex; }
void addFeature(int selectedFeatureIndex, PluginAPI *pluginAPI, WebAPIAdapterInterface *apiAdapter);
Feature *addFeature(int selectedFeatureIndex, PluginAPI *pluginAPI, WebAPIAdapterInterface *apiAdapter);
void removeFeatureInstance(Feature* feature);
void freeFeatures();
void deleteFeature(int featureIndex);

View File

@ -133,11 +133,6 @@ DeviceAPI *MainCore::getDevice(unsigned int deviceSetIndex)
}
}
void MainCore::sendDeviceChanged(int deviceSetIndex)
{
emit deviceChanged(deviceSetIndex);
}
ChannelAPI *MainCore::getChannel(unsigned int deviceSetIndex, int channelIndex)
{
if (deviceSetIndex < m_deviceSets.size()) {
@ -162,7 +157,6 @@ void MainCore::appendFeatureSet()
FeatureSet *featureSet = new FeatureSet(newIndex);
m_featureSets.push_back(featureSet);
m_featureSetsMap.insert(featureSet, newIndex);
emit featureSetAdded(newIndex);
}
void MainCore::removeFeatureSet(unsigned int index)
@ -172,7 +166,6 @@ void MainCore::removeFeatureSet(unsigned int index)
FeatureSet *featureSet = m_featureSets[index];
m_featureSetsMap.remove(featureSet);
m_featureSets.erase(m_featureSets.begin() + index);
emit featureSetRemoved(index);
}
}
@ -180,11 +173,9 @@ void MainCore::removeLastFeatureSet()
{
if (m_featureSets.size() != 0)
{
int size = m_featureSets.size();
FeatureSet *featureSet = m_featureSets.back();
m_featureSetsMap.remove(featureSet);
m_featureSets.pop_back();
emit featureSetRemoved(size - 1);
}
}
@ -194,18 +185,15 @@ void MainCore::appendDeviceSet(int deviceType)
DeviceSet *deviceSet = new DeviceSet(newIndex, deviceType);
m_deviceSets.push_back(deviceSet);
m_deviceSetsMap.insert(deviceSet, newIndex);
emit deviceSetAdded(newIndex, deviceSet->m_deviceAPI);
}
void MainCore::removeLastDeviceSet()
{
if (m_deviceSets.size() != 0)
{
int size = m_deviceSets.size();
DeviceSet *deviceSet = m_deviceSets.back();
m_deviceSetsMap.remove(deviceSet);
m_deviceSets.pop_back();
emit deviceSetRemoved(size - 1);
}
}

View File

@ -716,7 +716,6 @@ public:
std::vector<FeatureSet*>& getFeatureeSets() { return m_featureSets; }
void setLoggingOptions();
DeviceAPI *getDevice(unsigned int deviceSetIndex);
void sendDeviceChanged(int deviceSetIndex);
ChannelAPI *getChannel(unsigned int deviceSetIndex, int channelIndex);
Feature *getFeature(unsigned int featureSetIndex, int featureIndex);
bool existsChannel(const ChannelAPI *channel) const { return m_channelsMap.contains(const_cast<ChannelAPI*>(channel)); }

View File

@ -151,6 +151,11 @@ void DeviceUISet::deleteChannel(int channelIndex)
m_deviceSet->removeChannelInstanceAt(channelIndex);
}
ChannelAPI *DeviceUISet::getChannelAt(int channelIndex)
{
return m_deviceSet->getChannelAt(channelIndex);
}
void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI)
{
if (preset->isSourcePreset())

View File

@ -72,6 +72,7 @@ public:
int getNumberOfChannels() const { return m_channelInstanceRegistrations.size(); }
void freeChannels();
void deleteChannel(int channelIndex);
ChannelAPI *getChannelAt(int channelIndex);
void loadRxChannelSettings(const Preset* preset, PluginAPI *pluginAPI);
void saveRxChannelSettings(Preset* preset);
void loadTxChannelSettings(const Preset* preset, PluginAPI *pluginAPI);

View File

@ -412,6 +412,7 @@ void MainWindow::addSourceDevice(int deviceIndex)
m_deviceUIs.back()->m_deviceGUI = pluginGUI;
m_deviceUIs.back()->m_deviceAPI->getSampleSource()->init();
setDeviceGUI(deviceTabIndex, gui, deviceAPI->getSamplingDeviceDisplayName());
emit m_mainCore->deviceSetAdded(deviceTabIndex, deviceAPI);
}
void MainWindow::addSinkDevice()
@ -489,6 +490,7 @@ void MainWindow::addSinkDevice()
m_deviceUIs.back()->m_deviceGUI = pluginGUI;
m_deviceUIs.back()->m_deviceAPI->getSampleSink()->init();
setDeviceGUI(deviceTabIndex, gui, deviceAPI->getSamplingDeviceDisplayName(), 1);
emit m_mainCore->deviceSetAdded(deviceTabIndex, deviceAPI);
}
void MainWindow::addMIMODevice()
@ -574,11 +576,14 @@ void MainWindow::addMIMODevice()
m_deviceUIs.back()->m_deviceGUI = pluginGUI;
m_deviceUIs.back()->m_deviceAPI->getSampleMIMO()->init();
setDeviceGUI(deviceTabIndex, gui, deviceAPI->getSamplingDeviceDisplayName(), 2);
emit m_mainCore->deviceSetAdded(deviceTabIndex, deviceAPI);
}
void MainWindow::removeLastDevice()
{
if (m_deviceUIs.back()->m_deviceSourceEngine) // source tab
int removedTabIndex = m_deviceUIs.size() - 1;
if (m_deviceUIs.back()->m_deviceSourceEngine) // source tab
{
DSPDeviceSourceEngine *lastDeviceEngine = m_deviceUIs.back()->m_deviceSourceEngine;
lastDeviceEngine->stopAcquistion();
@ -677,6 +682,7 @@ void MainWindow::removeLastDevice()
m_deviceUIs.pop_back();
m_mainCore->removeLastDeviceSet();
emit m_mainCore->deviceSetRemoved(removedTabIndex);
}
void MainWindow::addFeatureSet()
@ -685,6 +691,7 @@ void MainWindow::addFeatureSet()
m_mainCore->appendFeatureSet();
m_featureUIs.push_back(new FeatureUISet(tabIndex, m_mainCore->m_featureSets[tabIndex]));
ui->tabFeatures->addTab(m_featureUIs.back()->m_featureWindow, QString("F%1").arg(tabIndex));
emit m_mainCore->featureSetAdded(tabIndex);
}
void MainWindow::removeFeatureSet(unsigned int tabIndex)
@ -694,6 +701,7 @@ void MainWindow::removeFeatureSet(unsigned int tabIndex)
delete m_featureUIs[tabIndex];
m_featureUIs.pop_back();
m_mainCore->removeFeatureSet(tabIndex);
emit m_mainCore->featureSetRemoved(tabIndex);
}
}
@ -1964,7 +1972,7 @@ void MainWindow::samplingDeviceChanged(int deviceType, int tabIndex, int newDevi
sampleMIMOChanged(tabIndex, newDeviceIndex);
}
MainCore::instance()->sendDeviceChanged(tabIndex);
emit MainCore::instance()->deviceChanged(tabIndex);
}
void MainWindow::sampleSourceChanged(int tabIndex, int newDeviceIndex)

View File

@ -311,6 +311,7 @@ void MainServer::addSinkDevice()
DeviceSampleSink *sink = deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
deviceAPI->getSamplingDeviceId(), deviceAPI);
deviceAPI->setSampleSink(sink);
emit m_mainCore->deviceSetAdded(deviceTabIndex, deviceAPI);
}
void MainServer::addSourceDevice()
@ -357,6 +358,7 @@ void MainServer::addSourceDevice()
DeviceSampleSource *source = deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
deviceAPI->getSamplingDeviceId(), deviceAPI);
deviceAPI->setSampleSource(source);
emit m_mainCore->deviceSetAdded(deviceTabIndex, deviceAPI);
}
void MainServer::addMIMODevice()
@ -401,10 +403,13 @@ void MainServer::addMIMODevice()
DeviceSampleMIMO *mimo = deviceAPI->getPluginInterface()->createSampleMIMOPluginInstance(
deviceAPI->getSamplingDeviceId(), deviceAPI);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSampleMIMO(mimo);
emit m_mainCore->deviceSetAdded(deviceTabIndex, deviceAPI);
}
void MainServer::removeLastDevice()
{
int removedTabIndex = m_mainCore->m_deviceSets.size() - 1;
if (m_mainCore->m_deviceSets.back()->m_deviceSourceEngine) // source set
{
DSPDeviceSourceEngine *lastDeviceEngine = m_mainCore->m_deviceSets.back()->m_deviceSourceEngine;
@ -447,6 +452,7 @@ void MainServer::removeLastDevice()
}
m_mainCore->m_deviceSets.pop_back();
emit m_mainCore->deviceSetRemoved(removedTabIndex);
}
void MainServer::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
@ -531,7 +537,7 @@ void MainServer::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // load new API settings
// Notify
m_mainCore->sendDeviceChanged(deviceSetIndex);
emit m_mainCore->deviceChanged(deviceSetIndex);
}
}
@ -701,12 +707,15 @@ void MainServer::deleteChannel(int deviceSetIndex, int channelIndex)
void MainServer::addFeatureSet()
{
m_mainCore->appendFeatureSet();
emit m_mainCore->featureSetAdded(m_mainCore->getFeatureeSets().size() - 1);
}
void MainServer::removeFeatureSet(unsigned int featureSetIndex)
{
if (featureSetIndex < m_mainCore->m_featureSets.size()) {
if (featureSetIndex < m_mainCore->m_featureSets.size())
{
m_mainCore->removeFeatureSet(featureSetIndex);
emit m_mainCore->featureSetRemoved(featureSetIndex);
}
}