26 #include <boost/iterator/transform_iterator.hpp>
27 #include <boost/property_tree/ptree.hpp>
29 #include <zmqpp/context.hpp>
30 #include <zmqpp/message.hpp>
38 zmqpp::socket *module_manager_pipe,
39 const boost::property_tree::ptree &config,
41 :
BaseModule(ctx, module_manager_pipe, config, utils)
42 , bus_push_(ctx_,
zmqpp::socket_type::push)
43 , general_cfg_(nullptr)
45 bus_push_.connect(
"inproc://zmq-bus-pull");
58 else if (str ==
"both")
60 else if (str ==
"falling")
62 else if (str ==
"rising")
70 boost::property_tree::ptree module_config = cfg.get_child(
"module_config");
74 for (
auto &node : module_config.get_child(
"gpios"))
76 boost::property_tree::ptree gpio_cfg = node.second;
79 std::string gpio_name;
80 std::string gpio_direction;
81 std::string gpio_interrupt;
83 bool gpio_initial_value;
85 gpio_name = gpio_cfg.get_child(
"name").data();
86 gpio_no = std::stoi(gpio_cfg.get_child(
"no").data());
87 gpio_direction = gpio_cfg.get_child(
"direction").data();
88 gpio_interrupt = gpio_cfg.get<std::string>(
"interrupt_mode",
"none");
89 gpio_initial_value = gpio_cfg.get<
bool>(
"value",
false);
91 using namespace Colorize;
97 interrupt_mode = gpio_interrupt_from_string(gpio_interrupt);
102 interrupt_mode, gpio_initial_value,
105 utils_->config_checker().register_object(gpio_name,
143 [](
const SysFsGpioPin *p) -> std::chrono::system_clock::time_point {
144 return p->next_update();
148 boost::make_transform_iterator(
gpios_.begin(), itr_transform),
149 boost::make_transform_iterator(
gpios_.end(), itr_transform));
151 for (
auto &gpio_pin :
gpios_)
153 if (gpio_pin->next_update() < std::chrono::system_clock::now())