kopia lustrzana https://github.com/f4exb/sdrangel
				
				
				
			Device UI set and Device set channel registrations unification
							rodzic
							
								
									ac39e55779
								
							
						
					
					
						commit
						836fd6f4e2
					
				|  | @ -82,85 +82,82 @@ void DeviceUISet::addRollupWidget(QWidget *widget) | |||
| 
 | ||||
| void DeviceUISet::registerRxChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI) | ||||
| { | ||||
|     m_rxChannelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, pluginGUI)); | ||||
|     renameRxChannelInstances(); | ||||
|     m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, pluginGUI, 0)); | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceUISet::registerTxChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI) | ||||
| { | ||||
|     m_txChannelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, pluginGUI)); | ||||
|     renameTxChannelInstances(); | ||||
|     m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, pluginGUI, 1)); | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceUISet::registerChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI) | ||||
| { | ||||
|     m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, pluginGUI, 2)); | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceUISet::removeRxChannelInstance(PluginInstanceGUI* pluginGUI) | ||||
| { | ||||
|     for(ChannelInstanceRegistrations::iterator it = m_rxChannelInstanceRegistrations.begin(); it != m_rxChannelInstanceRegistrations.end(); ++it) | ||||
|     for (ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it) | ||||
|     { | ||||
|         if(it->m_gui == pluginGUI) | ||||
|         if (it->m_gui == pluginGUI) | ||||
|         { | ||||
|             m_rxChannelInstanceRegistrations.erase(it); | ||||
|             m_channelInstanceRegistrations.erase(it); | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     renameRxChannelInstances(); | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceUISet::removeTxChannelInstance(PluginInstanceGUI* pluginGUI) | ||||
| { | ||||
|     for(ChannelInstanceRegistrations::iterator it = m_txChannelInstanceRegistrations.begin(); it != m_txChannelInstanceRegistrations.end(); ++it) | ||||
|     for (ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it) | ||||
|     { | ||||
|         if(it->m_gui == pluginGUI) | ||||
|         if (it->m_gui == pluginGUI) | ||||
|         { | ||||
|             m_txChannelInstanceRegistrations.erase(it); | ||||
|             m_channelInstanceRegistrations.erase(it); | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     renameTxChannelInstances(); | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceUISet::freeRxChannels() | ||||
| void DeviceUISet::removeChannelInstance(PluginInstanceGUI* pluginGUI) | ||||
| { | ||||
|     for(int i = 0; i < m_rxChannelInstanceRegistrations.count(); i++) | ||||
|     for (ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it) | ||||
|     { | ||||
|         qDebug("DeviceUISet::freeAll: destroying channel [%s]", qPrintable(m_rxChannelInstanceRegistrations[i].m_channelName)); | ||||
|         m_rxChannelInstanceRegistrations[i].m_gui->destroy(); | ||||
|         if (it->m_gui == pluginGUI) | ||||
|         { | ||||
|             m_channelInstanceRegistrations.erase(it); | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceUISet::freeChannels() | ||||
| { | ||||
|     for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) | ||||
|     { | ||||
|         qDebug("DeviceUISet::freeChannels: destroying channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelName)); | ||||
|         m_channelInstanceRegistrations[i].m_gui->destroy(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceUISet::freeTxChannels() | ||||
| void DeviceUISet::deleteChannel(int channelIndex) | ||||
| { | ||||
|     for(int i = 0; i < m_txChannelInstanceRegistrations.count(); i++) | ||||
|     if ((channelIndex >= 0) && (channelIndex < m_channelInstanceRegistrations.count())) | ||||
|     { | ||||
|         qDebug("DeviceUISet::freeAll: destroying channel [%s]", qPrintable(m_txChannelInstanceRegistrations[i].m_channelName)); | ||||
|         m_txChannelInstanceRegistrations[i].m_gui->destroy(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceUISet::deleteRxChannel(int channelIndex) | ||||
| { | ||||
|     if ((channelIndex >= 0) && (channelIndex < m_rxChannelInstanceRegistrations.count())) | ||||
|     { | ||||
|         qDebug("DeviceUISet::deleteRxChennel: delete channel [%s] at %d", | ||||
|                 qPrintable(m_rxChannelInstanceRegistrations[channelIndex].m_channelName), | ||||
|         qDebug("DeviceUISet::deleteChannel: delete channel [%s] at %d", | ||||
|                 qPrintable(m_channelInstanceRegistrations[channelIndex].m_channelName), | ||||
|                 channelIndex); | ||||
|         m_rxChannelInstanceRegistrations[channelIndex].m_gui->destroy(); | ||||
|         m_rxChannelInstanceRegistrations.removeAt(channelIndex); | ||||
|         renameRxChannelInstances(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceUISet::deleteTxChannel(int channelIndex) | ||||
| { | ||||
|     if ((channelIndex >= 0) && (channelIndex < m_txChannelInstanceRegistrations.count())) | ||||
|     { | ||||
|         qDebug("DeviceUISet::deleteTxChennel: delete channel [%s] at %d", | ||||
|                 qPrintable(m_txChannelInstanceRegistrations[channelIndex].m_channelName), | ||||
|                 channelIndex); | ||||
|         m_txChannelInstanceRegistrations[channelIndex].m_gui->destroy(); | ||||
|         m_txChannelInstanceRegistrations.removeAt(channelIndex); | ||||
|         renameTxChannelInstances(); | ||||
|         m_channelInstanceRegistrations.removeAt(channelIndex); | ||||
|         renameChannelInstances(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -174,8 +171,8 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA | |||
|         PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations(); | ||||
| 
 | ||||
|         // copy currently open channels and clear list
 | ||||
|         ChannelInstanceRegistrations openChannels = m_rxChannelInstanceRegistrations; | ||||
|         m_rxChannelInstanceRegistrations.clear(); | ||||
|         ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations; | ||||
|         m_channelInstanceRegistrations.clear(); | ||||
| 
 | ||||
|         for(int i = 0; i < openChannels.count(); i++) | ||||
|         { | ||||
|  | @ -204,7 +201,7 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA | |||
|                             (*channelRegistrations)[i].m_plugin->createRxChannelBS(m_deviceAPI); | ||||
|                     PluginInstanceGUI *rxChannelGUI = | ||||
|                             (*channelRegistrations)[i].m_plugin->createRxChannelGUI(this, rxChannel); | ||||
|                     reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, rxChannelGUI); | ||||
|                     reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, rxChannelGUI, 0); | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|  | @ -216,7 +213,7 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         renameRxChannelInstances(); | ||||
|         renameChannelInstances(); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|  | @ -228,12 +225,12 @@ void DeviceUISet::saveRxChannelSettings(Preset *preset) | |||
| { | ||||
|     if (preset->isSourcePreset()) | ||||
|     { | ||||
|         qSort(m_rxChannelInstanceRegistrations.begin(), m_rxChannelInstanceRegistrations.end()); // sort by increasing delta frequency and type
 | ||||
|         qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
 | ||||
| 
 | ||||
|         for(int i = 0; i < m_rxChannelInstanceRegistrations.count(); i++) | ||||
|         for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) | ||||
|         { | ||||
|             qDebug("DeviceUISet::saveRxChannelSettings: channel [%s] saved", qPrintable(m_rxChannelInstanceRegistrations[i].m_channelName)); | ||||
|             preset->addChannel(m_rxChannelInstanceRegistrations[i].m_channelName, m_rxChannelInstanceRegistrations[i].m_gui->serialize()); | ||||
|             qDebug("DeviceUISet::saveRxChannelSettings: channel [%s] saved", qPrintable(m_channelInstanceRegistrations[i].m_channelName)); | ||||
|             preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize()); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|  | @ -256,8 +253,8 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA | |||
|         PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getTxChannelRegistrations(); | ||||
| 
 | ||||
|         // copy currently open channels and clear list
 | ||||
|         ChannelInstanceRegistrations openChannels = m_txChannelInstanceRegistrations; | ||||
|         m_txChannelInstanceRegistrations.clear(); | ||||
|         ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations; | ||||
|         m_channelInstanceRegistrations.clear(); | ||||
| 
 | ||||
|         for(int i = 0; i < openChannels.count(); i++) | ||||
|         { | ||||
|  | @ -285,7 +282,7 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA | |||
|                             (*channelRegistrations)[i].m_plugin->createTxChannelBS(m_deviceAPI); | ||||
|                     PluginInstanceGUI *txChannelGUI = | ||||
|                             (*channelRegistrations)[i].m_plugin->createTxChannelGUI(this, txChannel); | ||||
|                     reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, txChannelGUI); | ||||
|                     reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, txChannelGUI, 1); | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|  | @ -297,7 +294,7 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         renameTxChannelInstances(); | ||||
|         renameChannelInstances(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -309,29 +306,27 @@ void DeviceUISet::saveTxChannelSettings(Preset *preset) | |||
|     } | ||||
|     else | ||||
|     { | ||||
|         qSort(m_txChannelInstanceRegistrations.begin(), m_txChannelInstanceRegistrations.end()); // sort by increasing delta frequency and type
 | ||||
|         qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
 | ||||
| 
 | ||||
|         for(int i = 0; i < m_txChannelInstanceRegistrations.count(); i++) | ||||
|         for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) | ||||
|         { | ||||
|             qDebug("DeviceUISet::saveTxChannelSettings: channel [%s] saved", qPrintable(m_txChannelInstanceRegistrations[i].m_channelName)); | ||||
|             preset->addChannel(m_txChannelInstanceRegistrations[i].m_channelName, m_txChannelInstanceRegistrations[i].m_gui->serialize()); | ||||
|             qDebug("DeviceUISet::saveTxChannelSettings: channel [%s] saved", qPrintable(m_channelInstanceRegistrations[i].m_channelName)); | ||||
|             preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceUISet::renameRxChannelInstances() | ||||
| void DeviceUISet::renameChannelInstances() | ||||
| { | ||||
|     for(int i = 0; i < m_rxChannelInstanceRegistrations.count(); i++) | ||||
|     { | ||||
|         m_rxChannelInstanceRegistrations[i].m_gui->setName(QString("%1:%2").arg(m_rxChannelInstanceRegistrations[i].m_channelName).arg(i)); | ||||
|     } | ||||
| } | ||||
|     int mimoCount = 0; | ||||
| 
 | ||||
| void DeviceUISet::renameTxChannelInstances() | ||||
| { | ||||
|     for(int i = 0; i < m_txChannelInstanceRegistrations.count(); i++) | ||||
|     for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) | ||||
|     { | ||||
|         m_txChannelInstanceRegistrations[i].m_gui->setName(QString("%1:%2").arg(m_txChannelInstanceRegistrations[i].m_channelName).arg(i)); | ||||
|         if (m_channelInstanceTypes[i] == 2) | ||||
|         { | ||||
|             m_channelInstanceRegistrations[i].m_gui->setName(QString("%1:%2").arg(m_channelInstanceRegistrations[i].m_channelName).arg(i)); | ||||
|             mimoCount++; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -58,20 +58,20 @@ public: | |||
|     void addChannelMarker(ChannelMarker* channelMarker); //!< Add channel marker to spectrum
 | ||||
|     void addRollupWidget(QWidget *widget);               //!< Add rollup widget to channel window
 | ||||
| 
 | ||||
|     int getNumberOfRxChannels() const { return m_rxChannelInstanceRegistrations.size(); } | ||||
|     int getNumberOfTxChannels() const { return m_txChannelInstanceRegistrations.size(); } | ||||
|     int getNumberOfChannels() const { return m_channelInstanceRegistrations.size(); } | ||||
|     void registerRxChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI); | ||||
|     void registerTxChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI); | ||||
|     void registerChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI); | ||||
|     void removeRxChannelInstance(PluginInstanceGUI* pluginGUI); | ||||
|     void removeTxChannelInstance(PluginInstanceGUI* pluginGUI); | ||||
|     void freeRxChannels(); | ||||
|     void freeTxChannels(); | ||||
|     void deleteRxChannel(int channelIndex); | ||||
|     void deleteTxChannel(int channelIndex); | ||||
|     void removeChannelInstance(PluginInstanceGUI* pluginGUI); | ||||
|     void freeChannels(); | ||||
|     void deleteChannel(int channelIndex); | ||||
|     void loadRxChannelSettings(const Preset* preset, PluginAPI *pluginAPI); | ||||
|     void saveRxChannelSettings(Preset* preset); | ||||
|     void loadTxChannelSettings(const Preset* preset, PluginAPI *pluginAPI); | ||||
|     void saveTxChannelSettings(Preset* preset); | ||||
|     //TODO: load and save MIMO channel settings when preset has MIMO type defined
 | ||||
| 
 | ||||
|     // These are the number of channel types available for selection
 | ||||
|     void setNumberOfAvailableRxChannels(int number) { m_nbAvailableRxChannels = number; } | ||||
|  | @ -86,15 +86,18 @@ private: | |||
|     { | ||||
|         QString m_channelName; | ||||
|         PluginInstanceGUI* m_gui; | ||||
|         int m_channelType; | ||||
| 
 | ||||
|         ChannelInstanceRegistration() : | ||||
|             m_channelName(), | ||||
|             m_gui(nullptr) | ||||
|             m_gui(nullptr), | ||||
|             m_channelType(0) | ||||
|         { } | ||||
| 
 | ||||
|         ChannelInstanceRegistration(const QString& channelName, PluginInstanceGUI* pluginGUI) : | ||||
|         ChannelInstanceRegistration(const QString& channelName, PluginInstanceGUI* pluginGUI, int channelType) : | ||||
|             m_channelName(channelName), | ||||
|             m_gui(pluginGUI) | ||||
|             m_gui(pluginGUI), | ||||
|             m_channelType(channelType) | ||||
|         { } | ||||
| 
 | ||||
|         bool operator<(const ChannelInstanceRegistration& other) const; | ||||
|  | @ -102,15 +105,16 @@ private: | |||
| 
 | ||||
|     typedef QList<ChannelInstanceRegistration> ChannelInstanceRegistrations; | ||||
| 
 | ||||
|     ChannelInstanceRegistrations m_rxChannelInstanceRegistrations; | ||||
|     ChannelInstanceRegistrations m_txChannelInstanceRegistrations; | ||||
|     // ChannelInstanceRegistrations m_rxChannelInstanceRegistrations;
 | ||||
|     // ChannelInstanceRegistrations m_txChannelInstanceRegistrations;
 | ||||
|     ChannelInstanceRegistrations m_channelInstanceRegistrations; | ||||
|     QList<int> m_channelInstanceTypes; | ||||
|     int m_deviceTabIndex; | ||||
|     int m_nbAvailableRxChannels;   //!< Number of Rx channels available for selection
 | ||||
|     int m_nbAvailableTxChannels;   //!< Number of Tx channels available for selection
 | ||||
|     int m_nbAvailableMIMOChannels; //!< Number of MIMO channels available for selection
 | ||||
| 
 | ||||
|     void renameRxChannelInstances(); | ||||
|     void renameTxChannelInstances(); | ||||
|     void renameChannelInstances(); | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -518,7 +518,7 @@ void MainWindow::removeLastDevice() | |||
| 	    ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1); | ||||
| 
 | ||||
|         // deletes old UI and input object
 | ||||
|         m_deviceUIs.back()->freeRxChannels();      // destroys the channel instances
 | ||||
|         m_deviceUIs.back()->freeChannels();      // destroys the channel instances
 | ||||
|         m_deviceUIs.back()->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(0); // have source stop sending messages to the GUI
 | ||||
|         m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceGUI( | ||||
|                 m_deviceUIs.back()->m_deviceAPI->getSamplingDevicePluginInstanceGUI()); | ||||
|  | @ -560,7 +560,7 @@ void MainWindow::removeLastDevice() | |||
| 	    ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1); | ||||
| 
 | ||||
|         // deletes old UI and output object
 | ||||
|         m_deviceUIs.back()->freeTxChannels(); | ||||
|         m_deviceUIs.back()->freeChannels(); | ||||
|         m_deviceUIs.back()->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(0); // have sink stop sending messages to the GUI
 | ||||
| 	    m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceGUI( | ||||
| 	            m_deviceUIs.back()->m_deviceAPI->getSamplingDevicePluginInstanceGUI()); | ||||
|  | @ -602,8 +602,7 @@ void MainWindow::removeLastDevice() | |||
| 	    ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1); | ||||
| 
 | ||||
|         // deletes old UI and output object
 | ||||
|         m_deviceUIs.back()->freeRxChannels(); | ||||
|         m_deviceUIs.back()->freeTxChannels(); | ||||
|         m_deviceUIs.back()->freeChannels(); | ||||
|         m_deviceUIs.back()->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
 | ||||
| 	    m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceGUI( | ||||
| 	            m_deviceUIs.back()->m_deviceAPI->getSamplingDevicePluginInstanceGUI()); | ||||
|  | @ -642,15 +641,7 @@ void MainWindow::deleteChannel(int deviceSetIndex, int channelIndex) | |||
|     if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_deviceUIs.size())) | ||||
|     { | ||||
|         DeviceUISet *deviceSet = m_deviceUIs[deviceSetIndex]; | ||||
| 
 | ||||
|         if (deviceSet->m_deviceSourceEngine) // source device => Rx channels
 | ||||
|         { | ||||
|             deviceSet->deleteRxChannel(channelIndex); | ||||
|         } | ||||
|         else if (deviceSet->m_deviceSinkEngine) // sink device => Tx channels
 | ||||
|         { | ||||
|             deviceSet->deleteTxChannel(channelIndex); | ||||
|         } | ||||
|         deviceSet->deleteChannel(channelIndex); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -250,23 +250,20 @@ private: | |||
|     public: | ||||
|         int getDeviceSetIndex() const { return m_deviceSetIndex; } | ||||
|         int getChannelIndex() const { return m_channelIndex; } | ||||
|         bool isTx() const { return m_tx; } | ||||
| 
 | ||||
|         static MsgDeleteChannel* create(int deviceSetIndex, int channelIndex, bool tx) | ||||
|         static MsgDeleteChannel* create(int deviceSetIndex, int channelIndex) | ||||
|         { | ||||
|             return new MsgDeleteChannel(deviceSetIndex, channelIndex, tx); | ||||
|             return new MsgDeleteChannel(deviceSetIndex, channelIndex); | ||||
|         } | ||||
| 
 | ||||
|     private: | ||||
|         int m_deviceSetIndex; | ||||
|         int m_channelIndex; | ||||
|         bool m_tx; | ||||
| 
 | ||||
|         MsgDeleteChannel(int deviceSetIndex, int channelIndex, bool tx) : | ||||
|         MsgDeleteChannel(int deviceSetIndex, int channelIndex) : | ||||
|             Message(), | ||||
|             m_deviceSetIndex(deviceSetIndex), | ||||
|             m_channelIndex(channelIndex), | ||||
|             m_tx(tx) | ||||
|             m_channelIndex(channelIndex) | ||||
|         { } | ||||
|     }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1648,53 +1648,23 @@ int WebAPIAdapterGUI::devicesetChannelDelete( | |||
|     { | ||||
|         DeviceUISet *deviceSet = m_mainWindow.m_deviceUIs[deviceSetIndex]; | ||||
| 
 | ||||
|         if (deviceSet->m_deviceSourceEngine) // Rx
 | ||||
|         if (channelIndex < deviceSet->getNumberOfChannels()) | ||||
|         { | ||||
|             if (channelIndex < deviceSet->getNumberOfRxChannels()) | ||||
|             { | ||||
|                 MainWindow::MsgDeleteChannel *msg = MainWindow::MsgDeleteChannel::create(deviceSetIndex, channelIndex, false); | ||||
|                 m_mainWindow.m_inputMessageQueue.push(msg); | ||||
|             MainWindow::MsgDeleteChannel *msg = MainWindow::MsgDeleteChannel::create(deviceSetIndex, channelIndex); | ||||
|             m_mainWindow.m_inputMessageQueue.push(msg); | ||||
| 
 | ||||
|                 response.init(); | ||||
|                 *response.getMessage() = QString("Message to delete a channel (MsgDeleteChannel) was submitted successfully"); | ||||
|             response.init(); | ||||
|             *response.getMessage() = QString("Message to delete a channel (MsgDeleteChannel) was submitted successfully"); | ||||
| 
 | ||||
|                 return 202; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 error.init(); | ||||
|                 *error.getMessage() = QString("There is no channel at index %1. There are %2 Rx channels") | ||||
|                         .arg(channelIndex) | ||||
|                         .arg(channelIndex < deviceSet->getNumberOfRxChannels()); | ||||
|                 return 400; | ||||
|             } | ||||
|         } | ||||
|         else if (deviceSet->m_deviceSinkEngine) // Tx
 | ||||
|         { | ||||
|             if (channelIndex < deviceSet->getNumberOfTxChannels()) | ||||
|             { | ||||
|                 MainWindow::MsgDeleteChannel *msg = MainWindow::MsgDeleteChannel::create(deviceSetIndex, channelIndex, true); | ||||
|                 m_mainWindow.m_inputMessageQueue.push(msg); | ||||
| 
 | ||||
|                 response.init(); | ||||
|                 *response.getMessage() = QString("Message to delete a channel (MsgDeleteChannel) was submitted successfully"); | ||||
| 
 | ||||
|                 return 202; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 error.init(); | ||||
|                 *error.getMessage() = QString("There is no channel at index %1. There are %2 Tx channels") | ||||
|                         .arg(channelIndex) | ||||
|                         .arg(channelIndex < deviceSet->getNumberOfRxChannels()); | ||||
|                 return 400; | ||||
|             } | ||||
|             return 202; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             error.init(); | ||||
|             *error.getMessage() = QString("DeviceSet error"); | ||||
|             return 500; | ||||
|             *error.getMessage() = QString("There is no channel at index %1. There are %2 channels") | ||||
|                     .arg(channelIndex) | ||||
|                     .arg(channelIndex < deviceSet->getNumberOfChannels()); | ||||
|             return 400; | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|  |  | |||
|  | @ -29,25 +29,8 @@ | |||
| 
 | ||||
| DeviceSet::ChannelInstanceRegistration::ChannelInstanceRegistration(const QString& channelName, ChannelAPI* channelAPI) : | ||||
|     m_channelName(channelName), | ||||
|     m_channelSinkAPI(channelAPI), | ||||
|     m_channelSourceAPI(0) | ||||
| { | ||||
|     if (channelAPI->getStreamType() == ChannelAPI::StreamSingleSink) | ||||
|     { | ||||
|         m_channelSinkAPI = channelAPI; | ||||
|         m_channelSourceAPI = nullptr; | ||||
|     } | ||||
|     else if (channelAPI->getStreamType() == ChannelAPI::StreamSingleSource) | ||||
|     { | ||||
|         m_channelSinkAPI = nullptr; | ||||
|         m_channelSourceAPI = channelAPI; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         m_channelSinkAPI = nullptr; | ||||
|         m_channelSourceAPI = nullptr; | ||||
|     } | ||||
| } | ||||
|     m_channelAPI(channelAPI) | ||||
| {} | ||||
| 
 | ||||
| DeviceSet::DeviceSet(int tabIndex) | ||||
| { | ||||
|  | @ -64,79 +47,80 @@ DeviceSet::~DeviceSet() | |||
| 
 | ||||
| void DeviceSet::registerRxChannelInstance(const QString& channelName, ChannelAPI* channelAPI) | ||||
| { | ||||
|     m_rxChannelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI)); | ||||
|     renameRxChannelInstances(); | ||||
|     m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI)); | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::registerTxChannelInstance(const QString& channelName, ChannelAPI* channelAPI) | ||||
| { | ||||
|     m_txChannelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI)); | ||||
|     renameTxChannelInstances(); | ||||
|     m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI)); | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::registerChannelInstance(const QString& channelName, ChannelAPI* channelAPI) | ||||
| { | ||||
|     m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI)); | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::removeRxChannelInstance(ChannelAPI* channelAPI) | ||||
| { | ||||
|     for(ChannelInstanceRegistrations::iterator it = m_rxChannelInstanceRegistrations.begin(); it != m_rxChannelInstanceRegistrations.end(); ++it) | ||||
|     for (ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it) | ||||
|     { | ||||
|         if(it->m_channelSinkAPI == channelAPI) | ||||
|         if (it->m_channelAPI == channelAPI) | ||||
|         { | ||||
|             m_rxChannelInstanceRegistrations.erase(it); | ||||
|             m_channelInstanceRegistrations.erase(it); | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     renameRxChannelInstances(); | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::removeTxChannelInstance(ChannelAPI* channelAPI) | ||||
| { | ||||
|     for(ChannelInstanceRegistrations::iterator it = m_txChannelInstanceRegistrations.begin(); it != m_txChannelInstanceRegistrations.end(); ++it) | ||||
|     for(ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it) | ||||
|     { | ||||
|         if(it->m_channelSourceAPI == channelAPI) | ||||
|         if(it->m_channelAPI == channelAPI) | ||||
|         { | ||||
|             m_txChannelInstanceRegistrations.erase(it); | ||||
|             m_channelInstanceRegistrations.erase(it); | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     renameTxChannelInstances(); | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::freeRxChannels() | ||||
| void DeviceSet::removeChannelInstance(ChannelAPI* channelAPI) | ||||
| { | ||||
|     for(int i = 0; i < m_rxChannelInstanceRegistrations.count(); i++) | ||||
|     for(ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it) | ||||
|     { | ||||
|         qDebug("DeviceSet::freeAll: destroying channel [%s]", qPrintable(m_rxChannelInstanceRegistrations[i].m_channelName)); | ||||
|         m_rxChannelInstanceRegistrations[i].m_channelSinkAPI->destroy(); | ||||
|         if(it->m_channelAPI == channelAPI) | ||||
|         { | ||||
|             m_channelInstanceRegistrations.erase(it); | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     renameChannelInstances(); | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::freeChannels() | ||||
| { | ||||
|     for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) | ||||
|     { | ||||
|         qDebug("DeviceSet::freeChannels: destroying channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelName)); | ||||
|         m_channelInstanceRegistrations[i].m_channelAPI->destroy(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::freeTxChannels() | ||||
| void DeviceSet::deleteChannel(int channelIndex) | ||||
| { | ||||
|     for(int i = 0; i < m_txChannelInstanceRegistrations.count(); i++) | ||||
|     if (channelIndex < m_channelInstanceRegistrations.count()) | ||||
|     { | ||||
|         qDebug("DeviceSet::freeAll: destroying channel [%s]", qPrintable(m_txChannelInstanceRegistrations[i].m_channelName)); | ||||
|         m_txChannelInstanceRegistrations[i].m_channelSourceAPI->destroy(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::deleteRxChannel(int channelIndex) | ||||
| { | ||||
|     if (channelIndex < m_rxChannelInstanceRegistrations.count()) | ||||
|     { | ||||
|         m_rxChannelInstanceRegistrations[channelIndex].m_channelSinkAPI->destroy(); | ||||
|         m_rxChannelInstanceRegistrations.removeAt(channelIndex); | ||||
|         renameRxChannelInstances(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::deleteTxChannel(int channelIndex) | ||||
| { | ||||
|     if (channelIndex < m_txChannelInstanceRegistrations.count()) | ||||
|     { | ||||
|         m_txChannelInstanceRegistrations[channelIndex].m_channelSourceAPI->destroy(); | ||||
|         m_txChannelInstanceRegistrations.removeAt(channelIndex); | ||||
|         renameTxChannelInstances(); | ||||
|         m_channelInstanceRegistrations[channelIndex].m_channelAPI->destroy(); | ||||
|         m_channelInstanceRegistrations.removeAt(channelIndex); | ||||
|         renameChannelInstances(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -145,7 +129,7 @@ void DeviceSet::addRxChannel(int selectedChannelIndex, PluginAPI *pluginAPI) | |||
|     PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations(); // Available channel plugins
 | ||||
|     ChannelAPI *rxChannel =(*channelRegistrations)[selectedChannelIndex].m_plugin->createRxChannelCS(m_deviceAPI); | ||||
|     ChannelInstanceRegistration reg = ChannelInstanceRegistration(rxChannel->getName(), rxChannel); | ||||
|     m_rxChannelInstanceRegistrations.append(reg); | ||||
|     m_channelInstanceRegistrations.append(reg); | ||||
|     qDebug("DeviceSet::addRxChannel: %s", qPrintable(rxChannel->getName())); | ||||
| } | ||||
| 
 | ||||
|  | @ -154,10 +138,19 @@ void DeviceSet::addTxChannel(int selectedChannelIndex, PluginAPI *pluginAPI) | |||
|     PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getTxChannelRegistrations(); // Available channel plugins
 | ||||
|     ChannelAPI *txChannel = (*channelRegistrations)[selectedChannelIndex].m_plugin->createTxChannelCS(m_deviceAPI); | ||||
|     ChannelInstanceRegistration reg = ChannelInstanceRegistration(txChannel->getName(), txChannel); | ||||
|     m_txChannelInstanceRegistrations.append(reg); | ||||
|     m_channelInstanceRegistrations.append(reg); | ||||
|     qDebug("DeviceSet::addTxChannel: %s", qPrintable(txChannel->getName())); | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::addMIMOChannel(int selectedChannelIndex, PluginAPI *pluginAPI) | ||||
| { | ||||
|     PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getMIMOChannelRegistrations(); // Available channel plugins
 | ||||
|     ChannelAPI *mimoChannel = (*channelRegistrations)[selectedChannelIndex].m_plugin->createMIMOChannelCS(m_deviceAPI); | ||||
|     ChannelInstanceRegistration reg = ChannelInstanceRegistration(mimoChannel->getName(), mimoChannel); | ||||
|     m_channelInstanceRegistrations.append(reg); | ||||
|     qDebug("DeviceSet::addMIMOChannel: %s", qPrintable(mimoChannel->getName())); | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI) | ||||
| { | ||||
|     if (preset->isSourcePreset()) | ||||
|  | @ -168,8 +161,8 @@ void DeviceSet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI | |||
|         PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations(); | ||||
| 
 | ||||
|         // copy currently open channels and clear list
 | ||||
|         ChannelInstanceRegistrations openChannels = m_rxChannelInstanceRegistrations; | ||||
|         m_rxChannelInstanceRegistrations.clear(); | ||||
|         ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations; | ||||
|         m_channelInstanceRegistrations.clear(); | ||||
| 
 | ||||
|         qDebug("DeviceSet::loadChannelSettings: %d channel(s) in preset", preset->getChannelCount()); | ||||
| 
 | ||||
|  | @ -189,14 +182,14 @@ void DeviceSet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI | |||
|                 { | ||||
|                     qDebug("DeviceSet::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName)); | ||||
|                     reg = openChannels.takeAt(i); | ||||
|                     m_rxChannelInstanceRegistrations.append(reg); | ||||
|                     m_channelInstanceRegistrations.append(reg); | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             // if we haven't one already, create one
 | ||||
| 
 | ||||
|             if (reg.m_channelSinkAPI == 0) | ||||
|             if (reg.m_channelAPI == nullptr) | ||||
|             { | ||||
|                 for (int i = 0; i < channelRegistrations->count(); i++) | ||||
|                 { | ||||
|  | @ -208,16 +201,16 @@ void DeviceSet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI | |||
|                                 qPrintable(channelConfig.m_channelIdURI)); | ||||
|                         ChannelAPI *rxChannel = (*channelRegistrations)[i].m_plugin->createRxChannelCS(m_deviceAPI); | ||||
|                         reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, rxChannel); | ||||
|                         m_rxChannelInstanceRegistrations.append(reg); | ||||
|                         m_channelInstanceRegistrations.append(reg); | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             if (reg.m_channelSinkAPI != 0) | ||||
|             if (reg.m_channelAPI != nullptr) | ||||
|             { | ||||
|                 qDebug("DeviceSet::loadChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI)); | ||||
|                 reg.m_channelSinkAPI->deserialize(channelConfig.m_config); | ||||
|                 reg.m_channelAPI->deserialize(channelConfig.m_config); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | @ -225,10 +218,10 @@ void DeviceSet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI | |||
|         for (int i = 0; i < openChannels.count(); i++) | ||||
|         { | ||||
|             qDebug("DeviceSet::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName)); | ||||
|             openChannels[i].m_channelSinkAPI->destroy(); | ||||
|             openChannels[i].m_channelAPI->destroy(); | ||||
|         } | ||||
| 
 | ||||
|         renameRxChannelInstances(); | ||||
|         renameChannelInstances(); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|  | @ -240,12 +233,12 @@ void DeviceSet::saveRxChannelSettings(Preset *preset) | |||
| { | ||||
|     if (preset->isSourcePreset()) | ||||
|     { | ||||
|         qSort(m_rxChannelInstanceRegistrations.begin(), m_rxChannelInstanceRegistrations.end()); // sort by increasing delta frequency and type
 | ||||
|         qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
 | ||||
| 
 | ||||
|         for(int i = 0; i < m_rxChannelInstanceRegistrations.count(); i++) | ||||
|         for (int i = 0; i < m_channelInstanceRegistrations.count(); i++) | ||||
|         { | ||||
|             qDebug("DeviceSet::saveChannelSettings: channel [%s] saved", qPrintable(m_rxChannelInstanceRegistrations[i].m_channelName)); | ||||
|             preset->addChannel(m_rxChannelInstanceRegistrations[i].m_channelName, m_rxChannelInstanceRegistrations[i].m_channelSinkAPI->serialize()); | ||||
|             qDebug("DeviceSet::saveChannelSettings: channel [%s] saved", qPrintable(m_channelInstanceRegistrations[i].m_channelName)); | ||||
|             preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_channelAPI->serialize()); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|  | @ -268,63 +261,63 @@ void DeviceSet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginAPI | |||
|         PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getTxChannelRegistrations(); | ||||
| 
 | ||||
|         // copy currently open channels and clear list
 | ||||
|         ChannelInstanceRegistrations openChannels = m_txChannelInstanceRegistrations; | ||||
|         m_txChannelInstanceRegistrations.clear(); | ||||
|         ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations; | ||||
|         m_channelInstanceRegistrations.clear(); | ||||
| 
 | ||||
|         qDebug("DeviceSet::loadChannelSettings: %d channel(s) in preset", preset->getChannelCount()); | ||||
| 
 | ||||
|         for(int i = 0; i < preset->getChannelCount(); i++) | ||||
|         for (int i = 0; i < preset->getChannelCount(); i++) | ||||
|         { | ||||
|             const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i); | ||||
|             ChannelInstanceRegistration reg; | ||||
| 
 | ||||
|             // if we have one instance available already, use it
 | ||||
| 
 | ||||
|             for(int i = 0; i < openChannels.count(); i++) | ||||
|             for (int i = 0; i < openChannels.count(); i++) | ||||
|             { | ||||
|                 qDebug("DeviceSet::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channelIdURI)); | ||||
| 
 | ||||
|                 if(openChannels[i].m_channelName == channelConfig.m_channelIdURI) | ||||
|                 if (openChannels[i].m_channelName == channelConfig.m_channelIdURI) | ||||
|                 { | ||||
|                     qDebug("DeviceSet::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName)); | ||||
|                     reg = openChannels.takeAt(i); | ||||
|                     m_txChannelInstanceRegistrations.append(reg); | ||||
|                     m_channelInstanceRegistrations.append(reg); | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             // if we haven't one already, create one
 | ||||
| 
 | ||||
|             if(reg.m_channelSourceAPI == 0) | ||||
|             if (reg.m_channelAPI == nullptr) | ||||
|             { | ||||
|                 for(int i = 0; i < channelRegistrations->count(); i++) | ||||
|                 for (int i = 0; i < channelRegistrations->count(); i++) | ||||
|                 { | ||||
|                     if((*channelRegistrations)[i].m_channelIdURI == channelConfig.m_channelIdURI) | ||||
|                     if ((*channelRegistrations)[i].m_channelIdURI == channelConfig.m_channelIdURI) | ||||
|                     { | ||||
|                         qDebug("DeviceSet::loadChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channelIdURI)); | ||||
|                         ChannelAPI *txChannel = (*channelRegistrations)[i].m_plugin->createTxChannelCS(m_deviceAPI); | ||||
|                         reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, txChannel); | ||||
|                         m_txChannelInstanceRegistrations.append(reg); | ||||
|                         m_channelInstanceRegistrations.append(reg); | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             if(reg.m_channelSourceAPI != 0) | ||||
|             if (reg.m_channelAPI != nullptr) | ||||
|             { | ||||
|                 qDebug("DeviceSet::loadChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI)); | ||||
|                 reg.m_channelSourceAPI->deserialize(channelConfig.m_config); | ||||
|                 reg.m_channelAPI->deserialize(channelConfig.m_config); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // everything, that is still "available" is not needed anymore
 | ||||
|         for(int i = 0; i < openChannels.count(); i++) | ||||
|         for (int i = 0; i < openChannels.count(); i++) | ||||
|         { | ||||
|             qDebug("DeviceSet::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName)); | ||||
|             openChannels[i].m_channelSourceAPI->destroy(); | ||||
|             openChannels[i].m_channelAPI->destroy(); | ||||
|         } | ||||
| 
 | ||||
|         renameTxChannelInstances(); | ||||
|         renameChannelInstances(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -336,55 +329,36 @@ void DeviceSet::saveTxChannelSettings(Preset *preset) | |||
|     } | ||||
|     else | ||||
|     { | ||||
|         qSort(m_txChannelInstanceRegistrations.begin(), m_txChannelInstanceRegistrations.end()); // sort by increasing delta frequency and type
 | ||||
|         qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
 | ||||
| 
 | ||||
|         for(int i = 0; i < m_txChannelInstanceRegistrations.count(); i++) | ||||
|         for (int i = 0; i < m_channelInstanceRegistrations.count(); i++) | ||||
|         { | ||||
|             qDebug("DeviceSet::saveChannelSettings: channel [%s] saved", qPrintable(m_txChannelInstanceRegistrations[i].m_channelName)); | ||||
|             preset->addChannel(m_txChannelInstanceRegistrations[i].m_channelName, m_txChannelInstanceRegistrations[i].m_channelSourceAPI->serialize()); | ||||
|             qDebug("DeviceSet::saveChannelSettings: channel [%s] saved", qPrintable(m_channelInstanceRegistrations[i].m_channelName)); | ||||
|             preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_channelAPI->serialize()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::renameRxChannelInstances() | ||||
| void DeviceSet::renameChannelInstances() | ||||
| { | ||||
|     for(int i = 0; i < m_rxChannelInstanceRegistrations.count(); i++) | ||||
|     for (int i = 0; i < m_channelInstanceRegistrations.count(); i++) | ||||
|     { | ||||
|         m_rxChannelInstanceRegistrations[i].m_channelSinkAPI->setName(QString("%1:%2").arg(m_rxChannelInstanceRegistrations[i].m_channelName).arg(i)); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void DeviceSet::renameTxChannelInstances() | ||||
| { | ||||
|     for(int i = 0; i < m_txChannelInstanceRegistrations.count(); i++) | ||||
|     { | ||||
|         m_txChannelInstanceRegistrations[i].m_channelSourceAPI->setName(QString("%1:%2").arg(m_txChannelInstanceRegistrations[i].m_channelName).arg(i)); | ||||
|         m_channelInstanceRegistrations[i].m_channelAPI->setName(QString("%1:%2").arg(m_channelInstanceRegistrations[i].m_channelName).arg(i)); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| // sort by increasing delta frequency and type (i.e. name)
 | ||||
| bool DeviceSet::ChannelInstanceRegistration::operator<(const ChannelInstanceRegistration& other) const | ||||
| { | ||||
|     if (m_channelSinkAPI && other.m_channelSinkAPI) | ||||
|     if (m_channelAPI && other.m_channelAPI) | ||||
|     { | ||||
|         if (m_channelSinkAPI->getCenterFrequency() == other.m_channelSinkAPI->getCenterFrequency()) | ||||
|         if (m_channelAPI->getCenterFrequency() == other.m_channelAPI->getCenterFrequency()) | ||||
|         { | ||||
|             return m_channelSinkAPI->getName() < other.m_channelSinkAPI->getName(); | ||||
|             return m_channelAPI->getName() < other.m_channelAPI->getName(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return m_channelSinkAPI->getCenterFrequency() < other.m_channelSinkAPI->getCenterFrequency(); | ||||
|         } | ||||
|     } | ||||
|     else if (m_channelSourceAPI && other.m_channelSourceAPI) | ||||
|     { | ||||
|         if (m_channelSourceAPI->getCenterFrequency() == other.m_channelSourceAPI->getCenterFrequency()) | ||||
|         { | ||||
|             return m_channelSourceAPI->getName() < other.m_channelSourceAPI->getName(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return m_channelSourceAPI->getCenterFrequency() < other.m_channelSourceAPI->getCenterFrequency(); | ||||
|             return m_channelAPI->getCenterFrequency() < other.m_channelAPI->getCenterFrequency(); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|  |  | |||
|  | @ -39,18 +39,18 @@ public: | |||
|     DeviceSet(int tabIndex); | ||||
|     ~DeviceSet(); | ||||
| 
 | ||||
|     int getNumberOfRxChannels() const { return m_rxChannelInstanceRegistrations.size(); } | ||||
|     int getNumberOfTxChannels() const { return m_txChannelInstanceRegistrations.size(); } | ||||
|     int getNumberOfChannels() const { return m_channelInstanceRegistrations.size(); } | ||||
|     void addRxChannel(int selectedChannelIndex, PluginAPI *pluginAPI); | ||||
|     void addTxChannel(int selectedChannelIndex, PluginAPI *pluginAPI); | ||||
|     void deleteRxChannel(int channelIndex); | ||||
|     void deleteTxChannel(int channelIndex); | ||||
|     void addMIMOChannel(int selectedChannelIndex, PluginAPI *pluginAPI); | ||||
|     void deleteChannel(int channelIndex); | ||||
|     void registerRxChannelInstance(const QString& channelName, ChannelAPI* channelAPI); | ||||
|     void registerTxChannelInstance(const QString& channelName, ChannelAPI* channelAPI); | ||||
|     void registerChannelInstance(const QString& channelName, ChannelAPI* channelAPI); | ||||
|     void removeRxChannelInstance(ChannelAPI* channelAPI); | ||||
|     void removeTxChannelInstance(ChannelAPI* channelAPI); | ||||
|     void freeRxChannels(); | ||||
|     void freeTxChannels(); | ||||
|     void removeChannelInstance(ChannelAPI* channelAPI); | ||||
|     void freeChannels(); | ||||
|     void loadRxChannelSettings(const Preset* preset, PluginAPI *pluginAPI); | ||||
|     void saveRxChannelSettings(Preset* preset); | ||||
|     void loadTxChannelSettings(const Preset* preset, PluginAPI *pluginAPI); | ||||
|  | @ -60,13 +60,11 @@ private: | |||
|     struct ChannelInstanceRegistration | ||||
|     { | ||||
|         QString m_channelName; | ||||
|         ChannelAPI *m_channelSinkAPI; | ||||
|         ChannelAPI *m_channelSourceAPI; | ||||
|         ChannelAPI *m_channelAPI; | ||||
| 
 | ||||
|         ChannelInstanceRegistration() : | ||||
|             m_channelName(), | ||||
|             m_channelSinkAPI(nullptr), | ||||
|             m_channelSourceAPI(nullptr) | ||||
|             m_channelAPI(nullptr) | ||||
|         { } | ||||
| 
 | ||||
|         ChannelInstanceRegistration(const QString& channelName, ChannelAPI* channelAPI); | ||||
|  | @ -76,12 +74,10 @@ private: | |||
| 
 | ||||
|     typedef QList<ChannelInstanceRegistration> ChannelInstanceRegistrations; | ||||
| 
 | ||||
|     ChannelInstanceRegistrations m_rxChannelInstanceRegistrations; | ||||
|     ChannelInstanceRegistrations m_txChannelInstanceRegistrations; | ||||
|     ChannelInstanceRegistrations m_channelInstanceRegistrations; | ||||
|     int m_deviceTabIndex; | ||||
| 
 | ||||
|     void renameRxChannelInstances(); | ||||
|     void renameTxChannelInstances(); | ||||
|     void renameChannelInstances(); | ||||
| }; | ||||
| 
 | ||||
| #endif /* SDRSRV_DEVICE_DEVICESET_H_ */ | ||||
|  |  | |||
|  | @ -365,7 +365,7 @@ void MainCore::removeLastDevice() | |||
|         lastDeviceEngine->stopAcquistion(); | ||||
| 
 | ||||
|         // deletes old UI and input object
 | ||||
|         m_deviceSets.back()->freeRxChannels();      // destroys the channel instances
 | ||||
|         m_deviceSets.back()->freeChannels();      // destroys the channel instances
 | ||||
|         m_deviceSets.back()->m_deviceAPI->resetSamplingDeviceId(); | ||||
|         m_deviceSets.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput( | ||||
|                 m_deviceSets.back()->m_deviceAPI->getSampleSource()); | ||||
|  | @ -385,7 +385,7 @@ void MainCore::removeLastDevice() | |||
|         lastDeviceEngine->stopGeneration(); | ||||
| 
 | ||||
|         // deletes old UI and output object
 | ||||
|         m_deviceSets.back()->freeTxChannels(); | ||||
|         m_deviceSets.back()->freeChannels(); | ||||
|         m_deviceSets.back()->m_deviceAPI->resetSamplingDeviceId(); | ||||
|         m_deviceSets.back()->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput( | ||||
|                 m_deviceSets.back()->m_deviceAPI->getSampleSink()); | ||||
|  | @ -561,15 +561,7 @@ void MainCore::deleteChannel(int deviceSetIndex, int channelIndex) | |||
|     if (deviceSetIndex >= 0) | ||||
|     { | ||||
|         DeviceSet *deviceSet = m_deviceSets[deviceSetIndex]; | ||||
| 
 | ||||
|         if (deviceSet->m_deviceSourceEngine) // source device => Rx channels
 | ||||
|         { | ||||
|             deviceSet->deleteRxChannel(channelIndex); | ||||
|         } | ||||
|         else if (deviceSet->m_deviceSinkEngine) // sink device => Tx channels
 | ||||
|         { | ||||
|             deviceSet->deleteTxChannel(channelIndex); | ||||
|         } | ||||
|         deviceSet->deleteChannel(channelIndex); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -250,23 +250,20 @@ private: | |||
|     public: | ||||
|         int getDeviceSetIndex() const { return m_deviceSetIndex; } | ||||
|         int getChannelIndex() const { return m_channelIndex; } | ||||
|         bool isTx() const { return m_tx; } | ||||
| 
 | ||||
|         static MsgDeleteChannel* create(int deviceSetIndex, int channelIndex, bool tx) | ||||
|         static MsgDeleteChannel* create(int deviceSetIndex, int channelIndex) | ||||
|         { | ||||
|             return new MsgDeleteChannel(deviceSetIndex, channelIndex, tx); | ||||
|             return new MsgDeleteChannel(deviceSetIndex, channelIndex); | ||||
|         } | ||||
| 
 | ||||
|     private: | ||||
|         int m_deviceSetIndex; | ||||
|         int m_channelIndex; | ||||
|         bool m_tx; | ||||
| 
 | ||||
|         MsgDeleteChannel(int deviceSetIndex, int channelIndex, bool tx) : | ||||
|         MsgDeleteChannel(int deviceSetIndex, int channelIndex) : | ||||
|             Message(), | ||||
|             m_deviceSetIndex(deviceSetIndex), | ||||
|             m_channelIndex(channelIndex), | ||||
|             m_tx(tx) | ||||
|             m_channelIndex(channelIndex) | ||||
|         { } | ||||
|     }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1733,53 +1733,23 @@ int WebAPIAdapterSrv::devicesetChannelDelete( | |||
|     { | ||||
|         DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; | ||||
| 
 | ||||
|         if (deviceSet->m_deviceSourceEngine) // Rx
 | ||||
|         if (channelIndex < deviceSet->getNumberOfChannels()) | ||||
|         { | ||||
|             if (channelIndex < deviceSet->getNumberOfRxChannels()) | ||||
|             { | ||||
|                 MainCore::MsgDeleteChannel *msg = MainCore::MsgDeleteChannel::create(deviceSetIndex, channelIndex, false); | ||||
|                 m_mainCore.m_inputMessageQueue.push(msg); | ||||
|             MainCore::MsgDeleteChannel *msg = MainCore::MsgDeleteChannel::create(deviceSetIndex, channelIndex); | ||||
|             m_mainCore.m_inputMessageQueue.push(msg); | ||||
| 
 | ||||
|                 response.init(); | ||||
|                 *response.getMessage() = QString("Message to delete a channel (MsgDeleteChannel) was submitted successfully"); | ||||
|             response.init(); | ||||
|             *response.getMessage() = QString("Message to delete a channel (MsgDeleteChannel) was submitted successfully"); | ||||
| 
 | ||||
|                 return 202; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 error.init(); | ||||
|                 *error.getMessage() = QString("There is no channel at index %1. There are %2 Rx channels") | ||||
|                         .arg(channelIndex) | ||||
|                         .arg(channelIndex < deviceSet->getNumberOfRxChannels()); | ||||
|                 return 400; | ||||
|             } | ||||
|         } | ||||
|         else if (deviceSet->m_deviceSinkEngine) // Tx
 | ||||
|         { | ||||
|             if (channelIndex < deviceSet->getNumberOfTxChannels()) | ||||
|             { | ||||
|                 MainCore::MsgDeleteChannel *msg = MainCore::MsgDeleteChannel::create(deviceSetIndex, channelIndex, true); | ||||
|                 m_mainCore.m_inputMessageQueue.push(msg); | ||||
| 
 | ||||
|                 response.init(); | ||||
|                 *response.getMessage() = QString("Message to delete a channel (MsgDeleteChannel) was submitted successfully"); | ||||
| 
 | ||||
|                 return 202; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 error.init(); | ||||
|                 *error.getMessage() = QString("There is no channel at index %1. There are %2 Tx channels") | ||||
|                         .arg(channelIndex) | ||||
|                         .arg(channelIndex < deviceSet->getNumberOfRxChannels()); | ||||
|                 return 400; | ||||
|             } | ||||
|             return 202; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             error.init(); | ||||
|             *error.getMessage() = QString("DeviceSet error"); | ||||
|             return 500; | ||||
|             *error.getMessage() = QString("There is no channel at index %1. There are %2 channels") | ||||
|                     .arg(channelIndex) | ||||
|                     .arg(channelIndex < deviceSet->getNumberOfChannels()); | ||||
|             return 400; | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 f4exb
						f4exb