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

This is a implementation class. More...

#include <SysFSGPIOPin.hpp>

+ Collaboration diagram for Leosac::Module::SysFsGpio::SysFsGpioPin:

Public Types

enum  InterruptMode { InterruptMode::None, InterruptMode::Rising, InterruptMode::Falling, InterruptMode::Both }
 
using Direction = Hardware::GPIO::Direction
 

Public Member Functions

 SysFsGpioPin (zmqpp::context &ctx, const std::string &name, int gpio_no, Direction direction, InterruptMode interrupt_mode, bool initial_value, SysFsGpioModule &module)
 
 ~SysFsGpioPin ()
 
 SysFsGpioPin (const SysFsGpioPin &)=delete
 
SysFsGpioPinoperator= (const SysFsGpioPin &)=delete
 
SysFsGpioPinoperator= (SysFsGpioPin &&)=delete
 
 SysFsGpioPin (SysFsGpioPin &&o)=delete
 
void register_sockets (zmqpp::reactor *reactor)
 Register own socket to the module's reactor. More...
 
std::chrono::system_clock::time_point next_update () const
 This method shall returns the time point at which we want to be updated. More...
 
void update ()
 Update the PIN. More...
 

Private Member Functions

void handle_interrupt ()
 Interrupt happened for this GPIO ping. More...
 
bool read_value ()
 Read value from filesystem. More...
 
bool turn_on (zmqpp::message *msg=nullptr)
 Write to sysfs to turn the gpio on. More...
 
bool turn_off ()
 Write to sysfs to turn the gpio on. More...
 
bool toggle ()
 Read to sysfs and then write the opposite value. More...
 
void handle_message ()
 The SysFsGpioModule will register this method so its called when a message is ready on the pin socket. More...
 
void set_direction (Direction dir)
 Write direction to the direction file. More...
 
void set_interrupt (InterruptMode mode)
 Write interrupt mode to the edge file. More...
 

Private Attributes

int file_fd_
 File descriptor of the GPIO in sysfs. More...
 
int gpio_no_
 Number of the GPIO. More...
 
zmqpp::socket sock_
 listen to command from other component. More...
 
std::string name_
 
const Direction direction_
 Direction of the PIN. More...
 
const bool initial_value_
 Initial value of the PIN. More...
 
SysFsGpioModulemodule_
 Reference to the module. More...
 
const SysFsGpioConfigpath_cfg_
 
std::chrono::system_clock::time_point next_update_time_
 Time point of next wished update. More...
 

Detailed Description

This is a implementation class.

It's not exposed to the user and is for this module internal code only.

It abstract a GPIO pin.

Definition at line 41 of file SysFSGPIOPin.hpp.

Member Typedef Documentation

◆ Direction

Member Enumeration Documentation

◆ InterruptMode

Enumerator
None 
Rising 
Falling 
Both 

Definition at line 46 of file SysFSGPIOPin.hpp.

Constructor & Destructor Documentation

◆ SysFsGpioPin() [1/3]

SysFsGpioPin::SysFsGpioPin ( zmqpp::context &  ctx,
const std::string &  name,
int  gpio_no,
Direction  direction,
InterruptMode  interrupt_mode,
bool  initial_value,
SysFsGpioModule module 
)

Definition at line 29 of file SysFSGPIOPin.cpp.

◆ ~SysFsGpioPin()

SysFsGpioPin::~SysFsGpioPin ( )

Definition at line 59 of file SysFSGPIOPin.cpp.

◆ SysFsGpioPin() [2/3]

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

◆ SysFsGpioPin() [3/3]

Leosac::Module::SysFsGpio::SysFsGpioPin::SysFsGpioPin ( SysFsGpioPin &&  o)
delete

Member Function Documentation

◆ handle_interrupt()

void SysFsGpioPin::handle_interrupt ( )
private

Interrupt happened for this GPIO ping.

Definition at line 172 of file SysFSGPIOPin.cpp.

◆ handle_message()

void SysFsGpioPin::handle_message ( )
private

The SysFsGpioModule will register this method so its called when a message is ready on the pin socket.

