2024-05-18 19:59:28 +02:00
|
|
|
#define SATDUMP_DLL_EXPORT2 1
|
2021-05-14 19:38:02 +02:00
|
|
|
#include "processing.h"
|
2025-05-19 22:26:32 +02:00
|
|
|
#include "logger.h"
|
|
|
|
|
#include <filesystem>
|
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;
|
|
|
|
|
|
2023-01-16 21:17:54 +01:00
|
|
|
std::mutex processing_mutex;
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
namespace processing
|
2021-08-15 16:47:44 +02:00
|
|
|
{
|
2025-05-19 22:26:32 +02:00
|
|
|
void process(std::string downlink_pipeline, std::string input_level, std::string input_file, std::string output_file, nlohmann::json parameters)
|
2024-07-21 14:58:03 -04:00
|
|
|
{
|
|
|
|
|
// Get pipeline
|
2025-05-31 20:26:47 +02:00
|
|
|
pipeline::Pipeline pipeline = pipeline::getPipelineFromID(downlink_pipeline);
|
|
|
|
|
// if (!pipeline.has_value())
|
|
|
|
|
// {
|
|
|
|
|
// logger->critical("Pipeline " + downlink_pipeline + " does not exist!");
|
|
|
|
|
// return;
|
|
|
|
|
// } TODOREWORK
|
2024-07-21 14:58:03 -04:00
|
|
|
|
2025-05-31 20:26:47 +02:00
|
|
|
process(pipeline, input_level, input_file, output_file, parameters);
|
2024-07-21 14:58:03 -04:00
|
|
|
}
|
2025-01-25 19:07:35 +01:00
|
|
|
|
2025-05-31 20:26:47 +02:00
|
|
|
void process(pipeline::Pipeline downlink_pipeline, std::string input_level, std::string input_file, std::string output_file, nlohmann::json parameters)
|
2022-03-10 19:56:37 +01:00
|
|
|
{
|
2023-01-16 21:17:54 +01:00
|
|
|
processing_mutex.lock();
|
2022-03-10 19:56:37 +01:00
|
|
|
is_processing = true;
|
|
|
|
|
|
2024-07-21 14:58:03 -04:00
|
|
|
logger->info("Starting processing pipeline " + downlink_pipeline.name + "...");
|
2022-03-10 19:56:37 +01:00
|
|
|
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
|
|
|
|
2023-07-02 14:06:40 +02:00
|
|
|
ui_call_list_mutex->lock();
|
|
|
|
|
ui_call_list->clear();
|
|
|
|
|
ui_call_list_mutex->unlock();
|
|
|
|
|
|
2024-07-21 14:58:03 -04:00
|
|
|
try
|
2022-03-10 19:56:37 +01:00
|
|
|
{
|
2024-07-21 14:58:03 -04:00
|
|
|
downlink_pipeline.run(input_file, output_file, parameters, input_level, true, ui_call_list, ui_call_list_mutex);
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception &e)
|
|
|
|
|
{
|
|
|
|
|
logger->error("Fatal error running pipeline : " + std::string(e.what()));
|
|
|
|
|
is_processing = false;
|
|
|
|
|
processing_mutex.unlock();
|
|
|
|
|
return;
|
2022-03-10 19:56:37 +01:00
|
|
|
}
|
2021-05-14 19:38:02 +02:00
|
|
|
|
2022-05-07 20:18:47 +02:00
|
|
|
is_processing = false;
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
logger->info("Done! Goodbye");
|
2022-04-26 15:07:18 +02:00
|
|
|
|
2025-06-08 16:57:37 +02:00
|
|
|
if (satdump_cfg.main_cfg["user_interface"]["open_viewer_post_processing"]["value"].get<bool>())
|
2022-04-26 15:07:18 +02:00
|
|
|
{
|
|
|
|
|
if (std::filesystem::exists(output_file + "/dataset.json"))
|
|
|
|
|
{
|
|
|
|
|
logger->info("Opening viewer!");
|
2025-05-19 22:26:32 +02:00
|
|
|
viewer_app2->tryOpenFileInViewer(output_file + "/dataset.json");
|
2022-04-26 15:07:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-07-02 14:06:40 +02:00
|
|
|
|
2023-01-16 21:17:54 +01:00
|
|
|
processing_mutex.unlock();
|
2022-03-10 19:56:37 +01:00
|
|
|
}
|
2021-05-14 19:38:02 +02:00
|
|
|
|
2025-05-31 20:26:47 +02:00
|
|
|
SATDUMP_DLL2 std::shared_ptr<std::vector<std::shared_ptr<pipeline::ProcessingModule>>> ui_call_list = std::make_shared<std::vector<std::shared_ptr<pipeline::ProcessingModule>>>();
|
2024-05-18 19:59:28 +02:00
|
|
|
SATDUMP_DLL2 std::shared_ptr<std::mutex> ui_call_list_mutex = std::make_shared<std::mutex>();
|
|
|
|
|
SATDUMP_DLL2 bool is_processing = false;
|
2025-05-19 22:26:32 +02:00
|
|
|
} // namespace processing
|
|
|
|
|
} // namespace satdump
|