Finished RigCTL server

This commit is contained in:
Ryzerth
2021-07-18 04:30:55 +02:00
parent 2ddb1b93c4
commit 336d69c043
17 changed files with 522 additions and 69 deletions

View File

@ -187,6 +187,7 @@ int sdrpp_main(int argc, char *argv[]) {
defConfig["moduleInstances"]["Frequency Manager"] = "frequency_manager";
defConfig["moduleInstances"]["Recorder"] = "recorder";
defConfig["moduleInstances"]["Rigctl Server"] = "rigctl_server";
// Themes

View File

@ -2,7 +2,6 @@
namespace sdrpp_credits {
const char* contributors[] = {
"Alexandre Rouma (Author)",
"Aang23",
"Alexsey Shestacov",
"Aosync",

View File

@ -219,4 +219,127 @@ namespace dsp {
stream<int16_t>* _in;
};
class ComplexToInt16C : public generic_block<ComplexToInt16C> {
public:
ComplexToInt16C() {}
ComplexToInt16C(stream<complex_t>* in) { init(in); }
void init(stream<complex_t>* in) {
_in = in;
generic_block<ComplexToInt16C>::registerInput(_in);
generic_block<ComplexToInt16C>::registerOutput(&out);
generic_block<ComplexToInt16C>::_block_init = true;
}
void setInput(stream<complex_t>* in) {
assert(generic_block<ComplexToInt16C>::_block_init);
std::lock_guard<std::mutex> lck(generic_block<ComplexToInt16C>::ctrlMtx);
generic_block<ComplexToInt16C>::tempStop();
generic_block<ComplexToInt16C>::unregisterInput(_in);
_in = in;
generic_block<ComplexToInt16C>::registerInput(_in);
generic_block<ComplexToInt16C>::tempStart();
}
int run() {
int count = _in->read();
if (count < 0) { return -1; }
volk_32f_s32f_convert_16i(out.writeBuf, (float*)_in->readBuf, 32768.0f, count * 2);
_in->flush();
if (!out.swap(count)) { return -1; }
return count;
}
stream<int16_t> out;
private:
stream<complex_t>* _in;
};
class Int16ToFloat : public generic_block<Int16ToFloat> {
public:
Int16ToFloat() {}
Int16ToFloat(stream<int16_t>* in) { init(in); }
void init(stream<int16_t>* in) {
_in = in;
generic_block<Int16ToFloat>::registerInput(_in);
generic_block<Int16ToFloat>::registerOutput(&out);
generic_block<Int16ToFloat>::_block_init = true;
}
void setInput(stream<int16_t>* in) {
assert(generic_block<Int16ToFloat>::_block_init);
std::lock_guard<std::mutex> lck(generic_block<Int16ToFloat>::ctrlMtx);
generic_block<Int16ToFloat>::tempStop();
generic_block<Int16ToFloat>::unregisterInput(_in);
_in = in;
generic_block<Int16ToFloat>::registerInput(_in);
generic_block<Int16ToFloat>::tempStart();
}
int run() {
int count = _in->read();
if (count < 0) { return -1; }
volk_16i_s32f_convert_32f(out.writeBuf, _in->readBuf, 32768.0f, count);
_in->flush();
if (!out.swap(count)) { return -1; }
return count;
}
stream<float> out;
private:
stream<int16_t>* _in;
};
class FloatToInt16 : public generic_block<FloatToInt16> {
public:
FloatToInt16() {}
FloatToInt16(stream<float>* in) { init(in); }
void init(stream<float>* in) {
_in = in;
generic_block<FloatToInt16>::registerInput(_in);
generic_block<FloatToInt16>::registerOutput(&out);
generic_block<FloatToInt16>::_block_init = true;
}
void setInput(stream<float>* in) {
assert(generic_block<FloatToInt16>::_block_init);
std::lock_guard<std::mutex> lck(generic_block<FloatToInt16>::ctrlMtx);
generic_block<FloatToInt16>::tempStop();
generic_block<FloatToInt16>::unregisterInput(_in);
_in = in;
generic_block<FloatToInt16>::registerInput(_in);
generic_block<FloatToInt16>::tempStart();
}
int run() {
int count = _in->read();
if (count < 0) { return -1; }
volk_32f_s32f_convert_16i(out.writeBuf, _in->readBuf, 32768.0f, count);
_in->flush();
if (!out.swap(count)) { return -1; }
return count;
}
stream<int16_t> out;
private:
stream<float>* _in;
};
}

View File

@ -27,7 +27,7 @@ namespace credits {
ImGui::Spacing();
ImGui::Spacing();
ImGui::Text("This software is brought to you by\n\n");
ImGui::Text("This software is brought to you by Alexandre Rouma with the help of\n\n");
ImGui::Columns(3, "CreditColumns", true);
@ -53,7 +53,7 @@ namespace credits {
ImGui::Spacing();
ImGui::Spacing();
ImGui::Spacing();
ImGui::Text("SDR++ v" VERSION_STR);
ImGui::Text("SDR++ v" VERSION_STR " (Built at " __TIME__ ", " __DATE__ ")");
ImVec2 dispSize = ImGui::GetIO().DisplaySize;
ImVec2 winSize = ImGui::GetWindowSize();

View File

@ -87,7 +87,7 @@ void MainWindow::init() {
vfoCreatedHandler.handler = vfoAddedHandler;
vfoCreatedHandler.ctx = this;
sigpath::vfoManager.vfoCreatedEvent.bindHandler(&vfoCreatedHandler);
sigpath::vfoManager.onVfoCreated.bindHandler(&vfoCreatedHandler);
spdlog::info("Loading modules");
@ -211,6 +211,8 @@ void MainWindow::init() {
}
initComplete = true;
onInitComplete.emit(true);
}
void MainWindow::fftHandler(dsp::complex_t* samples, int count, void* ctx) {

View File

@ -34,6 +34,7 @@ public:
bool lockWaterfallControls = false;
Event<bool> onPlayStateChange;
Event<bool> onInitComplete;
private:
void generateFFTWindow(int win, int size);

View File

@ -72,7 +72,7 @@ namespace vfo_color_menu {
}
vfoAddHndl.handler = vfoAddHandler;
sigpath::vfoManager.vfoCreatedEvent.bindHandler(&vfoAddHndl);
sigpath::vfoManager.onVfoCreated.bindHandler(&vfoAddHndl);
core::configManager.release(modified);
}

View File

@ -5,7 +5,10 @@
namespace tuner {
void centerTuning(std::string vfoName, double freq) {
if (vfoName != "") { sigpath::vfoManager.setOffset(vfoName, 0); }
if (vfoName != "") {
if (gui::waterfall.vfos.find(vfoName) == gui::waterfall.vfos.end()) { return; }
sigpath::vfoManager.setOffset(vfoName, 0);
}
double BW = gui::waterfall.getBandwidth();
double viewBW = gui::waterfall.getViewBandwidth();
gui::waterfall.setViewOffset((BW / 2.0) - (viewBW / 2.0));
@ -20,6 +23,7 @@ namespace tuner {
centerTuning(vfoName, freq);
return;
}
if (gui::waterfall.vfos.find(vfoName) == gui::waterfall.vfos.end()) { return; }
double viewBW = gui::waterfall.getViewBandwidth();
double BW = gui::waterfall.getBandwidth();

View File

@ -97,6 +97,7 @@ void ModuleManager::createInstance(std::string name, std::string module) {
inst.module = modules[module];
inst.instance = inst.module.createInstance(name);
instances[name] = inst;
onInstanceCreated.emit(name);
}
void ModuleManager::deleteInstance(std::string name) {
@ -104,9 +105,11 @@ void ModuleManager::deleteInstance(std::string name) {
spdlog::error("Tried to remove non-existant instance '{0}'", name);
return;
}
onInstanceDelete.emit(name);
Instance_t inst = instances[name];
inst.module.deleteInstance(inst.instance);
instances.erase(name);
onInstanceDeleted.emit(name);
}
void ModuleManager::deleteInstance(ModuleManager::Instance* instance) {
@ -137,6 +140,14 @@ bool ModuleManager::instanceEnabled(std::string name) {
return instances[name].instance->isEnabled();
}
std::string ModuleManager::getInstanceModuleName(std::string name) {
if (instances.find(name) == instances.end()) {
spdlog::error("Cannot get module name of'{0}', instance doesn't exist", name);
return false;
}
return std::string(instances[name].module.info->name);
}
int ModuleManager::countModuleInstances(std::string module) {
if (modules.find(module) == modules.end()) {
spdlog::error("Cannot count instances of '{0}', Module doesn't exist", module);

View File

@ -2,6 +2,7 @@
#include <string>
#include <map>
#include <json.hpp>
#include <utils/event.h>
#ifdef _WIN32
#ifdef SDRPP_IS_CORE
@ -83,9 +84,14 @@ public:
void enableInstance(std::string name);
void disableInstance(std::string name);
bool instanceEnabled(std::string name);
std::string getInstanceModuleName(std::string name);
int countModuleInstances(std::string module);
Event<std::string> onInstanceCreated;
Event<std::string> onInstanceDelete;
Event<std::string> onInstanceDeleted;
std::map<std::string, ModuleManager::Module_t> modules;
std::map<std::string, ModuleManager::Instance_t> instances;

View File

@ -92,7 +92,7 @@ VFOManager::VFO* VFOManager::createVFO(std::string name, int reference, double o
}
VFOManager::VFO* vfo = new VFO(name, reference, offset, bandwidth, sampleRate, minBandwidth, maxBandwidth, bandwidthLocked);
vfos[name] = vfo;
vfoCreatedEvent.emit(vfo);
onVfoCreated.emit(vfo);
return vfo;
}
@ -107,9 +107,10 @@ void VFOManager::deleteVFO(VFOManager::VFO* vfo) {
if (name == "") {
return;
}
vfoDeletedEvent.emit(vfo);
onVfoDelete.emit(vfo);
vfos.erase(name);
delete vfo;
onVfoDeleted.emit(name);
}
void VFOManager::setOffset(std::string name, double offset) {

View File

@ -54,8 +54,9 @@ public:
void updateFromWaterfall(ImGui::WaterFall* wtf);
Event<VFOManager::VFO*> vfoCreatedEvent;
Event<VFOManager::VFO*> vfoDeletedEvent;
Event<VFOManager::VFO*> onVfoCreated;
Event<VFOManager::VFO*> onVfoDelete;
Event<std::string> onVfoDeleted;
private:
std::map<std::string, VFO*> vfos;