Leosac  0.8.0
Open Source Access Control
Leosac::Module::Wiegand::Strategy::WiegandCardAndPin Class Reference

Strategy for reading a card then a PIN code. More...

#include <WiegandCardAndPin.hpp>

+ Inheritance diagram for Leosac::Module::Wiegand::Strategy::WiegandCardAndPin:
+ Collaboration diagram for Leosac::Module::Wiegand::Strategy::WiegandCardAndPin:

Public Member Functions

 WiegandCardAndPin (WiegandReaderImpl *reader, CardReadingUPtr read_card, PinReadingUPtr read_pin, std::chrono::milliseconds delay)
 Create a strategy that read card and PIN code. More...
 
virtual void timeout () override
 This is called when the module detect a timeout. More...
 
virtual bool completed () const override
 Did the strategy gather needed data? If this function returns true, that means that the strategy implementation successfully retrieve data from wiegand bits. More...
 
virtual void signal (zmqpp::socket &sock) override
 Tells the strategy implementation to send a message to the application containing the received credentials. More...
 
virtual void set_reader (WiegandReaderImpl *new_ptr) override
 Update the pointer that points back to the associated reader. More...
 
- Public Member Functions inherited from Leosac::Module::Wiegand::Strategy::WiegandStrategy
 WiegandStrategy (WiegandReaderImpl *reader)
 
virtual ~WiegandStrategy ()=default
 

Private Types

using TimePoint = std::chrono::system_clock::time_point
 

Private Member Functions

void reset () override
 Reset self. More...
 

Private Attributes

CardReadingUPtr read_card_strategy_
 
PinReadingUPtr read_pin_strategy_
 
std::chrono::milliseconds delay_
 
TimePoint time_card_read_
 
bool reading_card_
 
bool ready_
 

Additional Inherited Members

- Protected Attributes inherited from Leosac::Module::Wiegand::Strategy::WiegandStrategy
WiegandReaderImplreader_
 

Detailed Description

Strategy for reading a card then a PIN code.

We reuse existing strategy.

Definition at line 38 of file WiegandCardAndPin.hpp.

Member Typedef Documentation

◆ TimePoint

using Leosac::Module::Wiegand::Strategy::WiegandCardAndPin::TimePoint = std::chrono::system_clock::time_point
private

Definition at line 73 of file WiegandCardAndPin.hpp.

Constructor & Destructor Documentation

◆ WiegandCardAndPin()

WiegandCardAndPin::WiegandCardAndPin ( WiegandReaderImpl reader,
CardReadingUPtr  read_card,
PinReadingUPtr  read_pin,
std::chrono::milliseconds  delay 
)

Create a strategy that read card and PIN code.

Parameters
readerthe reader object we provide the strategy for.
read_cardstrategy object that will read a card number.
read_pinstrategy object that will read a PIN code.
delaymax nb of msec between reading the card and receiving pin code data.

Definition at line 27 of file WiegandCardAndPin.cpp.

Member Function Documentation

◆ completed()

bool WiegandCardAndPin::completed ( ) const
overridevirtual

Did the strategy gather needed data? If this function returns true, that means that the strategy implementation successfully retrieve data from wiegand bits.

It successfully build a card_id, or a PIN code, etc. The reader implementation will call signal() if completed() returns true.

Implements Leosac::Module::Wiegand::Strategy::WiegandStrategy.

Definition at line 77 of file WiegandCardAndPin.cpp.

◆ reset()

void WiegandCardAndPin::reset ( )
overrideprivatevirtual

Reset self.

We create new strategy instance, reset the boolean flag to defaults and reset the underlying reader buffer.

Implements Leosac::Module::Wiegand::Strategy::WiegandStrategy.

Definition at line 102 of file WiegandCardAndPin.cpp.

◆ set_reader()

void WiegandCardAndPin::set_reader ( WiegandReaderImpl new_ptr)
overridevirtual

Update the pointer that points back to the associated reader.

Reimplemented from Leosac::Module::Wiegand::Strategy::WiegandStrategy.

Definition at line 95 of file WiegandCardAndPin.cpp.

◆ signal()

void WiegandCardAndPin::signal ( zmqpp::socket &  sock)
overridevirtual

Tells the strategy implementation to send a message to the application containing the received credentials.

It is up to the strategy to format a correct message. This is required because only the strategy knows what kind of credential it can generate.

Parameters
sockthe socket where we write the message containing credentials.

Implements Leosac::Module::Wiegand::Strategy::WiegandStrategy.

Definition at line 82 of file WiegandCardAndPin.cpp.

◆ timeout()

void WiegandCardAndPin::timeout ( )
overridevirtual

This is called when the module detect a timeout.

(2 ms of inactivity).

Implements Leosac::Module::Wiegand::Strategy::WiegandStrategy.

Definition at line 41 of file WiegandCardAndPin.cpp.

Member Data Documentation

◆ delay_

std::chrono::milliseconds Leosac::Module::Wiegand::Strategy::WiegandCardAndPin::delay_
private

Definition at line 72 of file WiegandCardAndPin.hpp.

◆ read_card_strategy_

CardReadingUPtr Leosac::Module::Wiegand::Strategy::WiegandCardAndPin::read_card_strategy_
private

Definition at line 69 of file WiegandCardAndPin.hpp.

◆ read_pin_strategy_

PinReadingUPtr Leosac::Module::Wiegand::Strategy::WiegandCardAndPin::read_pin_strategy_
private

Definition at line 70 of file WiegandCardAndPin.hpp.

◆ reading_card_

bool Leosac::Module::Wiegand::Strategy::WiegandCardAndPin::reading_card_
private

Definition at line 76 of file WiegandCardAndPin.hpp.

◆ ready_

bool Leosac::Module::Wiegand::Strategy::WiegandCardAndPin::ready_
private

Definition at line 77 of file WiegandCardAndPin.hpp.

◆ time_card_read_

TimePoint Leosac::Module::Wiegand::Strategy::WiegandCardAndPin::time_card_read_
private

Definition at line 74 of file WiegandCardAndPin.hpp.


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