Leosac  0.8.0
Open Source Access Control
SysFsGpioModule.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 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 "SysFSGPIOPin.hpp"
23 #include "SysFsGpioConfig.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 SysFsGpio
40 {
41 class SysFsGpioPin;
42 
43 class SysFsGpioConfig;
44 
50 {
51  public:
52  SysFsGpioModule(zmqpp::context &ctx, zmqpp::socket *module_manager_pipe,
53  const boost::property_tree::ptree &config, CoreUtilsPtr utils);
54 
56 
57  SysFsGpioModule(const SysFsGpioModule &) = delete;
58 
60 
65  void publish_on_bus(zmqpp::message &msg);
66 
70  const SysFsGpioConfig &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  void export_gpio(int gpio_no);
90 
94  zmqpp::socket bus_push_;
95 
99  std::vector<SysFsGpioPin *> gpios_;
100 
105 };
106 }
107 }
108 }
Leosac::Module::SysFsGpio::SysFsGpioModule::process_config
void process_config(const boost::property_tree::ptree &cfg)
Process the configuration, preparing configured GPIO pin.
Definition: SysFsGpioModule.cpp:68
Leosac::Module::BaseModule
Base class for module implementation.
Definition: BaseModule.hpp:110
Leosac::Module::SysFsGpio::SysFsGpioModule::run
virtual void run() override
This is the main loop of the module.
Definition: SysFsGpioModule.cpp:138
Leosac::Module::SysFsGpio::SysFsGpioModule::general_cfg_
SysFsGpioConfig * general_cfg_
General configuration for module.
Definition: SysFsGpioModule.hpp:104
Leosac::Module::SysFsGpio::SysFsGpioModule::publish_on_bus
void publish_on_bus(zmqpp::message &msg)
Write the message eon the bus.
Definition: SysFsGpioModule.cpp:122
BaseModule.hpp
SysFsGpioConfig.hpp
Leosac::Module::SysFsGpio::SysFsGpioModule::process_general_config
void process_general_config()
General configuration (file paths, etc).
Definition: SysFsGpioModule.cpp:127
Leosac::Module::SysFsGpio::SysFsGpioConfig
Internal configuration helper for sysfsgpio module.
Definition: SysFsGpioConfig.hpp:40
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Module::SysFsGpio::SysFsGpioModule::general_config
const SysFsGpioConfig & general_config() const
Retrieve a reference to the config object.
Definition: SysFsGpioModule.cpp:133
SysFSGPIOPin.hpp
Leosac::Module::SysFsGpio::SysFsGpioModule::~SysFsGpioModule
~SysFsGpioModule()
Definition: SysFsGpioModule.cpp:115
Leosac::Module::SysFsGpio::SysFsGpioModule::bus_push_
zmqpp::socket bus_push_
Socket to write the bus.
Definition: SysFsGpioModule.hpp:94
Leosac::Module::SysFsGpio::SysFsGpioModule
Handle GPIO management over sysfs.
Definition: SysFsGpioModule.hpp:49
Leosac::Module::SysFsGpio::SysFsGpioModule::SysFsGpioModule
SysFsGpioModule(zmqpp::context &ctx, zmqpp::socket *module_manager_pipe, const boost::property_tree::ptree &config, CoreUtilsPtr utils)
Definition: SysFsGpioModule.cpp:37
Leosac::Module::SysFsGpio::SysFsGpioModule::operator=
SysFsGpioModule & operator=(SysFsGpioModule &&)=delete
Leosac::Module::SysFsGpio::SysFsGpioModule::export_gpio
void export_gpio(int gpio_no)
Write to "gpio_export_path" so the kernel export the socket to sysfs.
Definition: SysFsGpioModule.cpp:110
Leosac::CoreUtilsPtr
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35
Leosac::Module::SysFsGpio::SysFsGpioModule::gpios_
std::vector< SysFsGpioPin * > gpios_
Vector of underlying pin object.
Definition: SysFsGpioModule.hpp:99