mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-14 16:11:47 -05:00
Enumerator class and warnings cleanup
This commit is contained in:
parent
f97f368a6a
commit
a409822429
16
external/cubicvr2/math/aabb.h
vendored
16
external/cubicvr2/math/aabb.h
vendored
@ -14,7 +14,7 @@
|
||||
|
||||
namespace CubicVR {
|
||||
|
||||
enum aabb_enum { AABB_DISJOINT, AABB_A_INSIDE_B, AABB_B_INSIDE_A, AABB_INTERSECT };
|
||||
enum class aabb_intersect { AABB_DISJOINT, AABB_A_INSIDE_B, AABB_B_INSIDE_A, AABB_INTERSECT };
|
||||
|
||||
struct aabb {
|
||||
vec3 min, max;
|
||||
@ -76,33 +76,33 @@ namespace CubicVR {
|
||||
CubicVR.enums.aabb.B_INSIDE_A if boxB is inside boxA
|
||||
CubicVR.enums.aabb.DISJOINT if AABBs are disjoint (do not intersect)
|
||||
*/
|
||||
aabb_enum intersects(aabb boxA, aabb boxB) {
|
||||
aabb_intersect intersects(aabb boxA, aabb boxB) {
|
||||
// Disjoint
|
||||
if( boxA.min[0] > boxB.max[0] || boxA.max[0] < boxB.min[0] ){
|
||||
return AABB_DISJOINT;
|
||||
return aabb_intersect::AABB_DISJOINT;
|
||||
}
|
||||
if( boxA.min[1] > boxB.max[1] || boxA.max[1] < boxB.min[1] ){
|
||||
return AABB_DISJOINT;
|
||||
return aabb_intersect::AABB_DISJOINT;
|
||||
}
|
||||
if( boxA.min[2] > boxB.max[2] || boxA.max[2] < boxB.min[2] ){
|
||||
return AABB_DISJOINT;
|
||||
return aabb_intersect::AABB_DISJOINT;
|
||||
}
|
||||
|
||||
// boxA is inside boxB.
|
||||
if( boxA.min[0] >= boxB.min[0] && boxA.max[0] <= boxB.max[0] &&
|
||||
boxA.min[1] >= boxB.min[1] && boxA.max[1] <= boxB.max[1] &&
|
||||
boxA.min[2] >= boxB.min[2] && boxA.max[2] <= boxB.max[2]) {
|
||||
return AABB_A_INSIDE_B;
|
||||
return aabb_intersect::AABB_A_INSIDE_B;
|
||||
}
|
||||
// boxB is inside boxA.
|
||||
if( boxB.min[0] >= boxA.min[0] && boxB.max[0] <= boxA.max[0] &&
|
||||
boxB.min[1] >= boxA.min[1] && boxB.max[1] <= boxA.max[1] &&
|
||||
boxB.min[2] >= boxA.min[2] && boxB.max[2] <= boxA.max[2]) {
|
||||
return AABB_B_INSIDE_A;
|
||||
return aabb_intersect::AABB_B_INSIDE_A;
|
||||
}
|
||||
|
||||
// Otherwise AABB's intersect.
|
||||
return AABB_INTERSECT;
|
||||
return aabb_intersect::AABB_INTERSECT;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -1496,7 +1496,7 @@ bool AppFrame::actionOnMenuSettings(wxCommandEvent& event) {
|
||||
try {
|
||||
currentVal = std::stoi(wxGetApp().getSDRThread()->readSetting(arg.key));
|
||||
}
|
||||
catch (const std::invalid_argument &e) {
|
||||
catch (const std::invalid_argument &) {
|
||||
currentVal = 0;
|
||||
}
|
||||
int intVal = wxGetNumberFromUser(arg.description, arg.units, arg.name, currentVal, arg.range.minimum(), arg.range.maximum(), this);
|
||||
@ -1513,7 +1513,7 @@ bool AppFrame::actionOnMenuSettings(wxCommandEvent& event) {
|
||||
try {
|
||||
wxGetApp().getSDRThread()->writeSetting(arg.key, floatVal.ToStdString());
|
||||
}
|
||||
catch (const std::invalid_argument &e) {
|
||||
catch (const std::invalid_argument &) {
|
||||
// ...
|
||||
}
|
||||
settingsMenuItems[menuIdx + wxID_SETTINGS_BASE]->SetItemLabel(getSettingsLabel(arg.name, floatVal.ToStdString(), arg.units));
|
||||
|
@ -592,7 +592,7 @@ std::wstring BookmarkMgr::getSafeWstringValue(DataNode* node, const std::string&
|
||||
try {
|
||||
childNode->element()->get(decodedWString);
|
||||
|
||||
} catch (const DataTypeMismatchException &e) {
|
||||
} catch (const DataTypeMismatchException &) {
|
||||
//2) wstring decode fail, try simple std::string
|
||||
std::string decodedStdString;
|
||||
try {
|
||||
@ -602,7 +602,7 @@ std::wstring BookmarkMgr::getSafeWstringValue(DataNode* node, const std::string&
|
||||
//use wxString for a clean conversion to a wstring:
|
||||
decodedWString = wxString(decodedStdString).ToStdWstring();
|
||||
|
||||
} catch (const DataTypeMismatchException &e) {
|
||||
} catch (const DataTypeMismatchException &) {
|
||||
//nothing works, return an empty string.
|
||||
decodedWString = L"";
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
||||
if (targetMode == FDIALOG_TARGET_WATERFALL_LPS) {
|
||||
try {
|
||||
freq = std::stoi(strValue);
|
||||
} catch (const exception &e) {
|
||||
} catch (const exception &) {
|
||||
Close();
|
||||
break;
|
||||
}
|
||||
@ -185,7 +185,7 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
||||
if (targetMode == FDIALOG_TARGET_SPECTRUM_AVG) {
|
||||
try {
|
||||
dblval = std::stod(strValue);
|
||||
} catch (const exception &e) {
|
||||
} catch (const exception &) {
|
||||
Close();
|
||||
break;
|
||||
}
|
||||
@ -201,7 +201,7 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
||||
if (targetMode == FDIALOG_TARGET_GAIN) {
|
||||
try {
|
||||
freq = std::stoi(strValue);
|
||||
} catch (const exception &e) {
|
||||
} catch (const exception &) {
|
||||
break;
|
||||
}
|
||||
SDRDeviceInfo *devInfo = wxGetApp().getDevice();
|
||||
|
@ -87,7 +87,7 @@ void ModemProperties::initDefaultProperties() {
|
||||
outputArg.key ="._audio_output";
|
||||
outputArg.name = "Audio Out";
|
||||
outputArg.description = "Set the current modem's audio output device.";
|
||||
outputArg.type = ModemArgInfo::STRING;
|
||||
outputArg.type = ModemArgInfo::Type::STRING;
|
||||
outputArg.options = outputOpts;
|
||||
outputArg.optionNames = outputOptNames;
|
||||
}
|
||||
@ -137,10 +137,10 @@ wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgIn
|
||||
std::vector<std::string>::iterator stringIter;
|
||||
|
||||
switch (arg.type) {
|
||||
case ModemArgInfo::INT:
|
||||
case ModemArgInfo::Type::INT:
|
||||
try {
|
||||
intVal = std::stoi(arg.value);
|
||||
} catch (const std::invalid_argument &e) {
|
||||
} catch (const std::invalid_argument &) {
|
||||
intVal = 0;
|
||||
}
|
||||
prop = pg->Append( new wxIntProperty(arg.name, wxPG_LABEL, intVal) );
|
||||
@ -149,10 +149,10 @@ wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgIn
|
||||
pg->SetPropertyAttribute( prop, wxPG_ATTR_MAX, arg.range.maximum());
|
||||
}
|
||||
break;
|
||||
case ModemArgInfo::FLOAT:
|
||||
case ModemArgInfo::Type::FLOAT:
|
||||
try {
|
||||
floatVal = std::stod(arg.value);
|
||||
} catch (const std::invalid_argument &e) {
|
||||
} catch (const std::invalid_argument &) {
|
||||
floatVal = 0;
|
||||
}
|
||||
prop = pg->Append( new wxFloatProperty(arg.name, wxPG_LABEL, floatVal) );
|
||||
@ -161,10 +161,10 @@ wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgIn
|
||||
pg->SetPropertyAttribute( prop, wxPG_ATTR_MAX, arg.range.maximum());
|
||||
}
|
||||
break;
|
||||
case ModemArgInfo::BOOL:
|
||||
case ModemArgInfo::Type::BOOL:
|
||||
prop = pg->Append( new wxBoolProperty(arg.name, wxPG_LABEL, (arg.value=="true")) );
|
||||
break;
|
||||
case ModemArgInfo::STRING:
|
||||
case ModemArgInfo::Type::STRING:
|
||||
if (!arg.options.empty()) {
|
||||
intVal = 0;
|
||||
prop = pg->Append( new wxEnumProperty(arg.name, wxPG_LABEL) );
|
||||
@ -186,11 +186,11 @@ wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgIn
|
||||
prop = pg->Append( new wxStringProperty(arg.name, wxPG_LABEL, arg.value) );
|
||||
}
|
||||
break;
|
||||
case ModemArgInfo::PATH_DIR:
|
||||
case ModemArgInfo::Type::PATH_DIR:
|
||||
break;
|
||||
case ModemArgInfo::PATH_FILE:
|
||||
case ModemArgInfo::Type::PATH_FILE:
|
||||
break;
|
||||
case ModemArgInfo::COLOR:
|
||||
case ModemArgInfo::Type::COLOR:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -211,9 +211,9 @@ std::string ModemProperties::readProperty(const std::string& key) {
|
||||
wxPGProperty *prop = props[key];
|
||||
|
||||
std::string result;
|
||||
if (arg.type == ModemArgInfo::STRING && !arg.options.empty()) {
|
||||
if (arg.type == ModemArgInfo::Type::STRING && !arg.options.empty()) {
|
||||
return arg.options[prop->GetChoiceSelection()];
|
||||
} else if (arg.type == ModemArgInfo::BOOL) {
|
||||
} else if (arg.type == ModemArgInfo::Type::BOOL) {
|
||||
return (prop->GetValueAsString()=="True")?"true":"false";
|
||||
} else {
|
||||
return prop->GetValueAsString().ToStdString();
|
||||
@ -239,7 +239,7 @@ void ModemProperties::OnChange(wxPropertyGridEvent &event) {
|
||||
if (demodContext) {
|
||||
try {
|
||||
demodContext->setOutputDevice(std::stoi(outputArg.value));
|
||||
} catch (const exception &e) {
|
||||
} catch (const exception &) {
|
||||
// .. this should never happen ;)
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ void AudioThread::setDeviceSampleRate(int deviceId, int sampleRate) {
|
||||
if (matchingControllerThread != nullptr) {
|
||||
|
||||
AudioThreadCommand refreshDevice;
|
||||
refreshDevice.cmd = AudioThreadCommand::AUDIO_THREAD_CMD_SET_SAMPLE_RATE;
|
||||
refreshDevice.cmdType = AudioThreadCommand::Type::AUDIO_THREAD_CMD_SET_SAMPLE_RATE;
|
||||
refreshDevice.int_value = sampleRate;
|
||||
//VSO : blocking push !
|
||||
matchingControllerThread->getCommandQueue()->push(refreshDevice);
|
||||
@ -497,10 +497,10 @@ void AudioThread::run() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (command.cmd == AudioThreadCommand::AUDIO_THREAD_CMD_SET_DEVICE) {
|
||||
if (command.cmdType == AudioThreadCommand::Type::AUDIO_THREAD_CMD_SET_DEVICE) {
|
||||
setupDevice(command.int_value);
|
||||
}
|
||||
if (command.cmd == AudioThreadCommand::AUDIO_THREAD_CMD_SET_SAMPLE_RATE) {
|
||||
if (command.cmdType == AudioThreadCommand::Type::AUDIO_THREAD_CMD_SET_SAMPLE_RATE) {
|
||||
setSampleRate(command.int_value);
|
||||
}
|
||||
} //end while
|
||||
|
@ -58,15 +58,15 @@ typedef std::shared_ptr<DemodulatorThreadOutputQueue> DemodulatorThreadOutputQue
|
||||
|
||||
class AudioThreadCommand {
|
||||
public:
|
||||
enum AudioThreadCommandEnum {
|
||||
enum class Type {
|
||||
AUDIO_THREAD_CMD_NULL, AUDIO_THREAD_CMD_SET_DEVICE, AUDIO_THREAD_CMD_SET_SAMPLE_RATE
|
||||
};
|
||||
|
||||
AudioThreadCommand() :
|
||||
cmd(AUDIO_THREAD_CMD_NULL), int_value(0) {
|
||||
cmdType(AudioThreadCommand::Type::AUDIO_THREAD_CMD_NULL), int_value(0) {
|
||||
}
|
||||
|
||||
AudioThreadCommandEnum cmd;
|
||||
AudioThreadCommand::Type cmdType;
|
||||
int int_value;
|
||||
};
|
||||
|
||||
|
@ -15,19 +15,6 @@
|
||||
|
||||
class DemodulatorThread;
|
||||
|
||||
class DemodulatorThreadControlCommand {
|
||||
public:
|
||||
enum DemodulatorThreadControlCommandEnum {
|
||||
DEMOD_THREAD_CMD_CTL_NULL, DEMOD_THREAD_CMD_CTL_SQUELCH_ON, DEMOD_THREAD_CMD_CTL_SQUELCH_OFF
|
||||
};
|
||||
|
||||
DemodulatorThreadControlCommand() :
|
||||
cmd(DEMOD_THREAD_CMD_CTL_NULL) {
|
||||
}
|
||||
|
||||
DemodulatorThreadControlCommandEnum cmd;
|
||||
};
|
||||
|
||||
class DemodulatorThreadIQData {
|
||||
public:
|
||||
long long frequency;
|
||||
@ -76,8 +63,6 @@ typedef std::shared_ptr<DemodulatorThreadPostIQData> DemodulatorThreadPostIQData
|
||||
|
||||
typedef ThreadBlockingQueue<DemodulatorThreadIQDataPtr> DemodulatorThreadInputQueue;
|
||||
typedef ThreadBlockingQueue<DemodulatorThreadPostIQDataPtr> DemodulatorThreadPostInputQueue;
|
||||
typedef ThreadBlockingQueue<DemodulatorThreadControlCommand> DemodulatorThreadControlCommandQueue;
|
||||
|
||||
typedef std::shared_ptr<DemodulatorThreadInputQueue> DemodulatorThreadInputQueuePtr;
|
||||
typedef std::shared_ptr<DemodulatorThreadPostInputQueue> DemodulatorThreadPostInputQueuePtr;
|
||||
typedef std::shared_ptr<DemodulatorThreadControlCommandQueue> DemodulatorThreadControlCommandQueuePtr;
|
||||
|
@ -46,7 +46,6 @@ DemodulatorInstance::DemodulatorInstance() {
|
||||
#endif
|
||||
|
||||
active.store(false);
|
||||
squelch.store(false);
|
||||
muted.store(false);
|
||||
recording.store(false);
|
||||
deltaLock.store(false);
|
||||
@ -73,12 +72,8 @@ DemodulatorInstance::DemodulatorInstance() {
|
||||
pipeAudioData = std::make_shared<AudioThreadInputQueue>();
|
||||
pipeAudioData->set_max_num_items(100);
|
||||
|
||||
threadQueueControl = std::make_shared<DemodulatorThreadControlCommandQueue>();
|
||||
threadQueueControl->set_max_num_items(2);
|
||||
|
||||
demodulatorThread = new DemodulatorThread(this);
|
||||
demodulatorThread->setInputQueue("IQDataInput",pipeIQDemodData);
|
||||
demodulatorThread->setInputQueue("ControlQueue",threadQueueControl);
|
||||
demodulatorThread->setOutputQueue("AudioDataOutput", pipeAudioData);
|
||||
|
||||
audioThread->setInputQueue("AudioDataInput", pipeAudioData);
|
||||
@ -192,7 +187,6 @@ void DemodulatorInstance::terminate() {
|
||||
pipeIQInputData->flush();
|
||||
pipeAudioData->flush();
|
||||
pipeIQDemodData->flush();
|
||||
threadQueueControl->flush();
|
||||
}
|
||||
|
||||
std::string DemodulatorInstance::getLabel() {
|
||||
@ -305,30 +299,15 @@ void DemodulatorInstance::setActive(bool state) {
|
||||
}
|
||||
|
||||
void DemodulatorInstance::squelchAuto() {
|
||||
DemodulatorThreadControlCommand command;
|
||||
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_ON;
|
||||
//VSO: blocking push
|
||||
threadQueueControl->push(command);
|
||||
squelch = true;
|
||||
demodulatorThread->setSquelchEnabled(true);
|
||||
}
|
||||
|
||||
bool DemodulatorInstance::isSquelchEnabled() {
|
||||
return (demodulatorThread->getSquelchLevel() != 0.0);
|
||||
return demodulatorThread->isSquelchEnabled();
|
||||
}
|
||||
|
||||
void DemodulatorInstance::setSquelchEnabled(bool state) {
|
||||
if (!state && squelch) {
|
||||
DemodulatorThreadControlCommand command;
|
||||
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_OFF;
|
||||
threadQueueControl->push(command);
|
||||
} else if (state && !squelch) {
|
||||
DemodulatorThreadControlCommand command;
|
||||
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_ON;
|
||||
//VSO: blocking push!
|
||||
threadQueueControl->push(command);
|
||||
}
|
||||
|
||||
squelch = state;
|
||||
demodulatorThread->setSquelchEnabled(state);
|
||||
}
|
||||
|
||||
float DemodulatorInstance::getSignalLevel() {
|
||||
@ -358,7 +337,7 @@ void DemodulatorInstance::setOutputDevice(int device_id) {
|
||||
audioThread->setInitOutputDevice(device_id);
|
||||
} else if (audioThread) {
|
||||
AudioThreadCommand command;
|
||||
command.cmd = AudioThreadCommand::AUDIO_THREAD_CMD_SET_DEVICE;
|
||||
command.cmdType = AudioThreadCommand::Type::AUDIO_THREAD_CMD_SET_DEVICE;
|
||||
command.int_value = device_id;
|
||||
//VSO: blocking push
|
||||
audioThread->getCommandQueue()->push(command);
|
||||
|
@ -145,7 +145,6 @@ private:
|
||||
AudioThreadInputQueuePtr pipeAudioData;
|
||||
DemodulatorPreThread *demodulatorPreThread;
|
||||
DemodulatorThread *demodulatorThread;
|
||||
DemodulatorThreadControlCommandQueuePtr threadQueueControl;
|
||||
|
||||
AudioSinkThread *audioSinkThread = nullptr;
|
||||
std::thread *t_AudioSink = nullptr;
|
||||
@ -159,7 +158,6 @@ private:
|
||||
std::atomic<std::wstring *> user_label;
|
||||
|
||||
std::atomic_bool active;
|
||||
std::atomic_bool squelch;
|
||||
std::atomic_bool muted;
|
||||
std::atomic_bool deltaLock;
|
||||
std::atomic_bool recording;
|
||||
|
@ -454,7 +454,7 @@ std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
|
||||
try {
|
||||
node->element()->get(decodedWString);
|
||||
|
||||
} catch (const DataTypeMismatchException &e) {
|
||||
} catch (const DataTypeMismatchException &) {
|
||||
//2) wstring decode fail, try simple std::string
|
||||
std::string decodedStdString;
|
||||
try {
|
||||
@ -464,7 +464,7 @@ std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
|
||||
//use wxString for a clean conversion to a wstring:
|
||||
decodedWString = wxString(decodedStdString).ToStdWstring();
|
||||
|
||||
} catch (const DataTypeMismatchException &e) {
|
||||
} catch (const DataTypeMismatchException &) {
|
||||
//nothing works, return an empty string.
|
||||
decodedWString = L"";
|
||||
}
|
||||
@ -496,7 +496,7 @@ DemodulatorInstancePtr DemodulatorMgr::loadInstance(DataNode *node) {
|
||||
|
||||
DataNode *demodTypeNode = node->hasAnother("type")?node->getNext("type"):nullptr;
|
||||
|
||||
if (demodTypeNode && demodTypeNode->element()->getDataType() == DataElement::DATA_INT) {
|
||||
if (demodTypeNode && demodTypeNode->element()->getDataType() == DataElement::Type::DATA_INT) {
|
||||
int legacyType = (int)*demodTypeNode;
|
||||
int legacyStereo = node->hasAnother("stereo") ? (int) *node->getNext("stereo") : 0;
|
||||
switch (legacyType) { // legacy demod ID
|
||||
@ -518,7 +518,7 @@ DemodulatorInstancePtr DemodulatorMgr::loadInstance(DataNode *node) {
|
||||
case 16: type = "I/Q"; break;
|
||||
default: type = "FM"; break;
|
||||
}
|
||||
} else if (demodTypeNode && demodTypeNode->element()->getDataType() == DataElement::DATA_STRING) {
|
||||
} else if (demodTypeNode && demodTypeNode->element()->getDataType() == DataElement::Type::DATA_STRING) {
|
||||
demodTypeNode->element()->get(type);
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ void DemodulatorPreThread::run() {
|
||||
}
|
||||
|
||||
if (demodTypeChanged.load() && (newSampleRate && newAudioSampleRate && newBandwidth)) {
|
||||
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD);
|
||||
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD);
|
||||
command.frequency = newFrequency;
|
||||
command.sampleRate = newSampleRate;
|
||||
command.demodType = newDemodType;
|
||||
@ -137,7 +137,7 @@ void DemodulatorPreThread::run() {
|
||||
(bandwidthChanged.load() || sampleRateChanged.load() || audioSampleRateChanged.load() || cModem->shouldRebuildKit()) &&
|
||||
(newSampleRate && newAudioSampleRate && newBandwidth)
|
||||
) {
|
||||
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS);
|
||||
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS);
|
||||
command.frequency = newFrequency;
|
||||
command.sampleRate = newSampleRate;
|
||||
command.bandwidth = newBandwidth;
|
||||
@ -225,7 +225,7 @@ void DemodulatorPreThread::run() {
|
||||
while (!stopping && workerResults->try_pop(result)) {
|
||||
|
||||
switch (result.cmd) {
|
||||
case DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS:
|
||||
case DemodulatorWorkerThreadResult::Type::DEMOD_WORKER_THREAD_RESULT_FILTERS:
|
||||
if (result.iqResampler) {
|
||||
if (iqResampler) {
|
||||
msresamp_crcf_destroy(iqResampler);
|
||||
|
@ -22,12 +22,8 @@ DemodulatorInstance* DemodulatorThread::squelchLock(nullptr);
|
||||
std::mutex DemodulatorThread::squelchLockMutex;
|
||||
|
||||
DemodulatorThread::DemodulatorThread(DemodulatorInstance* parent)
|
||||
: IOThread(), outputBuffers("DemodulatorThreadBuffers"), squelchLevel(-100),
|
||||
signalLevel(-100), signalFloor(-30), signalCeil(30), squelchEnabled(false) {
|
||||
|
||||
demodInstance = parent;
|
||||
muted.store(false);
|
||||
squelchBreak = false;
|
||||
: IOThread(), demodInstance(parent), outputBuffers("DemodulatorThreadBuffers"), squelchLevel(-100),
|
||||
signalLevel(-100), signalFloor(-30), signalCeil(30), muted(false), squelchEnabled(false), squelchBreak(false) {
|
||||
}
|
||||
|
||||
DemodulatorThread::~DemodulatorThread() {
|
||||
@ -82,7 +78,6 @@ void DemodulatorThread::run() {
|
||||
|
||||
iqInputQueue = std::static_pointer_cast<DemodulatorThreadPostInputQueue>(getInputQueue("IQDataInput"));
|
||||
audioOutputQueue = std::static_pointer_cast<AudioThreadInputQueue>(getOutputQueue("AudioDataOutput"));
|
||||
threadQueueControl = std::static_pointer_cast<DemodulatorThreadControlCommandQueue>(getInputQueue("ControlQueue"));
|
||||
|
||||
ModemIQData modemData;
|
||||
|
||||
@ -167,7 +162,7 @@ void DemodulatorThread::run() {
|
||||
currentSignalLevel = linearToDb(accum / double(inp->data.size()));
|
||||
}
|
||||
|
||||
float sf = signalFloor.load(), sc = signalCeil.load(), sl = squelchLevel.load();
|
||||
float sf = signalFloor, sc = signalCeil, sl = squelchLevel;
|
||||
|
||||
|
||||
if (currentSignalLevel > sc) {
|
||||
@ -190,8 +185,8 @@ void DemodulatorThread::run() {
|
||||
sc -= (sc - (currentSignalLevel + 2.0f)) * sampleTime * 0.05f;
|
||||
sf += ((currentSignalLevel - 5.0f) - sf) * sampleTime * 0.15f;
|
||||
|
||||
signalFloor.store(sf);
|
||||
signalCeil.store(sc);
|
||||
signalFloor = sf;
|
||||
signalCeil = sc;
|
||||
}
|
||||
|
||||
if (currentSignalLevel > signalLevel) {
|
||||
@ -321,7 +316,7 @@ void DemodulatorThread::run() {
|
||||
}
|
||||
|
||||
if (!squelched && ati != nullptr) {
|
||||
if (!muted.load() && (!wxGetApp().getSoloMode() || (demodInstance ==
|
||||
if (!muted && (!wxGetApp().getSoloMode() || (demodInstance ==
|
||||
wxGetApp().getDemodMgr().getCurrentModem().get()))) {
|
||||
//non-blocking push needed for audio out
|
||||
if (!audioOutputQueue->try_push(ati)) {
|
||||
@ -348,23 +343,6 @@ void DemodulatorThread::run() {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
}
|
||||
|
||||
DemodulatorThreadControlCommand command;
|
||||
|
||||
//empty command queue, execute commands
|
||||
while (threadQueueControl->try_pop(command)) {
|
||||
|
||||
switch (command.cmd) {
|
||||
case DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_ON:
|
||||
squelchEnabled = true;
|
||||
break;
|
||||
case DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_OFF:
|
||||
squelchEnabled = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// end while !stopping
|
||||
|
||||
@ -381,27 +359,34 @@ void DemodulatorThread::terminate() {
|
||||
//unblock the curretly blocked push()
|
||||
iqInputQueue->flush();
|
||||
audioOutputQueue->flush();
|
||||
threadQueueControl->flush();
|
||||
}
|
||||
|
||||
bool DemodulatorThread::isMuted() {
|
||||
return muted.load();
|
||||
return muted;
|
||||
}
|
||||
|
||||
void DemodulatorThread::setMuted(bool muted_in) {
|
||||
muted.store(muted_in);
|
||||
muted = muted_in;
|
||||
}
|
||||
|
||||
float DemodulatorThread::getSignalLevel() {
|
||||
return signalLevel.load();
|
||||
return signalLevel;
|
||||
}
|
||||
|
||||
float DemodulatorThread::getSignalFloor() {
|
||||
return signalFloor.load();
|
||||
return signalFloor;
|
||||
}
|
||||
|
||||
float DemodulatorThread::getSignalCeil() {
|
||||
return signalCeil.load();
|
||||
return signalCeil;
|
||||
}
|
||||
|
||||
void DemodulatorThread::setSquelchEnabled(bool squelchEnabled_in) {
|
||||
squelchEnabled = squelchEnabled_in;
|
||||
}
|
||||
|
||||
bool DemodulatorThread::isSquelchEnabled() {
|
||||
return squelchEnabled;
|
||||
}
|
||||
|
||||
void DemodulatorThread::setSquelchLevel(float signal_level_in) {
|
||||
|
@ -34,6 +34,8 @@ public:
|
||||
|
||||
float getSignalLevel();
|
||||
float getSignalCeil();
|
||||
void setSquelchEnabled(bool squelchEnabled_in);
|
||||
bool isSquelchEnabled();
|
||||
float getSignalFloor();
|
||||
void setSquelchLevel(float signal_level_in);
|
||||
float getSquelchLevel();
|
||||
@ -54,7 +56,7 @@ protected:
|
||||
|
||||
std::atomic<float> squelchLevel;
|
||||
std::atomic<float> signalLevel, signalFloor, signalCeil;
|
||||
bool squelchEnabled, squelchBreak;
|
||||
std::atomic<bool> squelchEnabled, squelchBreak;
|
||||
|
||||
static DemodulatorInstance* squelchLock;
|
||||
static std::mutex squelchLockMutex;
|
||||
@ -66,8 +68,6 @@ protected:
|
||||
DemodulatorThreadPostInputQueuePtr iqInputQueue;
|
||||
AudioThreadInputQueuePtr audioOutputQueue;
|
||||
DemodulatorThreadOutputQueuePtr audioVisOutputQueue;
|
||||
DemodulatorThreadControlCommandQueuePtr threadQueueControl;
|
||||
|
||||
DemodulatorThreadOutputQueuePtr audioSinkOutputQueue = nullptr;
|
||||
|
||||
//protects the audioVisOutputQueue dynamic binding change at runtime (in DemodulatorMgr)
|
||||
|
@ -37,11 +37,11 @@ void DemodulatorWorkerThread::run() {
|
||||
}
|
||||
|
||||
switch (command.cmd) {
|
||||
case DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS:
|
||||
case DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS:
|
||||
filterChanged = true;
|
||||
filterCommand = command;
|
||||
break;
|
||||
case DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD:
|
||||
case DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD:
|
||||
makeDemod = true;
|
||||
demodCommand = command;
|
||||
break;
|
||||
@ -52,7 +52,7 @@ void DemodulatorWorkerThread::run() {
|
||||
} //end while done.
|
||||
|
||||
if ((makeDemod || filterChanged) && !stopping) {
|
||||
DemodulatorWorkerThreadResult result(DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS);
|
||||
DemodulatorWorkerThreadResult result(DemodulatorWorkerThreadResult::Type::DEMOD_WORKER_THREAD_RESULT_FILTERS);
|
||||
|
||||
|
||||
if (filterCommand.sampleRate) {
|
||||
|
@ -14,21 +14,21 @@
|
||||
|
||||
class DemodulatorWorkerThreadResult {
|
||||
public:
|
||||
enum DemodulatorThreadResultEnum {
|
||||
enum class Type {
|
||||
DEMOD_WORKER_THREAD_RESULT_NULL, DEMOD_WORKER_THREAD_RESULT_FILTERS
|
||||
};
|
||||
|
||||
DemodulatorWorkerThreadResult() :
|
||||
cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr) {
|
||||
cmd(DemodulatorWorkerThreadResult::Type::DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr) {
|
||||
|
||||
}
|
||||
|
||||
explicit DemodulatorWorkerThreadResult(DemodulatorThreadResultEnum cmd) :
|
||||
explicit DemodulatorWorkerThreadResult(DemodulatorWorkerThreadResult::Type cmd) :
|
||||
DemodulatorWorkerThreadResult() {
|
||||
this->cmd = cmd;
|
||||
}
|
||||
|
||||
DemodulatorThreadResultEnum cmd;
|
||||
DemodulatorWorkerThreadResult::Type cmd;
|
||||
|
||||
msresamp_crcf iqResampler;
|
||||
double iqResampleRatio;
|
||||
@ -43,21 +43,21 @@ public:
|
||||
|
||||
class DemodulatorWorkerThreadCommand {
|
||||
public:
|
||||
enum DemodulatorThreadCommandEnum {
|
||||
enum class Type {
|
||||
DEMOD_WORKER_THREAD_CMD_NULL, DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS, DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD
|
||||
};
|
||||
|
||||
DemodulatorWorkerThreadCommand() :
|
||||
cmd(DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
|
||||
cmd(DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
|
||||
|
||||
}
|
||||
|
||||
explicit DemodulatorWorkerThreadCommand(DemodulatorThreadCommandEnum cmd) :
|
||||
explicit DemodulatorWorkerThreadCommand(DemodulatorWorkerThreadCommand::Type cmd) :
|
||||
cmd(cmd), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
|
||||
|
||||
}
|
||||
|
||||
DemodulatorThreadCommandEnum cmd;
|
||||
DemodulatorWorkerThreadCommand::Type cmd;
|
||||
|
||||
long long frequency;
|
||||
long long sampleRate;
|
||||
|
@ -278,12 +278,12 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
|
||||
|
||||
for (const auto& gn_i : groupNameList) {
|
||||
auto* tvi = new TreeViewItem();
|
||||
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP;
|
||||
tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP;
|
||||
tvi->groupName = gn_i;
|
||||
wxTreeItemId group_itm = m_treeView->AppendItem(bookmarkBranch, gn_i);
|
||||
SetTreeItemData(group_itm, tvi);
|
||||
groups[gn_i] = group_itm;
|
||||
if (prevSelCopy != nullptr && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP && gn_i == prevSelCopy->groupName) {
|
||||
if (prevSelCopy != nullptr && prevSelCopy->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP && gn_i == prevSelCopy->groupName) {
|
||||
bmSelFound = group_itm;
|
||||
} else if (!nextGroup.empty() && gn_i == nextGroup) {
|
||||
bmSelFound = group_itm;
|
||||
@ -324,13 +324,13 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
|
||||
}
|
||||
|
||||
auto* tvi = new TreeViewItem();
|
||||
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK;
|
||||
tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK;
|
||||
tvi->bookmarkEnt = bmEnt;
|
||||
tvi->groupName = gn_i;
|
||||
|
||||
wxTreeItemId itm = m_treeView->AppendItem(groupItem, labelVal);
|
||||
SetTreeItemData(itm, tvi);
|
||||
if (prevSelCopy != nullptr && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK && prevSelCopy->bookmarkEnt == bmEnt && groupExpanded) {
|
||||
if (prevSelCopy != nullptr && prevSelCopy->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK && prevSelCopy->bookmarkEnt == bmEnt && groupExpanded) {
|
||||
bmSelFound = itm;
|
||||
}
|
||||
if (nextEnt == bmEnt) {
|
||||
@ -392,7 +392,7 @@ void BookmarkView::doUpdateActiveList() {
|
||||
}
|
||||
|
||||
auto* tvi = new TreeViewItem();
|
||||
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE;
|
||||
tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE;
|
||||
tvi->demod = demod_i;
|
||||
|
||||
wxTreeItemId itm = m_treeView->AppendItem(activeBranch,activeLabel);
|
||||
@ -415,7 +415,7 @@ void BookmarkView::doUpdateActiveList() {
|
||||
|
||||
for (auto &re_i: bmRanges) {
|
||||
auto* tvi = new TreeViewItem();
|
||||
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE;
|
||||
tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE;
|
||||
tvi->rangeEnt = re_i;
|
||||
|
||||
std::wstring labelVal = re_i->label;
|
||||
@ -432,7 +432,7 @@ void BookmarkView::doUpdateActiveList() {
|
||||
if (nextRange == re_i) {
|
||||
selItem = itm;
|
||||
nextRange = nullptr;
|
||||
} else if (!selItem && rangeExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE && prevSelCopy->rangeEnt == re_i) {
|
||||
} else if (!selItem && rangeExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE && prevSelCopy->rangeEnt == re_i) {
|
||||
selItem = itm;
|
||||
}
|
||||
}
|
||||
@ -446,7 +446,7 @@ void BookmarkView::doUpdateActiveList() {
|
||||
|
||||
for (auto &bmr_i: bmRecents) {
|
||||
auto* tvi = new TreeViewItem();
|
||||
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT;
|
||||
tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT;
|
||||
tvi->bookmarkEnt = bmr_i;
|
||||
|
||||
std::wstring labelVal;
|
||||
@ -481,7 +481,7 @@ void BookmarkView::doUpdateActiveList() {
|
||||
if (nextEnt == bmr_i) {
|
||||
selItem = itm;
|
||||
nextEnt = nullptr;
|
||||
} else if (!selItem && recentExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT && prevSelCopy->bookmarkEnt == bmr_i) {
|
||||
} else if (!selItem && recentExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT && prevSelCopy->bookmarkEnt == bmr_i) {
|
||||
selItem = itm;
|
||||
}
|
||||
}
|
||||
@ -538,15 +538,15 @@ void BookmarkView::onKeyUp( wxKeyEvent& event ) {
|
||||
|
||||
// Handlers
|
||||
if (event.m_keyCode == WXK_DELETE || event.m_keyCode == WXK_NUMPAD_DELETE) {
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
onRemoveActive(treeEvent);
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
onRemoveRecent(treeEvent);
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
onRemoveBookmark(treeEvent);
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
onRemoveRange(treeEvent);
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
onRemoveGroup(treeEvent);
|
||||
}
|
||||
|
||||
@ -565,21 +565,21 @@ void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (!tvi->demod->isActive()) {
|
||||
wxGetApp().setFrequency(tvi->demod->getFrequency());
|
||||
nextDemod = tvi->demod;
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(nextDemod, false);
|
||||
}
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
|
||||
nextEnt = tvi->bookmarkEnt;
|
||||
wxGetApp().getBookmarkMgr().removeRecent(tvi->bookmarkEnt);
|
||||
|
||||
activateBookmark(tvi->bookmarkEnt);
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
activateBookmark(tvi->bookmarkEnt);
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
activateRange(tvi->rangeEnt);
|
||||
}
|
||||
}
|
||||
@ -606,7 +606,7 @@ void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
|
||||
TreeViewItem *tvi = itemToTVI(event.GetItem());
|
||||
|
||||
if (tvi != nullptr) {
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
wxGetApp().getBookmarkMgr().setExpandState(tvi->groupName,false);
|
||||
}
|
||||
}
|
||||
@ -636,7 +636,7 @@ void BookmarkView::onTreeExpanded( wxTreeEvent& event ) {
|
||||
TreeViewItem *tvi = itemToTVI(event.GetItem());
|
||||
|
||||
if (tvi != nullptr) {
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
wxGetApp().getBookmarkMgr().setExpandState(tvi->groupName,true);
|
||||
}
|
||||
}
|
||||
@ -804,7 +804,7 @@ void BookmarkView::updateBookmarkChoices() {
|
||||
|
||||
TreeViewItem *activeSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
bookmarkChoices.push_back(((activeSel != nullptr && activeSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK))?BOOKMARK_VIEW_CHOICE_MOVE:BOOKMARK_VIEW_CHOICE_DEFAULT);
|
||||
bookmarkChoices.push_back(((activeSel != nullptr && activeSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK))?BOOKMARK_VIEW_CHOICE_MOVE:BOOKMARK_VIEW_CHOICE_DEFAULT);
|
||||
wxGetApp().getBookmarkMgr().getGroups(bookmarkChoices);
|
||||
bookmarkChoices.push_back(BOOKMARK_VIEW_CHOICE_NEW);
|
||||
}
|
||||
@ -842,13 +842,13 @@ void BookmarkView::onBookmarkChoice( wxCommandEvent & /* event */ ) {
|
||||
}
|
||||
|
||||
if (tvi != nullptr) {
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
doBookmarkActive(stringVal.ToStdString(), tvi->demod);
|
||||
}
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
doBookmarkRecent(stringVal.ToStdString(), tvi->bookmarkEnt);
|
||||
}
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
doMoveBookmark(tvi->bookmarkEnt, stringVal.ToStdString());
|
||||
}
|
||||
}
|
||||
@ -1137,20 +1137,20 @@ void BookmarkView::onTreeSelect( wxTreeEvent& event ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
activeSelection(tvi->demod);
|
||||
if (tvi->demod->isActive()) {
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(nullptr, true);
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(tvi->demod, false);
|
||||
tvi->demod->setTracking(true);
|
||||
}
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
recentSelection(tvi->bookmarkEnt);
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
bookmarkSelection(tvi->bookmarkEnt);
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
groupSelection(tvi->groupName);
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
rangeSelection(tvi->rangeEnt);
|
||||
} else {
|
||||
hideProps();
|
||||
@ -1178,21 +1178,21 @@ void BookmarkView::onLabelText( wxCommandEvent& /* event */ ) {
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel != nullptr) {
|
||||
if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
curSel->demod->setDemodulatorUserLabel(newLabel);
|
||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
||||
} else if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
} else if (curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
curSel->bookmarkEnt->label = m_labelText->GetValue().ToStdWstring();
|
||||
curSel->bookmarkEnt->node->child("user_label")->element()->set(newLabel);
|
||||
wxGetApp().getBookmarkMgr().updateBookmarks();
|
||||
} else if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
} else if (curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
curSel->bookmarkEnt->label = m_labelText->GetValue().ToStdWstring();
|
||||
curSel->bookmarkEnt->node->child("user_label")->element()->set(newLabel);
|
||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
||||
} else if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
} else if (curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
curSel->rangeEnt->label = m_labelText->GetValue().ToStdWstring();
|
||||
wxGetApp().getBookmarkMgr().updateActiveList();
|
||||
} else if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
} else if (curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
std::string newGroupName = m_labelText->GetValue().ToStdString();
|
||||
|
||||
if (!newGroupName.empty() && newGroupName != curSel->groupName) {
|
||||
@ -1211,7 +1211,7 @@ void BookmarkView::onDoubleClickFreq( wxMouseEvent& /* event */ ) {
|
||||
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(nullptr, true);
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(curSel->demod, false);
|
||||
wxGetApp().showFrequencyInput(FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT);
|
||||
@ -1223,7 +1223,7 @@ void BookmarkView::onDoubleClickBandwidth( wxMouseEvent& /* event */ ) {
|
||||
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(nullptr, true);
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(curSel->demod, false);
|
||||
wxGetApp().showFrequencyInput(FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_BANDWIDTH);
|
||||
@ -1235,7 +1235,7 @@ void BookmarkView::onRemoveActive( wxCommandEvent& /* event */ ) {
|
||||
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
doRemoveActive(curSel->demod);
|
||||
}
|
||||
}
|
||||
@ -1244,7 +1244,7 @@ void BookmarkView::onStartRecording( wxCommandEvent& /* event */ ) {
|
||||
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (!curSel->demod->isRecording() && wxGetApp().getConfig()->verifyRecordingPath()) {
|
||||
curSel->demod->setRecording(true);
|
||||
|
||||
@ -1258,7 +1258,7 @@ void BookmarkView::onStopRecording( wxCommandEvent& /* event */ ) {
|
||||
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (curSel->demod->isRecording()) {
|
||||
curSel->demod->setRecording(false);
|
||||
|
||||
@ -1272,7 +1272,7 @@ void BookmarkView::onStopRecording( wxCommandEvent& /* event */ ) {
|
||||
void BookmarkView::onRemoveBookmark( wxCommandEvent& /* event */ ) {
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
ActionDialog::showDialog(new ActionDialogRemoveBookmark(curSel->bookmarkEnt));
|
||||
}
|
||||
}
|
||||
@ -1282,7 +1282,7 @@ void BookmarkView::onActivateBookmark( wxCommandEvent& /* event */ ) {
|
||||
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
activateBookmark(curSel->bookmarkEnt);
|
||||
}
|
||||
}
|
||||
@ -1292,7 +1292,7 @@ void BookmarkView::onActivateRecent( wxCommandEvent& /* event */ ) {
|
||||
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
BookmarkEntryPtr bookmarkEntToActivate = curSel->bookmarkEnt;
|
||||
|
||||
//let removeRecent() + activateBookmark() refresh the tree
|
||||
@ -1307,7 +1307,7 @@ void BookmarkView::onActivateRecent( wxCommandEvent& /* event */ ) {
|
||||
void BookmarkView::onRemoveRecent ( wxCommandEvent& /* event */ ) {
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
BookmarkEntryPtr bookmarkEntToRemove = curSel->bookmarkEnt;
|
||||
|
||||
//let removeRecent() + updateActiveList() refresh the tree
|
||||
@ -1334,7 +1334,7 @@ void BookmarkView::onAddGroup( wxCommandEvent& /* event */ ) {
|
||||
void BookmarkView::onRemoveGroup( wxCommandEvent& /* event */ ) {
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
ActionDialog::showDialog(new ActionDialogRemoveGroup(curSel->groupName));
|
||||
}
|
||||
}
|
||||
@ -1354,7 +1354,7 @@ void BookmarkView::onAddRange( wxCommandEvent& /* event */ ) {
|
||||
void BookmarkView::onRemoveRange( wxCommandEvent& /* event */ ) {
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
ActionDialog::showDialog(new ActionDialogRemoveRange(curSel->rangeEnt));
|
||||
}
|
||||
}
|
||||
@ -1364,7 +1364,7 @@ void BookmarkView::onRenameRange( wxCommandEvent& /* event */ ) {
|
||||
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (!curSel || curSel->type != TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
if (!curSel || curSel->type != TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1383,7 +1383,7 @@ void BookmarkView::onActivateRange( wxCommandEvent& /* event */ ) {
|
||||
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
activateRange(curSel->rangeEnt);
|
||||
}
|
||||
}
|
||||
@ -1392,7 +1392,7 @@ void BookmarkView::onUpdateRange( wxCommandEvent& /* event */ ) {
|
||||
|
||||
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
|
||||
|
||||
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
|
||||
ActionDialog::showDialog(new ActionDialogUpdateRange(curSel->rangeEnt));
|
||||
}
|
||||
}
|
||||
@ -1414,10 +1414,10 @@ void BookmarkView::onTreeBeginDrag( wxTreeEvent& event ) {
|
||||
bool bAllow = false;
|
||||
std::wstring dragItemName;
|
||||
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
bAllow = true;
|
||||
dragItemName = BookmarkMgr::getActiveDisplayName(tvi->demod);
|
||||
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT || tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT || tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
bAllow = true;
|
||||
dragItemName = BookmarkMgr::getBookmarkEntryDisplayName(tvi->bookmarkEnt);
|
||||
}
|
||||
@ -1468,24 +1468,24 @@ void BookmarkView::onTreeEndDrag( wxTreeEvent& event ) {
|
||||
|
||||
if (!tvi) {
|
||||
if (event.GetItem() == bookmarkBranch) {
|
||||
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
|
||||
doBookmarkActive(BOOKMARK_VIEW_STR_UNNAMED, dragItem->demod);
|
||||
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
} else if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
|
||||
doBookmarkRecent(BOOKMARK_VIEW_STR_UNNAMED, dragItem->bookmarkEnt);
|
||||
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
} else if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
doMoveBookmark(dragItem->bookmarkEnt, BOOKMARK_VIEW_STR_UNNAMED);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP || tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Group Item
|
||||
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP || tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
|
||||
if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Group Item
|
||||
doBookmarkActive(tvi->groupName, dragItem->demod);
|
||||
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Group Item
|
||||
} else if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Group Item
|
||||
doBookmarkRecent(tvi->groupName, dragItem->bookmarkEnt);
|
||||
m_treeView->Delete(dragItemId);
|
||||
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) { // Bookmark -> Group Item
|
||||
} else if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) { // Bookmark -> Group Item
|
||||
doMoveBookmark(dragItem->bookmarkEnt, tvi->groupName);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
class TreeViewItem : public wxTreeItemData {
|
||||
public:
|
||||
enum TreeViewItemType {
|
||||
enum class Type {
|
||||
TREEVIEW_ITEM_TYPE_GROUP,
|
||||
TREEVIEW_ITEM_TYPE_ACTIVE,
|
||||
TREEVIEW_ITEM_TYPE_RECENT,
|
||||
@ -34,9 +34,9 @@ public:
|
||||
groupName = src.groupName;
|
||||
};
|
||||
|
||||
~TreeViewItem() override = default;;
|
||||
~TreeViewItem() override = default;
|
||||
|
||||
TreeViewItemType type;
|
||||
TreeViewItem::Type type;
|
||||
|
||||
BookmarkEntryPtr bookmarkEnt;
|
||||
BookmarkRangeEntryPtr rangeEnt;
|
||||
|
@ -54,7 +54,7 @@ wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR:
|
||||
case SoapySDR::ArgInfo::INT:
|
||||
try {
|
||||
intVal = std::stoi(arg.value);
|
||||
} catch (const std::invalid_argument &e) {
|
||||
} catch (const std::invalid_argument &) {
|
||||
intVal = 0;
|
||||
}
|
||||
prop = pg->Append( new wxIntProperty(arg.name, wxPG_LABEL, intVal) );
|
||||
@ -66,7 +66,7 @@ wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR:
|
||||
case SoapySDR::ArgInfo::FLOAT:
|
||||
try {
|
||||
floatVal = std::stod(arg.value);
|
||||
} catch (const std::invalid_argument &e) {
|
||||
} catch (const std::invalid_argument &) {
|
||||
floatVal = 0;
|
||||
}
|
||||
prop = pg->Append( new wxFloatProperty(arg.name, wxPG_LABEL, floatVal) );
|
||||
@ -555,7 +555,7 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
|
||||
if (dev->isActive() || !wxGetApp().getDevice()) {
|
||||
wxGetApp().setSampleRate(srate);
|
||||
}
|
||||
} catch (const std::invalid_argument &e) {
|
||||
} catch (const std::invalid_argument &) {
|
||||
// nop
|
||||
}
|
||||
} else if (dev && event.GetProperty() == devSettings["antenna"]) {
|
||||
@ -570,7 +570,7 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
|
||||
wxGetApp().setAntennaName(strAntennaName);
|
||||
}
|
||||
}
|
||||
catch (const std::invalid_argument &e) {
|
||||
catch (const std::invalid_argument &) {
|
||||
// nop
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
std::string units;
|
||||
|
||||
//! The data type of the argument (required)
|
||||
enum Type { BOOL, INT, FLOAT, STRING, PATH_DIR, PATH_FILE, COLOR } type;
|
||||
enum class Type { BOOL, INT, FLOAT, STRING, PATH_DIR, PATH_FILE, COLOR } type;
|
||||
|
||||
/*!
|
||||
* The range of possible numeric values (optional)
|
||||
|
@ -40,7 +40,7 @@ ModemArgInfoList ModemCW::getSettings() {
|
||||
offsetArg.value = std::to_string(mBeepFrequency);
|
||||
offsetArg.units = "Hz";
|
||||
offsetArg.description = "Frequency Offset / Beep frequency (200-1000Hz)";
|
||||
offsetArg.type = ModemArgInfo::FLOAT;
|
||||
offsetArg.type = ModemArgInfo::Type::FLOAT;
|
||||
offsetArg.range = ModemRange(200.0, 1000.0);
|
||||
args.push_back(offsetArg);
|
||||
|
||||
@ -48,7 +48,7 @@ ModemArgInfoList ModemCW::getSettings() {
|
||||
autoGain.key = "auto";
|
||||
autoGain.name = "Auto Gain";
|
||||
autoGain.value = "on";
|
||||
autoGain.type = ModemArgInfo::STRING;
|
||||
autoGain.type = ModemArgInfo::Type::STRING;
|
||||
std::vector<std::string> autoOpts;
|
||||
autoOpts.push_back("on");
|
||||
autoOpts.push_back("off");
|
||||
@ -63,7 +63,7 @@ ModemArgInfoList ModemCW::getSettings() {
|
||||
gain.units = "dB";
|
||||
gain.description = "Gain Setting (0-40dB)";
|
||||
gain.range = ModemRange(0.0, 40.0);
|
||||
gain.type = ModemArgInfo::FLOAT;
|
||||
gain.type = ModemArgInfo::Type::FLOAT;
|
||||
args.push_back(gain);
|
||||
return args;
|
||||
}
|
||||
@ -101,7 +101,7 @@ std::string ModemCW::getName() {
|
||||
int ModemCW::checkSampleRate(long long srate, int /* arate */) {
|
||||
if (srate < MIN_BANDWIDTH)
|
||||
return MIN_BANDWIDTH;
|
||||
return srate;
|
||||
return (int)srate;
|
||||
}
|
||||
|
||||
int ModemCW::getDefaultSampleRate() {
|
||||
@ -122,7 +122,7 @@ ModemKit *ModemCW::buildKit(long long sampleRate, int audioSampleRate) {
|
||||
kit->sampleRate = sampleRate;
|
||||
kit->audioSampleRate = audioSampleRate;
|
||||
kit->audioResampleRatio = ratio;
|
||||
kit->mInputResampler = msresamp_cccf_create(ratio, As);
|
||||
kit->mInputResampler = msresamp_cccf_create((float)ratio, As);
|
||||
return kit;
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ void ModemCW::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *au
|
||||
|
||||
// Interpolate IQ samples to full audio band. We need to be able to
|
||||
// sample at 2 times the desired beep frequency.
|
||||
msresamp_cccf_execute(cwkit->mInputResampler, &input->data[0], bufSize, &mInput[0], &outSize);
|
||||
msresamp_cccf_execute(cwkit->mInputResampler, &input->data[0], (unsigned int)bufSize, &mInput[0], &outSize);
|
||||
|
||||
// Make the shoe fit.
|
||||
if (demodOutputData.size() != outSize) {
|
||||
@ -174,7 +174,7 @@ void ModemCW::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *au
|
||||
}
|
||||
|
||||
// Set the LO to the desired beep frequency.
|
||||
nco_crcf_set_frequency(mLO, 2.0 * M_PI * mBeepFrequency / kit->audioSampleRate);
|
||||
nco_crcf_set_frequency(mLO, 2.0f * (float)M_PI * mBeepFrequency / kit->audioSampleRate);
|
||||
|
||||
// Mix up from base band by beep frequency. Extract real part
|
||||
for (unsigned int i = 0; i < outSize; i++) {
|
||||
@ -195,12 +195,12 @@ void ModemCW::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *au
|
||||
}
|
||||
}
|
||||
|
||||
mGain = 10.0 * std::log10(0.5f / aOutputCeilMAA);
|
||||
mGain = 10.0f * std::log10(0.5f / aOutputCeilMAA);
|
||||
}
|
||||
|
||||
// Apply gain to demodulated output data
|
||||
for (size_t i = 0; i < outSize; i++) {
|
||||
demodOutputData[i] *= std::pow(10.0, mGain / 10.0);
|
||||
demodOutputData[i] *= std::pow(10.0f, mGain / 10.0f);
|
||||
}
|
||||
|
||||
audioOut->channels = 1;
|
||||
|
@ -10,7 +10,7 @@ class ModemKitCW : public ModemKitAnalog {
|
||||
public:
|
||||
ModemKitCW() : ModemKitAnalog() {
|
||||
};
|
||||
msresamp_cccf mInputResampler;
|
||||
msresamp_cccf mInputResampler{};
|
||||
};
|
||||
|
||||
class ModemCW : public ModemAnalog {
|
||||
|
@ -47,7 +47,7 @@ ModemArgInfoList ModemFMStereo::getSettings() {
|
||||
demphArg.value = std::to_string(_demph);
|
||||
demphArg.description = "FM Stereo De-Emphasis, typically 75us in US/Canada, 50us elsewhere.";
|
||||
|
||||
demphArg.type = ModemArgInfo::STRING;
|
||||
demphArg.type = ModemArgInfo::Type::STRING;
|
||||
|
||||
std::vector<std::string> demphOptNames;
|
||||
demphOptNames.push_back("None");
|
||||
|
@ -6,7 +6,8 @@
|
||||
|
||||
class ModemKitFMStereo: public ModemKit {
|
||||
public:
|
||||
ModemKitFMStereo() : audioResampler(nullptr), stereoResampler(nullptr), audioResampleRatio(0), firStereoLeft(nullptr), firStereoRight(nullptr), iirStereoPilot(nullptr) {
|
||||
ModemKitFMStereo() : audioResampler(nullptr), stereoResampler(nullptr), audioResampleRatio(0), firStereoLeft(nullptr), firStereoRight(nullptr), iirStereoPilot(nullptr),
|
||||
demph(0), iirDemphR(nullptr), iirDemphL(nullptr), firStereoR2C(nullptr), firStereoC2R(nullptr), stereoPilot(nullptr) {
|
||||
}
|
||||
|
||||
msresamp_rrrf audioResampler;
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
}
|
||||
|
||||
SDRThreadIQData(long long bandwidth, long long frequency, std::vector<signed char> * /* data */) :
|
||||
frequency(frequency), sampleRate(bandwidth) {
|
||||
frequency(frequency), sampleRate(bandwidth), dcCorrected(false), numChannels(0) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ using namespace std;
|
||||
|
||||
#define MAX_STR_SIZE (1024)
|
||||
|
||||
DataElement::DataElement() : data_type(DATA_NULL) {
|
||||
DataElement::DataElement() : data_type(DataElement::Type::DATA_NULL) {
|
||||
//
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ char * DataElement::getDataPointer() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DataElement::DataElementTypeEnum DataElement::getDataType() {
|
||||
DataElement::Type DataElement::getDataType() {
|
||||
return data_type;
|
||||
}
|
||||
|
||||
@ -68,13 +68,13 @@ size_t DataElement::getDataSize() {
|
||||
|
||||
|
||||
void DataElement::set(const char *data_in, long size_in) {
|
||||
data_type = DATA_VOID;
|
||||
data_type = DataElement::Type::DATA_VOID;
|
||||
|
||||
data_val.assign(data_in, data_in + size_in);
|
||||
}
|
||||
|
||||
void DataElement::set(const char *data_in) {
|
||||
data_type = DATA_STRING;
|
||||
data_type = DataElement::Type::DATA_STRING;
|
||||
|
||||
size_t clamped_size = ::strnlen(data_in, MAX_STR_SIZE);
|
||||
|
||||
@ -96,7 +96,7 @@ void DataElement::set(const std::set<string> &strset_in) {
|
||||
|
||||
void DataElement::get(DataElement::DataElementBuffer& data_in) {
|
||||
|
||||
if (data_type != DATA_VOID) {
|
||||
if (data_type != DataElement::Type::DATA_VOID) {
|
||||
throw(DataTypeMismatchException("Type mismatch, not a VOID*"));
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ void DataElement::get(DataElement::DataElementBuffer& data_in) {
|
||||
|
||||
void DataElement::get(std::set<string> &strset_out) {
|
||||
|
||||
if (data_type != DATA_STR_VECTOR)
|
||||
if (data_type != DataElement::Type::DATA_STR_VECTOR)
|
||||
throw(DataTypeMismatchException("Type mismatch, not a STRING VECTOR/SET"));
|
||||
|
||||
std::vector<string> tmp_vect;
|
||||
@ -121,33 +121,33 @@ void DataElement::get(std::set<string> &strset_out) {
|
||||
}
|
||||
|
||||
std::string DataElement::toString() {
|
||||
int dataType = getDataType();
|
||||
DataElement::Type dataType = getDataType();
|
||||
std::string strValue;
|
||||
|
||||
try {
|
||||
if (dataType == DATA_STRING) {
|
||||
if (dataType == DataElement::Type::DATA_STRING) {
|
||||
get(strValue);
|
||||
} else if (dataType == DATA_INT || dataType == DATA_LONG || dataType == DATA_LONGLONG) {
|
||||
} else if (dataType == DataElement::Type::DATA_INT || dataType == DataElement::Type::DATA_LONG || dataType == DataElement::Type::DATA_LONGLONG) {
|
||||
long long intSettingValue;
|
||||
get(intSettingValue);
|
||||
strValue = std::to_string(intSettingValue);
|
||||
} else if (dataType == DATA_FLOAT || dataType == DATA_DOUBLE) {
|
||||
} else if (dataType == DataElement::Type::DATA_FLOAT || dataType == DataElement::Type::DATA_DOUBLE) {
|
||||
double floatSettingValue;
|
||||
get(floatSettingValue);
|
||||
strValue = std::to_string(floatSettingValue);
|
||||
} else if (dataType == DATA_NULL) {
|
||||
} else if (dataType == DataElement::Type::DATA_NULL) {
|
||||
strValue = "";
|
||||
} else if (dataType == DATA_WSTRING) {
|
||||
} else if (dataType == DataElement::Type::DATA_WSTRING) {
|
||||
std::wstring wstr;
|
||||
get(wstr);
|
||||
//TODO: code below returns a forced cast in (char*) beware...
|
||||
strValue = *wstr.c_str();
|
||||
}
|
||||
else {
|
||||
std::cout << "Unhandled DataElement toString for type: " << dataType << std::endl;
|
||||
std::cout << "Unhandled DataElement toString for type: " << (int)dataType << std::endl;
|
||||
}
|
||||
} catch (const DataTypeMismatchException &e) {
|
||||
std::cout << "toString() DataTypeMismatch: " << dataType << std::endl;
|
||||
} catch (const DataTypeMismatchException &) {
|
||||
std::cout << "toString() DataTypeMismatch: " << (int)dataType << std::endl;
|
||||
}
|
||||
|
||||
return strValue;
|
||||
@ -659,9 +659,9 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
long long tmp_llong;
|
||||
|
||||
switch (child->element()->getDataType()) {
|
||||
case DataElement::DATA_NULL:
|
||||
case DataElement::Type::DATA_NULL:
|
||||
break;
|
||||
case DataElement::DATA_VOID:
|
||||
case DataElement::Type::DATA_VOID:
|
||||
child->element()->get(tmp_pstr_as_string); // returned VOID as string
|
||||
// following badgerfish xml->json and xml->ruby convention for attributes..
|
||||
if (nodeName.substr(0, 1) == string("@")) {
|
||||
@ -673,7 +673,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
}
|
||||
break;
|
||||
case DataElement::DATA_CHAR:
|
||||
case DataElement::Type::DATA_CHAR:
|
||||
child->element()->get(tmp_char);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -683,7 +683,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
text = new TiXmlText(tmp_stream.str().c_str());
|
||||
element->LinkEndChild(text);
|
||||
break;
|
||||
case DataElement::DATA_UCHAR:
|
||||
case DataElement::Type::DATA_UCHAR:
|
||||
child->element()->get(tmp_uchar);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -693,7 +693,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
text = new TiXmlText(tmp_stream.str().c_str());
|
||||
element->LinkEndChild(text);
|
||||
break;
|
||||
case DataElement::DATA_INT:
|
||||
case DataElement::Type::DATA_INT:
|
||||
child->element()->get(tmp_int);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -703,7 +703,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
text = new TiXmlText(tmp_stream.str().c_str());
|
||||
element->LinkEndChild(text);
|
||||
break;
|
||||
case DataElement::DATA_UINT:
|
||||
case DataElement::Type::DATA_UINT:
|
||||
child->element()->get(tmp_uint);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -713,7 +713,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
text = new TiXmlText(tmp_stream.str().c_str());
|
||||
element->LinkEndChild(text);
|
||||
break;
|
||||
case DataElement::DATA_LONG:
|
||||
case DataElement::Type::DATA_LONG:
|
||||
child->element()->get(tmp_long);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -723,7 +723,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
text = new TiXmlText(tmp_stream.str().c_str());
|
||||
element->LinkEndChild(text);
|
||||
break;
|
||||
case DataElement::DATA_ULONG:
|
||||
case DataElement::Type::DATA_ULONG:
|
||||
child->element()->get(tmp_ulong);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -733,7 +733,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
text = new TiXmlText(tmp_stream.str().c_str());
|
||||
element->LinkEndChild(text);
|
||||
break;
|
||||
case DataElement::DATA_LONGLONG:
|
||||
case DataElement::Type::DATA_LONGLONG:
|
||||
child->element()->get(tmp_llong);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -743,7 +743,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
text = new TiXmlText(tmp_stream.str().c_str());
|
||||
element->LinkEndChild(text);
|
||||
break;
|
||||
case DataElement::DATA_FLOAT:
|
||||
case DataElement::Type::DATA_FLOAT:
|
||||
child->element()->get(tmp_float);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -753,7 +753,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
text = new TiXmlText(tmp_stream.str().c_str());
|
||||
element->LinkEndChild(text);
|
||||
break;
|
||||
case DataElement::DATA_DOUBLE:
|
||||
case DataElement::Type::DATA_DOUBLE:
|
||||
child->element()->get(tmp_double);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -763,7 +763,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
text = new TiXmlText(tmp_stream.str().c_str());
|
||||
element->LinkEndChild(text);
|
||||
break;
|
||||
case DataElement::DATA_STRING:
|
||||
case DataElement::Type::DATA_STRING:
|
||||
child->element()->get(tmp);
|
||||
if (nodeName.substr(0, 1) == string("@")) {
|
||||
elxml->SetAttribute(nodeName.substr(1).c_str(), tmp.c_str());
|
||||
@ -774,7 +774,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
}
|
||||
break;
|
||||
case DataElement::DATA_WSTRING:
|
||||
case DataElement::Type::DATA_WSTRING:
|
||||
child->element()->get(wtmp);
|
||||
tmp = wsEncode(wtmp);
|
||||
if (nodeName.substr(0, 1) == string("@")) {
|
||||
@ -786,7 +786,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
}
|
||||
break;
|
||||
case DataElement::DATA_STR_VECTOR:
|
||||
case DataElement::Type::DATA_STR_VECTOR:
|
||||
child->element()->get(tmp_stringvect);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -800,7 +800,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
|
||||
tmp_stringvect.clear();
|
||||
break;
|
||||
case DataElement::DATA_CHAR_VECTOR:
|
||||
case DataElement::Type::DATA_CHAR_VECTOR:
|
||||
child->element()->get(tmp_charvect);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -815,7 +815,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
tmp_charvect.clear();
|
||||
break;
|
||||
case DataElement::DATA_UCHAR_VECTOR:
|
||||
case DataElement::Type::DATA_UCHAR_VECTOR:
|
||||
child->element()->get(tmp_ucharvect);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -830,7 +830,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
tmp_ucharvect.clear();
|
||||
break;
|
||||
case DataElement::DATA_INT_VECTOR:
|
||||
case DataElement::Type::DATA_INT_VECTOR:
|
||||
child->element()->get(tmp_intvect);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -845,7 +845,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
tmp_intvect.clear();
|
||||
break;
|
||||
case DataElement::DATA_UINT_VECTOR:
|
||||
case DataElement::Type::DATA_UINT_VECTOR:
|
||||
child->element()->get(tmp_uintvect);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -860,7 +860,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
tmp_uintvect.clear();
|
||||
break;
|
||||
case DataElement::DATA_LONG_VECTOR:
|
||||
case DataElement::Type::DATA_LONG_VECTOR:
|
||||
child->element()->get(tmp_longvect);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -875,7 +875,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
tmp_longvect.clear();
|
||||
break;
|
||||
case DataElement::DATA_ULONG_VECTOR:
|
||||
case DataElement::Type::DATA_ULONG_VECTOR:
|
||||
child->element()->get(tmp_ulongvect);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -890,7 +890,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
tmp_ulongvect.clear();
|
||||
break;
|
||||
case DataElement::DATA_LONGLONG_VECTOR:
|
||||
case DataElement::Type::DATA_LONGLONG_VECTOR:
|
||||
child->element()->get(tmp_llongvect);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -905,7 +905,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
tmp_llongvect.clear();
|
||||
break;
|
||||
case DataElement::DATA_FLOAT_VECTOR:
|
||||
case DataElement::Type::DATA_FLOAT_VECTOR:
|
||||
child->element()->get(tmp_floatvect);
|
||||
|
||||
tmp_stream.str("");
|
||||
@ -920,7 +920,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
element->LinkEndChild(text);
|
||||
tmp_floatvect.clear();
|
||||
break;
|
||||
case DataElement::DATA_DOUBLE_VECTOR:
|
||||
case DataElement::Type::DATA_DOUBLE_VECTOR:
|
||||
child->element()->get(tmp_doublevect);
|
||||
|
||||
tmp_stream.str("");
|
||||
|
@ -78,7 +78,7 @@ class DataElement
|
||||
{
|
||||
public :
|
||||
|
||||
enum DataElementTypeEnum {
|
||||
enum class Type {
|
||||
DATA_NULL,
|
||||
DATA_CHAR,
|
||||
DATA_UCHAR,
|
||||
@ -109,7 +109,7 @@ public :
|
||||
typedef vector< DataElementBuffer > DataElementBufferVector;
|
||||
|
||||
private:
|
||||
DataElementTypeEnum data_type;
|
||||
Type data_type;
|
||||
|
||||
// raw buffer holding data_type element in bytes form.
|
||||
DataElementBuffer data_val;
|
||||
@ -123,66 +123,66 @@ private:
|
||||
|
||||
//if the exact right determineScalarDataType specialization was not used, throw exception at runtime.
|
||||
template<typename U, typename Dummy = int >
|
||||
DataElementTypeEnum determineScalarDataType(const U& /* type_in */) { throw DataTypeMismatchException("determineScalarDataType(U) usage with unsupported type !"); }
|
||||
Type determineScalarDataType(const U& /* type_in */) { throw DataTypeMismatchException("determineScalarDataType(U) usage with unsupported type !"); }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineScalarDataType(const char& /* type_in */) { return DATA_CHAR; }
|
||||
Type determineScalarDataType(const char& /* type_in */) { return DataElement::Type::DATA_CHAR; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineScalarDataType(const unsigned char& /* type_in */) { return DATA_UCHAR; }
|
||||
Type determineScalarDataType(const unsigned char& /* type_in */) { return DataElement::Type::DATA_UCHAR; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineScalarDataType(const int& /* type_in */) { return DATA_INT; }
|
||||
Type determineScalarDataType(const int& /* type_in */) { return DataElement::Type::DATA_INT; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineScalarDataType(const unsigned int& /* type_in */) { return DATA_UINT; }
|
||||
Type determineScalarDataType(const unsigned int& /* type_in */) { return DataElement::Type::DATA_UINT; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineScalarDataType(const long& /* type_in */) { return DATA_LONG; }
|
||||
Type determineScalarDataType(const long& /* type_in */) { return DataElement::Type::DATA_LONG; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineScalarDataType(const unsigned long& /* type_in */) { return DATA_ULONG; }
|
||||
Type determineScalarDataType(const unsigned long& /* type_in */) { return DataElement::Type::DATA_ULONG; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineScalarDataType(const long long& /* type_in */) { return DATA_LONGLONG; }
|
||||
Type determineScalarDataType(const long long& /* type_in */) { return DataElement::Type::DATA_LONGLONG; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineScalarDataType(const float& /* type_in */) { return DATA_FLOAT; }
|
||||
Type determineScalarDataType(const float& /* type_in */) { return DataElement::Type::DATA_FLOAT; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineScalarDataType(const double& /* type_in */) { return DATA_DOUBLE; }
|
||||
Type determineScalarDataType(const double& /* type_in */) { return DataElement::Type::DATA_DOUBLE; }
|
||||
|
||||
//vector versions:
|
||||
//if the exact right determineVectorDataType specialization was not used, throw exception at runtime.
|
||||
template<typename V, typename Dummy = int >
|
||||
DataElementTypeEnum determineVectorDataType(const vector<V>& /* type_in */) { throw DataTypeMismatchException("determineVectorDataType(V) usage with unsupported type !"); }
|
||||
Type determineVectorDataType(const vector<V>& /* type_in */) { throw DataTypeMismatchException("determineVectorDataType(V) usage with unsupported type !"); }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineVectorDataType(const vector<char>& /* type_in */) { return DATA_CHAR_VECTOR; }
|
||||
Type determineVectorDataType(const vector<char>& /* type_in */) { return DataElement::Type::DATA_CHAR_VECTOR; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineVectorDataType(const vector<unsigned char>& /* type_in */) { return DATA_UCHAR_VECTOR; }
|
||||
Type determineVectorDataType(const vector<unsigned char>& /* type_in */) { return DataElement::Type::DATA_UCHAR_VECTOR; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineVectorDataType(const vector<int>& /* type_in */) { return DATA_INT_VECTOR; }
|
||||
Type determineVectorDataType(const vector<int>& /* type_in */) { return DataElement::Type::DATA_INT_VECTOR; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineVectorDataType(const vector<unsigned int>& /* type_in */) { return DATA_UINT_VECTOR; }
|
||||
Type determineVectorDataType(const vector<unsigned int>& /* type_in */) { return DataElement::Type::DATA_UINT_VECTOR; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineVectorDataType(const vector<long>& /* type_in */) { return DATA_LONG_VECTOR; }
|
||||
Type determineVectorDataType(const vector<long>& /* type_in */) { return DataElement::Type::DATA_LONG_VECTOR; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineVectorDataType(const vector<unsigned long>& /* type_in */) { return DATA_ULONG_VECTOR; }
|
||||
Type determineVectorDataType(const vector<unsigned long>& /* type_in */) { return DataElement::Type::DATA_ULONG_VECTOR; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineVectorDataType(const vector<long long>& /* type_in */) { return DATA_LONGLONG_VECTOR; }
|
||||
Type determineVectorDataType(const vector<long long>& /* type_in */) { return DataElement::Type::DATA_LONGLONG_VECTOR; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineVectorDataType(const vector<float>& /* type_in */) { return DATA_FLOAT_VECTOR; }
|
||||
Type determineVectorDataType(const vector<float>& /* type_in */) { return DataElement::Type::DATA_FLOAT_VECTOR; }
|
||||
|
||||
template< typename Dummy = int >
|
||||
DataElementTypeEnum determineVectorDataType(const vector<double>& /* type_in */) { return DATA_DOUBLE_VECTOR; }
|
||||
Type determineVectorDataType(const vector<double>& /* type_in */) { return DataElement::Type::DATA_DOUBLE_VECTOR; }
|
||||
|
||||
public:
|
||||
|
||||
@ -190,7 +190,7 @@ public:
|
||||
DataElement(DataElement &cloneFrom);
|
||||
~DataElement();
|
||||
|
||||
DataElementTypeEnum getDataType();
|
||||
Type getDataType();
|
||||
char *getDataPointer();
|
||||
size_t getDataSize();
|
||||
|
||||
@ -239,7 +239,7 @@ public:
|
||||
template< typename Dummy = int >
|
||||
void set(const string& str_in) {
|
||||
|
||||
data_type = DATA_STRING;
|
||||
data_type = DataElement::Type::DATA_STRING;
|
||||
|
||||
data_val.assign(str_in.begin(), str_in.end());
|
||||
}
|
||||
@ -248,7 +248,7 @@ public:
|
||||
template< typename Dummy = int >
|
||||
void set(const wstring& wstr_in) {
|
||||
|
||||
data_type = DATA_WSTRING;
|
||||
data_type = DataElement::Type::DATA_WSTRING;
|
||||
|
||||
//wchar_t is tricky, the terminating zero is actually a (wchar_t)0 !
|
||||
//wchar_t is typically 16 bits on windows, and 32 bits on Unix, so use sizeof(wchar_t) everywhere.
|
||||
@ -269,7 +269,7 @@ public:
|
||||
template< typename Dummy = int >
|
||||
void set(const vector<string>& vector_str_in) {
|
||||
|
||||
data_type = DATA_STR_VECTOR;
|
||||
data_type = DataElement::Type::DATA_STR_VECTOR;
|
||||
|
||||
data_val_vector.clear();
|
||||
|
||||
@ -299,43 +299,43 @@ public:
|
||||
throw DataException("Cannot get() the scalar, DataElement is empty !");
|
||||
}
|
||||
|
||||
DataElementTypeEnum storageType = getDataType();
|
||||
DataElement::Type storageType = getDataType();
|
||||
|
||||
//TODO: smarter way with templates ?
|
||||
if (storageType == DATA_CHAR) {
|
||||
if (storageType == DataElement::Type::DATA_CHAR) {
|
||||
char* storage_ptr = reinterpret_cast<char*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
|
||||
} else if (storageType == DATA_UCHAR) {
|
||||
} else if (storageType == DataElement::Type::DATA_UCHAR) {
|
||||
auto* storage_ptr = reinterpret_cast<unsigned char*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_INT) {
|
||||
} else if (storageType == DataElement::Type::DATA_INT) {
|
||||
int* storage_ptr = reinterpret_cast<int*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_UINT) {
|
||||
} else if (storageType == DataElement::Type::DATA_UINT) {
|
||||
auto* storage_ptr = reinterpret_cast<unsigned int*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_LONG) {
|
||||
} else if (storageType == DataElement::Type::DATA_LONG) {
|
||||
long* storage_ptr = reinterpret_cast<long*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_ULONG) {
|
||||
} else if (storageType == DataElement::Type::DATA_ULONG) {
|
||||
auto* storage_ptr = reinterpret_cast<unsigned long*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_LONGLONG) {
|
||||
} else if (storageType == DataElement::Type::DATA_LONGLONG) {
|
||||
auto* storage_ptr = reinterpret_cast<long long*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_FLOAT) {
|
||||
} else if (storageType == DataElement::Type::DATA_FLOAT) {
|
||||
auto* storage_ptr = reinterpret_cast<float*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_DOUBLE) {
|
||||
} else if (storageType == DataElement::Type::DATA_DOUBLE) {
|
||||
auto* storage_ptr = reinterpret_cast<double*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
@ -350,7 +350,7 @@ public:
|
||||
|
||||
DataElementBuffer single_buffer;
|
||||
|
||||
DataElementTypeEnum storageType = getDataType();
|
||||
Type storageType = getDataType();
|
||||
|
||||
for (auto single_storage_element : data_val_vector) {
|
||||
|
||||
@ -361,40 +361,40 @@ public:
|
||||
T scalar_out;
|
||||
|
||||
//TODO: smarter way with templates ?
|
||||
if (storageType == DATA_CHAR_VECTOR) {
|
||||
if (storageType == DataElement::Type::DATA_CHAR_VECTOR) {
|
||||
char* storage_ptr = reinterpret_cast<char*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
|
||||
} else if (storageType == DATA_UCHAR_VECTOR) {
|
||||
} else if (storageType == DataElement::Type::DATA_UCHAR_VECTOR) {
|
||||
auto* storage_ptr = reinterpret_cast<unsigned char*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_INT_VECTOR) {
|
||||
} else if (storageType == DataElement::Type::DATA_INT_VECTOR) {
|
||||
int* storage_ptr = reinterpret_cast<int*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_UINT_VECTOR) {
|
||||
} else if (storageType == DataElement::Type::DATA_UINT_VECTOR) {
|
||||
auto* storage_ptr = reinterpret_cast<unsigned int*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_LONG_VECTOR) {
|
||||
} else if (storageType == DataElement::Type::DATA_LONG_VECTOR) {
|
||||
long* storage_ptr = reinterpret_cast<long*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_ULONG_VECTOR) {
|
||||
} else if (storageType == DataElement::Type::DATA_ULONG_VECTOR) {
|
||||
auto* storage_ptr = reinterpret_cast<unsigned long*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_LONGLONG_VECTOR) {
|
||||
} else if (storageType == DataElement::Type::DATA_LONGLONG_VECTOR) {
|
||||
auto* storage_ptr = reinterpret_cast<long long*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_FLOAT_VECTOR) {
|
||||
} else if (storageType == DataElement::Type::DATA_FLOAT_VECTOR) {
|
||||
auto* storage_ptr = reinterpret_cast<float*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_DOUBLE_VECTOR) {
|
||||
} else if (storageType == DataElement::Type::DATA_DOUBLE_VECTOR) {
|
||||
auto* storage_ptr = reinterpret_cast<double*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
@ -411,13 +411,13 @@ public:
|
||||
//reset
|
||||
str_out.clear();
|
||||
|
||||
if (data_type == DATA_NULL) {
|
||||
if (data_type == DataElement::Type::DATA_NULL) {
|
||||
//it means TinyXML has parsed an empty tag,
|
||||
//so return an empty string.
|
||||
return;
|
||||
}
|
||||
|
||||
if (data_type != DATA_STRING && data_type != DATA_VOID) {
|
||||
if (data_type != DataElement::Type::DATA_STRING && data_type != DataElement::Type::DATA_VOID) {
|
||||
throw(DataTypeMismatchException("Type mismatch, neither a STRING nor a VOID*"));
|
||||
}
|
||||
|
||||
@ -433,13 +433,13 @@ public:
|
||||
//reset
|
||||
wstr_out.clear();
|
||||
|
||||
if (data_type == DATA_NULL) {
|
||||
if (data_type == DataElement::Type::DATA_NULL) {
|
||||
//it means TinyXML has parsed an empty tag,
|
||||
//so return an empty string.
|
||||
return;
|
||||
}
|
||||
|
||||
if (data_type != DATA_WSTRING) {
|
||||
if (data_type != DataElement::Type::DATA_WSTRING) {
|
||||
throw(DataTypeMismatchException("Type mismatch, not a WSTRING"));
|
||||
}
|
||||
|
||||
@ -465,7 +465,7 @@ public:
|
||||
template< typename Dummy = int >
|
||||
void get(vector<string>& vector_str_out) {
|
||||
|
||||
if (data_type != DATA_STR_VECTOR) {
|
||||
if (data_type != DataElement::Type::DATA_STR_VECTOR) {
|
||||
throw(DataTypeMismatchException("Type mismatch, not a STRING VECTOR"));
|
||||
}
|
||||
|
||||
@ -551,7 +551,7 @@ public:
|
||||
void findAll(const char *name_in, vector<DataNode *> &node_list_out);
|
||||
|
||||
explicit operator string () { string s; element()->get(s); return s; }
|
||||
explicit operator const char * () { if (element()->getDataType() == DataElement::DATA_STRING) { return element()->getDataPointer(); } else { return nullptr; } }
|
||||
explicit operator const char * () { if (element()->getDataType() == DataElement::Type::DATA_STRING) { return element()->getDataPointer(); } else { return nullptr; } }
|
||||
explicit operator char () { char v=0; element()->get(v); return v; }
|
||||
explicit operator unsigned char () { unsigned char v=0; element()->get(v); return v; }
|
||||
explicit operator int () { int v=0; element()->get(v); return v; }
|
||||
|
Loading…
Reference in New Issue
Block a user