Leosac  0.8.0
Open Source Access Control
Leosac::Module::SysFsGpio::SysFsGpioModule Class Reference

Handle GPIO management over sysfs. More...

#include <SysFsGpioModule.hpp>

+ Inheritance diagram for Leosac::Module::SysFsGpio::SysFsGpioModule:
+ Collaboration diagram for Leosac::Module::SysFsGpio::SysFsGpioModule:

Public Member Functions

 SysFsGpioModule (zmqpp::context &ctx, zmqpp::socket *module_manager_pipe, const boost::property_tree::ptree &config, CoreUtilsPtr utils)
 
 ~SysFsGpioModule ()
 
 SysFsGpioModule (const SysFsGpioModule &)=delete
 
SysFsGpioModuleoperator= (SysFsGpioModule &&)=delete
 
void publish_on_bus (zmqpp::message &msg)
 Write the message eon the bus. More...
 
const SysFsGpioConfiggeneral_config () const
 Retrieve a reference to the config object. More...
 
virtual void run () override
 This is the main loop of the module. More...
 
- Public Member Functions inherited from Leosac::Module::BaseModule
 BaseModule (zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
 Constructor of BaseModule. More...
 
virtual ~BaseModule ()=default
 

Private Member Functions

void process_config (const boost::property_tree::ptree &cfg)
 Process the configuration, preparing configured GPIO pin. More...
 
void process_general_config ()
 General configuration (file paths, etc). More...
 
void export_gpio (int gpio_no)
 Write to "gpio_export_path" so the kernel export the socket to sysfs. More...
 

Private Attributes

zmqpp::socket bus_push_
 Socket to write the bus. More...
 
std::vector< SysFsGpioPin * > gpios_
 Vector of underlying pin object. More...
 
SysFsGpioConfiggeneral_cfg_
 General configuration for module. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Leosac::Module::BaseModule
virtual void handle_pipe ()
 The base class register the pipe_ socket to its reactor_ so that this function is called when the pipe_ is available from reading. More...
 
virtual void handle_control ()
 Handle called when a message on the module's control socket arrives. More...
 
virtual void dump_additional_config (zmqpp::message *out) const
 Dump additional configuration (for example module specific config file). More...
 
void dump_config (ConfigManager::ConfigFormat fmt, zmqpp::message *out_msg) const
 Fills a message with the module's configuration information. More...
 
void config_check (const std::string &obj_name, Leosac::Hardware::DeviceClass type)
 An helper that checks configuration the existence of some objects. More...
 
void config_check (const std::string &obj_name)
 An helper that checks configuration the existence of some objects. More...
 
- Protected Attributes inherited from Leosac::Module::BaseModule
zmqpp::context & ctx_
 A reference to the ZeroMQ context in case you need it to create additional socket. More...
 
zmqpp::socket & pipe_
 A reference to the pair socket that link back to the module manager. More...
 
boost::property_tree::ptree config_
 The configuration tree passed to the start_module function. More...
 
CoreUtilsPtr utils_
 Pointer to the core utils, which gives access to scheduler and others. More...
 
bool is_running_
 Boolean indicating whether the main loop should run or not. More...
 
zmqpp::socket control_
 Control REP socket. More...
 
zmqpp::reactor reactor_
 The reactor object we poll() on in the main loop. More...
 
std::string name_
 

Detailed Description

Handle GPIO management over sysfs.

See also
Configuration Options for configuration information.

Definition at line 49 of file SysFsGpioModule.hpp.

Constructor & Destructor Documentation

◆ SysFsGpioModule() [1/2]

SysFsGpioModule::SysFsGpioModule ( zmqpp::context &  ctx,
zmqpp::socket *  module_manager_pipe,
const boost::property_tree::ptree &  config,
CoreUtilsPtr  utils 
)

Definition at line 37 of file SysFsGpioModule.cpp.

◆ ~SysFsGpioModule()

SysFsGpioModule::~SysFsGpioModule ( )

Definition at line 115 of file SysFsGpioModule.cpp.

◆ SysFsGpioModule() [2/2]

Leosac::Module::SysFsGpio::SysFsGpioModule::SysFsGpioModule ( const SysFsGpioModule )
delete

Member Function Documentation

◆ export_gpio()

void SysFsGpioModule::export_gpio ( int  gpio_no)
private

Write to "gpio_export_path" so the kernel export the socket to sysfs.

Definition at line 110 of file SysFsGpioModule.cpp.

◆ general_config()

const SysFsGpioConfig & SysFsGpioModule::general_config ( ) const

Retrieve a reference to the config object.

Definition at line 133 of file SysFsGpioModule.cpp.

◆ operator=()

SysFsGpioModule& Leosac::Module::SysFsGpio::SysFsGpioModule::operator= ( SysFsGpioModule &&  )
delete

◆ process_config()

void SysFsGpioModule::process_config ( const boost::property_tree::ptree &  cfg)
private

Process the configuration, preparing configured GPIO pin.

Definition at line 68 of file SysFsGpioModule.cpp.

◆ process_general_config()

void SysFsGpioModule::process_general_config ( )
private

General configuration (file paths, etc).

Definition at line 127 of file SysFsGpioModule.cpp.

◆ publish_on_bus()

void SysFsGpioModule::publish_on_bus ( zmqpp::message &  msg)

Write the message eon the bus.

This is intended for use by the SysFsGpioPin

Definition at line 122 of file SysFsGpioModule.cpp.

◆ run()

void SysFsGpioModule::run ( )
overridevirtual

This is the main loop of the module.

It should only exit when receiving signal::stop on its pipe_ socket. This is completely handled by this base class. In case you override this, make sure you watch the pipe_ socket.

Reimplemented from Leosac::Module::BaseModule.

Definition at line 138 of file SysFsGpioModule.cpp.

Member Data Documentation

◆ bus_push_

zmqpp::socket Leosac::Module::SysFsGpio::SysFsGpioModule::bus_push_
private

Socket to write the bus.

Definition at line 94 of file SysFsGpioModule.hpp.

◆ general_cfg_

SysFsGpioConfig* Leosac::Module::SysFsGpio::SysFsGpioModule::general_cfg_
private

General configuration for module.

Definition at line 104 of file SysFsGpioModule.hpp.

◆ gpios_

std::vector<SysFsGpioPin *> Leosac::Module::SysFsGpio::SysFsGpioModule::gpios_
private

Vector of underlying pin object.

Definition at line 99 of file SysFsGpioModule.hpp.


The documentation for this class was generated from the following files: