Leosac
0.8.0
Open Source Access Control
|
Variable strategy that tries to autodetect what it reads. More...
#include <Autodetect.hpp>
Public Member Functions | |
Autodetect (WiegandReaderImpl *reader, std::chrono::milliseconds delay, char pin_key_end, bool nowait) | |
Create a strategy that read whatever it can and tries its best to determine what is was that it read. 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... | |
PinReadingUPtr | build_strategy (int bits) |
Dynamically instanciate a new strategy based on the number of bits available. More... | |
void | check_timeout () |
Called when timeout() was called but nothing was read. More... | |
Private Attributes | |
CardReadingUPtr | read_card_strategy_ |
PinReadingUPtr | read_pin_strategy_ |
std::chrono::milliseconds | delay_ |
TimePoint | time_card_read_ |
TimePoint | last_pin_read_ |
bool | reading_pin_ |
bool | reading_card_ |
bool | ready_ |
char | pin_key_end_ |
bool | nowait_ |
Additional Inherited Members | |
Protected Attributes inherited from Leosac::Module::Wiegand::Strategy::WiegandStrategy | |
WiegandReaderImpl * | reader_ |
Variable strategy that tries to autodetect what it reads.
It can credentials multiple type of credentials, based on what was detected.
We have 3 possible scenario:
Definition at line 42 of file Autodetect.hpp.
|
private |
Definition at line 94 of file Autodetect.hpp.
Autodetect::Autodetect | ( | WiegandReaderImpl * | reader, |
std::chrono::milliseconds | delay, | ||
char | pin_key_end, | ||
bool | nowait | ||
) |
Create a strategy that read whatever it can and tries its best to determine what is was that it read.
reader | the reader object we provide the strategy for. |
delay | max nb of msec between reading the card and receiving pin code data. |
pin_key_end | what key on the reader signals the end of the pin code ? |
Definition at line 27 of file Autodetect.cpp.
|
private |
Dynamically instanciate a new strategy based on the number of bits available.
This depends on the wiegand reader mode, and this class support either 4 or 8 bits.
Definition at line 178 of file Autodetect.cpp.
|
private |
Called when timeout()
was called but nothing was read.
Definition at line 87 of file Autodetect.cpp.
|
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 129 of file Autodetect.cpp.
|
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 166 of file Autodetect.cpp.
|
overridevirtual |
Update the pointer that points back to the associated reader.
Reimplemented from Leosac::Module::Wiegand::Strategy::WiegandStrategy.
Definition at line 158 of file Autodetect.cpp.
|
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.
sock | the socket where we write the message containing credentials. |
Implements Leosac::Module::Wiegand::Strategy::WiegandStrategy.
Definition at line 134 of file Autodetect.cpp.
|
overridevirtual |
This is called when the module detect a timeout.
(2 ms of inactivity).
Implements Leosac::Module::Wiegand::Strategy::WiegandStrategy.
Definition at line 43 of file Autodetect.cpp.
|
private |
Definition at line 93 of file Autodetect.hpp.
|
private |
Definition at line 96 of file Autodetect.hpp.
|
private |
Definition at line 103 of file Autodetect.hpp.
|
private |
Definition at line 102 of file Autodetect.hpp.
|
private |
Definition at line 90 of file Autodetect.hpp.
|
private |
Definition at line 91 of file Autodetect.hpp.
|
private |
Definition at line 99 of file Autodetect.hpp.
|
private |
Definition at line 98 of file Autodetect.hpp.
|
private |
Definition at line 100 of file Autodetect.hpp.
|
private |
Definition at line 95 of file Autodetect.hpp.