Definition at line 112 of file SysFSGPIOPin.cpp.

◆ next_update()

std::chrono::system_clock::time_point SysFsGpioPin::next_update ( ) const

This method shall returns the time point at which we want to be updated.

Definition at line 195 of file SysFSGPIOPin.cpp.

◆ operator=() [1/2]

SysFsGpioPin& Leosac::Module::SysFsGpio::SysFsGpioPin::operator= ( const SysFsGpioPin )
delete

◆ operator=() [2/2]

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

◆ read_value()

bool SysFsGpioPin::read_value ( )
private

Read value from filesystem.

Definition at line 167 of file SysFSGPIOPin.cpp.

◆ register_sockets()

void SysFsGpioPin::register_sockets ( zmqpp::reactor *  reactor)

Register own socket to the module's reactor.

Parameters
reactorReactor object owned by the module.

Definition at line 187 of file SysFSGPIOPin.cpp.

◆ set_direction()

void SysFsGpioPin::set_direction ( Direction  dir)
private

Write direction to the direction file.

Definition at line 90 of file SysFSGPIOPin.cpp.

◆ set_interrupt()

void SysFsGpioPin::set_interrupt ( InterruptMode  mode)
private

Write interrupt mode to the edge file.

Definition at line 96 of file SysFSGPIOPin.cpp.

◆ toggle()

bool SysFsGpioPin::toggle ( )
private

Read to sysfs and then write the opposite value.

Definition at line 160 of file SysFSGPIOPin.cpp.

◆ turn_off()

bool SysFsGpioPin::turn_off ( )
private

Write to sysfs to turn the gpio on.

Definition at line 154 of file SysFSGPIOPin.cpp.

◆ turn_on()

bool SysFsGpioPin::turn_on ( zmqpp::message *  msg = nullptr)
private

Write to sysfs to turn the gpio on.

Definition at line 133 of file SysFSGPIOPin.cpp.

◆ update()

void SysFsGpioPin::update ( )

Update the PIN.

The update will simply turn the PIN off (as a timeout for ON command).

Note
This is similar to PFDigitalPin.

Definition at line 200 of file SysFSGPIOPin.cpp.

Member Data Documentation

◆ direction_

const Direction Leosac::Module::SysFsGpio::SysFsGpioPin::direction_
private

Direction of the PIN.

Definition at line 150 of file SysFSGPIOPin.hpp.

◆ file_fd_

int Leosac::Module::SysFsGpio::SysFsGpioPin::file_fd_
private

File descriptor of the GPIO in sysfs.

Definition at line 133 of file SysFSGPIOPin.hpp.

◆ gpio_no_

int Leosac::Module::SysFsGpio::SysFsGpioPin::gpio_no_
private

Number of the GPIO.

Definition at line 138 of file SysFSGPIOPin.hpp.

◆ initial_value_

const bool Leosac::Module::SysFsGpio::SysFsGpioPin::initial_value_
private

Initial value of the PIN.

We set the pin's value to this on module shutdown.

Definition at line 155 of file SysFSGPIOPin.hpp.

◆ module_

SysFsGpioModule& Leosac::Module::SysFsGpio::SysFsGpioPin::module_
private

Reference to the module.

We use this to publish on the bus.

Definition at line 160 of file SysFSGPIOPin.hpp.

◆ name_

std::string Leosac::Module::SysFsGpio::SysFsGpioPin::name_
private

Definition at line 145 of file SysFSGPIOPin.hpp.

◆ next_update_time_

std::chrono::system_clock::time_point Leosac::Module::SysFsGpio::SysFsGpioPin::next_update_time_
private

Time point of next wished update.

(Used for timeout on ON)

Definition at line 167 of file SysFSGPIOPin.hpp.

◆ path_cfg_

const SysFsGpioConfig& Leosac::Module::SysFsGpio::SysFsGpioPin::path_cfg_
private

Definition at line 162 of file SysFSGPIOPin.hpp.

◆ sock_

zmqpp::socket Leosac::Module::SysFsGpio::SysFsGpioPin::sock_
private

listen to command from other component.

Definition at line 143 of file SysFSGPIOPin.hpp.


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