fixes and start mana_nng_client

This commit is contained in:
Florian Lüke 2024-12-28 19:18:18 +01:00
parent cad7b29796
commit 92ec0eaf05
6 changed files with 90 additions and 4 deletions

@ -1 +1 @@
Subproject commit 5888edb2bdc10167e71e1f5e4d39bb342e2cf552 Subproject commit d6276febaf90be8f2401bff2ab2ac5b48e30383b

View file

@ -1,6 +1,6 @@
set(MVLC_NNG_MNODE_WARN_FLAGS -Wall -Werror=return-type) 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 target_include_directories(mesytec-mnode-nng
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/mesytec-mnode) PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/mesytec-mnode)

View file

@ -6,8 +6,8 @@
#include <list> #include <list>
#include <mesytec-mnode/mnode_cpp_types.h> #include <mesytec-mnode/mnode_cpp_types.h>
#include <mesytec-mnode/mnode_math.h> #include <mesytec-mnode/mnode_math.h>
#include <mesytec-mvlc/util/fmt.h>
#include <numeric> #include <numeric>
#include <spdlog/fmt/fmt.h>
#include <vector> #include <vector>
namespace mesytec::mnode::mana namespace mesytec::mnode::mana

View file

@ -1,8 +1,10 @@
#ifndef CF5E5AFF_F218_4A25_95DF_8097D7C5685B #ifndef CF5E5AFF_F218_4A25_95DF_8097D7C5685B
#define CF5E5AFF_F218_4A25_95DF_8097D7C5685B #define CF5E5AFF_F218_4A25_95DF_8097D7C5685B
#include "mana_analysis.h" #include "mana_api.hpp"
#include <mesytec-mnode/mnode_cpp_types.h>
#include <mesytec-mnode/mnode_nng.h> #include <mesytec-mnode/mnode_nng.h>
#include <spdlog/spdlog.h>
namespace mesytec::mnode::mana namespace mesytec::mnode::mana
{ {

View file

@ -26,6 +26,8 @@ find_package(Boost CONFIG COMPONENTS filesystem system)
if (Boost_FOUND) if (Boost_FOUND)
add_mnode_dev_executable(mana_auto_replay) add_mnode_dev_executable(mana_auto_replay)
target_link_libraries(mana_auto_replay PRIVATE nlohmann_json::nlohmann_json mnode::resources Boost::filesystem Boost::system) 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() endif()
add_mnode_proto_dev_executable(mnode_proto_test1) add_mnode_proto_dev_executable(mnode_proto_test1)

View file

@ -0,0 +1,82 @@
#include <boost/dll.hpp>
#include <spdlog/spdlog.h>
#include "internal/argh.h"
#include "internal/mana_analysis.h" // ManaCountingSink
#include "internal/mana_api.hpp"
#include <iostream>
using namespace mesytec;
using namespace mesytec::mnode;
void usage(const char *self)
{
std::cout << fmt::format("usage: {} [--plugin=<plugin.so>] <url>\n", self);
std::cout
<< " --plugin=<plugin.so> Load a plugin to process the data. Default is a "
"simple counting plugin.\n"
<< " --processing-strategy=<name> Use a specific processing strategy. "
"Available: 'single-threaded', 'nng-pair'. Default: 'nng-pair'\n"
<< " --log-level=<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<mana::IManaPlugin> manaCppPlugin;
std::unique_ptr<mana::IManaSink> destSink;
if (parser("--plugin"))
{
auto pluginFile = parser("--plugin").str();
try
{
pluginHandle = boost::dll::shared_library(pluginFile);
try
{
destSink = std::make_unique<mana::ManaCSink>(
pluginHandle.get<mana_sink_plugin_t()>("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<mana::IManaPlugin>(
pluginHandle.get<mana::IManaPlugin *()>("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<mana::ManaCountingSink>();
}
}