Leosac  0.8.0
Open Source Access Control
Autodetect.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "Strategies.hpp"
23 
24 namespace Leosac
25 {
26 namespace Module
27 {
28 
29 namespace Wiegand
30 {
31 namespace Strategy
32 {
43 {
44  public:
54  Autodetect(WiegandReaderImpl *reader, std::chrono::milliseconds delay,
55  char pin_key_end, bool nowait);
56 
57  virtual void timeout() override;
58 
59  virtual bool completed() const override;
60 
61  virtual void signal(zmqpp::socket &sock) override;
62 
63  virtual void set_reader(WiegandReaderImpl *new_ptr) override;
64 
65  private:
71  void reset() override;
72 
84 
88  void check_timeout();
89 
92 
93  std::chrono::milliseconds delay_;
94  using TimePoint = std::chrono::system_clock::time_point;
97 
100  bool ready_;
101 
103  bool nowait_;
104 };
105 }
106 }
107 }
108 }
Leosac::Module::Wiegand::Strategy::Autodetect::TimePoint
std::chrono::system_clock::time_point TimePoint
Definition: Autodetect.hpp:94
Strategies.hpp
Leosac::Module::Wiegand::Strategy::CardReadingUPtr
std::unique_ptr< CardReading > CardReadingUPtr
Definition: CardReading.hpp:34
Leosac::Module::Wiegand::Strategy::Autodetect::nowait_
bool nowait_
Definition: Autodetect.hpp:103
Leosac::Module::Wiegand::WiegandReaderImpl
An implementation class that represents a Wiegand Reader.
Definition: WiegandReaderImpl.hpp:41
Leosac::Module::Wiegand::Strategy::Autodetect::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.
Definition: Autodetect.cpp:27
Leosac::Module::Wiegand::Strategy::Autodetect
Variable strategy that tries to autodetect what it reads.
Definition: Autodetect.hpp:42
Leosac::Module::Wiegand::Strategy::Autodetect::signal
virtual void signal(zmqpp::socket &sock) override
Tells the strategy implementation to send a message to the application containing the received creden...
Definition: Autodetect.cpp:134
Leosac::Module::Wiegand::Strategy::Autodetect::reading_pin_
bool reading_pin_
Definition: Autodetect.hpp:98
Leosac::Module::Wiegand::Strategy::Autodetect::time_card_read_
TimePoint time_card_read_
Definition: Autodetect.hpp:95
Leosac::Module::Wiegand::Strategy::Autodetect::ready_
bool ready_
Definition: Autodetect.hpp:100
Leosac::Module::Wiegand::Strategy::Autodetect::reading_card_
bool reading_card_
Definition: Autodetect.hpp:99
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Module::Wiegand::Strategy::Autodetect::set_reader
virtual void set_reader(WiegandReaderImpl *new_ptr) override
Update the pointer that points back to the associated reader.
Definition: Autodetect.cpp:158
Leosac::Module::Wiegand::Strategy::Autodetect::read_pin_strategy_
PinReadingUPtr read_pin_strategy_
Definition: Autodetect.hpp:91
Leosac::Module::Wiegand::Strategy::Autodetect::pin_key_end_
char pin_key_end_
Definition: Autodetect.hpp:102
Leosac::Module::Wiegand::Strategy::Autodetect::delay_
std::chrono::milliseconds delay_
Definition: Autodetect.hpp:93
Leosac::Module::Wiegand::Strategy::Autodetect::build_strategy
PinReadingUPtr build_strategy(int bits)
Dynamically instanciate a new strategy based on the number of bits available.
Definition: Autodetect.cpp:178
Leosac::Module::Wiegand::Strategy::WiegandStrategy
The multiple modes available to wiegand reader are implemented through the strategy pattern.
Definition: WiegandStrategy.hpp:50
Leosac::Module::Wiegand::Strategy::Autodetect::timeout
virtual void timeout() override
This is called when the module detect a timeout.
Definition: Autodetect.cpp:43
Leosac::Module::Wiegand::Strategy::Autodetect::last_pin_read_
TimePoint last_pin_read_
Definition: Autodetect.hpp:96
Leosac::Module::Wiegand::Strategy::PinReadingUPtr
std::unique_ptr< PinReading > PinReadingUPtr
Definition: StrategiesFwd.hpp:33
Leosac::Module::Wiegand::Strategy::Autodetect::completed
virtual bool completed() const override
Did the strategy gather needed data? If this function returns true, that means that the strategy impl...
Definition: Autodetect.cpp:129
Leosac::Module::Wiegand::Strategy::Autodetect::read_card_strategy_
CardReadingUPtr read_card_strategy_
Definition: Autodetect.hpp:90
Leosac::Module::Wiegand::Strategy::Autodetect::reset
void reset() override
Reset self.
Definition: Autodetect.cpp:166
Leosac::Module::Wiegand::Strategy::Autodetect::check_timeout
void check_timeout()
Called when timeout() was called but nothing was read.
Definition: Autodetect.cpp:87