Skip to content
Snippets Groups Projects
Commit 3cf00b41 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Initial net slave code for #54

parent c49da91f
No related branches found
No related tags found
No related merge requests found
Pipeline #11173 passed
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <ftl/display.hpp> #include <ftl/display.hpp>
#include <ftl/rgbd_streamer.hpp> #include <ftl/rgbd_streamer.hpp>
#include <ftl/net/universe.hpp> #include <ftl/net/universe.hpp>
#include <ftl/net/slave.hpp>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
...@@ -80,7 +81,7 @@ void disparityToDepth(const cv::Mat &disparity, cv::Mat &depth, const cv::Mat &q ...@@ -80,7 +81,7 @@ void disparityToDepth(const cv::Mat &disparity, cv::Mat &depth, const cv::Mat &q
static void run(ftl::Configurable *root) { static void run(ftl::Configurable *root) {
Universe *net = ftl::create<Universe>(root, "net"); Universe *net = ftl::create<Universe>(root, "net");
LOG(INFO) << "Net started."; ftl::net::Slave slave(net, root);
auto paths = root->get<vector<string>>("paths"); auto paths = root->get<vector<string>>("paths");
string file = ""; string file = "";
......
...@@ -9,6 +9,7 @@ add_library(ftlnet ...@@ -9,6 +9,7 @@ add_library(ftlnet
src/dispatcher.cpp src/dispatcher.cpp
src/universe.cpp src/universe.cpp
src/ws_internal.cpp src/ws_internal.cpp
src/slave.cpp
) )
target_include_directories(ftlnet PUBLIC target_include_directories(ftlnet PUBLIC
......
#ifndef _FTL_NET_SLAVE_HPP_
#define _FTL_NET_SLAVE_HPP_
#include <ftl/net/universe.hpp>
#include <ftl/configurable.hpp>
namespace ftl {
namespace net {
class Slave {
public:
Slave(Universe *, ftl::Configurable *);
~Slave();
};
}
}
#endif // _FTL_NET_SLAVE_HPP_
#include <ftl/net/slave.hpp>
#include <loguru.hpp>
using ftl::Configurable;
using ftl::net::Universe;
using ftl::net::Slave;
static void netLog(void* user_data, const loguru::Message& message) {
Universe *net = (Universe*)user_data;
net->publish("log", message.preamble, message.message);
}
Slave::Slave(Universe *net, ftl::Configurable *root) {
net->bind("restart", []() {
LOG(WARNING) << "Remote restart...";
exit(1);
});
net->bind("shutdown", []() {
LOG(WARNING) << "Remote shutdown...";
exit(0);
});
loguru::add_callback("net_log", netLog, net, loguru::Verbosity_INFO);
}
Slave::~Slave() {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment