diff --git a/CMakeLists.txt b/CMakeLists.txt index 39df351..f2f72e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,6 +229,7 @@ SET (cubicsdr_sources src/AppConfig.cpp src/FrequencyDialog.cpp src/IOThread.cpp + src/sdr/SDRDeviceInfo.cpp src/sdr/SDRThread.cpp src/sdr/SDRPostThread.cpp src/demod/DemodulatorPreThread.cpp @@ -279,6 +280,7 @@ SET (cubicsdr_headers src/AppConfig.h src/FrequencyDialog.h src/IOThread.h + src/sdr/SDRDeviceInfo.h src/sdr/SDRThread.h src/sdr/SDRPostThread.h src/demod/DemodulatorPreThread.h diff --git a/src/sdr/SDRDeviceInfo.cpp b/src/sdr/SDRDeviceInfo.cpp new file mode 100644 index 0000000..992f331 --- /dev/null +++ b/src/sdr/SDRDeviceInfo.cpp @@ -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; +} + diff --git a/src/sdr/SDRDeviceInfo.h b/src/sdr/SDRDeviceInfo.h new file mode 100644 index 0000000..36086ad --- /dev/null +++ b/src/sdr/SDRDeviceInfo.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +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; +}; diff --git a/src/sdr/SDRThread.cpp b/src/sdr/SDRThread.cpp index e31473c..a9a0d43 100644 --- a/src/sdr/SDRThread.cpp +++ b/src/sdr/SDRThread.cpp @@ -300,3 +300,11 @@ void SDRThread::run() { std::cout << "SDR thread done." << std::endl; } + +int SDRThread::getDeviceId() const { + return deviceId.load(); +} + +void SDRThread::setDeviceId(int deviceId) { + this->deviceId.store(deviceId); +} diff --git a/src/sdr/SDRThread.h b/src/sdr/SDRThread.h index 4b59d81..4b3a8ac 100644 --- a/src/sdr/SDRThread.h +++ b/src/sdr/SDRThread.h @@ -6,77 +6,7 @@ #include "ThreadQueue.h" #include "DemodulatorMgr.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; -}; +#include "SDRDeviceInfo.h" class SDRThreadCommand { public: @@ -133,13 +63,8 @@ public: void run(); - int getDeviceId() const { - return deviceId.load(); - } - - void setDeviceId(int deviceId) { - this->deviceId.store(deviceId); - } + int getDeviceId() const; + void setDeviceId(int deviceId); protected: std::atomic sampleRate;