Basic console window for digital output

- Probably end up making this a single tabbed dialog but this works for
the moment
This commit is contained in:
Charles J. Cliffe
2015-11-28 23:03:07 -05:00
parent cdddd5850f
commit 7e4d173996
31 changed files with 1030 additions and 67 deletions
+75 -1
View File
@@ -2,8 +2,11 @@
#include "CubicSDR.h"
DemodulatorInstance::DemodulatorInstance() :
t_PreDemod(NULL), t_Demod(NULL), t_Audio(NULL) {
t_PreDemod(nullptr), t_Demod(nullptr), t_Audio(nullptr) {
#if ENABLE_DIGITAL_LAB
activeOutput = nullptr;
#endif
terminated.store(true);
audioTerminated.store(true);
demodTerminated.store(true);
@@ -42,6 +45,9 @@ DemodulatorInstance::DemodulatorInstance() :
}
DemodulatorInstance::~DemodulatorInstance() {
#if ENABLE_DIGITAL_LAB
delete activeOutput;
#endif
delete audioThread;
delete demodulatorThread;
delete demodulatorPreThread;
@@ -137,6 +143,11 @@ bool DemodulatorInstance::isTerminated() {
#else
t_Demod->join();
delete t_Demod;
#endif
#if ENABLE_DIGITAL_LAB
if (activeOutput) {
closeOutput();
}
#endif
demodTerminated = true;
break;
@@ -165,8 +176,18 @@ bool DemodulatorInstance::isActive() {
void DemodulatorInstance::setActive(bool state) {
if (active && !state) {
#if ENABLE_DIGITAL_LAB
if (activeOutput && !isTerminated()) {
activeOutput->Hide();
}
#endif
audioThread->setActive(state);
} else if (!active && state) {
#if ENABLE_DIGITAL_LAB
if (activeOutput) {
activeOutput->Show();
}
#endif
audioThread->setActive(state);
}
if (!state) {
@@ -244,6 +265,11 @@ void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
if ((currentDemodType != "") && (currentDemodType != demod_type_in)) {
lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings();
}
#if ENABLE_DIGITAL_LAB
if (activeOutput) {
activeOutput->Hide();
}
#endif
demodulatorPreThread->setDemodType(demod_type_in);
}
}
@@ -284,6 +310,14 @@ void DemodulatorInstance::setFrequency(long long freq) {
}
demodulatorPreThread->setFrequency(freq);
#if ENABLE_DIGITAL_LAB
if (activeOutput) {
if (isModemInitialized() && getModemType() == "digital") {
ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)getOutput();
outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency()));
}
}
#endif
}
long long DemodulatorInstance::getFrequency() {
@@ -375,6 +409,13 @@ bool DemodulatorInstance::isModemInitialized() {
return demodulatorPreThread->isInitialized();
}
std::string DemodulatorInstance::getModemType() {
if (isModemInitialized()) {
return demodulatorPreThread->getModem()->getType();
}
return "";
}
ModemSettings DemodulatorInstance::getLastModemSettings(std::string demodType) {
if (lastModemSettings.find(demodType) != lastModemSettings.end()) {
return lastModemSettings[demodType];
@@ -383,3 +424,36 @@ ModemSettings DemodulatorInstance::getLastModemSettings(std::string demodType) {
return mods;
}
}
#if ENABLE_DIGITAL_LAB
ModemDigitalOutput *DemodulatorInstance::getOutput() {
if (activeOutput == nullptr) {
activeOutput = new ModemDigitalOutputConsole();
}
return activeOutput;
}
void DemodulatorInstance::showOutput() {
if (activeOutput != nullptr) {
activeOutput->Show();
}
}
void DemodulatorInstance::hideOutput() {
if (activeOutput != nullptr) {
activeOutput->Hide();
}
}
void DemodulatorInstance::closeOutput() {
if (isModemInitialized()) {
if (getModemType() == "digital") {
ModemDigital *dModem = (ModemDigital *)demodulatorPreThread->getModem();
dModem->setOutput(nullptr);
}
}
if (activeOutput) {
activeOutput->Close();
}
}
#endif
+17 -2
View File
@@ -10,6 +10,10 @@
#include "ModemDigital.h"
#include "ModemAnalog.h"
#if ENABLE_DIGITAL_LAB
#include "DigitalConsole.h"
#endif
class DemodulatorInstance {
public:
@@ -89,8 +93,16 @@ public:
void writeModemSettings(ModemSettings settings);
bool isModemInitialized();
std::string getModemType();
ModemSettings getLastModemSettings(std::string demodType);
#if ENABLE_DIGITAL_LAB
ModemDigitalOutput *getOutput();
void showOutput();
void hideOutput();
void closeOutput();
#endif
protected:
DemodulatorThreadInputQueue* pipeIQInputData;
DemodulatorThreadPostInputQueue* pipeIQDemodData;
@@ -115,4 +127,7 @@ private:
std::atomic<float> currentAudioGain;
std::atomic_bool follow, tracking;
std::map<std::string, ModemSettings> lastModemSettings;
};
#if ENABLE_DIGITAL_LAB
ModemDigitalOutput *activeOutput;
#endif
};
+7
View File
@@ -120,6 +120,7 @@ void DemodulatorPreThread::run() {
cModem = nullptr;
cModemKit = nullptr;
demodTypeChanged.store(false);
initialized.store(false);
}
else if (
cModemKit && cModem &&
@@ -226,6 +227,12 @@ void DemodulatorPreThread::run() {
if (result.modem != nullptr) {
cModem = result.modem;
#if ENABLE_DIGITAL_LAB
if (cModem->getType() == "digital") {
ModemDigital *mDigi = (ModemDigital *)cModem;
mDigi->setOutput(parent->getOutput());
}
#endif
}
if (result.modemKit != nullptr) {