本文整理汇总了C++中DeviceConfig::getStreamOpts方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceConfig::getStreamOpts方法的具体用法?C++ DeviceConfig::getStreamOpts怎么用?C++ DeviceConfig::getStreamOpts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceConfig
的用法示例。
在下文中一共展示了DeviceConfig::getStreamOpts方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refreshDeviceProperties
//.........这里部分代码省略.........
if (!deviceSampleRate) {
deviceSampleRate = selDev->getSampleRateNear(SOAPY_SDR_RX, 0, currentSampleRate);
}
SoapySDR::ArgInfo sampleRateArg;
std::vector<long> rateOpts = selDev->getSampleRates(SOAPY_SDR_RX, 0);
for (long rate : rateOpts) {
sampleRateArg.options.push_back(std::to_string(rate));
sampleRateArg.optionNames.push_back(frequencyToStr(rate));
}
sampleRateArg.type = SoapySDR::ArgInfo::STRING;
sampleRateArg.units = "Hz";
sampleRateArg.name = "Sample Rate";
sampleRateArg.key = "sample_rate";
sampleRateArg.value = std::to_string(deviceSampleRate);
devSettings["sample_rate"] = addArgInfoProperty(m_propertyGrid, sampleRateArg);
deviceArgs["sample_rate"] = sampleRateArg;
//B) Runtime Settings:
runtimeArgs.clear();
runtimeProps.clear();
streamProps.clear();
if (args.size()) {
m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings"));
for (SoapySDR::ArgInfoList::const_iterator args_i = args.begin(); args_i != args.end(); args_i++) {
SoapySDR::ArgInfo arg = (*args_i);
//We-reread the Device configuration, else we use the user settings.
if (dev) {
//Apply saved settings
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
arg.value = devConfig->getSetting(arg.key, soapyDev->readSetting(arg.key)); //use SoapyDevice data as fallback.
}
else {
//re-read the SoapyDevice
arg.value = soapyDev->readSetting(arg.key);
}
runtimeProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg);
runtimeArgs[arg.key] = arg;
}
}
if (dev) {
args = dev->getSoapyDevice()->getStreamArgsInfo(SOAPY_SDR_RX, 0);
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
ConfigSettings devStreamOpts = devConfig->getStreamOpts();
if (devStreamOpts.size()) {
for (int j = 0, jMax = args.size(); j < jMax; j++) {
if (devStreamOpts.find(args[j].key) != devStreamOpts.end()) {
args[j].value = devStreamOpts[args[j].key];
}
}
}
if (args.size()) {
m_propertyGrid->Append(new wxPropertyCategory("Stream Settings"));
for (SoapySDR::ArgInfo arg : args) {
streamProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg);
}
}
}
if (selDev->isManual()) {
m_addRemoteButton->SetLabel("Remove");
removeId = selId;
} else {
m_addRemoteButton->SetLabel("Add");
removeId = nullptr;
}
} else if (selDev && !selDev->isAvailable() && selDev->isManual()) {
m_propertyGrid->Clear();
devSettings.clear();
runtimeArgs.clear();
runtimeProps.clear();
streamProps.clear();
removeId = devTree->GetSelection();
dev = nullptr;
selId = nullptr;
editId = nullptr;
m_addRemoteButton->SetLabel("Remove");
} else if (!selDev) {
m_addRemoteButton->SetLabel("Add");
removeId = nullptr;
}
}
示例2: OnSelectionChanged
void SDRDevicesDialog::OnSelectionChanged( wxTreeEvent& event ) {
SDRDeviceInfo *selDev = getSelectedDevice(devTree->GetSelection());
if (selDev && selDev->isAvailable()) {
dev = selDev;
selId = devTree->GetSelection();
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getName());
m_propertyGrid->Clear();
SoapySDR::ArgInfoList args = dev->getSettingsArgInfo();
SoapySDR::ArgInfoList::const_iterator args_i;
m_propertyGrid->Append(new wxPropertyCategory("General Settings"));
devSettings.erase(devSettings.begin(),devSettings.end());
devSettings["name"] = m_propertyGrid->Append( new wxStringProperty("Name", wxPG_LABEL, devConfig->getDeviceName()) );
devSettings["offset"] = m_propertyGrid->Append( new wxIntProperty("Offset (Hz)", wxPG_LABEL, devConfig->getOffset()) );
props.erase(props.begin(), props.end());
if (args.size()) {
m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings"));
for (args_i = args.begin(); args_i != args.end(); args_i++) {
SoapySDR::ArgInfo arg = (*args_i);
props.push_back(addArgInfoProperty(m_propertyGrid, arg));
}
}
if (dev->getRxChannel()) {
args = dev->getRxChannel()->getStreamArgsInfo();
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
ConfigSettings devStreamOpts = devConfig->getStreamOpts();
if (devStreamOpts.size()) {
for (int j = 0, jMax = args.size(); j < jMax; j++) {
if (devStreamOpts.find(args[j].key) != devStreamOpts.end()) {
args[j].value = devStreamOpts[args[j].key];
}
}
}
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);
props.push_back(addArgInfoProperty(m_propertyGrid, arg));
}
}
}
if (selDev->isManual()) {
m_addRemoteButton->SetLabel("Remove");
removeId = selId;
} else {
m_addRemoteButton->SetLabel("Add");
removeId = nullptr;
}
} else if (selDev && !selDev->isAvailable() && selDev->isManual()) {
m_propertyGrid->Clear();
devSettings.erase(devSettings.begin(),devSettings.end());
props.erase(props.begin(), props.end());
removeId = devTree->GetSelection();
dev = nullptr;
selId = nullptr;
editId = nullptr;
m_addRemoteButton->SetLabel("Remove");
} else if (!selDev) {
m_addRemoteButton->SetLabel("Add");
removeId = nullptr;
}
event.Skip();
}
示例3: wxGetApp
//.........这里部分代码省略.........
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Querying device #") + std::to_string(i) + ": " + dev->getName());
}
SoapySDR::ArgInfoList settingsInfo = device->getSettingInfo();
DeviceConfig *cfg = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
ConfigSettings devSettings = cfg->getSettings();
if (devSettings.size()) {
for (ConfigSettings::const_iterator set_i = devSettings.begin(); set_i != devSettings.end(); set_i++) {
deviceArgs[set_i->first] = set_i->second;
}
for (int j = 0; j < settingsInfo.size(); j++) {
if (deviceArgs.find(settingsInfo[j].key) != deviceArgs.end()) {
settingsInfo[j].value = deviceArgs[settingsInfo[j].key];
}
}
}
dev->setDeviceArgs(deviceArgs);
dev->setSettingsInfo(settingsInfo);
int numChan = device->getNumChannels(SOAPY_SDR_RX);
for (int i = 0; i < numChan; i++) {
SDRDeviceChannel *chan = new SDRDeviceChannel();
SoapySDR::RangeList rfRange = device->getFrequencyRange(SOAPY_SDR_RX, i);
double rfMin = rfRange[0].minimum();
double rfMax = rfRange[rfRange.size()-1].maximum();
chan->setChannel(i);
chan->setFullDuplex(device->getFullDuplex(SOAPY_SDR_RX, i));
chan->setRx(true);
chan->setTx(false);
chan->getRFRange().setLow(rfMin);
chan->getRFRange().setHigh(rfMax);
std::vector<std::string> freqs = device->listFrequencies(SOAPY_SDR_RX,i);
if (std::find(freqs.begin(), freqs.end(), "CORR") != freqs.end()) {
chan->setCORR(true);
} else {
chan->setCORR(false);
}
if (device->hasDCOffsetMode(SOAPY_SDR_RX, i)) {
chan->setHardwareDC(true);
} else {
chan->setHardwareDC(false);
}
std::vector<double> rates = device->listSampleRates(SOAPY_SDR_RX, i);
for (std::vector<double>::iterator i = rates.begin(); i != rates.end(); i++) {
chan->getSampleRates().push_back((long)(*i));
}
ConfigSettings devStreamOpts = cfg->getStreamOpts();
if (devStreamOpts.size()) {
dev->setStreamArgs(devStreamOpts);
}
SoapySDR::ArgInfoList optArgs = device->getStreamArgsInfo(SOAPY_SDR_RX, i);
if (devStreamOpts.size()) {
for (int j = 0, jMax = optArgs.size(); j < jMax; j++) {
if (devStreamOpts.find(optArgs[j].key) != devStreamOpts.end()) {
optArgs[j].value = devStreamOpts[optArgs[j].key];
}
}
}
chan->setStreamArgsInfo(optArgs);
std::vector<std::string> gainNames = device->listGains(SOAPY_SDR_RX, i);
for (std::vector<std::string>::iterator gname = gainNames.begin(); gname!= gainNames.end(); gname++) {
chan->addGain((*gname),device->getGainRange(SOAPY_SDR_RX, i, (*gname)));
}
dev->addChannel(chan);
}
SoapySDR::Device::unmake(device);
dev->setAvailable(true);
} catch (const std::exception &ex) {
std::cerr << "Error making device: " << ex.what() << std::endl;
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Error querying device #") + std::to_string(i));
dev->setAvailable(false);
} else {
dev->setAvailable(false);
}
std::cout << std::endl;
SDREnumerator::devs[remoteAddr].push_back(dev);
}
if (SDREnumerator::devs[remoteAddr].empty()) {
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("No devices found!"));
}
std::cout << std::endl;
return &SDREnumerator::devs[remoteAddr];
}
示例4: refreshDeviceProperties
void SDRDevicesDialog::refreshDeviceProperties() {
SDRDeviceInfo *selDev = getSelectedDevice(devTree->GetSelection());
if (selDev && selDev->isAvailable()) {
dev = selDev;
selId = devTree->GetSelection();
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getName());
m_propertyGrid->Clear();
SoapySDR::Device *soapyDev = dev->getSoapyDevice();
SoapySDR::ArgInfoList args = soapyDev->getSettingInfo();
SoapySDR::ArgInfoList::const_iterator args_i;
m_propertyGrid->Append(new wxPropertyCategory("General Settings"));
devSettings.erase(devSettings.begin(),devSettings.end());
devSettings["name"] = m_propertyGrid->Append( new wxStringProperty("Name", wxPG_LABEL, devConfig->getDeviceName()) );
devSettings["offset"] = m_propertyGrid->Append( new wxIntProperty("Offset (Hz)", wxPG_LABEL, devConfig->getOffset()) );
runtimeArgs.erase(runtimeArgs.begin(), runtimeArgs.end());
runtimeProps.erase(runtimeProps.begin(), runtimeProps.end());
streamProps.erase(streamProps.begin(), streamProps.end());
if (args.size()) {
m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings"));
for (args_i = args.begin(); args_i != args.end(); args_i++) {
SoapySDR::ArgInfo arg = (*args_i);
arg.value = soapyDev->readSetting(arg.key);
runtimeProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg);
runtimeArgs[arg.key] = arg;
}
}
if (dev) {
args = dev->getSoapyDevice()->getStreamArgsInfo(SOAPY_SDR_RX, 0);
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
ConfigSettings devStreamOpts = devConfig->getStreamOpts();
if (devStreamOpts.size()) {
for (int j = 0, jMax = args.size(); j < jMax; j++) {
if (devStreamOpts.find(args[j].key) != devStreamOpts.end()) {
args[j].value = devStreamOpts[args[j].key];
}
}
}
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);
streamProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg);
}
}
}
if (selDev->isManual()) {
m_addRemoteButton->SetLabel("Remove");
removeId = selId;
} else {
m_addRemoteButton->SetLabel("Add");
removeId = nullptr;
}
} else if (selDev && !selDev->isAvailable() && selDev->isManual()) {
m_propertyGrid->Clear();
devSettings.erase(devSettings.begin(),devSettings.end());
runtimeArgs.erase(runtimeArgs.begin(), runtimeArgs.end());
runtimeProps.erase(runtimeProps.begin(), runtimeProps.end());
streamProps.erase(streamProps.begin(), streamProps.end());
removeId = devTree->GetSelection();
dev = nullptr;
selId = nullptr;
editId = nullptr;
m_addRemoteButton->SetLabel("Remove");
} else if (!selDev) {
m_addRemoteButton->SetLabel("Add");
removeId = nullptr;
}
}