Leosac  0.8.0
Open Source Access Control
PFDigitalPin Struct Reference

This is a implementation class. More...

#include <PFDigitalPin.hpp>

+ Collaboration diagram for PFDigitalPin:

Public Types

using Direction = Leosac::Hardware::GPIO::Direction
 

Public Member Functions

 PFDigitalPin (zmqpp::context &ctx, const std::string &name, int gpio_no, Direction direction, bool value, uint8_t hardware_address)
 Create a new GPIO pin. More...
 
 ~PFDigitalPin ()
 
 PFDigitalPin (const PFDigitalPin &)=delete
 
PFDigitalPinoperator= (const PFDigitalPin &)=delete
 
 PFDigitalPin (PFDigitalPin &&o)
 
PFDigitalPinoperator= (PFDigitalPin &&)=delete
 
void publish_state ()
 
void update ()
 Let the GPIO pin perform internal task. 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...
 
bool turn_on (zmqpp::message *msg=nullptr)
 Write to PFDigital to turn the gpio on. More...
 
bool turn_off ()
 Write to PFDigital turn the gpio off. More...
 
bool toggle ()
 
void handle_message ()
 The PFGpioModule will register this method so its called when a message is ready on the pin socket. More...
 
void send_state ()
 Send the current GPIO state on the socket. More...
 
bool read_value ()
 Ask the PiFace device for this pin's value and return it. More...
 

Public Attributes

uint8_t gpio_no_
 
zmqpp::socket sock_
 listen to command from other component. More...
 
zmqpp::socket * bus_push_
 PUSH socket to write to the bus. More...
 
std::string name_
 
const Direction direction_
 This is the direction of the GPIO pin. More...
 
bool default_value_
 The default value of the pin, it is only relevant is the pin is output. More...
 
std::chrono::system_clock::time_point next_update_time_
 Time point of next wished update. More...
 
uint8_t hardware_address_
 
bool want_update_
 Does this object wants to be update()d ? 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 driven by the PifaceDigital card.

Definition at line 33 of file PFDigitalPin.hpp.

Member Typedef Documentation

◆ Direction

Constructor & Destructor Documentation

◆ PFDigitalPin() [1/3]

PFDigitalPin::PFDigitalPin ( zmqpp::context &  ctx,
const std::string &  name,
int  gpio_no,
Direction  direction,
bool  value,
uint8_t  hardware_address 
)

Create a new GPIO pin.

Parameters
ctxThe ZeroMQ context
namethe name we defined for the PIN
gpio_noThe number of this GPIO
directionWhether this an input or output pin.
valuethe initial value of the pin. This only make sense if the pin is an output pin.

Definition at line 24 of file PFDigitalPin.cpp.

◆ ~PFDigitalPin()

PFDigitalPin::~PFDigitalPin ( )

Definition at line 43 of file PFDigitalPin.cpp.

◆ PFDigitalPin() [2/3]

PFDigitalPin::PFDigitalPin ( const PFDigitalPin )
delete

◆ PFDigitalPin() [3/3]

PFDigitalPin::PFDigitalPin ( PFDigitalPin &&  o)

Definition at line 50 of file PFDigitalPin.cpp.

Member Function Documentation

◆ handle_message()

void PFDigitalPin::handle_message ( )

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

Definition at line 64 of file PFDigitalPin.cpp.

◆ next_update()

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

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

If you do not want to be updated, return time_point::max() basically making sure we wont be called.

Definition at line 146 of file PFDigitalPin.cpp.

◆ operator=() [1/2]

PFDigitalPin& PFDigitalPin::operator= ( const PFDigitalPin )
delete

◆ operator=() [2/2]

PFDigitalPin& PFDigitalPin::operator= ( PFDigitalPin &&  )
delete

◆ publish_state()

void PFDigitalPin::publish_state ( )

Definition at line 153 of file PFDigitalPin.cpp.

◆ read_value()

bool PFDigitalPin::read_value ( )

Ask the PiFace device for this pin's value and return it.

Definition at line 132 of file PFDigitalPin.cpp.

◆ send_state()

void PFDigitalPin::send_state ( )

Send the current GPIO state on the socket.

Definition at line 160 of file PFDigitalPin.cpp.

◆ toggle()

bool PFDigitalPin::toggle ( )

Definition at line 116 of file PFDigitalPin.cpp.

◆ turn_off()

bool PFDigitalPin::turn_off ( )

Write to PFDigital turn the gpio off.

Definition at line 106 of file PFDigitalPin.cpp.

◆ turn_on()

bool PFDigitalPin::turn_on ( zmqpp::message *  msg = nullptr)

Write to PFDigital to turn the gpio on.

Parameters
msgoptional pointer to the source message. We can extract optional parameter, if any

Definition at line 86 of file PFDigitalPin.cpp.

◆ update()

void PFDigitalPin::update ( )

Let the GPIO pin perform internal task.

This is called by the PFDigitalModule in the main loop.

Note
For example we use this to perform "auto turn off" after receiving a "ON" command with a duration parameter.
the previous example is the only use case for now, so we lack code determining what to do on update.

Definition at line 139 of file PFDigitalPin.cpp.

Member Data Documentation

◆ bus_push_

zmqpp::socket* PFDigitalPin::bus_push_

PUSH socket to write to the bus.

Definition at line 113 of file PFDigitalPin.hpp.

◆ default_value_

bool PFDigitalPin::default_value_

The default value of the pin, it is only relevant is the pin is output.

We store this to reset the pin its initial state upon unloading the module.

Definition at line 132 of file PFDigitalPin.hpp.

◆ direction_

const Direction PFDigitalPin::direction_

This is the direction of the GPIO pin.

This cannot be modified once the GPIO has been created.

Definition at line 126 of file PFDigitalPin.hpp.

◆ gpio_no_

uint8_t PFDigitalPin::gpio_no_

Definition at line 103 of file PFDigitalPin.hpp.

◆ hardware_address_

uint8_t PFDigitalPin::hardware_address_

Definition at line 139 of file PFDigitalPin.hpp.

◆ name_

std::string PFDigitalPin::name_

Definition at line 115 of file PFDigitalPin.hpp.

◆ next_update_time_

std::chrono::system_clock::time_point PFDigitalPin::next_update_time_

Time point of next wished update.

Definition at line 137 of file PFDigitalPin.hpp.

◆ sock_

zmqpp::socket PFDigitalPin::sock_

listen to command from other component.

Definition at line 108 of file PFDigitalPin.hpp.

◆ want_update_

bool PFDigitalPin::want_update_

Does this object wants to be update()d ?

Definition at line 144 of file PFDigitalPin.hpp.


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