mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-27 22:14:26 -04:00
Save offset, direct sampling mode and i/q swap per device
This commit is contained in:
+64
-4
@@ -1,6 +1,7 @@
|
||||
#include "AppConfig.h"
|
||||
#include "CubicSDR.h"
|
||||
|
||||
DeviceConfig::DeviceConfig() : ppm(0), deviceId("") {
|
||||
DeviceConfig::DeviceConfig() : deviceId(""), ppm(0), directSampling(false), offset(0) {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +17,30 @@ int DeviceConfig::getPPM() {
|
||||
return ppm;
|
||||
}
|
||||
|
||||
void DeviceConfig::setDirectSampling(int mode) {
|
||||
directSampling = mode;
|
||||
}
|
||||
|
||||
int DeviceConfig::getDirectSampling() {
|
||||
return directSampling;
|
||||
}
|
||||
|
||||
void DeviceConfig::setOffset(long long offset) {
|
||||
this->offset = offset;
|
||||
}
|
||||
|
||||
long long DeviceConfig::getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
void DeviceConfig::setIQSwap(bool iqSwap) {
|
||||
this->iqSwap = iqSwap;
|
||||
}
|
||||
|
||||
bool DeviceConfig::getIQSwap() {
|
||||
return iqSwap;
|
||||
}
|
||||
|
||||
void DeviceConfig::setDeviceId(std::string deviceId) {
|
||||
this->deviceId = deviceId;
|
||||
}
|
||||
@@ -25,9 +50,11 @@ std::string DeviceConfig::getDeviceId() {
|
||||
}
|
||||
|
||||
void DeviceConfig::save(DataNode *node) {
|
||||
node->newChild("id")->element()->set(deviceId);
|
||||
DataNode *ppm_node = node->newChild("ppm");
|
||||
ppm_node->element()->set((int)ppm);
|
||||
*node->newChild("id") = deviceId;
|
||||
*node->newChild("ppm") = (int)ppm;
|
||||
*node->newChild("iq_swap") = iqSwap;
|
||||
*node->newChild("direct_sampling") = directSampling;
|
||||
*node->newChild("offset") = offset;
|
||||
}
|
||||
|
||||
void DeviceConfig::load(DataNode *node) {
|
||||
@@ -38,6 +65,39 @@ void DeviceConfig::load(DataNode *node) {
|
||||
setPPM(ppmValue);
|
||||
std::cout << "Loaded PPM for device '" << deviceId << "' at " << ppmValue << "ppm" << std::endl;
|
||||
}
|
||||
if (node->hasAnother("iq_swap")) {
|
||||
DataNode *iq_swap_node = node->getNext("iq_swap");
|
||||
int iqSwapValue = 0;
|
||||
iq_swap_node->element()->get(iqSwapValue);
|
||||
setIQSwap(iqSwapValue?true:false);
|
||||
std::cout << "Loaded I/Q Swap for device '" << deviceId << "' as " << (iqSwapValue?"swapped":"not swapped") << std::endl;
|
||||
}
|
||||
if (node->hasAnother("direct_sampling")) {
|
||||
DataNode *direct_sampling_node = node->getNext("direct_sampling");
|
||||
int directSamplingValue = 0;
|
||||
direct_sampling_node->element()->get(directSamplingValue);
|
||||
setDirectSampling(directSamplingValue);
|
||||
std::cout << "Loaded Direct Sampling Mode for device '" << deviceId << "': ";
|
||||
switch (directSamplingValue) {
|
||||
case 0:
|
||||
std::cout << "off" << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "I-ADC" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Q-ADC" << std::endl;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if (node->hasAnother("offset")) {
|
||||
DataNode *offset_node = node->getNext("offset");
|
||||
long long offsetValue = 0;
|
||||
offset_node->element()->get(offsetValue);
|
||||
setOffset(offsetValue);
|
||||
std::cout << "Loaded offset for device '" << deviceId << "' at " << offsetValue << "ppm" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user