2022-05-12 15:24:25 -07:00
|
|
|
#define SATDUMP_DLL_EXPORT 1
|
2021-03-22 18:53:09 +01:00
|
|
|
#include "init.h"
|
|
|
|
|
#include "logger.h"
|
2022-03-05 12:44:19 +01:00
|
|
|
#include "core/module.h"
|
|
|
|
|
#include "core/pipeline.h"
|
2021-05-04 12:23:22 +02:00
|
|
|
#include <filesystem>
|
2022-12-13 19:56:06 +01:00
|
|
|
// #include "tle.h"
|
2022-03-05 12:44:19 +01:00
|
|
|
#include "core/plugin.h"
|
2021-08-19 00:37:25 +02:00
|
|
|
#include "satdump_vars.h"
|
2022-03-07 20:29:23 +01:00
|
|
|
#include "core/config.h"
|
2021-08-02 23:33:10 +02:00
|
|
|
|
2022-04-21 16:10:00 +02:00
|
|
|
#include "common/tracking/tle.h"
|
2022-05-20 20:19:14 +02:00
|
|
|
#include "products/products.h"
|
2022-04-21 16:10:00 +02:00
|
|
|
|
2022-08-30 12:01:12 +02:00
|
|
|
#include "core/opencl.h"
|
|
|
|
|
|
2023-01-31 20:40:37 +01:00
|
|
|
#include "common/dsp/buffer.h"
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
namespace satdump
|
2021-03-22 18:53:09 +01:00
|
|
|
{
|
2022-05-12 15:24:25 -07:00
|
|
|
SATDUMP_DLL std::string user_path;
|
2022-09-11 19:15:24 +02:00
|
|
|
SATDUMP_DLL std::string tle_file_override = "";
|
2023-01-23 14:23:09 +01:00
|
|
|
SATDUMP_DLL bool tle_do_update_on_init = true;
|
2022-05-07 17:06:56 +02:00
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
void initSatdump()
|
|
|
|
|
{
|
|
|
|
|
logger->info(" _____ __ ____ ");
|
|
|
|
|
logger->info(" / ___/____ _/ /_/ __ \\__ ______ ___ ____ ");
|
|
|
|
|
logger->info(" \\__ \\/ __ `/ __/ / / / / / / __ `__ \\/ __ \\");
|
|
|
|
|
logger->info(" ___/ / /_/ / /_/ /_/ / /_/ / / / / / / /_/ /");
|
|
|
|
|
logger->info("/____/\\__,_/\\__/_____/\\__,_/_/ /_/ /_/ .___/ ");
|
|
|
|
|
logger->info(" /_/ ");
|
|
|
|
|
logger->info("Starting SatDump v" + (std::string)SATDUMP_VERSION);
|
|
|
|
|
logger->info("");
|
|
|
|
|
|
2022-03-30 15:41:23 +02:00
|
|
|
#ifdef _WIN32
|
2022-05-07 17:06:56 +02:00
|
|
|
user_path = ".";
|
2022-05-13 21:35:51 +02:00
|
|
|
#elif __ANDROID__
|
|
|
|
|
user_path = ".";
|
2022-03-30 15:41:23 +02:00
|
|
|
#else
|
2022-05-07 17:06:56 +02:00
|
|
|
user_path = std::string(getenv("HOME")) + "/.config/satdump";
|
2022-03-30 15:41:23 +02:00
|
|
|
#endif
|
|
|
|
|
|
2022-05-12 16:56:46 +02:00
|
|
|
if (std::filesystem::exists("satdump_cfg.json"))
|
|
|
|
|
config::loadConfig("satdump_cfg.json", user_path);
|
|
|
|
|
else
|
|
|
|
|
config::loadConfig(satdump::RESPATH + "satdump_cfg.json", user_path);
|
2022-03-10 19:56:37 +01:00
|
|
|
|
2022-11-26 17:50:44 +01:00
|
|
|
if (config::main_cfg["satdump_general"].contains("log_to_file"))
|
|
|
|
|
{
|
|
|
|
|
bool log_file = config::main_cfg["satdump_general"]["log_to_file"]["value"];
|
|
|
|
|
if (log_file)
|
|
|
|
|
initFileSink();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-26 17:34:22 +01:00
|
|
|
if (config::main_cfg["satdump_general"].contains("log_level"))
|
|
|
|
|
{
|
2022-11-27 21:30:17 +01:00
|
|
|
std::string log_level = config::main_cfg["satdump_general"]["log_level"]["value"];
|
|
|
|
|
if (log_level == "trace")
|
2023-02-26 00:54:58 +00:00
|
|
|
setConsoleLevel(slog::LOG_TRACE);
|
2022-11-27 21:30:17 +01:00
|
|
|
else if (log_level == "debug")
|
2023-02-26 00:54:58 +00:00
|
|
|
setConsoleLevel(slog::LOG_DEBUG);
|
2022-11-27 21:30:17 +01:00
|
|
|
else if (log_level == "info")
|
2023-02-26 00:54:58 +00:00
|
|
|
setConsoleLevel(slog::LOG_INFO);
|
2022-11-27 21:30:17 +01:00
|
|
|
else if (log_level == "warn")
|
2023-02-26 00:54:58 +00:00
|
|
|
setConsoleLevel(slog::LOG_WARN);
|
2022-11-27 21:30:17 +01:00
|
|
|
else if (log_level == "error")
|
2023-02-26 00:54:58 +00:00
|
|
|
setConsoleLevel(slog::LOG_ERROR);
|
2022-11-27 21:30:17 +01:00
|
|
|
else if (log_level == "critical")
|
2023-02-26 00:54:58 +00:00
|
|
|
setConsoleLevel(slog::LOG_CRIT);
|
2022-11-26 17:34:22 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
loadPlugins();
|
|
|
|
|
|
|
|
|
|
registerModules();
|
|
|
|
|
|
|
|
|
|
// Load pipelines
|
|
|
|
|
if (std::filesystem::exists("pipelines") && std::filesystem::is_directory("pipelines"))
|
|
|
|
|
loadPipelines("pipelines");
|
|
|
|
|
else
|
2022-05-12 16:56:46 +02:00
|
|
|
loadPipelines(satdump::RESPATH + "pipelines");
|
2022-03-10 19:56:37 +01:00
|
|
|
|
|
|
|
|
// List them
|
|
|
|
|
logger->debug("Registered pipelines :");
|
|
|
|
|
for (Pipeline &pipeline : pipelines)
|
|
|
|
|
logger->debug(" - " + pipeline.name);
|
|
|
|
|
|
2022-08-30 12:01:12 +02:00
|
|
|
#ifdef USE_OPENCL
|
|
|
|
|
// OpenCL
|
|
|
|
|
opencl::initOpenCL();
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
// TLEs
|
2022-09-11 19:15:24 +02:00
|
|
|
if (tle_file_override == "")
|
2022-09-08 23:03:54 +02:00
|
|
|
{
|
2023-01-23 14:23:09 +01:00
|
|
|
if (config::main_cfg["satdump_general"]["update_tles_startup"]["value"].get<bool>() && tle_do_update_on_init)
|
2022-09-11 19:15:24 +02:00
|
|
|
updateTLEFile(user_path + "/satdump_tles.txt");
|
2022-09-08 23:03:54 +02:00
|
|
|
loadTLEFileIntoRegistry(user_path + "/satdump_tles.txt");
|
2023-01-23 14:23:09 +01:00
|
|
|
if (general_tle_registry.size() == 0 && tle_do_update_on_init) // NO TLEs? Download now.
|
2022-09-11 19:15:24 +02:00
|
|
|
{
|
|
|
|
|
updateTLEFile(user_path + "/satdump_tles.txt");
|
|
|
|
|
loadTLEFileIntoRegistry(user_path + "/satdump_tles.txt");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (std::filesystem::exists(tle_file_override))
|
|
|
|
|
loadTLEFileIntoRegistry(tle_file_override);
|
|
|
|
|
else
|
|
|
|
|
logger->error("TLE File doesn't exist : " + tle_file_override);
|
2022-09-08 23:03:54 +02:00
|
|
|
}
|
2022-03-10 19:56:37 +01:00
|
|
|
|
2022-05-20 20:19:14 +02:00
|
|
|
// Products
|
|
|
|
|
registerProducts();
|
|
|
|
|
|
2023-01-31 20:40:37 +01:00
|
|
|
// Set DSP buffer sizes if they have been changed
|
|
|
|
|
if (config::main_cfg.contains("advanced_settings"))
|
|
|
|
|
{
|
|
|
|
|
if (config::main_cfg["advanced_settings"].contains("default_buffer_size"))
|
|
|
|
|
{
|
|
|
|
|
int new_sz = config::main_cfg["advanced_settings"]["default_buffer_size"].get<int>();
|
|
|
|
|
dsp::STREAM_BUFFER_SIZE = new_sz;
|
|
|
|
|
dsp::RING_BUF_SZ = new_sz;
|
2023-05-08 23:08:34 +02:00
|
|
|
logger->warn("DSP Buffer size was changed to %d", new_sz);
|
2023-01-31 20:40:37 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-10 19:56:37 +01:00
|
|
|
// Let plugins know we started
|
|
|
|
|
eventBus->fire_event<SatDumpStartedEvent>({});
|
2022-12-13 19:56:06 +01:00
|
|
|
|
|
|
|
|
#ifdef BUILD_IS_DEBUG
|
|
|
|
|
// If in debug, warn the user!
|
|
|
|
|
logger->error("██████╗ █████╗ ███╗ ██╗ ██████╗ ███████╗██████╗ ");
|
|
|
|
|
logger->error("██╔══██╗██╔══██╗████╗ ██║██╔════╝ ██╔════╝██╔══██╗");
|
|
|
|
|
logger->error("██║ ██║███████║██╔██╗ ██║██║ ███╗█████╗ ██████╔╝");
|
|
|
|
|
logger->error("██║ ██║██╔══██║██║╚██╗██║██║ ██║██╔══╝ ██╔══██╗");
|
|
|
|
|
logger->error("██████╔╝██║ ██║██║ ╚████║╚██████╔╝███████╗██║ ██║");
|
|
|
|
|
logger->error("╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝");
|
|
|
|
|
logger->error("SatDump has NOT been built in Release mode.");
|
|
|
|
|
logger->error("If you are not a developer but intending to use the software,");
|
|
|
|
|
logger->error("you probably do not want this. If so, make sure to");
|
|
|
|
|
logger->error("specify -DCMAKE_BUILD_TYPE=Release in CMake.");
|
|
|
|
|
#endif
|
2022-03-10 19:56:37 +01:00
|
|
|
}
|
|
|
|
|
}
|