static SoapySDR::Device *make_bladeRF(const SoapySDR::Kwargs &args) { SoapySDR::Device *bladerf = new bladeRF_SoapySDR(kwargs_to_devinfo(args)); //apply applicable settings found in args for (const auto &info : bladerf->getSettingInfo()) { if (args.count(info.key) == 0) continue; bladerf->writeSetting(info.key, args.at(info.key)); } return bladerf; }
void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) { if (editId && event.GetProperty() == devSettings["name"]) { DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); wxString devName = event.GetPropertyValue().GetString(); devConfig->setDeviceName(devName.ToStdString()); if (editId) { devTree->SetItemText(editId, devConfig->getDeviceName()); } if (devName == "") { event.GetProperty()->SetValueFromString(devConfig->getDeviceName()); } } else if (dev && event.GetProperty() == devSettings["offset"]) { DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); long offset = event.GetPropertyValue().GetInteger(); devConfig->setOffset(offset); } else if (editId && dev) { wxPGProperty *prop = event.GetProperty(); for (std::map<std::string, wxPGProperty *>::iterator rtp = runtimeProps.begin(); rtp != runtimeProps.end(); rtp++) { if (rtp->second == prop) { SoapySDR::Device *soapyDev = dev->getSoapyDevice(); std::string settingValue = prop->GetValueAsString().ToStdString(); SoapySDR::ArgInfo arg = runtimeArgs[rtp->first]; if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) { settingValue = arg.options[prop->GetChoiceSelection()]; } else if (arg.type == SoapySDR::ArgInfo::BOOL) { settingValue = (prop->GetValueAsString()=="True")?"true":"false"; } else { settingValue = prop->GetValueAsString(); } soapyDev->writeSetting(rtp->first, settingValue); if (dev->isActive()) { wxGetApp().getSDRThread()->writeSetting(rtp->first, settingValue); } refreshDeviceProperties(); return; } } } }
void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) { if (editId && event.GetProperty() == devSettings["name"]) { DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); wxString devName = event.GetPropertyValue().GetString(); devConfig->setDeviceName(devName.ToStdString()); if (editId) { devTree->SetItemText(editId, devConfig->getDeviceName()); } if (devName == "") { event.GetProperty()->SetValueFromString(devConfig->getDeviceName()); } } else if (dev && event.GetProperty() == devSettings["offset"]) { DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); long offset = event.GetPropertyValue().GetInteger(); devConfig->setOffset(offset); if (dev->isActive() || !wxGetApp().getDevice()) { wxGetApp().setOffset(offset); } } else if (dev && event.GetProperty() == devSettings["sample_rate"]) { DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); std::string strRate = deviceArgs["sample_rate"].options[event.GetPropertyValue().GetInteger()]; long srate = 0; try { srate = std::stol(strRate); devConfig->setSampleRate(srate); if (dev->isActive() || !wxGetApp().getDevice()) { wxGetApp().setSampleRate(srate); } } catch (std::invalid_argument e) { // nop } } else if (dev && event.GetProperty() == devSettings["antenna"]) { DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); std::string strAntennaName = deviceArgs["antenna"].options[event.GetPropertyValue().GetInteger()]; try { devConfig->setAntennaName(strAntennaName); if (dev->isActive() || !wxGetApp().getDevice()) { wxGetApp().setAntennaName(strAntennaName); } } catch (std::invalid_argument e) { // nop } } else if (editId && dev) { wxPGProperty *prop = event.GetProperty(); //change value of RuntimeProps for (std::map<std::string, wxPGProperty *>::iterator rtp = runtimeProps.begin(); rtp != runtimeProps.end(); rtp++) { if (rtp->second == prop) { SoapySDR::Device *soapyDev = dev->getSoapyDevice(); std::string settingValue = prop->GetValueAsString().ToStdString(); SoapySDR::ArgInfo arg = runtimeArgs[rtp->first]; if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) { settingValue = arg.options[prop->GetChoiceSelection()]; } else if (arg.type == SoapySDR::ArgInfo::BOOL) { settingValue = (prop->GetValueAsString()=="True")?"true":"false"; } else { settingValue = prop->GetValueAsString(); } soapyDev->writeSetting(rtp->first, settingValue); if (dev->isActive()) { wxGetApp().getSDRThread()->writeSetting(rtp->first, settingValue); } wxGetApp().notifyMainUIOfDeviceChange(); return; } } } // general refresh. wxGetApp().notifyMainUIOfDeviceChange(); }