2021-05-14 19:38:02 +02:00
|
|
|
#include <filesystem>
|
|
|
|
|
#include "processing.h"
|
2022-03-10 19:56:37 +01:00
|
|
|
#include "logger.h"
|
|
|
|
|
#include "core/pipeline.h"
|
|
|
|
|
#include "error.h"
|
2021-05-14 19:38:02 +02:00
|
|
|
|
2022-04-26 15:07:18 +02:00
|
|
|
#include "core/config.h"
|
2022-05-07 18:16:24 +02:00
|
|
|
#include "main_ui.h"
|
2022-04-26 15:07:18 +02:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
namespace satdump
|
2021-05-14 19:38:02 +02:00
|
|
|
{
|
2022-04-26 15:07:18 +02:00
|
|
|
// TMP, MOVE TO HEADER
|
|
|
|
|
extern std::shared_ptr<Application> current_app;
|
|
|
|
|
extern bool in_app;
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
namespace processing
|
2021-08-15 16:47:44 +02:00
|
|
|
{
|
2022-03-10 19:56:37 +01:00
|
|
|
void process(std::string downlink_pipeline,
|
|
|
|
|
std::string input_level,
|
|
|
|
|
std::string input_file,
|
|
|
|
|
std::string output_file,
|
|
|
|
|
nlohmann::json parameters)
|
|
|
|
|
{
|
|
|
|
|
is_processing = true;
|
|
|
|
|
|
|
|
|
|
logger->info("Starting processing pipeline " + downlink_pipeline + "...");
|
|
|
|
|
logger->debug("Input file (" + input_level + ") : " + input_file);
|
|
|
|
|
logger->debug("Output file : " + output_file);
|
2021-05-14 19:38:02 +02:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
if (!std::filesystem::exists(output_file))
|
|
|
|
|
std::filesystem::create_directories(output_file);
|
2021-05-14 19:38:02 +02:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
// Get pipeline
|
|
|
|
|
std::optional<Pipeline> pipeline = getPipelineFromName(downlink_pipeline);
|
2021-05-14 19:38:02 +02:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
if (pipeline.has_value())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2022-03-10 20:50:47 +01:00
|
|
|
pipeline.value().run(input_file, output_file, parameters, input_level, true, ui_call_list, ui_call_list_mutex);
|
2022-03-10 19:56:37 +01:00
|
|
|
}
|
|
|
|
|
catch (std::exception &e)
|
|
|
|
|
{
|
|
|
|
|
logger->error("Fatal error running pipeline : " + std::string(e.what()));
|
|
|
|
|
error::set_error("Pipeline Error", e.what());
|
|
|
|
|
is_processing = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
logger->critical("Pipeline " + downlink_pipeline + " does not exist!");
|
2021-05-14 19:38:02 +02:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
logger->info("Done! Goodbye");
|
2022-04-26 15:07:18 +02:00
|
|
|
|
|
|
|
|
if (config::main_cfg["user_interface"]["open_viewer_post_processing"]["value"].get<bool>())
|
|
|
|
|
{
|
|
|
|
|
if (std::filesystem::exists(output_file + "/dataset.json"))
|
|
|
|
|
{
|
|
|
|
|
logger->info("Opening viewer!");
|
2022-05-07 18:16:24 +02:00
|
|
|
viewer_app->loadDatasetInViewer(output_file + "/dataset.json");
|
2022-04-26 15:07:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
is_processing = false;
|
|
|
|
|
}
|
2021-05-14 19:38:02 +02:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
std::shared_ptr<std::vector<std::shared_ptr<ProcessingModule>>> ui_call_list = std::make_shared<std::vector<std::shared_ptr<ProcessingModule>>>();
|
|
|
|
|
std::shared_ptr<std::mutex> ui_call_list_mutex = std::make_shared<std::mutex>();
|
|
|
|
|
bool is_processing = false;
|
2021-08-15 16:47:44 +02:00
|
|
|
}
|
2021-05-14 19:38:02 +02:00
|
|
|
}
|