23 #include <zmqpp/z85.hpp>
27 static std::string z85_pad(
const std::string &in,
char pad_char)
31 while (out.size() % 4)
37 const boost::property_tree::ptree &cfg,
40 , bus_(ctx,
zmqpp::socket_type::sub)
43 , kernel_(ctx,
zmqpp::socket_type::req)
45 kernel_.connect(
"inproc://leosac-kernel");
47 bus_.connect(
"inproc://zmq-bus-pub");
58 std::chrono::duration_cast<std::chrono::seconds>(
70 auto system_bus_logger = spdlog::get(
"system_bus_event");
71 assert(system_bus_logger);
74 std::stringstream full_msg;
78 for (
size_t i = 0; i < msg.parts(); ++i)
86 if (std::find_if(buf.begin(), buf.end(),
87 [](
char c) { return !isprint(c); }) != buf.end())
90 buf = zmqpp::z85::encode(z85_pad(buf, 0));
91 full_msg <<
"F" << i <<
": {" << buf <<
"} ; ";
95 full_msg <<
"F" << i <<
": {" << buf <<
"} ; ";
98 system_bus_logger->info(full_msg.str());
101 auto monitor_stdout = spdlog::get(
"monitor_stdout");
102 assert(monitor_stdout);
103 monitor_stdout->info(full_msg.str());
129 <<
" was successful. Looks like network is up.");
135 <<
" failed. Network is probably down.");
145 zmqpp::poller poller;
151 throw std::runtime_error(
"Internal Error, timeout'd");
157 std::string system_bus_log_file =
158 config_.get_child(
"module_config").get<std::string>(
"file-bus",
"");
159 if (!system_bus_log_file.empty())
162 spdlog::rotating_logger_mt(
"system_bus_event", system_bus_log_file,
165 verbose_ =
config_.get_child(
"module_config").get<
bool>(
"verbose",
false);
168 spdlog::stdout_logger_mt(
"monitor_stdout");
171 std::string system_led_name =
172 config_.get_child(
"module_config").get<std::string>(
"system_ok",
"");
173 if (!system_led_name.empty())
176 std::make_unique<Leosac::Hardware::FLED>(
ctx_, system_led_name);
185 auto ping_node =
config_.get_child(
"module_config").get_child_optional(
"ping");
189 std::string network_led_name = ping_node->get<std::string>(
"led");
191 std::make_unique<Leosac::Hardware::FLED>(
ctx_, network_led_name);
198 config_.get_child(
"module_config").get_child_optional(
"reader");
203 std::string reader_led_name = reader_node->get<std::string>(
"led");
205 std::make_unique<Leosac::Hardware::FLED>(
ctx_, reader_led_name);