本文整理汇总了C++中DeviceConfig::getDeviceName方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceConfig::getDeviceName方法的具体用法?C++ DeviceConfig::getDeviceName怎么用?C++ DeviceConfig::getDeviceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceConfig
的用法示例。
在下文中一共展示了DeviceConfig::getDeviceName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPropGridChanged
void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
if (!editId) {
return;
}
SDRDeviceInfo *dev = getSelectedDevice(editId);
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());
}
}
if (dev && event.GetProperty() == devSettings["offset"]) {
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
long offset = event.GetPropertyValue().GetInteger();
devConfig->setOffset(offset);
}
}
示例2: OnPropGridChanged
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;
}
}
}
}
示例3: OnPropGridChanged
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();
}
示例4: OnDeviceTimer
void SDRDevicesDialog::OnDeviceTimer( wxTimerEvent& event ) {
if (refresh) {
if (wxGetApp().areModulesMissing()) {
if (!failed) {
wxMessageDialog *info;
info = new wxMessageDialog(NULL, wxT("\nNo SoapySDR modules were found.\n\nCubicSDR requires at least one SoapySDR device support module to be installed.\n\nPlease visit https://github.com/cjcliffe/CubicSDR/wiki and in the build instructions for your platform read the 'Support Modules' section for more information."), wxT("\x28\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35\x20\u253B\u2501\u253B"), wxOK | wxICON_ERROR);
info->ShowModal();
failed = true;
}
return;
}
if (wxGetApp().areDevicesEnumerating() || !wxGetApp().areDevicesReady()) {
std::string msg = wxGetApp().getNotification();
devStatusBar->SetStatusText(msg);
devTree->DeleteAllItems();
devTree->AddRoot(msg);
event.Skip();
return;
}
devTree->DeleteAllItems();
wxTreeItemId devRoot = devTree->AddRoot("Devices");
wxTreeItemId localBranch = devTree->AppendItem(devRoot, "Local");
wxTreeItemId dsBranch = devTree->AppendItem(devRoot, "Local Net");
wxTreeItemId remoteBranch = devTree->AppendItem(devRoot, "Remote");
wxTreeItemId manualBranch = devTree->AppendItem(devRoot, "Manual");
devs[""] = SDREnumerator::enumerate_devices("",true);
if (devs[""] != NULL) {
for (devs_i = devs[""]->begin(); devs_i != devs[""]->end(); devs_i++) {
DeviceConfig *devConfig = nullptr;
if ((*devs_i)->isManual()) {
std::string devName = "Unknown";
if ((*devs_i)->isAvailable()) {
devConfig = wxGetApp().getConfig()->getDevice((*devs_i)->getDeviceId());
devName = devConfig->getDeviceName();
} else {
devName = (*devs_i)->getDeviceId();
}
devItems[devTree->AppendItem(manualBranch, devName)] = (*devs_i);
} else if ((*devs_i)->isRemote()) {
devConfig = wxGetApp().getConfig()->getDevice((*devs_i)->getDeviceId());
devItems[devTree->AppendItem(dsBranch, devConfig->getDeviceName())] = (*devs_i);
} else {
devConfig = wxGetApp().getConfig()->getDevice((*devs_i)->getDeviceId());
devItems[devTree->AppendItem(localBranch, devConfig->getDeviceName())] = (*devs_i);
}
}
}
std::vector<std::string> remotes = SDREnumerator::getRemotes();
std::vector<SDRDeviceInfo *>::iterator remoteDevs_i;
if (remotes.size()) {
for (std::string remote : remotes) {
devs[remote] = SDREnumerator::enumerate_devices(remote, true);
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(remote);
wxTreeItemId remoteNode = devTree->AppendItem(remoteBranch, devConfig->getDeviceName());
if (devs[remote] != NULL) {
for (remoteDevs_i = devs[remote]->begin(); remoteDevs_i != devs[remote]->end(); remoteDevs_i++) {
devItems[devTree->AppendItem(remoteNode, (*remoteDevs_i)->getName())] = (*remoteDevs_i);
}
}
}
}
m_refreshButton->Enable();
m_addRemoteButton->Enable();
m_useSelectedButton->Enable();
devTree->Enable();
devTree->ExpandAll();
devStatusBar->SetStatusText("Ready.");
refresh = false;
}
}
示例5: 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();
//A) General settings: name, offset, sample rate, agc, antennas (if > 1)
m_propertyGrid->Append(new wxPropertyCategory("General Settings"));
devSettings.clear();
//A-1) Name
devSettings["name"] = m_propertyGrid->Append( new wxStringProperty("Name", wxPG_LABEL, devConfig->getDeviceName()) );
//A-2) Offset
devSettings["offset"] = m_propertyGrid->Append( new wxIntProperty("Offset (KHz)", wxPG_LABEL, devConfig->getOffset() / 1000) );
//A-3) Antennas, is there are more than 1 RX antenna, else do not expose the setting.
//get the saved setting
const std::string& currentSetAntenna = devConfig->getAntennaName();
//compare to the list of existing antennas
SoapySDR::ArgInfo antennasArg;
std::vector<std::string> antennaOpts = selDev->getAntennaNames(SOAPY_SDR_RX, 0);
//only do something if there is more than 1 antenna
if (antennaOpts.size() > 1) {
//by default, choose the first of the list.
std::string antennaToSelect = antennaOpts.front();
auto found_i = std::find(antennaOpts.begin(), antennaOpts.end(), currentSetAntenna);
if (found_i != antennaOpts.end()) {
antennaToSelect = currentSetAntenna;
}
else {
//erroneous antenna name, re-write device config with the first choice of teh list.
devConfig->setAntennaName(antennaToSelect);
}
//build device settings
for (std::string antenna : antennaOpts) {
antennasArg.options.push_back(antenna);
antennasArg.optionNames.push_back(antenna);
}
antennasArg.type = SoapySDR::ArgInfo::STRING;
antennasArg.units = "";
antennasArg.name = "Antenna";
antennasArg.key = "antenna";
antennasArg.value = antennaToSelect;
devSettings["antenna"] = addArgInfoProperty(m_propertyGrid, antennasArg);
deviceArgs["antenna"] = antennasArg;
} //end if more than 1 antenna
else {
devConfig->setAntennaName("");
}
//A-4) Sample_rate:
long currentSampleRate = wxGetApp().getSampleRate();
long deviceSampleRate = devConfig->getSampleRate();
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"));
//.........这里部分代码省略.........
示例6: 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();
}
示例7: 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;
}
}