diff --git a/external/mesytec-mvlc b/external/mesytec-mvlc index 5888edb..d6276fe 160000 --- a/external/mesytec-mvlc +++ b/external/mesytec-mvlc @@ -1 +1 @@ -Subproject commit 5888edb2bdc10167e71e1f5e4d39bb342e2cf552 +Subproject commit d6276febaf90be8f2401bff2ab2ac5b48e30383b diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9bc03c2..4c084d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ set(MVLC_NNG_MNODE_WARN_FLAGS -Wall -Werror=return-type) -add_library(mesytec-mnode-nng mnode_nng.cc) +add_library(mesytec-mnode-nng mnode_nng.cc internal/mana_nng.cc) target_include_directories(mesytec-mnode-nng PUBLIC $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/mesytec-mnode) diff --git a/src/internal/mana_arena.h b/src/internal/mana_arena.h index 5c99636..a51843b 100644 --- a/src/internal/mana_arena.h +++ b/src/internal/mana_arena.h @@ -6,8 +6,8 @@ #include #include #include -#include #include +#include #include namespace mesytec::mnode::mana diff --git a/src/internal/mana_nng.hpp b/src/internal/mana_nng.hpp index d43644f..32b0bb1 100644 --- a/src/internal/mana_nng.hpp +++ b/src/internal/mana_nng.hpp @@ -1,8 +1,10 @@ #ifndef CF5E5AFF_F218_4A25_95DF_8097D7C5685B #define CF5E5AFF_F218_4A25_95DF_8097D7C5685B -#include "mana_analysis.h" +#include "mana_api.hpp" +#include #include +#include namespace mesytec::mnode::mana { diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 7569022..292c77b 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -26,6 +26,8 @@ find_package(Boost CONFIG COMPONENTS filesystem system) if (Boost_FOUND) add_mnode_dev_executable(mana_auto_replay) target_link_libraries(mana_auto_replay PRIVATE nlohmann_json::nlohmann_json mnode::resources Boost::filesystem Boost::system) + add_mnode_dev_executable(mana_nng_client) + target_link_libraries(mana_nng_client PRIVATE nlohmann_json::nlohmann_json mnode::resources Boost::filesystem Boost::system) endif() add_mnode_proto_dev_executable(mnode_proto_test1) diff --git a/src/tools/mana_nng_client.cc b/src/tools/mana_nng_client.cc new file mode 100644 index 0000000..fcc1b39 --- /dev/null +++ b/src/tools/mana_nng_client.cc @@ -0,0 +1,82 @@ +#include +#include + +#include "internal/argh.h" +#include "internal/mana_analysis.h" // ManaCountingSink +#include "internal/mana_api.hpp" + +#include + +using namespace mesytec; +using namespace mesytec::mnode; + +void usage(const char *self) +{ + std::cout << fmt::format("usage: {} [--plugin=] \n", self); + std::cout + << " --plugin= Load a plugin to process the data. Default is a " + "simple counting plugin.\n" + << " --processing-strategy= Use a specific processing strategy. " + "Available: 'single-threaded', 'nng-pair'. Default: 'nng-pair'\n" + << " --log-level= One of 'trace', 'debug', 'info', 'warn', 'error', " + "'off'.\n"; +} + +int main(int argc, char *argv[]) +{ + argh::parser parser({"-h", "--help", "--plugin", "--log-level"}); + parser.parse(argc, argv); + + auto url = parser[1]; + + if (parser["-h"] || parser["--help"] || url.empty()) + { + usage(argv[0]); + return 0; + } + + spdlog::set_level(spdlog::level::info); + + boost::dll::shared_library pluginHandle; + std::unique_ptr manaCppPlugin; + std::unique_ptr destSink; + + if (parser("--plugin")) + { + auto pluginFile = parser("--plugin").str(); + try + { + pluginHandle = boost::dll::shared_library(pluginFile); + + try + { + destSink = std::make_unique( + pluginHandle.get("mana_get_sink_plugin")()); + } + catch (const std::exception &e) + { + spdlog::debug("plugin {} is not a MANA_C_SINK_PLUGIN", pluginFile); + try + { + manaCppPlugin = std::unique_ptr( + pluginHandle.get("mana_get_plugin")()); + destSink = manaCppPlugin->makeSink(); + } + catch (const std::exception &e) + { + std::cerr << fmt::format("Error loading plugin: {}\n", e.what()); + return 1; + } + } + } + catch (const std::exception &e) + { + std::cerr << fmt::format("Error loading plugin: {}\n", e.what()); + return 1; + } + } + else + { + destSink = std::make_unique(); + } +}