1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-08 17:46:03 -05:00
sdrangel/plugins/samplesource/airspyhfi/airspyhfiplugin.cpp

128 lines
4.0 KiB
C++
Raw Normal View History

2018-02-01 03:12:38 -05:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QtPlugin>
#include <QAction>
#include <libairspyhf/airspyhf.h>
#include <device/devicesourceapi.h>
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
2018-02-05 02:38:47 -05:00
#include "airspyhfiplugin.h"
2018-02-01 03:12:38 -05:00
2018-02-05 02:38:47 -05:00
#include "airspyhfigui.h"
2018-02-01 03:12:38 -05:00
2018-02-05 02:38:47 -05:00
const PluginDescriptor AirspyHFIPlugin::m_pluginDescriptor = {
QString("AirspyHF Input (int)"),
2018-02-01 03:12:38 -05:00
QString("3.12.0"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
QString("https://github.com/f4exb/sdrangel")
};
2018-02-05 02:38:47 -05:00
const QString AirspyHFIPlugin::m_hardwareID = "AirspyHFI";
const QString AirspyHFIPlugin::m_deviceTypeID = AIRSPYHFI_DEVICE_TYPE_ID;
const int AirspyHFIPlugin::m_maxDevices = 32;
2018-02-01 03:12:38 -05:00
2018-02-05 02:38:47 -05:00
AirspyHFIPlugin::AirspyHFIPlugin(QObject* parent) :
2018-02-01 03:12:38 -05:00
QObject(parent)
{
}
2018-02-05 02:38:47 -05:00
const PluginDescriptor& AirspyHFIPlugin::getPluginDescriptor() const
2018-02-01 03:12:38 -05:00
{
return m_pluginDescriptor;
}
2018-02-05 02:38:47 -05:00
void AirspyHFIPlugin::initPlugin(PluginAPI* pluginAPI)
2018-02-01 03:12:38 -05:00
{
pluginAPI->registerSampleSource(m_deviceTypeID, this);
}
2018-02-05 02:38:47 -05:00
PluginInterface::SamplingDevices AirspyHFIPlugin::enumSampleSources()
2018-02-01 03:12:38 -05:00
{
SamplingDevices result;
int nbDevices;
uint64_t deviceSerials[m_maxDevices];
nbDevices = airspyhf_list_devices(deviceSerials, m_maxDevices);
if (nbDevices < 0)
{
2018-02-05 02:38:47 -05:00
qCritical("AirspyHFIPlugin::enumSampleSources: failed to list Airspy HF devices");
2018-02-01 03:12:38 -05:00
}
for (int i = 0; i < nbDevices; i++)
{
if (deviceSerials[i])
{
QString serial_str = QString::number(deviceSerials[i], 16);
2018-02-05 02:38:47 -05:00
QString displayedName(QString("AirspyHF(int)[%1] %2").arg(i).arg(serial_str));
2018-02-01 03:12:38 -05:00
result.append(SamplingDevice(displayedName,
m_hardwareID,
m_deviceTypeID,
serial_str,
i,
PluginInterface::SamplingDevice::PhysicalDevice,
true,
1,
0));
2018-02-05 02:38:47 -05:00
qDebug("AirspyHFIPlugin::enumSampleSources: enumerated Airspy device #%d", i);
2018-02-01 03:12:38 -05:00
}
else
{
2018-02-05 02:38:47 -05:00
qDebug("AirspyHFIPlugin::enumSampleSources: finished to enumerate Airspy HF. %d devices found", i);
2018-02-01 03:12:38 -05:00
break; // finished
}
}
return result;
}
2018-02-05 02:38:47 -05:00
PluginInstanceGUI* AirspyHFIPlugin::createSampleSourcePluginInstanceGUI(
2018-02-01 03:12:38 -05:00
const QString& sourceId,
QWidget **widget,
DeviceUISet *deviceUISet)
{
if (sourceId == m_deviceTypeID)
{
2018-02-05 02:38:47 -05:00
AirspyHFIGui* gui = new AirspyHFIGui(deviceUISet);
2018-02-01 03:12:38 -05:00
*widget = gui;
return gui;
}
else
{
return 0;
}
}
2018-02-05 02:38:47 -05:00
DeviceSampleSource *AirspyHFIPlugin::createSampleSourcePluginInstanceInput(const QString& sourceId, DeviceSourceAPI *deviceAPI)
2018-02-01 03:12:38 -05:00
{
if (sourceId == m_deviceTypeID)
{
2018-02-05 02:38:47 -05:00
AirspyHFIInput* input = new AirspyHFIInput(deviceAPI);
2018-02-01 03:12:38 -05:00
return input;
}
else
{
return 0;
}
}