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

Minor changes, attempt to receive log

parent 2bb0acd7
No related branches found
No related tags found
1 merge request!23Feature/gui implements #53
...@@ -18,6 +18,6 @@ target_include_directories(ftl-gui PUBLIC ...@@ -18,6 +18,6 @@ target_include_directories(ftl-gui PUBLIC
#endif() #endif()
#target_include_directories(cv-node PUBLIC ${PROJECT_SOURCE_DIR}/include) #target_include_directories(cv-node PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(ftl-gui ftlcommon ftlrgbd Threads::Threads ${OpenCV_LIBS} glog::glog ftlnet ftlrender nanogui GL) target_link_libraries(ftl-gui ftlcommon ftlctrl ftlrgbd Threads::Threads ${OpenCV_LIBS} glog::glog ftlnet ftlrender nanogui GL)
#include <ftl/configuration.hpp> #include <ftl/configuration.hpp>
#include <ftl/net/universe.hpp> #include <ftl/net/universe.hpp>
#include <ftl/rgbd.hpp> #include <ftl/rgbd.hpp>
#include <ftl/master.hpp>
#include <glog/logging.h> #include <loguru.hpp>
#include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
...@@ -148,7 +149,7 @@ class VirtualCameraView : public nanogui::ImageView { ...@@ -148,7 +149,7 @@ class VirtualCameraView : public nanogui::ImageView {
class FTLApplication : public nanogui::Screen { class FTLApplication : public nanogui::Screen {
public: public:
explicit FTLApplication(ftl::Configurable *root, ftl::net::Universe *net) : nanogui::Screen(Eigen::Vector2i(1024, 768), "FT-Lab GUI") { explicit FTLApplication(ftl::Configurable *root, ftl::net::Universe *net, ftl::ctrl::Master *controller) : nanogui::Screen(Eigen::Vector2i(1024, 768), "FT-Lab GUI") {
using namespace nanogui; using namespace nanogui;
net_ = net; net_ = net;
...@@ -207,6 +208,11 @@ int main(int argc, char **argv) { ...@@ -207,6 +208,11 @@ int main(int argc, char **argv) {
net->waitConnections(); net->waitConnections();
ftl::ctrl::Master controller(root, net);
controller.onLog([](const ftl::ctrl::LogEvent &e){
LOG(INFO) << "Remote log: " << e.message;
});
/*auto available = net.findAll<string>("list_streams"); /*auto available = net.findAll<string>("list_streams");
for (auto &a : available) { for (auto &a : available) {
std::cout << " -- " << a << std::endl; std::cout << " -- " << a << std::endl;
...@@ -216,7 +222,7 @@ int main(int argc, char **argv) { ...@@ -216,7 +222,7 @@ int main(int argc, char **argv) {
nanogui::init(); nanogui::init();
/* scoped variables */ { /* scoped variables */ {
nanogui::ref<FTLApplication> app = new FTLApplication(root, net); nanogui::ref<FTLApplication> app = new FTLApplication(root, net, &controller);
app->drawAll(); app->drawAll();
app->setVisible(true); app->setVisible(true);
nanogui::mainloop(); nanogui::mainloop();
...@@ -233,5 +239,8 @@ int main(int argc, char **argv) { ...@@ -233,5 +239,8 @@ int main(int argc, char **argv) {
return -1; return -1;
} }
delete net;
delete root;
return 0; return 0;
} }
\ No newline at end of file
...@@ -11,7 +11,8 @@ using ftl::ctrl::LogEvent; ...@@ -11,7 +11,8 @@ using ftl::ctrl::LogEvent;
Master::Master(Configurable *root, Universe *net) Master::Master(Configurable *root, Universe *net)
: root_(root), net_(net) { : root_(root), net_(net) {
net_->bind("log", [this](const std::string &pre, const std::string &msg) { net_->subscribe("log", [this](const std::string &pre, const std::string &msg) {
LOG(INFO) << "RECEIVE LOG";
for (auto f : log_handlers_) { for (auto f : log_handlers_) {
f({pre,msg}); f({pre,msg});
} }
......
...@@ -11,6 +11,7 @@ static void netLog(void* user_data, const loguru::Message& message) { ...@@ -11,6 +11,7 @@ static void netLog(void* user_data, const loguru::Message& message) {
} }
Slave::Slave(Universe *net, ftl::Configurable *root) { Slave::Slave(Universe *net, ftl::Configurable *root) {
net->createResource("log");
net->bind("restart", []() { net->bind("restart", []() {
LOG(WARNING) << "Remote restart..."; LOG(WARNING) << "Remote restart...";
exit(1); exit(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment