2021-03-22 22:26:21 +01:00
|
|
|
#include "offline.h"
|
2021-03-22 18:53:09 +01:00
|
|
|
#include "imgui/imgui.h"
|
|
|
|
|
#include "global.h"
|
|
|
|
|
#include "pipeline.h"
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include "logger.h"
|
2021-06-16 13:30:22 +02:00
|
|
|
#ifndef __ANDROID__
|
2021-03-22 18:53:09 +01:00
|
|
|
#include "portable-file-dialogs.h"
|
2021-06-16 13:30:22 +02:00
|
|
|
#endif
|
2021-03-22 18:53:09 +01:00
|
|
|
#include "processing.h"
|
2021-05-05 15:52:12 +02:00
|
|
|
#include "settings.h"
|
2021-03-22 18:53:09 +01:00
|
|
|
|
2021-06-16 13:30:22 +02:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
|
std::string getFilePath();
|
|
|
|
|
std::string getDirPath();
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-03-22 18:53:09 +01:00
|
|
|
void renderOfflineProcessing()
|
|
|
|
|
{
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
{
|
|
|
|
|
std::string names;
|
|
|
|
|
|
2021-05-28 20:43:36 +02:00
|
|
|
for (int i = 0; i < (int)pipeline_categories.size(); i++)
|
2021-03-22 18:53:09 +01:00
|
|
|
{
|
2021-04-02 14:48:28 +02:00
|
|
|
names += pipeline_categories[i] + '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::Text("Category : ");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
|
|
if (ImGui::Combo("##category", &category_id, names.c_str()))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
|
|
std::vector<Pipeline> catPipelines = getPipelinesInCategory(pipeline_categories[category_id]);
|
|
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
{
|
|
|
|
|
std::string names;
|
|
|
|
|
|
2021-05-28 20:43:36 +02:00
|
|
|
for (int i = 0; i < (int)catPipelines.size(); i++)
|
2021-04-02 14:48:28 +02:00
|
|
|
{
|
|
|
|
|
names += catPipelines[i].readable_name + '\0';
|
2021-03-22 18:53:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::Text("Pipeline : ");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
|
|
if (ImGui::Combo("##pipeline", &pipeline_id, names.c_str()))
|
|
|
|
|
{
|
2021-04-02 14:48:28 +02:00
|
|
|
downlink_pipeline = catPipelines[pipeline_id].name;
|
|
|
|
|
std::memcpy(samplerate, std::to_string(catPipelines[pipeline_id].default_samplerate).c_str(), std::to_string(catPipelines[pipeline_id].default_samplerate).length());
|
2021-03-22 18:53:09 +01:00
|
|
|
|
2021-04-02 14:48:28 +02:00
|
|
|
if (catPipelines[pipeline_id].default_baseband_type == "f32")
|
2021-03-22 18:53:09 +01:00
|
|
|
{
|
|
|
|
|
baseband_type_option = 0;
|
|
|
|
|
}
|
2021-04-02 14:48:28 +02:00
|
|
|
else if (catPipelines[pipeline_id].default_baseband_type == "i8")
|
2021-03-22 18:53:09 +01:00
|
|
|
{
|
|
|
|
|
baseband_type_option = 2;
|
|
|
|
|
}
|
2021-04-02 14:48:28 +02:00
|
|
|
else if (catPipelines[pipeline_id].default_baseband_type == "i16")
|
2021-03-22 18:53:09 +01:00
|
|
|
{
|
|
|
|
|
baseband_type_option = 1;
|
|
|
|
|
}
|
2021-04-02 14:48:28 +02:00
|
|
|
else if (catPipelines[pipeline_id].default_baseband_type == "w8")
|
2021-03-22 18:53:09 +01:00
|
|
|
{
|
|
|
|
|
baseband_type_option = 3;
|
|
|
|
|
}
|
2021-04-02 14:48:28 +02:00
|
|
|
baseband_format = catPipelines[pipeline_id].default_baseband_type;
|
2021-03-22 18:53:09 +01:00
|
|
|
|
|
|
|
|
input_level_id = 0;
|
2021-04-02 14:48:28 +02:00
|
|
|
|
|
|
|
|
input_level = catPipelines[pipeline_id].steps[input_level_id].level_name;
|
2021-03-22 18:53:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
{
|
|
|
|
|
ImGui::Text("Input Level : ");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
|
|
// logger->info(names);
|
|
|
|
|
|
|
|
|
|
std::string names; // = "baseband\0";
|
|
|
|
|
|
|
|
|
|
if (pipeline_id != -1)
|
2021-05-28 20:43:36 +02:00
|
|
|
for (int i = 0; i < (int)catPipelines[pipeline_id].steps.size(); i++)
|
2021-03-22 18:53:09 +01:00
|
|
|
{
|
2021-04-02 14:48:28 +02:00
|
|
|
names += catPipelines[pipeline_id].steps[i].level_name + '\0';
|
2021-03-22 18:53:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::Combo("##input_level", &input_level_id, names.c_str()))
|
|
|
|
|
{
|
2021-04-02 14:48:28 +02:00
|
|
|
input_level = catPipelines[pipeline_id].steps[input_level_id].level_name;
|
2021-03-22 18:53:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
{
|
|
|
|
|
ImGui::Text("Input File : ");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
|
|
if (ImGui::Button("Select Input"))
|
|
|
|
|
{
|
|
|
|
|
logger->debug("Opening file dialog");
|
2021-06-16 13:30:22 +02:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
|
input_file = getFilePath();
|
|
|
|
|
#else
|
2021-05-28 20:43:36 +02:00
|
|
|
auto result = pfd::open_file("Open input file", ".", {".*"}, pfd::opt::none);
|
2021-03-22 18:53:09 +01:00
|
|
|
while (result.ready(1000))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result.result().size() > 0)
|
|
|
|
|
input_file = result.result()[0];
|
2021-06-16 13:30:22 +02:00
|
|
|
#endif
|
2021-03-22 18:53:09 +01:00
|
|
|
|
|
|
|
|
logger->debug("Dir " + input_file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
2021-06-16 13:30:22 +02:00
|
|
|
ImGui::Text("%s", input_file.c_str());
|
2021-03-22 18:53:09 +01:00
|
|
|
}
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
{
|
|
|
|
|
ImGui::Text("Output dir : ");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
|
|
if (ImGui::Button("Select Output"))
|
|
|
|
|
{
|
|
|
|
|
logger->debug("Opening file dialog");
|
2021-06-16 13:30:22 +02:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
|
output_file = getDirPath();
|
|
|
|
|
#else
|
2021-03-22 18:53:09 +01:00
|
|
|
auto result = pfd::select_folder("Open output directory", ".");
|
|
|
|
|
while (result.ready(1000))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result.result().size() > 0)
|
|
|
|
|
output_file = result.result();
|
2021-06-16 13:30:22 +02:00
|
|
|
#endif
|
2021-03-22 18:53:09 +01:00
|
|
|
|
|
|
|
|
logger->debug("Dir " + output_file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
2021-06-16 13:30:22 +02:00
|
|
|
ImGui::Text("%s", output_file.c_str());
|
2021-03-22 18:53:09 +01:00
|
|
|
}
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
{
|
|
|
|
|
ImGui::Text("Parameters : ");
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginTable("table1", 2, ImGuiTableFlags_Borders))
|
|
|
|
|
{
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("Samplerate (Hz / SPS)");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
|
ImGui::InputText(" ", samplerate, 100);
|
|
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("Baseband Type");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
|
if (ImGui::Combo("", &baseband_type_option, "f32\0i16\0i8\0w8\0"))
|
|
|
|
|
{
|
|
|
|
|
switch (baseband_type_option)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
baseband_format = "f32";
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
baseband_format = "i16";
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
baseband_format = "i8";
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
baseband_format = "w8";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("DC Block");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
|
ImGui::Checkbox("DC Block", &dc_block);
|
|
|
|
|
|
2021-04-05 17:08:29 +02:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("IQ Swap (baseband file)");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
|
ImGui::Checkbox("IQ Swap", &iq_swap);
|
|
|
|
|
|
2021-03-22 18:53:09 +01:00
|
|
|
ImGui::EndTable();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::Button("Start"))
|
|
|
|
|
{
|
|
|
|
|
logger->debug("Starting...");
|
|
|
|
|
|
2021-05-05 15:52:12 +02:00
|
|
|
// Save settings
|
|
|
|
|
//{
|
|
|
|
|
// settings["offline_pipeline_id"] = pipeline_id;
|
|
|
|
|
// saveSettings();
|
|
|
|
|
//}
|
|
|
|
|
|
2021-03-22 18:53:09 +01:00
|
|
|
if (input_file == "")
|
|
|
|
|
{
|
|
|
|
|
sprintf(error_message, "Please select an input file!");
|
|
|
|
|
}
|
|
|
|
|
else if (output_file == "")
|
|
|
|
|
{
|
|
|
|
|
sprintf(error_message, "Please select an output file!");
|
|
|
|
|
}
|
|
|
|
|
else if (downlink_pipeline == "")
|
|
|
|
|
{
|
|
|
|
|
sprintf(error_message, "Please select a pipeline!");
|
|
|
|
|
}
|
|
|
|
|
else if (input_level == "")
|
|
|
|
|
{
|
|
|
|
|
sprintf(error_message, "Please select an input level!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
parameters.emplace("samplerate", std::string(samplerate));
|
|
|
|
|
|
|
|
|
|
parameters.emplace("baseband_format", baseband_format);
|
|
|
|
|
|
|
|
|
|
parameters.emplace("dc_block", dc_block ? "1" : "0");
|
2021-04-05 17:08:29 +02:00
|
|
|
parameters.emplace("iq_swap", iq_swap ? "1" : "0");
|
2021-03-22 18:53:09 +01:00
|
|
|
|
2021-06-16 13:30:22 +02:00
|
|
|
processThreadPool.push([&](int)
|
|
|
|
|
{ process(downlink_pipeline, input_level, input_file, output_level, output_file, parameters); });
|
2021-03-22 18:53:09 +01:00
|
|
|
//showStartup = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
2021-06-16 13:30:22 +02:00
|
|
|
ImGui::TextColored(ImColor::HSV(0 / 360.0, 1, 1, 1.0), "%s", error_message);
|
2021-03-22 18:53:09 +01:00
|
|
|
}
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
}
|