kopia lustrzana https://github.com/AlexandreRouma/SDRPlusPlus
				
				
				
			Work on spectran sources
							rodzic
							
								
									f163e926c7
								
							
						
					
					
						commit
						bd854b590e
					
				| 
						 | 
				
			
			@ -40,6 +40,7 @@ option(OPT_BUILD_RTL_SDR_SOURCE "Build RTL-SDR Source Module (Dependencies: libr
 | 
			
		|||
option(OPT_BUILD_RTL_TCP_SOURCE "Build RTL-TCP Source Module (no dependencies required)" ON)
 | 
			
		||||
option(OPT_BUILD_SDRPLAY_SOURCE "Build SDRplay Source Module (Dependencies: libsdrplay)" OFF)
 | 
			
		||||
option(OPT_BUILD_SOAPY_SOURCE "Build SoapySDR Source Module (Dependencies: soapysdr)" ON)
 | 
			
		||||
option(OPT_BUILD_SPECTRAN_SOURCE "Build Spectran Source Module (Dependencies: Aaronia RTSA Suite)" OFF)
 | 
			
		||||
option(OPT_BUILD_SPECTRAN_HTTP_SOURCE "Build Spectran HTTP Source Module (no dependencies required)" ON)
 | 
			
		||||
option(OPT_BUILD_SPYSERVER_SOURCE "Build SpyServer Source Module (no dependencies required)" ON)
 | 
			
		||||
option(OPT_BUILD_PLUTOSDR_SOURCE "Build PlutoSDR Source Module (Dependencies: libiio, libad9361)" ON)
 | 
			
		||||
| 
						 | 
				
			
			@ -130,6 +131,10 @@ if (OPT_BUILD_SOAPY_SOURCE)
 | 
			
		|||
add_subdirectory("source_modules/soapy_source")
 | 
			
		||||
endif (OPT_BUILD_SOAPY_SOURCE)
 | 
			
		||||
 | 
			
		||||
if (OPT_BUILD_SPECTRAN_SOURCE)
 | 
			
		||||
add_subdirectory("source_modules/spectran_source")
 | 
			
		||||
endif (OPT_BUILD_SPECTRAN_SOURCE)
 | 
			
		||||
 | 
			
		||||
if (OPT_BUILD_SPECTRAN_HTTP_SOURCE)
 | 
			
		||||
add_subdirectory("source_modules/spectran_http_source")
 | 
			
		||||
endif (OPT_BUILD_SPECTRAN_HTTP_SOURCE)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,6 +36,7 @@ namespace sdrpp_credits {
 | 
			
		|||
    };
 | 
			
		||||
 | 
			
		||||
    const char* hardwareDonators[] = {
 | 
			
		||||
        "Aaronia AG",
 | 
			
		||||
        "Airspy",
 | 
			
		||||
        "Analog Devices",
 | 
			
		||||
        "CaribouLabs",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -339,6 +339,7 @@ Modules in beta are still included in releases for the most part but not enabled
 | 
			
		|||
| sdrplay_source       | Working    | SDRplay API       | OPT_BUILD_SDRPLAY_SOURCE       | ⛔              | ✅                     | ✅                         |
 | 
			
		||||
| sdrpp_server_source  | Working    | -                 | OPT_BUILD_SDRPP_SERVER_SOURCE  | ✅              | ✅                     | ✅                         |
 | 
			
		||||
| soapy_source         | Working    | soapysdr          | OPT_BUILD_SOAPY_SOURCE         | ✅              | ✅                     | ✅                         |
 | 
			
		||||
| spectran_source      | Unfinished | RTSA Suite        | OPT_BUILD_SPECTRAN_SOURCE      | ⛔              | ⛔                     | ⛔                         |
 | 
			
		||||
| spectran_http_source | Unfinished | -                 | OPT_BUILD_SPECTRAN_HTTP_SOURCE | ✅              | ✅                     | ⛔                         |
 | 
			
		||||
| spyserver_source     | Working    | -                 | OPT_BUILD_SPYSERVER_SOURCE     | ✅              | ✅                     | ✅                         |
 | 
			
		||||
| usrp_source          | Beta       | libuhd            | OPT_BUILD_USRP_SOURCE          | ⛔              | ⛔                     | ⛔                         |
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ public:
 | 
			
		|||
        this->name = name;
 | 
			
		||||
 | 
			
		||||
        strcpy(hostname, "localhost");
 | 
			
		||||
        sampleRate = 5000000.0;
 | 
			
		||||
        sampleRate = 41000000.0;
 | 
			
		||||
 | 
			
		||||
        handler.ctx = this;
 | 
			
		||||
        handler.selectHandler = menuSelected;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,32 @@
 | 
			
		|||
cmake_minimum_required(VERSION 3.13)
 | 
			
		||||
project(spectran_source)
 | 
			
		||||
 | 
			
		||||
file(GLOB SRC "src/*.cpp")
 | 
			
		||||
 | 
			
		||||
add_library(spectran_source SHARED ${SRC})
 | 
			
		||||
target_link_libraries(spectran_source PRIVATE sdrpp_core)
 | 
			
		||||
set_target_properties(spectran_source PROPERTIES PREFIX "")
 | 
			
		||||
 | 
			
		||||
target_include_directories(spectran_source PRIVATE "src/")
 | 
			
		||||
 | 
			
		||||
if (MSVC)
 | 
			
		||||
    target_compile_options(spectran_source PRIVATE /O2 /Ob2 /std:c++17 /EHsc)
 | 
			
		||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
 | 
			
		||||
    target_compile_options(spectran_source PRIVATE -O3 -std=c++17 -Wno-unused-command-line-argument -undefined dynamic_lookup)
 | 
			
		||||
else ()
 | 
			
		||||
    target_compile_options(spectran_source PRIVATE -O3 -std=c++17)
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
if (MSVC)
 | 
			
		||||
    # Lib path
 | 
			
		||||
    target_link_directories(spectran_source PRIVATE "C:/Program Files/Aaronia AG/Aaronia RTSA-Suite PRO/sdk")
 | 
			
		||||
 | 
			
		||||
    target_include_directories(spectran_source PUBLIC "C:/Program Files/Aaronia AG/Aaronia RTSA-Suite PRO/sdk")
 | 
			
		||||
 | 
			
		||||
    target_link_libraries(spectran_source PRIVATE AaroniaRTSAAPI)
 | 
			
		||||
else (MSVC)
 | 
			
		||||
    # TODO
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
# Install directives
 | 
			
		||||
install(TARGETS spectran_source DESTINATION lib/sdrpp/plugins)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,347 @@
 | 
			
		|||
#include <imgui.h>
 | 
			
		||||
#include <spdlog/spdlog.h>
 | 
			
		||||
#include <module.h>
 | 
			
		||||
#include <gui/gui.h>
 | 
			
		||||
#include <signal_path/signal_path.h>
 | 
			
		||||
#include <core.h>
 | 
			
		||||
#include <gui/style.h>
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#include <gui/smgui.h>
 | 
			
		||||
#include <utils/optionlist.h>
 | 
			
		||||
#include <codecvt>
 | 
			
		||||
#include <aaroniartsaapi.h>
 | 
			
		||||
 | 
			
		||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
 | 
			
		||||
 | 
			
		||||
SDRPP_MOD_INFO{
 | 
			
		||||
    /* Name:            */ "spectran_source",
 | 
			
		||||
    /* Description:     */ "Spectran source module for SDR++",
 | 
			
		||||
    /* Author:          */ "Ryzerth",
 | 
			
		||||
    /* Version:         */ 0, 1, 0,
 | 
			
		||||
    /* Max instances    */ 1
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
ConfigManager config;
 | 
			
		||||
 | 
			
		||||
class SpectranSourceModule : public ModuleManager::Instance {
 | 
			
		||||
public:
 | 
			
		||||
    SpectranSourceModule(std::string name) {
 | 
			
		||||
        this->name = name;
 | 
			
		||||
 | 
			
		||||
        if (AARTSAAPI_Init(AARTSAAPI_MEMORY_MEDIUM) != AARTSAAPI_OK) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (AARTSAAPI_Open(&api) != AARTSAAPI_OK) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        sampleRate = 122000000.0/1.0;
 | 
			
		||||
 | 
			
		||||
        handler.ctx = this;
 | 
			
		||||
        handler.selectHandler = menuSelected;
 | 
			
		||||
        handler.deselectHandler = menuDeselected;
 | 
			
		||||
        handler.menuHandler = menuHandler;
 | 
			
		||||
        handler.startHandler = start;
 | 
			
		||||
        handler.stopHandler = stop;
 | 
			
		||||
        handler.tuneHandler = tune;
 | 
			
		||||
        handler.stream = &stream;
 | 
			
		||||
 | 
			
		||||
        refresh();
 | 
			
		||||
 | 
			
		||||
        // Select device from config
 | 
			
		||||
        config.acquire();
 | 
			
		||||
        std::string devSerial = config.conf["device"];
 | 
			
		||||
        config.release();
 | 
			
		||||
        // TODO: Select
 | 
			
		||||
        selectSerial("");
 | 
			
		||||
 | 
			
		||||
        sigpath::sourceManager.registerSource("Spectran", &handler);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~SpectranSourceModule() {
 | 
			
		||||
        stop(this);
 | 
			
		||||
        sigpath::sourceManager.unregisterSource("Spectran");
 | 
			
		||||
        AARTSAAPI_Close(&api);
 | 
			
		||||
        AARTSAAPI_Shutdown();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void postInit() {}
 | 
			
		||||
 | 
			
		||||
    void enable() {
 | 
			
		||||
        enabled = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void disable() {
 | 
			
		||||
        enabled = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool isEnabled() {
 | 
			
		||||
        return enabled;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void refresh() {
 | 
			
		||||
        // Clear device list
 | 
			
		||||
        devList.clear();
 | 
			
		||||
 | 
			
		||||
        // Rescan
 | 
			
		||||
        if (AARTSAAPI_RescanDevices(&api, 2000) != AARTSAAPI_OK) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // List spectran V6s
 | 
			
		||||
        std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
 | 
			
		||||
        AARTSAAPI_DeviceInfo dinfo = { sizeof(AARTSAAPI_DeviceInfo) };
 | 
			
		||||
        for (int i = 0; AARTSAAPI_EnumDevice(&api, L"spectranv6", i, &dinfo) == AARTSAAPI_OK; i++) {
 | 
			
		||||
            if (!dinfo.ready) { continue; }
 | 
			
		||||
            std::string serial = conv.to_bytes(dinfo.serialNumber);
 | 
			
		||||
            devList.define(serial, serial, dinfo.serialNumber);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void selectSerial(std::string serial) {
 | 
			
		||||
        // If no serial is available, deselect
 | 
			
		||||
        if (!devList.size()) {
 | 
			
		||||
            selectedSerial.clear();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // If serial doesn't exist, select first
 | 
			
		||||
        if (!devList.keyExists(serial)) {
 | 
			
		||||
            selectSerial(devList.key(0));
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        selectedSerial = serial;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    std::string getBandwdithScaled(double bw) {
 | 
			
		||||
        char buf[1024];
 | 
			
		||||
        if (bw >= 1000000.0) {
 | 
			
		||||
            sprintf(buf, "%.1lfMHz", bw / 1000000.0);
 | 
			
		||||
        }
 | 
			
		||||
        else if (bw >= 1000.0) {
 | 
			
		||||
            sprintf(buf, "%.1lfKHz", bw / 1000.0);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            sprintf(buf, "%.1lfHz", bw);
 | 
			
		||||
        }
 | 
			
		||||
        return std::string(buf);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static void menuSelected(void* ctx) {
 | 
			
		||||
        SpectranSourceModule* _this = (SpectranSourceModule*)ctx;
 | 
			
		||||
        core::setInputSampleRate(_this->sampleRate);
 | 
			
		||||
        spdlog::info("SpectranSourceModule '{0}': Menu Select!", _this->name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static void menuDeselected(void* ctx) {
 | 
			
		||||
        SpectranSourceModule* _this = (SpectranSourceModule*)ctx;
 | 
			
		||||
        spdlog::info("SpectranSourceModule '{0}': Menu Deselect!", _this->name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static void start(void* ctx) {
 | 
			
		||||
        SpectranSourceModule* _this = (SpectranSourceModule*)ctx;
 | 
			
		||||
        if (_this->running) { return; }
 | 
			
		||||
        if (_this->selectedSerial.empty()) { return; }
 | 
			
		||||
 | 
			
		||||
        if (AARTSAAPI_OpenDevice(&_this->api, &_this->dev, L"spectranv6/raw", _this->devList[_this->devId].c_str()) != AARTSAAPI_OK) {
 | 
			
		||||
            spdlog::error("Failed to open device");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        AARTSAAPI_Config config;
 | 
			
		||||
        AARTSAAPI_ConfigRoot(&_this->dev, &_this->croot);
 | 
			
		||||
 | 
			
		||||
        AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"device/receiverchannel");
 | 
			
		||||
        AARTSAAPI_ConfigSetString(&_this->dev, &config, L"Rx1");
 | 
			
		||||
 | 
			
		||||
        AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"device/outputformat");
 | 
			
		||||
        AARTSAAPI_ConfigSetString(&_this->dev, &config, L"iq");
 | 
			
		||||
 | 
			
		||||
        AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"device/receiverclock");
 | 
			
		||||
        AARTSAAPI_ConfigSetString(&_this->dev, &config, L"122MHz");
 | 
			
		||||
 | 
			
		||||
        AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"main/decimation");
 | 
			
		||||
        AARTSAAPI_ConfigSetString(&_this->dev, &config, L"Full");
 | 
			
		||||
 | 
			
		||||
        AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"main/centerfreq");
 | 
			
		||||
        AARTSAAPI_ConfigSetFloat(&_this->dev, &config, _this->freq);
 | 
			
		||||
 | 
			
		||||
        AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"main/reflevel");
 | 
			
		||||
        AARTSAAPI_ConfigSetFloat(&_this->dev, &config, -20.0);
 | 
			
		||||
 | 
			
		||||
        AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"calibration/rffilter");
 | 
			
		||||
        AARTSAAPI_ConfigSetString(&_this->dev, &config, L"Auto Extended");
 | 
			
		||||
 | 
			
		||||
        _this->updateAmps();
 | 
			
		||||
 | 
			
		||||
        if (AARTSAAPI_ConnectDevice(&_this->dev) != AARTSAAPI_OK) {
 | 
			
		||||
            spdlog::error("Failed to connect device");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (AARTSAAPI_StartDevice(&_this->dev) != AARTSAAPI_OK) {
 | 
			
		||||
            spdlog::error("Failed to start device");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Wait for first packet
 | 
			
		||||
        AARTSAAPI_Packet pkt = { sizeof(AARTSAAPI_Packet) };
 | 
			
		||||
        while (AARTSAAPI_GetPacket(&_this->dev, 0, 0, &pkt) == AARTSAAPI_EMPTY) { Sleep(1); }
 | 
			
		||||
 | 
			
		||||
        _this->workerThread = std::thread(&SpectranSourceModule::worker, _this);
 | 
			
		||||
 | 
			
		||||
        _this->running = true;
 | 
			
		||||
        spdlog::info("SpectranSourceModule '{0}': Start!", _this->name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static void stop(void* ctx) {
 | 
			
		||||
        SpectranSourceModule* _this = (SpectranSourceModule*)ctx;
 | 
			
		||||
        if (!_this->running) { return; }
 | 
			
		||||
        _this->running = false;
 | 
			
		||||
        
 | 
			
		||||
        _this->stream.stopWriter();
 | 
			
		||||
        AARTSAAPI_StopDevice(&_this->dev);
 | 
			
		||||
        AARTSAAPI_DisconnectDevice(&_this->dev);
 | 
			
		||||
        AARTSAAPI_CloseDevice(&_this->api, &_this->dev);
 | 
			
		||||
 | 
			
		||||
        if (_this->workerThread.joinable()) {
 | 
			
		||||
            _this->workerThread.join();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        _this->stream.clearWriteStop();
 | 
			
		||||
 | 
			
		||||
        spdlog::info("SpectranSourceModule '{0}': Stop!", _this->name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static void tune(double freq, void* ctx) {
 | 
			
		||||
        SpectranSourceModule* _this = (SpectranSourceModule*)ctx;
 | 
			
		||||
        if (_this->running) {
 | 
			
		||||
            AARTSAAPI_Config config;
 | 
			
		||||
            AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"main/centerfreq");
 | 
			
		||||
            AARTSAAPI_ConfigSetFloat(&_this->dev, &config, freq);
 | 
			
		||||
        }
 | 
			
		||||
        _this->freq = freq;
 | 
			
		||||
        spdlog::info("SpectranSourceModule '{0}': Tune: {1}!", _this->name, freq);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static void menuHandler(void* ctx) {
 | 
			
		||||
        SpectranSourceModule* _this = (SpectranSourceModule*)ctx;
 | 
			
		||||
 | 
			
		||||
        if (_this->running) { SmGui::BeginDisabled(); }
 | 
			
		||||
 | 
			
		||||
        SmGui::FillWidth();
 | 
			
		||||
        SmGui::ForceSync();
 | 
			
		||||
        if (ImGui::Combo(CONCAT("Refresh##_spectran_dev_", _this->name), &_this->devId, _this->devList.txt)) {
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
        // TODO: SR sel
 | 
			
		||||
 | 
			
		||||
        //SmGui::SameLine();
 | 
			
		||||
        SmGui::FillWidth();
 | 
			
		||||
        SmGui::ForceSync();
 | 
			
		||||
        if (SmGui::Button(CONCAT("Refresh##_spectran_refr_", _this->name))) {
 | 
			
		||||
            _this->refresh();
 | 
			
		||||
            _this->selectSerial(_this->selectedSerial);
 | 
			
		||||
            core::setInputSampleRate(_this->sampleRate);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (_this->running) { SmGui::EndDisabled(); }
 | 
			
		||||
 | 
			
		||||
        if (ImGui::Checkbox(CONCAT("Amp##_spectran_amp_", _this->name), &_this->amp)) {
 | 
			
		||||
            _this->updateAmps();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (ImGui::Checkbox(CONCAT("Preamp##_spectran_preamp_", _this->name), &_this->preamp)) {
 | 
			
		||||
            _this->updateAmps();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // TODO: Device options
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void updateAmps() {
 | 
			
		||||
        AARTSAAPI_Config config;
 | 
			
		||||
        AARTSAAPI_ConfigFind(&dev, &croot, &config, L"calibration/preamp");
 | 
			
		||||
        if (amp && preamp) {
 | 
			
		||||
            AARTSAAPI_ConfigSetString(&dev, &config, L"Both");
 | 
			
		||||
        }
 | 
			
		||||
        else if (amp) {
 | 
			
		||||
            AARTSAAPI_ConfigSetString(&dev, &config, L"Amp");
 | 
			
		||||
        }
 | 
			
		||||
        else if (preamp) {
 | 
			
		||||
            AARTSAAPI_ConfigSetString(&dev, &config, L"Preamp");
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            AARTSAAPI_ConfigSetString(&dev, &config, L"None");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void worker() {
 | 
			
		||||
        AARTSAAPI_Packet pkt = { sizeof(AARTSAAPI_Packet) };
 | 
			
		||||
        AARTSAAPI_Result res;
 | 
			
		||||
 | 
			
		||||
        while (true) {
 | 
			
		||||
            // Get next packet
 | 
			
		||||
            while ((res = AARTSAAPI_GetPacket(&dev, 0, 0, &pkt)) == AARTSAAPI_EMPTY) {
 | 
			
		||||
                std::this_thread::sleep_for(std::chrono::microseconds(100));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // If there was an error, return
 | 
			
		||||
            if (res != AARTSAAPI_OK) { break; }
 | 
			
		||||
 | 
			
		||||
            // Consume packet
 | 
			
		||||
            AARTSAAPI_ConsumePackets(&dev, 0, 1);
 | 
			
		||||
 | 
			
		||||
            // Write data
 | 
			
		||||
            memcpy(stream.writeBuf, pkt.fp32, pkt.num * sizeof(dsp::complex_t));
 | 
			
		||||
            if (!stream.swap(pkt.num)) { break; }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    std::string name;
 | 
			
		||||
    bool enabled = true;
 | 
			
		||||
    dsp::stream<dsp::complex_t> stream;
 | 
			
		||||
    double sampleRate;
 | 
			
		||||
    SourceManager::SourceHandler handler;
 | 
			
		||||
    bool running = false;
 | 
			
		||||
    double freq;
 | 
			
		||||
    
 | 
			
		||||
    std::string selectedSerial;
 | 
			
		||||
    int devId = 0;
 | 
			
		||||
    int srId = 0;
 | 
			
		||||
    bool amp = false;
 | 
			
		||||
    bool preamp = false;
 | 
			
		||||
 | 
			
		||||
    OptionList<std::string, std::wstring> devList;
 | 
			
		||||
 | 
			
		||||
    AARTSAAPI_Handle api;
 | 
			
		||||
    AARTSAAPI_Device dev;
 | 
			
		||||
    AARTSAAPI_Config croot;
 | 
			
		||||
 | 
			
		||||
    std::thread workerThread;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
MOD_EXPORT void _INIT_() {
 | 
			
		||||
    json def = json({});
 | 
			
		||||
    def["devices"] = json({});
 | 
			
		||||
    def["device"] = "";
 | 
			
		||||
    config.setPath(core::args["root"].s() + "/spectran_config.json");
 | 
			
		||||
    config.load(def);
 | 
			
		||||
    config.enableAutoSave();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
 | 
			
		||||
    return new SpectranSourceModule(name);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MOD_EXPORT void _DELETE_INSTANCE_(ModuleManager::Instance* instance) {
 | 
			
		||||
    delete (SpectranSourceModule*)instance;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MOD_EXPORT void _END_() {
 | 
			
		||||
    config.disableAutoSave();
 | 
			
		||||
    config.save();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,251 @@
 | 
			
		|||
root
 | 
			
		||||
    main
 | 
			
		||||
        centerfreq
 | 
			
		||||
        - min:  192500000.000000
 | 
			
		||||
        - max:  6000000000.000000
 | 
			
		||||
        - step: 1000.000000
 | 
			
		||||
        - unit: Frequency
 | 
			
		||||
        decimation
 | 
			
		||||
        -enum: Full;1 / 2;1 / 4;1 / 8;1 / 16;1 / 32;1 / 64;1 / 128;1 / 256;1 / 512
 | 
			
		||||
        reflevel
 | 
			
		||||
        - min:  -20.000000
 | 
			
		||||
        - max:  10.000000
 | 
			
		||||
        - step: 0.500000
 | 
			
		||||
        - unit: dBm
 | 
			
		||||
        transgain
 | 
			
		||||
        - min:  -100.000000
 | 
			
		||||
        - max:  10.000000
 | 
			
		||||
        - step: 0.010000
 | 
			
		||||
        - unit: dB
 | 
			
		||||
    device
 | 
			
		||||
        usbcompression
 | 
			
		||||
        -enum: auto;compressed;raw
 | 
			
		||||
        gaincontrol
 | 
			
		||||
        -enum: manual;peak;power
 | 
			
		||||
        loharmonic
 | 
			
		||||
        -enum: base;third;fifth
 | 
			
		||||
        outputformat
 | 
			
		||||
        -enum: iq;spectra;both;auto
 | 
			
		||||
        lowpower
 | 
			
		||||
        -bool
 | 
			
		||||
        fft0
 | 
			
		||||
            fftmergemode
 | 
			
		||||
            -enum: avg;sum;min;max
 | 
			
		||||
            fftaggregate
 | 
			
		||||
            - min:  1.000000
 | 
			
		||||
            - max:  65535.000000
 | 
			
		||||
            - step: 1.000000
 | 
			
		||||
            - unit:
 | 
			
		||||
            fftsizemode
 | 
			
		||||
            -enum: FFT;Bins;Step Frequency;RBW
 | 
			
		||||
            fftsize
 | 
			
		||||
            - min:  8.000000
 | 
			
		||||
            - max:  8192.000000
 | 
			
		||||
            - step: 1.000000
 | 
			
		||||
            - unit:
 | 
			
		||||
            fftbinsize
 | 
			
		||||
            - min:  32.000000
 | 
			
		||||
            - max:  8192.000000
 | 
			
		||||
            - step: 1.000000
 | 
			
		||||
            - unit:
 | 
			
		||||
            fftstepfreq
 | 
			
		||||
            - min:  1000.000000
 | 
			
		||||
            - max:  100000000.000000
 | 
			
		||||
            - step: 1000.000000
 | 
			
		||||
            - unit: Frequency
 | 
			
		||||
            fftrbwfreq
 | 
			
		||||
            - min:  0.001000
 | 
			
		||||
            - max:  100000000.000000
 | 
			
		||||
            - step: 0.001000
 | 
			
		||||
            - unit: Frequency
 | 
			
		||||
            fftwindow
 | 
			
		||||
            -enum: Hamming;Hann;Uniform;Blackman;Blackman Harris;Blackman Harris 7;Flat Top;Lanczos;Gaussion 0.5;Gaussion 0.4;Gaussian 0.3;Gaussion 0.2;Gaussian 0.1;Kaiser 6;Kaiser 12;Kaiser 18;Kaiser 36;Kaiser 72;Tukey 0.1;Tukey 0.3;Tukey 0.5;Tukey 0.7;Tukey 0.9
 | 
			
		||||
        fft1
 | 
			
		||||
            fftmergemode
 | 
			
		||||
            -enum: avg;sum;min;max
 | 
			
		||||
            fftaggregate
 | 
			
		||||
            - min:  1.000000
 | 
			
		||||
            - max:  65535.000000
 | 
			
		||||
            - step: 1.000000
 | 
			
		||||
            - unit:
 | 
			
		||||
            fftsizemode
 | 
			
		||||
            -enum: FFT;Bins;Step Frequency;RBW
 | 
			
		||||
            fftsize
 | 
			
		||||
            - min:  8.000000
 | 
			
		||||
            - max:  8192.000000
 | 
			
		||||
            - step: 1.000000
 | 
			
		||||
            - unit:
 | 
			
		||||
            fftbinsize
 | 
			
		||||
            - min:  32.000000
 | 
			
		||||
            - max:  8192.000000
 | 
			
		||||
            - step: 1.000000
 | 
			
		||||
            - unit:
 | 
			
		||||
            fftstepfreq
 | 
			
		||||
            - min:  1000.000000
 | 
			
		||||
            - max:  100000000.000000
 | 
			
		||||
            - step: 1000.000000
 | 
			
		||||
            - unit: Frequency
 | 
			
		||||
            fftrbwfreq
 | 
			
		||||
            - min:  0.001000
 | 
			
		||||
            - max:  100000000.000000
 | 
			
		||||
            - step: 0.001000
 | 
			
		||||
            - unit: Frequency
 | 
			
		||||
            fftwindow
 | 
			
		||||
            -enum: Hamming;Hann;Uniform;Blackman;Blackman Harris;Blackman Harris 7;Flat Top;Lanczos;Gaussion 0.5;Gaussion 0.4;Gaussian 0.3;Gaussion 0.2;Gaussian 0.1;Kaiser 6;Kaiser 12;Kaiser 18;Kaiser 36;Kaiser 72;Tukey 0.1;Tukey 0.3;Tukey 0.5;Tukey 0.7;Tukey 0.9
 | 
			
		||||
        receiverclock
 | 
			
		||||
        -enum: 92MHz;122MHz;184MHz;245MHz
 | 
			
		||||
        receiverchannel
 | 
			
		||||
        -enum: Rx1;Rx2;Rx1+Rx2;Rx1/Rx2;Rx Off;auto
 | 
			
		||||
        receiverchannelsel
 | 
			
		||||
        -enum: Rx1;Rx2;Rx2->1;Rx1->2
 | 
			
		||||
        transmittermode
 | 
			
		||||
        -enum: Off;Test;Stream;Reactive;Signal Generator;Pattern Generator
 | 
			
		||||
        transmitterclockvar
 | 
			
		||||
        - min:  0.000001
 | 
			
		||||
        - max:  1.000000
 | 
			
		||||
        - step: 0.000001
 | 
			
		||||
        - unit: Time
 | 
			
		||||
        generator
 | 
			
		||||
            type
 | 
			
		||||
            -enum: Relative Tone;Absolute Tone;Step;Sweep;Full Sweep;Center Sweep;Polytone;Relative Ditone;Absolute Ditone;Noise;Digital Noise;Off
 | 
			
		||||
            startfreq
 | 
			
		||||
            - min:  1000.000000
 | 
			
		||||
            - max:  20000000000.000000
 | 
			
		||||
            - step: 1.000000
 | 
			
		||||
            - unit: Frequency
 | 
			
		||||
            stopfreq
 | 
			
		||||
            - min:  1000.000000
 | 
			
		||||
            - max:  20000000000.000000
 | 
			
		||||
            - step: 1.000000
 | 
			
		||||
            - unit: Frequency
 | 
			
		||||
            stepfreq
 | 
			
		||||
            - min:  1.000000
 | 
			
		||||
            - max:  200000000.000000
 | 
			
		||||
            - step: 1.000000
 | 
			
		||||
            - unit: Frequency
 | 
			
		||||
            offsetfreq
 | 
			
		||||
            - min:  -60000000.000000
 | 
			
		||||
            - max:  60000000.000000
 | 
			
		||||
            - step: 1.000000
 | 
			
		||||
            - unit: Frequency
 | 
			
		||||
            duration
 | 
			
		||||
            - min:  0.000010
 | 
			
		||||
            - max:  3600.000000
 | 
			
		||||
            - step: 0.000010
 | 
			
		||||
            - unit: Time
 | 
			
		||||
            powerramp
 | 
			
		||||
            - min:  -150.000000
 | 
			
		||||
            - max:  150.000000
 | 
			
		||||
            - step: 0.100000
 | 
			
		||||
            - unit: dB
 | 
			
		||||
        sclksource
 | 
			
		||||
        -enum: Consumer;Oscillator;GPS;PPS;10MHz;Oscillator Provider;GPS Provider;PPS Provider
 | 
			
		||||
        triggeredge
 | 
			
		||||
        -enum: Off;High;Low;Rising;Falling;Changing
 | 
			
		||||
        triggerflag
 | 
			
		||||
        -enum: C0;C1;C2;C3
 | 
			
		||||
        gpsmode
 | 
			
		||||
        -enum: Disabled;Location;Time;Location and Time
 | 
			
		||||
        gpsrate
 | 
			
		||||
        - min:  0.100000
 | 
			
		||||
        - max:  5.000000
 | 
			
		||||
        - step: 0.100000
 | 
			
		||||
        - unit: Time
 | 
			
		||||
        tempfancontrol
 | 
			
		||||
        -bool
 | 
			
		||||
        serial
 | 
			
		||||
        -string
 | 
			
		||||
    calibration
 | 
			
		||||
        rffilter
 | 
			
		||||
        -enum: Calibration;Bypass;Auto;Auto Extended;75-145 (50);90-160 (50);110-195 (50);135-205 (50);155-270 (50);155-270 (100);155-280 (100);180-350 (100);230-460 (100);240-545;340-650;440-815;610-1055;850-1370;1162-2060;1850-3010;2800-4610;4400-6100
 | 
			
		||||
        preamp
 | 
			
		||||
        -enum: Disabled;Auto;None;Amp;Preamp;Both
 | 
			
		||||
        rftxfilter
 | 
			
		||||
        -enum: Calibration;Bypass;Auto;Auto Extended;75-145 (50);90-160 (50);110-195 (50);135-205 (50);155-270 (50);155-270 (100);155-280 (100);180-350 (100);230-460 (100);240-545;340-650;440-815;610-1055;850-1370;1162-2060;1850-3010;2800-4610;4400-6100
 | 
			
		||||
        calibrationmode
 | 
			
		||||
        -enum: Off;RX Attenuator;TX Attenuator;Tx No Amplifier;Tx Amplifier;Rx Thermal;Tx Thermal;Rx RTBW;Tx RTBW;Rx Filter;Rx Amplifier;Tx LO Leakage;Clock;Raw;Free
 | 
			
		||||
        txioffset
 | 
			
		||||
        - min:  -0.100000
 | 
			
		||||
        - max:  0.100000
 | 
			
		||||
        - step: 0.000100
 | 
			
		||||
        - unit: Number
 | 
			
		||||
        txqoffset
 | 
			
		||||
        - min:  -0.100000
 | 
			
		||||
        - max:  0.100000
 | 
			
		||||
        - step: 0.000100
 | 
			
		||||
        - unit: Number
 | 
			
		||||
        txexcent
 | 
			
		||||
        - min:  -0.100000
 | 
			
		||||
        - max:  0.100000
 | 
			
		||||
        - step: 0.000010
 | 
			
		||||
        - unit: Percentage
 | 
			
		||||
        txphaseskew
 | 
			
		||||
        - min:  -15.000000
 | 
			
		||||
        - max:  15.000000
 | 
			
		||||
        - step: 0.010000
 | 
			
		||||
        - unit: Degree
 | 
			
		||||
        clockscale
 | 
			
		||||
        - min:  -100.000000
 | 
			
		||||
        - max:  100.000000
 | 
			
		||||
        - step: 0.000001
 | 
			
		||||
        - unit: Frequency
 | 
			
		||||
        clockbygpsupdate
 | 
			
		||||
        -enum: Never;Once;Reset;On Startup;Slow;Fast;Realtime
 | 
			
		||||
        calibrationreload
 | 
			
		||||
        -bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    void dumpConfig(std::wstring serial) {
 | 
			
		||||
        AARTSAAPI_Device dev;
 | 
			
		||||
        if (AARTSAAPI_OpenDevice(&api, &dev, L"spectranv6/raw", serial.c_str()) != AARTSAAPI_OK) {
 | 
			
		||||
            spdlog::error("Could not open device");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        AARTSAAPI_Config root;
 | 
			
		||||
        if (AARTSAAPI_ConfigRoot(&dev, &root) != AARTSAAPI_OK) {
 | 
			
		||||
            spdlog::error("Could not get config root");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Dump configuration recursively
 | 
			
		||||
        dumpConfig(dev, root);
 | 
			
		||||
 | 
			
		||||
        AARTSAAPI_CloseDevice(&api, &dev);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void dumpConfig(AARTSAAPI_Device& dev, AARTSAAPI_Config& conf, int depth = 0) {
 | 
			
		||||
        std::string prefix = "";
 | 
			
		||||
        std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
 | 
			
		||||
        for (int i = 0; i < depth; i++) { prefix += "    "; }
 | 
			
		||||
        AARTSAAPI_ConfigInfo info;
 | 
			
		||||
        AARTSAAPI_ConfigGetInfo(&dev, &conf, &info);
 | 
			
		||||
 | 
			
		||||
        printf("%s%s\n", prefix.c_str(), conv.to_bytes(info.name).c_str());
 | 
			
		||||
 | 
			
		||||
        if (info.type == AARTSAAPI_CONFIG_TYPE_GROUP) {
 | 
			
		||||
            AARTSAAPI_Config item;
 | 
			
		||||
            AARTSAAPI_ConfigFirst(&dev, &conf, &item);
 | 
			
		||||
            do {
 | 
			
		||||
                dumpConfig(dev, item, depth + 1);
 | 
			
		||||
            }
 | 
			
		||||
            while (AARTSAAPI_ConfigNext(&dev, &conf, &item) == AARTSAAPI_OK);
 | 
			
		||||
        }
 | 
			
		||||
        else if (info.type == AARTSAAPI_CONFIG_TYPE_NUMBER) {
 | 
			
		||||
            printf("%s- min:  %lf\n", prefix.c_str(), info.minValue);
 | 
			
		||||
            printf("%s- max:  %lf\n", prefix.c_str(), info.maxValue);
 | 
			
		||||
            printf("%s- step: %lf\n", prefix.c_str(), info.stepValue);
 | 
			
		||||
            printf("%s- unit: %s\n", prefix.c_str(), conv.to_bytes(info.unit).c_str());
 | 
			
		||||
        }
 | 
			
		||||
        else if (info.type == AARTSAAPI_CONFIG_TYPE_BOOL) {
 | 
			
		||||
            printf("%s-bool\n", prefix.c_str());
 | 
			
		||||
        }
 | 
			
		||||
        else if (info.type == AARTSAAPI_CONFIG_TYPE_ENUM) {
 | 
			
		||||
            printf("%s-enum: %s\n", prefix.c_str(), conv.to_bytes(info.options).c_str());
 | 
			
		||||
        }
 | 
			
		||||
        else if (info.type == AARTSAAPI_CONFIG_TYPE_STRING) {
 | 
			
		||||
            printf("%s-string\n", prefix.c_str());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
		Ładowanie…
	
		Reference in New Issue