25 #include <boost/iterator/transform_iterator.hpp>
26 #include <boost/property_tree/ptree.hpp>
28 #include <zmqpp/context.hpp>
29 #include <zmqpp/message.hpp>
36 zmqpp::socket *module_manager_pipe,
37 const boost::property_tree::ptree &config,
39 :
BaseModule(ctx, module_manager_pipe, config, utils)
40 , bus_push_(ctx_,
zmqpp::socket_type::push)
41 , general_cfg_(nullptr)
43 bus_push_.connect(
"inproc://zmq-bus-pull");
56 else if (str ==
"both")
58 else if (str ==
"falling")
60 else if (str ==
"rising")
68 boost::property_tree::ptree module_config = cfg.get_child(
"module_config");
72 for (
auto &node : module_config.get_child(
"gpios"))
74 boost::property_tree::ptree gpio_cfg = node.second;
77 std::string gpio_name;
78 std::string gpio_device;
79 std::string gpio_direction;
80 std::string gpio_interrupt;
82 bool gpio_initial_value;
84 gpio_name = gpio_cfg.get_child(
"name").data();
85 gpio_device = gpio_cfg.get<std::string>(
"device",
"leosac");
86 gpio_offset = std::stoi(gpio_cfg.get_child(
"offset").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);
101 gpios_.push_back(std::make_shared<LibgpiodPin>(
ctx_, gpio_name, gpio_device, gpio_offset, direction,
102 interrupt_mode, gpio_initial_value,
105 utils_->config_checker().register_object(gpio_name,
137 [](std::shared_ptr<const LibgpiodPin> p) -> std::chrono::system_clock::time_point {
138 return p->next_update();
142 boost::make_transform_iterator(
gpios_.begin(), itr_transform),
143 boost::make_transform_iterator(
gpios_.end(), itr_transform));
145 for (
auto gpio_pin :
gpios_)
147 if (gpio_pin->next_update() < std::chrono::system_clock::now())