SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
soapysdrinputplugin.cpp
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include <QtPlugin>
19 #include "plugin/pluginapi.h"
20 #include "util/simpleserializer.h"
22 
23 #include "soapysdrinputplugin.h"
24 
25 #ifdef SERVER_MODE
26 #include "soapysdrinput.h"
27 #else
28 #include "soapysdrinputgui.h"
29 #endif
30 
32  QString("SoapySDR Input"),
33  QString("4.5.2"),
34  QString("(c) Edouard Griffiths, F4EXB"),
35  QString("https://github.com/f4exb/sdrangel"),
36  true,
37  QString("https://github.com/f4exb/sdrangel")
38 };
39 
40 const QString SoapySDRInputPlugin::m_hardwareID = "SoapySDR";
42 
44  QObject(parent)
45 {
46 }
47 
49 {
50  return m_pluginDescriptor;
51 }
52 
54 {
55  pluginAPI->registerSampleSource(m_deviceTypeID, this);
56 }
57 
59 {
60  SamplingDevices result;
61  DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance();
62  const std::vector<DeviceSoapySDRScan::SoapySDRDeviceEnum>& devicesEnumeration = deviceSoapySDR.getDevicesEnumeration();
63  qDebug("SoapySDRInputPlugin::enumSampleSources: %lu SoapySDR devices. Enumerate these with Rx channel(s):", devicesEnumeration.size());
64  std::vector<DeviceSoapySDRScan::SoapySDRDeviceEnum>::const_iterator it = devicesEnumeration.begin();
65 
66  for (int idev = 0; it != devicesEnumeration.end(); ++it, idev++)
67  {
68  unsigned int nbRxChannels = it->m_nbRx;
69 
70  for (unsigned int ichan = 0; ichan < nbRxChannels; ichan++)
71  {
72  QString displayedName(QString("SoapySDR[%1:%2] %3").arg(idev).arg(ichan).arg(it->m_label));
73  QString serial(QString("%1-%2").arg(it->m_driverName).arg(it->m_sequence));
74  qDebug("SoapySDRInputPlugin::enumSampleSources: device #%d (%s) serial %s channel %u",
75  idev, it->m_label.toStdString().c_str(), serial.toStdString().c_str(), ichan);
76  result.append(SamplingDevice(displayedName,
79  serial,
80  idev,
83  nbRxChannels,
84  ichan));
85  }
86  }
87 
88  return result;
89 }
90 
91 #ifdef SERVER_MODE
93  const QString& sourceId,
94  QWidget **widget,
95  DeviceUISet *deviceUISet)
96 {
97  (void) sourceId;
98  (void) widget;
99  (void) deviceUISet;
100  return 0;
101 }
102 #else
104  const QString& sourceId,
105  QWidget **widget,
106  DeviceUISet *deviceUISet)
107 {
108  if(sourceId == m_deviceTypeID)
109  {
110  SoapySDRInputGui* gui = new SoapySDRInputGui(deviceUISet);
111  *widget = gui;
112  return gui;
113  }
114  else
115  {
116  return 0;
117  }
118 }
119 #endif
120 
122 {
123  if (sourceId == m_deviceTypeID)
124  {
125  SoapySDRInput *input = new SoapySDRInput(deviceAPI);
126  return input;
127  }
128  else
129  {
130  return 0;
131  }
132 }
133 
134 
135 
136 
137 
#define SOAPYSDRINPUT_DEVICE_TYPE_ID
virtual DeviceSampleSource * createSampleSourcePluginInstance(const QString &sourceId, DeviceAPI *deviceAPI)
virtual PluginInstanceGUI * createSampleSourcePluginInstanceGUI(const QString &sourceId, QWidget **widget, DeviceUISet *deviceUISet)
static DeviceSoapySDR & instance()
void registerSampleSource(const QString &sourceName, PluginInterface *plugin)
Definition: pluginapi.cpp:9
const std::vector< DeviceSoapySDRScan::SoapySDRDeviceEnum > & getDevicesEnumeration() const
static const PluginDescriptor m_pluginDescriptor
const PluginDescriptor & getPluginDescriptor() const
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
static const QString m_deviceTypeID
Exposes a single input stream that can be one of the streams of a physical device.
void initPlugin(PluginAPI *pluginAPI)
static const QString m_hardwareID
virtual SamplingDevices enumSampleSources()
QList< SamplingDevice > SamplingDevices
SoapySDRInputPlugin(QObject *parent=0)