Leosac  0.8.0
Open Source Access Control
Leosac::Hardware::FGPIO Class Reference

A Facade to a GPIO object. More...

#include <FGPIO.hpp>

+ Collaboration diagram for Leosac::Hardware::FGPIO:

Public Member Functions

 FGPIO (zmqpp::context &ctx, const std::string &gpio_name)
 
 FGPIO (const FGPIO &)=delete
 Disabled copy-constructor. More...
 
 ~FGPIO ()=default
 Default destructor, RAII does the job. More...
 
bool turnOn (std::chrono::milliseconds duration)
 Turn the GPIO ON and turn it OFF duration milliseconds later. More...
 
bool turnOn ()
 Turn the GPIO ON by sending a message to the backend GPIO impl. More...
 
bool turnOff ()
 Turn the GPIO OFF by sending a message to the backend GPIO impl. More...
 
bool toggle ()
 Toggle the GPIO value by sending a message to the backend GPIO impl. More...
 
bool isOn ()
 Query the value of the GPIO and returns true if the LED is ON. More...
 
bool isOff ()
 Similar to isOn(). More...
 
const std::string & name () const
 Name of the GPIO pin as defined in the configuration file. More...
 

Private Attributes

std::string gpio_name_
 
zmqpp::socket backend_
 A socket to talk to the backend GPIO. More...
 
zmqpp::poller poller_
 A poller to not wait for infinity in case something went wrong. More...
 

Detailed Description

A Facade to a GPIO object.

This facade does not care about the GPIO implementation. It uses message passing to interact with the application "gpio controller".

The backend GPIO object (implemented by the gpio module (either sysfs or piface)) MUST exist. All you need is the GPIO name defined in the configuration file to create a facade.

Note
This class implements the client code to [theses specifications](Specification for GPIOs modules).

Definition at line 45 of file FGPIO.hpp.

Constructor & Destructor Documentation

◆ FGPIO() [1/2]

FGPIO::FGPIO ( zmqpp::context &  ctx,
const std::string &  gpio_name 
)

Definition at line 26 of file FGPIO.cpp.

◆ FGPIO() [2/2]

Leosac::Hardware::FGPIO::FGPIO ( const FGPIO )
delete

Disabled copy-constructor.

Manually create a new facade using the GPIO's name instead.

◆ ~FGPIO()

Leosac::Hardware::FGPIO::~FGPIO ( )
default

Default destructor, RAII does the job.

Member Function Documentation

◆ isOff()

bool FGPIO::isOff ( )

Similar to isOn().

Definition at line 108 of file FGPIO.cpp.

◆ isOn()

bool FGPIO::isOn ( )

Query the value of the GPIO and returns true if the LED is ON.

It returns false otherwise.

Definition at line 93 of file FGPIO.cpp.

◆ name()

const std::string & FGPIO::name ( ) const

Name of the GPIO pin as defined in the configuration file.

Definition at line 113 of file FGPIO.cpp.

◆ toggle()

bool FGPIO::toggle ( )

Toggle the GPIO value by sending a message to the backend GPIO impl.

Definition at line 79 of file FGPIO.cpp.

◆ turnOff()

bool FGPIO::turnOff ( )

Turn the GPIO OFF by sending a message to the backend GPIO impl.

Definition at line 65 of file FGPIO.cpp.

◆ turnOn() [1/2]

bool FGPIO::turnOn ( )

Turn the GPIO ON by sending a message to the backend GPIO impl.

Definition at line 51 of file FGPIO.cpp.

◆ turnOn() [2/2]

bool FGPIO::turnOn ( std::chrono::milliseconds  duration)

Turn the GPIO ON and turn it OFF duration milliseconds later.

Definition at line 34 of file FGPIO.cpp.

Member Data Documentation

◆ backend_

zmqpp::socket Leosac::Hardware::FGPIO::backend_
private

A socket to talk to the backend GPIO.

Definition at line 103 of file FGPIO.hpp.

◆ gpio_name_

std::string Leosac::Hardware::FGPIO::gpio_name_
private

Definition at line 98 of file FGPIO.hpp.

◆ poller_

zmqpp::poller Leosac::Hardware::FGPIO::poller_
private

A poller to not wait for infinity in case something went wrong.

Definition at line 108 of file FGPIO.hpp.


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