SDRDeviceInfo cleanup

This commit is contained in:
Charles J. Cliffe 2015-07-29 22:19:00 -04:00
parent 1f6276d090
commit 0d66c92f30
5 changed files with 114 additions and 78 deletions

View File

@ -229,6 +229,7 @@ SET (cubicsdr_sources
src/AppConfig.cpp src/AppConfig.cpp
src/FrequencyDialog.cpp src/FrequencyDialog.cpp
src/IOThread.cpp src/IOThread.cpp
src/sdr/SDRDeviceInfo.cpp
src/sdr/SDRThread.cpp src/sdr/SDRThread.cpp
src/sdr/SDRPostThread.cpp src/sdr/SDRPostThread.cpp
src/demod/DemodulatorPreThread.cpp src/demod/DemodulatorPreThread.cpp
@ -279,6 +280,7 @@ SET (cubicsdr_headers
src/AppConfig.h src/AppConfig.h
src/FrequencyDialog.h src/FrequencyDialog.h
src/IOThread.h src/IOThread.h
src/sdr/SDRDeviceInfo.h
src/sdr/SDRThread.h src/sdr/SDRThread.h
src/sdr/SDRPostThread.h src/sdr/SDRPostThread.h
src/demod/DemodulatorPreThread.h src/demod/DemodulatorPreThread.h

65
src/sdr/SDRDeviceInfo.cpp Normal file
View File

@ -0,0 +1,65 @@
#include "SDRDeviceInfo.h"
SDRDeviceInfo::SDRDeviceInfo() : name(""), serial(""), available(false) {
}
std::string SDRDeviceInfo::getDeviceId() {
std::string deviceId;
deviceId.append(getName());
deviceId.append(" :: ");
deviceId.append(getSerial());
return deviceId;
}
bool SDRDeviceInfo::isAvailable() const {
return available;
}
void SDRDeviceInfo::setAvailable(bool available) {
this->available = available;
}
const std::string& SDRDeviceInfo::getName() const {
return name;
}
void SDRDeviceInfo::setName(const std::string& name) {
this->name = name;
}
const std::string& SDRDeviceInfo::getSerial() const {
return serial;
}
void SDRDeviceInfo::setSerial(const std::string& serial) {
this->serial = serial;
}
const std::string& SDRDeviceInfo::getTuner() const {
return tuner;
}
void SDRDeviceInfo::setTuner(const std::string& tuner) {
this->tuner = tuner;
}
const std::string& SDRDeviceInfo::getManufacturer() const {
return manufacturer;
}
void SDRDeviceInfo::setManufacturer(const std::string& manufacturer) {
this->manufacturer = manufacturer;
}
const std::string& SDRDeviceInfo::getProduct() const {
return product;
}
void SDRDeviceInfo::setProduct(const std::string& product) {
this->product = product;
}

36
src/sdr/SDRDeviceInfo.h Normal file
View File

@ -0,0 +1,36 @@
#pragma once
#include <string>
class SDRDeviceInfo {
public:
SDRDeviceInfo();
std::string getDeviceId();
bool isAvailable() const;
void setAvailable(bool available);
const std::string& getName() const;
void setName(const std::string& name);
const std::string& getSerial() const;
void setSerial(const std::string& serial);
const std::string& getTuner() const;
void setTuner(const std::string& tuner);
const std::string& getManufacturer() const;
void setManufacturer(const std::string& manufacturer);
const std::string& getProduct() const;
void setProduct(const std::string& product);
private:
std::string name;
std::string serial;
std::string product;
std::string manufacturer;
std::string tuner;
bool available;
};

View File

@ -300,3 +300,11 @@ void SDRThread::run() {
std::cout << "SDR thread done." << std::endl; std::cout << "SDR thread done." << std::endl;
} }
int SDRThread::getDeviceId() const {
return deviceId.load();
}
void SDRThread::setDeviceId(int deviceId) {
this->deviceId.store(deviceId);
}

View File

@ -6,77 +6,7 @@
#include "ThreadQueue.h" #include "ThreadQueue.h"
#include "DemodulatorMgr.h" #include "DemodulatorMgr.h"
#include "SDRDeviceInfo.h"
class SDRDeviceInfo {
public:
SDRDeviceInfo() : name(""), serial(""), available(false) { }
std::string getDeviceId() {
std::string deviceId;
deviceId.append(getName());
deviceId.append(" :: ");
deviceId.append(getSerial());
return deviceId;
}
bool isAvailable() const {
return available;
}
void setAvailable(bool available) {
this->available = available;
}
const std::string& getName() const {
return name;
}
void setName(const std::string& name) {
this->name = name;
}
const std::string& getSerial() const {
return serial;
}
void setSerial(const std::string& serial) {
this->serial = serial;
}
const std::string& getTuner() const {
return tuner;
}
void setTuner(const std::string& tuner) {
this->tuner = tuner;
}
const std::string& getManufacturer() const {
return manufacturer;
}
void setManufacturer(const std::string& manufacturer) {
this->manufacturer = manufacturer;
}
const std::string& getProduct() const {
return product;
}
void setProduct(const std::string& product) {
this->product = product;
}
private:
std::string name;
std::string serial;
std::string product;
std::string manufacturer;
std::string tuner;
bool available;
};
class SDRThreadCommand { class SDRThreadCommand {
public: public:
@ -133,13 +63,8 @@ public:
void run(); void run();
int getDeviceId() const { int getDeviceId() const;
return deviceId.load(); void setDeviceId(int deviceId);
}
void setDeviceId(int deviceId) {
this->deviceId.store(deviceId);
}
protected: protected:
std::atomic<uint32_t> sampleRate; std::atomic<uint32_t> sampleRate;