mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
AFC feature: moved device scan in AFC class
This commit is contained in:
parent
0fad030382
commit
75b034180c
@ -40,6 +40,8 @@ MESSAGE_CLASS_DEFINITION(AFC::MsgConfigureAFC, Message)
|
||||
MESSAGE_CLASS_DEFINITION(AFC::MsgStartStop, Message)
|
||||
MESSAGE_CLASS_DEFINITION(AFC::MsgDeviceTrack, Message)
|
||||
MESSAGE_CLASS_DEFINITION(AFC::MsgDevicesApply, Message)
|
||||
MESSAGE_CLASS_DEFINITION(AFC::MsgDeviceSetListsQuery, Message)
|
||||
MESSAGE_CLASS_DEFINITION(AFC::MsgDeviceSetListsReport, Message)
|
||||
|
||||
const char* const AFC::m_featureIdURI = "sdrangel.feature.afc";
|
||||
const char* const AFC::m_featureId = "AFC";
|
||||
@ -170,6 +172,12 @@ bool AFC::handleMessage(const Message& cmd)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgDeviceSetListsQuery::match(cmd))
|
||||
{
|
||||
qDebug("AFC::handleMessage: MsgDeviceSetListsQuery");
|
||||
updateDeviceSetLists();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -270,6 +278,43 @@ void AFC::applySettings(const AFCSettings& settings, bool force)
|
||||
m_settings = settings;
|
||||
}
|
||||
|
||||
void AFC::updateDeviceSetLists()
|
||||
{
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
|
||||
std::vector<DeviceSet*>::const_iterator it = deviceSets.begin();
|
||||
MsgDeviceSetListsReport *msg = MsgDeviceSetListsReport::create();
|
||||
|
||||
unsigned int deviceIndex = 0;
|
||||
|
||||
for (; it != deviceSets.end(); ++it, deviceIndex++)
|
||||
{
|
||||
DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine;
|
||||
DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine;
|
||||
|
||||
if (deviceSourceEngine) {
|
||||
msg->addTrackedDevice(deviceIndex, true);
|
||||
} else if (deviceSinkEngine) {
|
||||
msg->addTrackedDevice(deviceIndex, false);
|
||||
}
|
||||
|
||||
for (int chi = 0; chi < (*it)->getNumberOfChannels(); chi++)
|
||||
{
|
||||
ChannelAPI *channel = (*it)->getChannelAt(chi);
|
||||
|
||||
if (channel->getURI() == "sdrangel.channel.freqtracker")
|
||||
{
|
||||
msg->addTrackerDevice(deviceIndex, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
getMessageQueueToGUI()->push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
int AFC::webapiRun(bool run,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage)
|
||||
@ -576,6 +621,10 @@ void AFC::networkManagerFinished(QNetworkReply *reply)
|
||||
|
||||
void AFC::trackerDeviceChange(int deviceIndex)
|
||||
{
|
||||
if (deviceIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
m_trackerDeviceSet = mainCore->getDeviceSets()[deviceIndex];
|
||||
|
||||
@ -601,6 +650,10 @@ void AFC::trackerDeviceChange(int deviceIndex)
|
||||
|
||||
void AFC::trackedDeviceChange(int deviceIndex)
|
||||
{
|
||||
if (deviceIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
m_trackedDeviceSet = mainCore->getDeviceSets()[deviceIndex];
|
||||
|
||||
|
@ -107,6 +107,52 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgDeviceSetListsQuery : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
static MsgDeviceSetListsQuery* create() {
|
||||
return new MsgDeviceSetListsQuery();
|
||||
}
|
||||
protected:
|
||||
MsgDeviceSetListsQuery() :
|
||||
Message()
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgDeviceSetListsReport : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
struct DeviceSetReference
|
||||
{
|
||||
unsigned int m_deviceIndex;
|
||||
bool m_rx;
|
||||
};
|
||||
|
||||
void addTrackerDevice(unsigned int index, bool rx) {
|
||||
m_trackerDevices.push_back(DeviceSetReference{index, rx});
|
||||
}
|
||||
void addTrackedDevice(unsigned int index, bool rx) {
|
||||
m_trackedDevices.push_back(DeviceSetReference{index, rx});
|
||||
}
|
||||
const QList<DeviceSetReference>& getTrackerDevices() const {
|
||||
return m_trackerDevices;
|
||||
}
|
||||
const QList<DeviceSetReference>& getTrackedDevices() const {
|
||||
return m_trackedDevices;
|
||||
}
|
||||
static MsgDeviceSetListsReport* create() {
|
||||
return new MsgDeviceSetListsReport();
|
||||
}
|
||||
private:
|
||||
MsgDeviceSetListsReport() :
|
||||
Message()
|
||||
{ }
|
||||
QList<DeviceSetReference> m_trackerDevices;
|
||||
QList<DeviceSetReference> m_trackedDevices;
|
||||
};
|
||||
|
||||
AFC(WebAPIAdapterInterface *webAPIAdapterInterface);
|
||||
virtual ~AFC();
|
||||
virtual void destroy() { delete this; }
|
||||
@ -175,6 +221,7 @@ private:
|
||||
void trackedDeviceChange(int deviceIndex);
|
||||
void removeTrackerFeatureReference();
|
||||
void removeTrackedFeatureReferences();
|
||||
void updateDeviceSetLists();
|
||||
|
||||
private slots:
|
||||
void networkManagerFinished(QNetworkReply *reply);
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include "ui_afcgui.h"
|
||||
#include "afcreport.h"
|
||||
#include "afc.h"
|
||||
#include "afcgui.h"
|
||||
|
||||
AFCGUI* AFCGUI::create(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature)
|
||||
@ -93,6 +92,11 @@ bool AFCGUI::handleMessage(const Message& message)
|
||||
m_autoTargetStatusTimer.start(500);
|
||||
return true;
|
||||
}
|
||||
else if (AFC::MsgDeviceSetListsReport::match(message))
|
||||
{
|
||||
const AFC::MsgDeviceSetListsReport& report = (AFC::MsgDeviceSetListsReport&) message;
|
||||
updateDeviceSetLists(report);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -155,7 +159,7 @@ AFCGUI::AFCGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *featur
|
||||
|
||||
m_settings.setRollupState(&m_rollupState);
|
||||
|
||||
updateDeviceSetLists();
|
||||
requestDeviceSetLists();
|
||||
displaySettings();
|
||||
applySettings(true);
|
||||
}
|
||||
@ -185,47 +189,37 @@ void AFCGUI::displaySettings()
|
||||
blockApplySettings(false);
|
||||
}
|
||||
|
||||
void AFCGUI::updateDeviceSetLists()
|
||||
void AFCGUI::requestDeviceSetLists()
|
||||
{
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
|
||||
std::vector<DeviceSet*>::const_iterator it = deviceSets.begin();
|
||||
AFC::MsgDeviceSetListsQuery *msg = AFC::MsgDeviceSetListsQuery::create();
|
||||
m_afc->getInputMessageQueue()->push(msg);
|
||||
}
|
||||
|
||||
void AFCGUI::updateDeviceSetLists(const AFC::MsgDeviceSetListsReport& report)
|
||||
{
|
||||
ui->trackerDevice->blockSignals(true);
|
||||
ui->trackedDevice->blockSignals(true);
|
||||
|
||||
ui->trackerDevice->clear();
|
||||
ui->trackedDevice->clear();
|
||||
|
||||
unsigned int deviceIndex = 0;
|
||||
for (const auto& deviceSetRef : report.getTrackerDevices()) {
|
||||
ui->trackerDevice->addItem(QString("R%1").arg(deviceSetRef.m_deviceIndex), deviceSetRef.m_deviceIndex);
|
||||
}
|
||||
|
||||
for (; it != deviceSets.end(); ++it, deviceIndex++)
|
||||
for (const auto& deviceSetRef : report.getTrackedDevices())
|
||||
{
|
||||
DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine;
|
||||
DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine;
|
||||
|
||||
if (deviceSourceEngine) {
|
||||
ui->trackedDevice->addItem(QString("R%1").arg(deviceIndex), deviceIndex);
|
||||
} else if (deviceSinkEngine) {
|
||||
ui->trackedDevice->addItem(QString("T%1").arg(deviceIndex), deviceIndex);
|
||||
}
|
||||
|
||||
for (int chi = 0; chi < (*it)->getNumberOfChannels(); chi++)
|
||||
{
|
||||
ChannelAPI *channel = (*it)->getChannelAt(chi);
|
||||
|
||||
if (channel->getURI() == "sdrangel.channel.freqtracker")
|
||||
{
|
||||
ui->trackerDevice->addItem(QString("R%1").arg(deviceIndex), deviceIndex);
|
||||
break;
|
||||
}
|
||||
if (deviceSetRef.m_rx) {
|
||||
ui->trackedDevice->addItem(QString("R%1").arg(deviceSetRef.m_deviceIndex), deviceSetRef.m_deviceIndex);
|
||||
} else {
|
||||
ui->trackedDevice->addItem(QString("T%1").arg(deviceSetRef.m_deviceIndex), deviceSetRef.m_deviceIndex);
|
||||
}
|
||||
}
|
||||
|
||||
int trackedDeviceIndex;
|
||||
int trackerDeviceIndex;
|
||||
|
||||
if (deviceIndex > 0)
|
||||
if ((report.getTrackerDevices().size() > 0) && (report.getTrackedDevices().size() > 0))
|
||||
{
|
||||
if (m_settings.m_trackedDeviceSetIndex < 0) {
|
||||
ui->trackedDevice->setCurrentIndex(0);
|
||||
@ -344,8 +338,7 @@ void AFCGUI::on_deviceTrack_clicked()
|
||||
|
||||
void AFCGUI::on_devicesRefresh_clicked()
|
||||
{
|
||||
updateDeviceSetLists();
|
||||
displaySettings();
|
||||
requestDeviceSetLists();
|
||||
}
|
||||
|
||||
void AFCGUI::on_trackerDevice_currentIndexChanged(int index)
|
||||
|
@ -25,11 +25,10 @@
|
||||
#include "settings/rollupstate.h"
|
||||
|
||||
#include "afcsettings.h"
|
||||
#include "afc.h"
|
||||
|
||||
class PluginAPI;
|
||||
class FeatureUISet;
|
||||
class AFC;
|
||||
|
||||
namespace Ui {
|
||||
class AFCGUI;
|
||||
}
|
||||
@ -65,7 +64,8 @@ private:
|
||||
void blockApplySettings(bool block);
|
||||
void applySettings(bool force = false);
|
||||
void displaySettings();
|
||||
void updateDeviceSetLists();
|
||||
void requestDeviceSetLists();
|
||||
void updateDeviceSetLists(const AFC::MsgDeviceSetListsReport& report);
|
||||
bool handleMessage(const Message& message);
|
||||
|
||||
void leaveEvent(QEvent*);
|
||||
|
@ -179,6 +179,10 @@ void AFCWorker::applySettings(const AFCSettings& settings, bool force)
|
||||
|
||||
void AFCWorker::initTrackerDeviceSet(int deviceSetIndex)
|
||||
{
|
||||
if (deviceSetIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
m_trackerDeviceSet = mainCore->getDeviceSets()[deviceSetIndex];
|
||||
|
||||
@ -231,6 +235,10 @@ void AFCWorker::initTrackerDeviceSet(int deviceSetIndex)
|
||||
|
||||
void AFCWorker::initTrackedDeviceSet(int deviceSetIndex)
|
||||
{
|
||||
if (deviceSetIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
m_trackedDeviceSet = mainCore->getDeviceSets()[deviceSetIndex];
|
||||
m_channelsMap.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user