From 5edc63243039b9137548f0f081489aae4a96bd84 Mon Sep 17 00:00:00 2001 From: Iiro Rastas <iitara@utu.fi> Date: Tue, 17 Dec 2019 13:19:41 +0200 Subject: [PATCH] Add a get_configurable RPC call --- components/control/cpp/include/ftl/master.hpp | 2 ++ components/control/cpp/src/master.cpp | 10 +++++++++- components/net/cpp/src/net_configurable.cpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/components/control/cpp/include/ftl/master.hpp b/components/control/cpp/include/ftl/master.hpp index 641dfa756..c4782d16e 100644 --- a/components/control/cpp/include/ftl/master.hpp +++ b/components/control/cpp/include/ftl/master.hpp @@ -58,6 +58,8 @@ class Master { ftl::config::json_t get(const ftl::UUID &peer, const std::string &uri); + ftl::config::json_t getConfigurable(const ftl::UUID &peer, const std::string &uri); + void watch(const std::string &uri, std::function<void()> f); Eigen::Matrix4d getPose(const std::string &uri); diff --git a/components/control/cpp/src/master.cpp b/components/control/cpp/src/master.cpp index 13bf86157..059dfe914 100644 --- a/components/control/cpp/src/master.cpp +++ b/components/control/cpp/src/master.cpp @@ -40,6 +40,10 @@ Master::Master(Configurable *root, Universe *net) return ftl::config::resolve(uri, false).dump(); }); + net->bind("get_configurable", [](const std::string &uri) -> std::string { + return ftl::config::find(uri)->getConfig().dump(); + }); + net->bind("list_configurables", []() { return ftl::config::list(); }); @@ -76,7 +80,7 @@ Master::Master(Configurable *root, Universe *net) for (auto c : cs) { //LOG(INFO) << "NET CONFIG: " << c; ftl::config::json_t *configuration = new ftl::config::json_t; - *configuration = get(peer, c); + *configuration = getConfigurable(peer, c); if (!configuration->empty()) { ftl::NetConfigurable *nc = new ftl::NetConfigurable(peer, c, *this, *configuration); peerConfigurables_[peer].push_back(nc); @@ -166,6 +170,10 @@ json_t Master::get(const ftl::UUID &peer, const string &uri) { return json_t::parse(net_->call<string>(peer, "get_cfg", uri)); } +json_t Master::getConfigurable(const ftl::UUID &peer, const string &uri) { + return json_t::parse(net_->call<string>(peer, "get_configurable", uri)); +} + void Master::watch(const string &uri, function<void()> f) { } diff --git a/components/net/cpp/src/net_configurable.cpp b/components/net/cpp/src/net_configurable.cpp index cf597c5c7..00852c666 100644 --- a/components/net/cpp/src/net_configurable.cpp +++ b/components/net/cpp/src/net_configurable.cpp @@ -12,5 +12,5 @@ void ftl::NetConfigurable::inject(const std::string &name, nlohmann::json &value } void ftl::NetConfigurable::refresh() { - (*config_) = ctrl.get(peer, suri); + (*config_) = ctrl.getConfigurable(peer, suri); } -- GitLab