From bcc5f8560f5b2234abea4a38fdd2b16845010fef Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 3 Nov 2015 00:53:39 -0500 Subject: [PATCH] Device dialog /w editable SoapySDR config -- not actually applied yet :) --- src/AppFrame.cpp | 22 +--- src/CubicSDR.cpp | 1 + src/forms/SDRDevices/SDRDevices.cpp | 129 +++++++++++++++++++----- src/forms/SDRDevices/SDRDevices.fbp | 2 +- src/forms/SDRDevices/SDRDevices.h | 3 + src/forms/SDRDevices/SDRDevicesForm.cpp | 2 +- 6 files changed, 110 insertions(+), 49 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 58bbe13..9e86fba 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -196,6 +196,7 @@ AppFrame::AppFrame() : waterfallDataThread->setInputQueue("IQDataInput", wxGetApp().getWaterfallVisualQueue()); waterfallDataThread->setOutputQueue("FFTDataOutput", waterfallCanvas->getVisualDataQueue()); + waterfallDataThread->getProcessor()->setHideDC(true); t_FFTData = new std::thread(&FFTVisualDataThread::threadMain, waterfallDataThread); @@ -636,24 +637,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) { } break; } - -// std::vector *devs = wxGetApp().getDevices(); -// if (event.GetId() >= wxID_DEVICE_ID && event.GetId() <= wxID_DEVICE_ID + devs->size()) { -// int devId = event.GetId() - wxID_DEVICE_ID; -// wxGetApp().setDevice(devId); -// -// SDRDeviceInfo *dev = (*wxGetApp().getDevices())[devId]; -// DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); -// -// int dsMode = devConfig->getDirectSampling(); -// -// if (dsMode >= 0 && dsMode <= 2) { -// directSamplingMenuItems[devConfig->getDirectSampling()]->Check(); -// } -// -// iqSwapMenuItem->Check(devConfig->getIQSwap()); -// } - + if (event.GetId() >= wxID_BANDWIDTH_BASE && event.GetId() < wxID_BANDWIDTH_BASE+sampleRates.size()) { wxGetApp().setSampleRate(sampleRates[event.GetId()-wxID_BANDWIDTH_BASE]); } @@ -864,7 +848,6 @@ void AppFrame::OnIdle(wxIdleEvent& event) { // wxGetApp().getSpectrumDistributor()->run(); SpectrumVisualProcessor *proc = wxGetApp().getSpectrumProcessor(); - proc->setHideDC(true); if (spectrumAvgMeter->inputChanged()) { float val = spectrumAvgMeter->getInputValue(); @@ -891,7 +874,6 @@ void AppFrame::OnIdle(wxIdleEvent& event) { dproc->setCenterFrequency(demodWaterfallCanvas->getCenterFrequency()); SpectrumVisualProcessor *wproc = waterfallDataThread->getProcessor(); - wproc->setHideDC(true); if (waterfallSpeedMeter->inputChanged()) { float val = waterfallSpeedMeter->getInputValue(); diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index c93f45e..986d213 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -159,6 +159,7 @@ bool CubicSDR::OnInit() { getDemodSpectrumProcessor()->setInput(pipeDemodIQVisualData); getSpectrumProcessor()->setInput(pipeIQVisualData); + getSpectrumProcessor()->setHideDC(true); pipeAudioVisualData = new DemodulatorThreadOutputQueue(); pipeAudioVisualData->set_max_num_items(1); diff --git a/src/forms/SDRDevices/SDRDevices.cpp b/src/forms/SDRDevices/SDRDevices.cpp index 25501c6..a158201 100644 --- a/src/forms/SDRDevices/SDRDevices.cpp +++ b/src/forms/SDRDevices/SDRDevices.cpp @@ -11,30 +11,7 @@ SDRDevicesDialog::SDRDevicesDialog( wxWindow* parent ): devFrame( parent ) { m_useSelectedButton->Disable(); m_deviceTimer.Start(250); - - // Add int property - m_propertyGrid->Append( new wxIntProperty("IntProperty", wxPG_LABEL, 12345678) ); - // Add float property (value type is actually double) - m_propertyGrid->Append( new wxFloatProperty("FloatProperty", wxPG_LABEL, 12345.678) ); - // Add a bool property - m_propertyGrid->Append( new wxBoolProperty("BoolProperty", wxPG_LABEL, false) ); - // A string property that can be edited in a separate editor dialog. - m_propertyGrid->Append( new wxLongStringProperty("LongStringProperty", - wxPG_LABEL, - "This is much longer string than the " - "first one. Edit it by clicking the button.")); - // String editor with dir selector button. - m_propertyGrid->Append( new wxDirProperty("DirProperty", wxPG_LABEL, ::wxGetUserHome()) ); - // wxArrayStringProperty embeds a wxArrayString. - m_propertyGrid->Append( new wxArrayStringProperty("Label of ArrayStringProperty", - "NameOfArrayStringProp")); - // A file selector property. - m_propertyGrid->Append( new wxFileProperty("FileProperty", wxPG_LABEL, wxEmptyString) ); - // Extra: set wild card for file property (format same as in wxFileDialog). - m_propertyGrid->SetPropertyAttribute( "FileProperty", - wxPG_FILE_WILDCARD, - "All files (*.*)|*.*" ); -} + } void SDRDevicesDialog::OnClose( wxCloseEvent& event ) { wxGetApp().setDeviceSelectorClosed(); @@ -45,7 +22,98 @@ void SDRDevicesDialog::OnDeleteItem( wxTreeEvent& event ) { event.Skip(); } +wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR::ArgInfo arg) { + + wxPGProperty *prop = NULL; + + int intVal; + double floatVal; + std::vector::iterator stringIter; + + switch (arg.type) { + case SoapySDR::ArgInfo::INT: + try { + intVal = std::stoi(arg.value); + } catch (std::invalid_argument e) { + intVal = 0; + } + prop = pg->Append( new wxIntProperty(arg.name, wxPG_LABEL, intVal) ); + if (arg.range.minimum() != arg.range.maximum()) { + pg->SetPropertyAttribute( prop, wxPG_ATTR_MIN, arg.range.minimum()); + pg->SetPropertyAttribute( prop, wxPG_ATTR_MAX, arg.range.maximum()); + } + break; + case SoapySDR::ArgInfo::FLOAT: + try { + floatVal = std::stod(arg.value); + } catch (std::invalid_argument e) { + floatVal = 0; + } + prop = pg->Append( new wxFloatProperty(arg.name, wxPG_LABEL, floatVal) ); + if (arg.range.minimum() != arg.range.maximum()) { + pg->SetPropertyAttribute( prop, wxPG_ATTR_MIN, arg.range.minimum()); + pg->SetPropertyAttribute( prop, wxPG_ATTR_MAX, arg.range.maximum()); + } + break; + case SoapySDR::ArgInfo::BOOL: + prop = pg->Append( new wxBoolProperty(arg.name, wxPG_LABEL, (arg.value=="true")) ); + break; + case SoapySDR::ArgInfo::STRING: + if (arg.options.size()) { + intVal = 0; + prop = pg->Append( new wxEnumProperty(arg.name, wxPG_LABEL) ); + for (stringIter = arg.options.begin(); stringIter != arg.options.end(); stringIter++) { + prop->AddChoice((*stringIter)); + if ((*stringIter)==arg.value) { + prop->SetChoiceSelection(intVal); + } + intVal++; + } + } else { + prop = pg->Append( new wxStringProperty(arg.name, wxPG_LABEL, arg.value) ); + } + break; + } + + if (prop != NULL) { + prop->SetHelpString(arg.key + ": " + arg.description); + } + + return prop; +} + void SDRDevicesDialog::OnSelectionChanged( wxTreeEvent& event ) { + wxTreeItemId selId = devTree->GetSelection(); + + dev = getSelectedDevice(selId); + + if (dev) { + m_propertyGrid->Clear(); + m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings")); + + SoapySDR::ArgInfoList::const_iterator args_i; + + SoapySDR::ArgInfoList args = dev->getSettingsArgInfo(); + + for (args_i = args.begin(); args_i != args.end(); args_i++) { + SoapySDR::ArgInfo arg = (*args_i); + addArgInfoProperty(m_propertyGrid, arg); + } + + if (dev->getRxChannel()) { + args = dev->getRxChannel()->getStreamArgsInfo(); + + if (args.size()) { + m_propertyGrid->Append(new wxPropertyCategory("Stream Settings")); + + for (args_i = args.begin(); args_i != args.end(); args_i++) { + SoapySDR::ArgInfo arg = (*args_i); + addArgInfoProperty(m_propertyGrid, arg); + } + } + } + + } event.Skip(); } @@ -70,12 +138,19 @@ void SDRDevicesDialog::OnAddRemote( wxMouseEvent& event ) { } +SDRDeviceInfo *SDRDevicesDialog::getSelectedDevice(wxTreeItemId selId) { + devItems_i = devItems.find(selId); + if (devItems_i != devItems.end()) { + return devItems[selId]; + } + return NULL; +} + void SDRDevicesDialog::OnUseSelected( wxMouseEvent& event ) { wxTreeItemId selId = devTree->GetSelection(); - devItems_i = devItems.find(selId); - if (devItems_i != devItems.end()) { - dev = devItems[selId]; + dev = getSelectedDevice(selId); + if (dev != NULL) { wxGetApp().setDevice(dev); Close(); } diff --git a/src/forms/SDRDevices/SDRDevices.fbp b/src/forms/SDRDevices/SDRDevices.fbp index 1bd7999..9d67c3f 100644 --- a/src/forms/SDRDevices/SDRDevices.fbp +++ b/src/forms/SDRDevices/SDRDevices.fbp @@ -787,7 +787,7 @@ 0 0 wxID_ANY - Stream Options + SoapySDR Device Options 0 diff --git a/src/forms/SDRDevices/SDRDevices.h b/src/forms/SDRDevices/SDRDevices.h index ccd8a77..faa6fac 100644 --- a/src/forms/SDRDevices/SDRDevices.h +++ b/src/forms/SDRDevices/SDRDevices.h @@ -21,6 +21,9 @@ public: void OnDeviceTimer( wxTimerEvent& event ); private: + SDRDeviceInfo *getSelectedDevice(wxTreeItemId selId); + wxPGProperty *addArgInfoProperty(wxPropertyGrid *pg, SoapySDR::ArgInfo arg); + bool refresh; std::map* > devs; std::vector::iterator devs_i; diff --git a/src/forms/SDRDevices/SDRDevicesForm.cpp b/src/forms/SDRDevices/SDRDevicesForm.cpp index ba012c9..8863060 100644 --- a/src/forms/SDRDevices/SDRDevicesForm.cpp +++ b/src/forms/SDRDevices/SDRDevicesForm.cpp @@ -56,7 +56,7 @@ devFrame::devFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons wxBoxSizer* bSizer7; bSizer7 = new wxBoxSizer( wxVERTICAL ); - m_staticText1 = new wxStaticText( m_panel61, wxID_ANY, wxT("Stream Options"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1 = new wxStaticText( m_panel61, wxID_ANY, wxT("SoapySDR Device Options"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( -1 ); bSizer7->Add( m_staticText1, 0, wxALL, 5 );