Save/Load manually specified devices
This commit is contained in:
parent
419705419c
commit
0b6edc09b6
|
@ -303,6 +303,14 @@ float AppConfig::getSpectrumAvgSpeed() {
|
||||||
return spectrumAvgSpeed.load();
|
return spectrumAvgSpeed.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppConfig::setManualDevices(std::vector<SDRManualDef> manuals) {
|
||||||
|
manualDevices = manuals;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<SDRManualDef> AppConfig::getManualDevices() {
|
||||||
|
return manualDevices;
|
||||||
|
}
|
||||||
|
|
||||||
void AppConfig::setConfigName(std::string configName) {
|
void AppConfig::setConfigName(std::string configName) {
|
||||||
this->configName = configName;
|
this->configName = configName;
|
||||||
}
|
}
|
||||||
|
@ -354,6 +362,15 @@ bool AppConfig::save() {
|
||||||
device_config_i->second->save(device_node);
|
device_config_i->second->save(device_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (manualDevices.size()) {
|
||||||
|
DataNode *manual_node = cfg.rootNode()->newChild("manual_devices");
|
||||||
|
for (std::vector<SDRManualDef>::const_iterator i = manualDevices.begin(); i != manualDevices.end(); i++) {
|
||||||
|
DataNode *rig_node = manual_node->newChild("device");
|
||||||
|
*rig_node->newChild("factory") = i->factory;
|
||||||
|
*rig_node->newChild("params") = i->params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_HAMLIB
|
#ifdef USE_HAMLIB
|
||||||
DataNode *rig_node = cfg.rootNode()->newChild("rig");
|
DataNode *rig_node = cfg.rootNode()->newChild("rig");
|
||||||
*rig_node->newChild("model") = rigModel.load();
|
*rig_node->newChild("model") = rigModel.load();
|
||||||
|
@ -474,6 +491,22 @@ bool AppConfig::load() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg.rootNode()->hasAnother("manual_devices")) {
|
||||||
|
DataNode *manuals_node = cfg.rootNode()->getNext("manual_devices");
|
||||||
|
|
||||||
|
while (manuals_node->hasAnother("device")) {
|
||||||
|
DataNode *manual_node = manuals_node->getNext("device");
|
||||||
|
if (manual_node->hasAnother("factory") && manual_node->hasAnother("params")) {
|
||||||
|
SDRManualDef mdef;
|
||||||
|
|
||||||
|
mdef.factory = manual_node->getNext("factory")->element()->toString();
|
||||||
|
mdef.params = manual_node->getNext("params")->element()->toString();
|
||||||
|
|
||||||
|
manualDevices.push_back(mdef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_HAMLIB
|
#ifdef USE_HAMLIB
|
||||||
if (cfg.rootNode()->hasAnother("rig")) {
|
if (cfg.rootNode()->hasAnother("rig")) {
|
||||||
DataNode *rig_node = cfg.rootNode()->getNext("rig");
|
DataNode *rig_node = cfg.rootNode()->getNext("rig");
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#include "DataTree.h"
|
#include "DataTree.h"
|
||||||
|
#include "CubicSDRDefs.h"
|
||||||
|
#include "SDRDeviceInfo.h"
|
||||||
|
|
||||||
typedef std::map<std::string, std::string> ConfigSettings;
|
typedef std::map<std::string, std::string> ConfigSettings;
|
||||||
|
|
||||||
|
@ -83,6 +85,9 @@ public:
|
||||||
void setSpectrumAvgSpeed(float avgSpeed);
|
void setSpectrumAvgSpeed(float avgSpeed);
|
||||||
float getSpectrumAvgSpeed();
|
float getSpectrumAvgSpeed();
|
||||||
|
|
||||||
|
void setManualDevices(std::vector<SDRManualDef> manuals);
|
||||||
|
std::vector<SDRManualDef> getManualDevices();
|
||||||
|
|
||||||
#if USE_HAMLIB
|
#if USE_HAMLIB
|
||||||
int getRigModel();
|
int getRigModel();
|
||||||
void setRigModel(int rigModel);
|
void setRigModel(int rigModel);
|
||||||
|
@ -110,6 +115,7 @@ private:
|
||||||
std::atomic_llong centerFreq;
|
std::atomic_llong centerFreq;
|
||||||
std::atomic_int waterfallLinesPerSec;
|
std::atomic_int waterfallLinesPerSec;
|
||||||
std::atomic<float> spectrumAvgSpeed;
|
std::atomic<float> spectrumAvgSpeed;
|
||||||
|
std::vector<SDRManualDef> manualDevices;
|
||||||
#if USE_HAMLIB
|
#if USE_HAMLIB
|
||||||
std::atomic_int rigModel, rigRate;
|
std::atomic_int rigModel, rigRate;
|
||||||
std::string rigPort;
|
std::string rigPort;
|
||||||
|
|
|
@ -680,22 +680,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
||||||
"Frequency Offset", wxGetApp().getOffset(), -2000000000, 2000000000, this);
|
"Frequency Offset", wxGetApp().getOffset(), -2000000000, 2000000000, this);
|
||||||
if (ofs != -1) {
|
if (ofs != -1) {
|
||||||
wxGetApp().setOffset(ofs);
|
wxGetApp().setOffset(ofs);
|
||||||
wxGetApp().saveConfig();
|
|
||||||
}
|
}
|
||||||
} else if (event.GetId() == wxID_SET_DS_OFF) {
|
|
||||||
// wxGetApp().setDirectSampling(0);
|
|
||||||
// wxGetApp().saveConfig();
|
|
||||||
} else if (event.GetId() == wxID_SET_DS_I) {
|
|
||||||
// wxGetApp().setDirectSampling(1);
|
|
||||||
// wxGetApp().saveConfig();
|
|
||||||
} else if (event.GetId() == wxID_SET_DS_Q) {
|
|
||||||
// wxGetApp().setDirectSampling(2);
|
|
||||||
// wxGetApp().saveConfig();
|
|
||||||
} else if (event.GetId() == wxID_SET_SWAP_IQ) {
|
|
||||||
// bool swap_state = !wxGetApp().getSwapIQ();
|
|
||||||
// wxGetApp().setSwapIQ(swap_state);
|
|
||||||
// wxGetApp().saveConfig();
|
|
||||||
// iqSwapMenuItem->Check(swap_state);
|
|
||||||
} else if (event.GetId() == wxID_AGC_CONTROL) {
|
} else if (event.GetId() == wxID_AGC_CONTROL) {
|
||||||
if (wxGetApp().getDevice() == NULL) {
|
if (wxGetApp().getDevice() == NULL) {
|
||||||
agcMenuItem->Check(true);
|
agcMenuItem->Check(true);
|
||||||
|
@ -722,7 +707,6 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
||||||
long ofs = wxGetNumberFromUser("Frequency correction for device in PPM.\ni.e. -51 for -51 PPM\n\nNote: you can adjust PPM interactively\nby holding ALT over the frequency tuning bar.\n", "Parts per million (PPM)",
|
long ofs = wxGetNumberFromUser("Frequency correction for device in PPM.\ni.e. -51 for -51 PPM\n\nNote: you can adjust PPM interactively\nby holding ALT over the frequency tuning bar.\n", "Parts per million (PPM)",
|
||||||
"Frequency Correction", wxGetApp().getPPM(), -1000, 1000, this);
|
"Frequency Correction", wxGetApp().getPPM(), -1000, 1000, this);
|
||||||
wxGetApp().setPPM(ofs);
|
wxGetApp().setPPM(ofs);
|
||||||
wxGetApp().saveConfig();
|
|
||||||
} else if (event.GetId() == wxID_SAVE) {
|
} else if (event.GetId() == wxID_SAVE) {
|
||||||
if (!currentSessionFile.empty()) {
|
if (!currentSessionFile.empty()) {
|
||||||
saveSession(currentSessionFile);
|
saveSession(currentSessionFile);
|
||||||
|
@ -1007,6 +991,7 @@ void AppFrame::OnClose(wxCloseEvent& event) {
|
||||||
wxGetApp().getConfig()->setCenterFreq(wxGetApp().getFrequency());
|
wxGetApp().getConfig()->setCenterFreq(wxGetApp().getFrequency());
|
||||||
wxGetApp().getConfig()->setSpectrumAvgSpeed(wxGetApp().getSpectrumProcessor()->getFFTAverageRate());
|
wxGetApp().getConfig()->setSpectrumAvgSpeed(wxGetApp().getSpectrumProcessor()->getFFTAverageRate());
|
||||||
wxGetApp().getConfig()->setWaterfallLinesPerSec(waterfallDataThread->getLinesPerSecond());
|
wxGetApp().getConfig()->setWaterfallLinesPerSec(waterfallDataThread->getLinesPerSecond());
|
||||||
|
wxGetApp().getConfig()->setManualDevices(SDREnumerator::getManuals());
|
||||||
#ifdef USE_HAMLIB
|
#ifdef USE_HAMLIB
|
||||||
wxGetApp().getConfig()->setRigModel(rigModel);
|
wxGetApp().getConfig()->setRigModel(rigModel);
|
||||||
wxGetApp().getConfig()->setRigRate(rigSerialRate);
|
wxGetApp().getConfig()->setRigRate(rigSerialRate);
|
||||||
|
|
|
@ -25,10 +25,6 @@
|
||||||
#define wxID_SET_FREQ_OFFSET 2001
|
#define wxID_SET_FREQ_OFFSET 2001
|
||||||
#define wxID_RESET 2002
|
#define wxID_RESET 2002
|
||||||
#define wxID_SET_PPM 2003
|
#define wxID_SET_PPM 2003
|
||||||
#define wxID_SET_DS_OFF 2004
|
|
||||||
#define wxID_SET_DS_I 2005
|
|
||||||
#define wxID_SET_DS_Q 2006
|
|
||||||
#define wxID_SET_SWAP_IQ 2007
|
|
||||||
#define wxID_SDR_DEVICES 2008
|
#define wxID_SDR_DEVICES 2008
|
||||||
#define wxID_AGC_CONTROL 2009
|
#define wxID_AGC_CONTROL 2009
|
||||||
|
|
||||||
|
|
|
@ -248,6 +248,8 @@ bool CubicSDR::OnInit() {
|
||||||
|
|
||||||
sdrEnum = new SDREnumerator();
|
sdrEnum = new SDREnumerator();
|
||||||
|
|
||||||
|
SDREnumerator::setManuals(config.getManualDevices());
|
||||||
|
|
||||||
appframe = new AppFrame();
|
appframe = new AppFrame();
|
||||||
t_SDREnum = new std::thread(&SDREnumerator::threadMain, sdrEnum);
|
t_SDREnum = new std::thread(&SDREnumerator::threadMain, sdrEnum);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ SDRDevicesDialog::SDRDevicesDialog( wxWindow* parent ): devFrame( parent ) {
|
||||||
m_deviceTimer.Start(250);
|
m_deviceTimer.Start(250);
|
||||||
selId = nullptr;
|
selId = nullptr;
|
||||||
editId = nullptr;
|
editId = nullptr;
|
||||||
|
removeId = nullptr;
|
||||||
devAddDialog = nullptr;
|
devAddDialog = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,23 +148,50 @@ void SDRDevicesDialog::OnSelectionChanged( wxTreeEvent& event ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selDev->isManual()) {
|
if (selDev->isManual()) {
|
||||||
// TODO: add remove button
|
m_addRemoteButton->SetLabel("Remove");
|
||||||
|
removeId = selId;
|
||||||
|
} else {
|
||||||
|
m_addRemoteButton->SetLabel("Add");
|
||||||
|
removeId = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (selDev && !selDev->isAvailable() && selDev->isManual()) {
|
} else if (selDev && !selDev->isAvailable() && selDev->isManual()) {
|
||||||
m_propertyGrid->Clear();
|
m_propertyGrid->Clear();
|
||||||
devSettings.erase(devSettings.begin(),devSettings.end());
|
devSettings.erase(devSettings.begin(),devSettings.end());
|
||||||
props.erase(props.begin(), props.end());
|
props.erase(props.begin(), props.end());
|
||||||
|
removeId = devTree->GetSelection();
|
||||||
dev = nullptr;
|
dev = nullptr;
|
||||||
selId = nullptr;
|
selId = nullptr;
|
||||||
editId = nullptr;
|
editId = nullptr;
|
||||||
// TODO: add remove option
|
|
||||||
|
|
||||||
|
m_addRemoteButton->SetLabel("Remove");
|
||||||
|
} else if (!selDev) {
|
||||||
|
m_addRemoteButton->SetLabel("Add");
|
||||||
|
removeId = nullptr;
|
||||||
}
|
}
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRDevicesDialog::OnAddRemote( wxMouseEvent& event ) {
|
void SDRDevicesDialog::OnAddRemote( wxMouseEvent& event ) {
|
||||||
|
if (removeId != nullptr) {
|
||||||
|
SDRDeviceInfo *selDev = getSelectedDevice(removeId);
|
||||||
|
|
||||||
|
if (selDev) {
|
||||||
|
SDREnumerator::removeManual(selDev->getDriver(),selDev->getManualParams());
|
||||||
|
m_propertyGrid->Clear();
|
||||||
|
devSettings.erase(devSettings.begin(),devSettings.end());
|
||||||
|
props.erase(props.begin(), props.end());
|
||||||
|
dev = nullptr;
|
||||||
|
selId = nullptr;
|
||||||
|
editId = nullptr;
|
||||||
|
devTree->Delete(removeId);
|
||||||
|
removeId = nullptr;
|
||||||
|
m_addRemoteButton->SetLabel("Add");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
devAddDialog = new SDRDeviceAddDialog(this);
|
devAddDialog = new SDRDeviceAddDialog(this);
|
||||||
devAddDialog->ShowModal();
|
devAddDialog->ShowModal();
|
||||||
|
|
||||||
|
@ -396,6 +424,8 @@ void SDRDevicesDialog::doRefreshDevices() {
|
||||||
wxGetApp().reEnumerateDevices();
|
wxGetApp().reEnumerateDevices();
|
||||||
selId = nullptr;
|
selId = nullptr;
|
||||||
editId = nullptr;
|
editId = nullptr;
|
||||||
|
removeId = nullptr;
|
||||||
dev = nullptr;
|
dev = nullptr;
|
||||||
refresh = true;
|
refresh = true;
|
||||||
|
m_addRemoteButton->SetLabel("Add");
|
||||||
}
|
}
|
|
@ -39,5 +39,6 @@ private:
|
||||||
std::map<std::string, wxPGProperty *> devSettings;
|
std::map<std::string, wxPGProperty *> devSettings;
|
||||||
wxTreeItemId selId;
|
wxTreeItemId selId;
|
||||||
wxTreeItemId editId;
|
wxTreeItemId editId;
|
||||||
|
wxTreeItemId removeId;
|
||||||
SDRDeviceAddDialog *devAddDialog;
|
SDRDeviceAddDialog *devAddDialog;
|
||||||
};
|
};
|
|
@ -5,32 +5,10 @@
|
||||||
|
|
||||||
#include <SoapySDR/Types.hpp>
|
#include <SoapySDR/Types.hpp>
|
||||||
|
|
||||||
/*
|
typedef struct _SDRManualDef {
|
||||||
----------------------------------------------------
|
std::string factory;
|
||||||
-- Device identification
|
std::string params;
|
||||||
----------------------------------------------------
|
} SDRManualDef;
|
||||||
driver=rtl
|
|
||||||
hardware=rtl
|
|
||||||
|
|
||||||
----------------------------------------------------
|
|
||||||
-- Peripheral summary
|
|
||||||
----------------------------------------------------
|
|
||||||
Channels: 1 Rx, 0 Tx
|
|
||||||
Timestamps: NO
|
|
||||||
|
|
||||||
----------------------------------------------------
|
|
||||||
-- RX Channel 0
|
|
||||||
----------------------------------------------------
|
|
||||||
Full-duplex: YES
|
|
||||||
Antennas: RX
|
|
||||||
Full gain range: [0, 49.6] dB
|
|
||||||
LNA gain range: [0, 49.6] dB
|
|
||||||
Full freq range: [24, 1766] MHz
|
|
||||||
RF freq range: [24, 1766] MHz
|
|
||||||
CORR freq range: MHz
|
|
||||||
Sample rates: [0.25, 2.56] MHz
|
|
||||||
Filter bandwidths: [] MHz
|
|
||||||
*/
|
|
||||||
|
|
||||||
class SDRDeviceRange {
|
class SDRDeviceRange {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -176,7 +176,7 @@ std::vector<SDRDeviceInfo *> *SDREnumerator::enumerate_devices(std::string remot
|
||||||
|
|
||||||
std::string strDevArgs = "driver="+m_i->factory+","+m_i->params;
|
std::string strDevArgs = "driver="+m_i->factory+","+m_i->params;
|
||||||
|
|
||||||
manualParams.push_back(strDevArgs);
|
manualParams.push_back(m_i->params);
|
||||||
|
|
||||||
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Enumerating manual device '") + strDevArgs + "'..");
|
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Enumerating manual device '") + strDevArgs + "'..");
|
||||||
|
|
||||||
|
@ -406,6 +406,29 @@ void SDREnumerator::addManual(std::string factory, std::string params) {
|
||||||
manuals.push_back(def);
|
manuals.push_back(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDREnumerator::removeManual(std::string factory, std::string params) {
|
||||||
|
for (std::vector<SDRManualDef>::const_iterator i = manuals.begin(); i != manuals.end(); i++) {
|
||||||
|
if (i->factory == factory && i->params == params) {
|
||||||
|
manuals.erase(i);
|
||||||
|
for (std::vector<SDRDeviceInfo *>::const_iterator subdevs_i = devs[""].begin(); subdevs_i != devs[""].end(); subdevs_i++) {
|
||||||
|
if ((*subdevs_i)->isManual() && (*subdevs_i)->getDriver() == factory && (*subdevs_i)->getManualParams() == params) {
|
||||||
|
devs[""].erase(subdevs_i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<SDRManualDef> &SDREnumerator::getManuals() {
|
||||||
|
return SDREnumerator::manuals;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDREnumerator::setManuals(std::vector<SDRManualDef> manuals) {
|
||||||
|
SDREnumerator::manuals = manuals;
|
||||||
|
}
|
||||||
|
|
||||||
bool SDREnumerator::hasRemoteModule() {
|
bool SDREnumerator::hasRemoteModule() {
|
||||||
return SDREnumerator::has_remote;
|
return SDREnumerator::has_remote;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,6 @@
|
||||||
#include <SoapySDR/Registry.hpp>
|
#include <SoapySDR/Registry.hpp>
|
||||||
#include <SoapySDR/Device.hpp>
|
#include <SoapySDR/Device.hpp>
|
||||||
|
|
||||||
typedef struct _SDRManualDef {
|
|
||||||
std::string factory;
|
|
||||||
std::string params;
|
|
||||||
} SDRManualDef;
|
|
||||||
|
|
||||||
|
|
||||||
class SDREnumerator: public IOThread {
|
class SDREnumerator: public IOThread {
|
||||||
private:
|
private:
|
||||||
|
@ -36,7 +31,9 @@ public:
|
||||||
static std::vector<std::string> &getRemotes();
|
static std::vector<std::string> &getRemotes();
|
||||||
static bool hasRemoteModule();
|
static bool hasRemoteModule();
|
||||||
static void addManual(std::string factory, std::string params);
|
static void addManual(std::string factory, std::string params);
|
||||||
// static void removeManual(std::string factory, std::string params);
|
static void removeManual(std::string factory, std::string params);
|
||||||
|
static std::vector<SDRManualDef> &getManuals();
|
||||||
|
static void setManuals(std::vector<SDRManualDef> manuals);
|
||||||
static void reset();
|
static void reset();
|
||||||
static std::vector<std::string> &getFactories();
|
static std::vector<std::string> &getFactories();
|
||||||
|
|
||||||
|
@ -47,4 +44,5 @@ protected:
|
||||||
static std::vector<std::string> remotes;
|
static std::vector<std::string> remotes;
|
||||||
static std::map< std::string, std::vector<SDRDeviceInfo *> > devs;
|
static std::map< std::string, std::vector<SDRDeviceInfo *> > devs;
|
||||||
static std::vector<SDRManualDef> manuals;
|
static std::vector<SDRManualDef> manuals;
|
||||||
|
static std::mutex devs_busy;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue