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

A Facade to a LED object. More...

#include <FLED.hpp>

Classes

struct  State
 

Public Member Functions

 FLED (zmqpp::context &ctx, const std::string &led_name)
 
 FLED (const FLED &)=delete
 Disabled copy-constructor. More...
 
 ~FLED ()=default
 Default destructor. More...
 
bool turnOn (int duration)
 Turn the LED ON and turn it OFF duration milliseconds later. More...
 
bool turnOn (std::chrono::milliseconds duration)
 Turn the LED ON and turn it OFF duration milliseconds later. More...
 
bool turnOn ()
 Turn the LED ON by sending a message to the backend LED impl. More...
 
bool turnOff ()
 Turn the LED OFF by sending a message to the backend LED impl. More...
 
bool toggle ()
 Toggle the LED value by sending a message to the backend LED impl. More...
 
bool blink ()
 Make the LED blink. More...
 
bool blink (std::chrono::milliseconds duration, std::chrono::milliseconds speed)
 Blink with a duration and a speed. More...
 
bool blink (int duration, int speed)
 
bool isOn ()
 Query the value of the GPIO and returns true if the LED is ON. More...
 
bool isOff ()
 Similar to isOn(). More...
 
bool isBlinking ()
 Returns true is the LED is currently blinking. More...
 
State state ()
 Return the state of the device. More...
 
zmqpp::socket & backend ()
 Access the backend socket (which is connect to the LED device) to send command directly. More...
 

Private Attributes

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

Detailed Description

A Facade to a LED object.

This object require a valid GPIO object to work. It abstract a LED, and add a simple command on top of GPIO. It requires a module that implements the behavior to work properly. However, unlike GPIO modules, we are unlikely to have multiple implementation of a LED module.

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

Definition at line 44 of file FLED.hpp.

Constructor & Destructor Documentation

◆ FLED() [1/2]

FLED::FLED ( zmqpp::context &  ctx,
const std::string &  led_name 
)

Definition at line 26 of file FLED.cpp.

◆ FLED() [2/2]

Leosac::Hardware::FLED::FLED ( const FLED )
delete

Disabled copy-constructor.

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

◆ ~FLED()

Leosac::Hardware::FLED::~FLED ( )
default

Default destructor.

Member Function Documentation

◆ backend()

zmqpp::socket & FLED::backend ( )

Access the backend socket (which is connect to the LED device) to send command directly.

Use carefully !

Definition at line 192 of file FLED.cpp.

◆ blink() [1/3]

bool FLED::blink ( )

Make the LED blink.

No optional parameter so the module shall use the default for the device.

Definition at line 93 of file FLED.cpp.

◆ blink() [2/3]

bool FLED::blink ( int  duration,
int  speed 
)

Definition at line 122 of file FLED.cpp.

◆ blink() [3/3]

bool FLED::blink ( std::chrono::milliseconds  duration,
std::chrono::milliseconds  speed 
)

Blink with a duration and a speed.

Definition at line 106 of file FLED.cpp.

◆ isBlinking()

bool FLED::isBlinking ( )

Returns true is the LED is currently blinking.

Definition at line 147 of file FLED.cpp.

◆ isOff()

bool FLED::isOff ( )

Similar to isOn().

If the GPIO is blinking, but currently OFF, this returns true.

Definition at line 142 of file FLED.cpp.

◆ isOn()

bool FLED::isOn ( )

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

It returns false otherwise.

If the GPIO is blinking, but currently ON, this returns true.

Definition at line 128 of file FLED.cpp.

◆ state()

FLED::State FLED::state ( )

Return the state of the device.

See FLED::State for more infos.

Definition at line 152 of file FLED.cpp.

◆ toggle()

bool FLED::toggle ( )

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

Definition at line 80 of file FLED.cpp.

◆ turnOff()

bool FLED::turnOff ( )

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

Definition at line 67 of file FLED.cpp.

◆ turnOn() [1/3]

bool FLED::turnOn ( )

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

Definition at line 54 of file FLED.cpp.

◆ turnOn() [2/3]

bool FLED::turnOn ( int  duration)

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

Definition at line 49 of file FLED.cpp.

◆ turnOn() [3/3]

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

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

Definition at line 33 of file FLED.cpp.

Member Data Documentation

◆ backend_

zmqpp::socket Leosac::Hardware::FLED::backend_
private

A socket to talk to the backend LED.

Definition at line 174 of file FLED.hpp.

◆ poller_

zmqpp::poller Leosac::Hardware::FLED::poller_
private

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

Definition at line 179 of file FLED.hpp.


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