| 
									
										
										
										
											2016-05-14 15:06:08 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  | // Copyright (C) 2015-2017 Edouard Griffiths, F4EXB                              //
 | 
					
						
							| 
									
										
										
										
											2016-05-14 15:06:08 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  | #include "samplingdevicecontrol.h"
 | 
					
						
							|  |  |  | #include "samplingdevicedialog.h"
 | 
					
						
							| 
									
										
										
										
											2016-05-14 15:06:08 +02:00
										 |  |  | #include "plugin/pluginmanager.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  | #include "device/deviceenumerator.h"
 | 
					
						
							| 
									
										
										
										
											2016-05-14 15:06:08 +02:00
										 |  |  | #include "ui_samplingdevicecontrol.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  | SamplingDeviceControl::SamplingDeviceControl(int tabIndex, bool rxElseTx, QWidget* parent) : | 
					
						
							| 
									
										
										
										
											2016-05-14 15:06:08 +02:00
										 |  |  |     QWidget(parent), | 
					
						
							|  |  |  |     ui(new Ui::SamplingDeviceControl), | 
					
						
							| 
									
										
										
										
											2017-11-01 20:06:33 +01:00
										 |  |  |     m_pluginManager(0), | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  |     m_deviceTabIndex(tabIndex), | 
					
						
							|  |  |  |     m_rxElseTx(rxElseTx), | 
					
						
							|  |  |  |     m_selectedDeviceIndex(-1) | 
					
						
							| 
									
										
										
										
											2016-05-14 15:06:08 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     ui->setupUi(this); | 
					
						
							| 
									
										
										
										
											2017-11-02 14:29:49 +01:00
										 |  |  |     ui->deviceSelectedText->setText("None"); | 
					
						
							| 
									
										
										
										
											2016-05-14 15:06:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SamplingDeviceControl::~SamplingDeviceControl() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  | void SamplingDeviceControl::on_deviceChange_clicked() | 
					
						
							| 
									
										
										
										
											2016-05-14 15:06:08 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  |     SamplingDeviceDialog dialog(m_rxElseTx, m_deviceTabIndex, this); | 
					
						
							|  |  |  |     dialog.exec(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (dialog.getSelectedDeviceIndex() >= 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_selectedDeviceIndex = dialog.getSelectedDeviceIndex(); | 
					
						
							|  |  |  |         setSelectedDeviceIndex(m_selectedDeviceIndex); | 
					
						
							|  |  |  |         emit changed(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-05-14 15:06:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  | void SamplingDeviceControl::on_deviceReload_clicked() | 
					
						
							| 
									
										
										
										
											2016-05-17 14:21:27 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  |     if (m_selectedDeviceIndex >= 0) { | 
					
						
							|  |  |  |         emit changed(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SamplingDeviceControl::setSelectedDeviceIndex(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_rxElseTx) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(index); | 
					
						
							| 
									
										
										
										
											2017-11-02 03:49:14 +01:00
										 |  |  |         DeviceEnumerator::instance()->changeRxSelection(m_deviceTabIndex, index); | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  |         ui->deviceSelectedText->setText(samplingDevice.displayedName); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(index); | 
					
						
							| 
									
										
										
										
											2017-11-02 03:49:14 +01:00
										 |  |  |         DeviceEnumerator::instance()->changeTxSelection(m_deviceTabIndex, index); | 
					
						
							| 
									
										
										
										
											2017-11-02 03:30:54 +01:00
										 |  |  |         ui->deviceSelectedText->setText(samplingDevice.displayedName); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_selectedDeviceIndex = index; | 
					
						
							| 
									
										
										
										
											2016-05-17 14:21:27 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 14:29:49 +01:00
										 |  |  | void SamplingDeviceControl::removeSelectedDeviceIndex() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_rxElseTx) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceEnumerator::instance()->removeRxSelection(m_deviceTabIndex); | 
					
						
							|  |  |  |         ui->deviceSelectedText->setText("None"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceEnumerator::instance()->removeTxSelection(m_deviceTabIndex); | 
					
						
							|  |  |  |         ui->deviceSelectedText->setText("None"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_selectedDeviceIndex = -1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-14 02:04:22 +02:00
										 |  |  | QComboBox *SamplingDeviceControl::getChannelSelector() | 
					
						
							| 
									
										
										
										
											2016-05-14 18:12:39 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-10-14 02:04:22 +02:00
										 |  |  |     return ui->channelSelect; | 
					
						
							| 
									
										
										
										
											2016-05-14 18:12:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-14 02:04:22 +02:00
										 |  |  | QPushButton *SamplingDeviceControl::getAddChannelButton() | 
					
						
							| 
									
										
										
										
											2016-05-14 18:12:39 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-10-14 02:04:22 +02:00
										 |  |  |     return ui->addChannel; | 
					
						
							| 
									
										
										
										
											2016-05-14 18:12:39 +02:00
										 |  |  | } |