Leosac  0.8.0
Open Source Access Control
LibgpiodModule.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2022 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "LibgpiodPin.hpp"
23 #include "LibgpiodConfig.hpp"
24 #include <boost/property_tree/ptree.hpp>
25 #include <modules/BaseModule.hpp>
26 #include <zmqpp/reactor.hpp>
27 #include <zmqpp/socket.hpp>
28 
29 namespace Leosac
30 {
31 namespace Module
32 {
39 namespace Libgpiod
40 {
41 class LibgpiodPin;
42 
43 class LibgpiodConfig;
44 
49 class LibgpiodModule : public BaseModule
50 {
51  public:
52  LibgpiodModule(zmqpp::context &ctx, zmqpp::socket *module_manager_pipe,
53  const boost::property_tree::ptree &config, CoreUtilsPtr utils);
54 
56 
57  LibgpiodModule(const LibgpiodModule &) = delete;
58 
60 
65  void publish_on_bus(zmqpp::message &msg);
66 
70  std::shared_ptr<LibgpiodConfig> general_config() const;
71 
72  virtual void run() override;
73 
74 
75  private:
79  void process_config(const boost::property_tree::ptree &cfg);
80 
85 
89  zmqpp::socket bus_push_;
90 
94  std::vector<std::shared_ptr<LibgpiodPin>> gpios_;
95 
99  std::shared_ptr<LibgpiodConfig> general_cfg_;
100 };
101 }
102 }
103 }
Leosac::Module::BaseModule
Base class for module implementation.
Definition: BaseModule.hpp:110
Leosac::Module::Libgpiod::LibgpiodModule::process_general_config
void process_general_config()
General configuration (file paths, etc).
Definition: LibgpiodModule.cpp:121
BaseModule.hpp
Leosac::Module::Libgpiod::LibgpiodModule::process_config
void process_config(const boost::property_tree::ptree &cfg)
Process the configuration, preparing configured GPIO pin.
Definition: LibgpiodModule.cpp:66
Leosac::Module::Libgpiod::LibgpiodModule::bus_push_
zmqpp::socket bus_push_
Socket to write the bus.
Definition: LibgpiodModule.hpp:89
Leosac::Module::Libgpiod::LibgpiodModule::operator=
LibgpiodModule & operator=(LibgpiodModule &&)=delete
Leosac::Module::Libgpiod::LibgpiodModule::publish_on_bus
void publish_on_bus(zmqpp::message &msg)
Write the message eon the bus.
Definition: LibgpiodModule.cpp:116
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Module::Libgpiod::LibgpiodModule
Handle GPIO management over libgpiod.
Definition: LibgpiodModule.hpp:49
Leosac::Module::Libgpiod::LibgpiodModule::general_config
std::shared_ptr< LibgpiodConfig > general_config() const
Retrieve the config object.
Definition: LibgpiodModule.cpp:127
Leosac::Module::Libgpiod::LibgpiodModule::LibgpiodModule
LibgpiodModule(zmqpp::context &ctx, zmqpp::socket *module_manager_pipe, const boost::property_tree::ptree &config, CoreUtilsPtr utils)
Definition: LibgpiodModule.cpp:35
Leosac::Module::Libgpiod::LibgpiodModule::general_cfg_
std::shared_ptr< LibgpiodConfig > general_cfg_
General configuration for module.
Definition: LibgpiodModule.hpp:99
Leosac::Module::Libgpiod::LibgpiodModule::~LibgpiodModule
~LibgpiodModule()
Definition: LibgpiodModule.cpp:110
Leosac::Module::Libgpiod::LibgpiodModule::run
virtual void run() override
This is the main loop of the module.
Definition: LibgpiodModule.cpp:132
Leosac::Module::Libgpiod::LibgpiodModule::gpios_
std::vector< std::shared_ptr< LibgpiodPin > > gpios_
Vector of underlying pin object.
Definition: LibgpiodModule.hpp:94
LibgpiodPin.hpp
LibgpiodConfig.hpp
Leosac::CoreUtilsPtr
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35