Leosac  0.8.0
Open Source Access Control
WiegandReaderImpl.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 "core/auth/Auth.hpp"
26 #include "zmqpp/zmqpp.hpp"
27 #include <chrono>
28 #include <string>
29 
30 namespace Leosac
31 {
32 namespace Module
33 {
34 
35 namespace Wiegand
36 {
42 {
43  public:
53  WiegandReaderImpl(zmqpp::context &ctx, const std::string &reader_name,
54  const std::string &data_high_pin,
55  const std::string &data_low_pin,
56  const std::string &green_led_name,
57  const std::string &buzzer_name,
58  std::unique_ptr<Strategy::WiegandStrategy> strategy);
59 
61 
62  WiegandReaderImpl(const WiegandReaderImpl &) = delete;
63 
65 
67 
71  zmqpp::socket bus_sub_;
72 
76  zmqpp::socket sock_;
77 
81  void handle_bus_msg();
82 
86  void handle_request();
87 
94  void timeout();
95 
101  void read_reset();
102 
108  int counter() const;
109 
115  const unsigned char *buffer() const;
116 
120  const std::string &name() const;
121 
122  private:
126  zmqpp::socket bus_push_;
127 
131  std::string topic_high_;
132 
136  std::string topic_low_;
137 
141  std::array<uint8_t, 16> buffer_;
142 
146  int counter_;
147 
151  std::string name_;
152 
156  std::unique_ptr<Hardware::FLED> green_led_;
157 
161  std::unique_ptr<Hardware::FBuzzer> buzzer_;
162 
166  std::unique_ptr<Strategy::WiegandStrategy> strategy_;
167 };
168 }
169 }
170 }
Leosac::Module::Wiegand::WiegandReaderImpl::handle_request
void handle_request()
Someone sent a request.
Definition: WiegandReaderImpl.cpp:131
Leosac::Module::Wiegand::WiegandReaderImpl::buzzer_
std::unique_ptr< Hardware::FBuzzer > buzzer_
Facade to the buzzer object.
Definition: WiegandReaderImpl.hpp:161
Leosac::Module::Wiegand::WiegandReaderImpl::counter_
int counter_
Count the number of bits received from GPIOs.
Definition: WiegandReaderImpl.hpp:146
Leosac::Module::Wiegand::WiegandReaderImpl::topic_low_
std::string topic_low_
ZMQ topic-string to interrupt on LOW gpio (low gpio's name)
Definition: WiegandReaderImpl.hpp:136
Leosac::Module::Wiegand::WiegandReaderImpl
An implementation class that represents a Wiegand Reader.
Definition: WiegandReaderImpl.hpp:41
Auth.hpp
Leosac::Module::Wiegand::WiegandReaderImpl::handle_bus_msg
void handle_bus_msg()
Something happened on the bus.
Definition: WiegandReaderImpl.cpp:91
Leosac::Module::Wiegand::WiegandReaderImpl::timeout
void timeout()
Timeout (no more data burst to handle).
Definition: WiegandReaderImpl.cpp:117
WiegandStrategy.hpp
Leosac::Module::Wiegand::WiegandReaderImpl::strategy_
std::unique_ptr< Strategy::WiegandStrategy > strategy_
Concrete implementation of the reader mode.
Definition: WiegandReaderImpl.hpp:166
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Module::Wiegand::WiegandReaderImpl::sock_
zmqpp::socket sock_
REP socket to receive command on.
Definition: WiegandReaderImpl.hpp:76
Leosac::Module::Wiegand::WiegandReaderImpl::bus_push_
zmqpp::socket bus_push_
Socket to write to the message bus.
Definition: WiegandReaderImpl.hpp:126
Leosac::Module::Wiegand::WiegandReaderImpl::read_reset
void read_reset()
Reset the "read state" of the reader, effectively cleaning the wiegand-bit-buffer and resetting the c...
Definition: WiegandReaderImpl.cpp:192
Leosac::Module::Wiegand::WiegandReaderImpl::counter
int counter() const
Returns the number of bits read.
Definition: WiegandReaderImpl.cpp:203
Leosac::Module::Wiegand::WiegandReaderImpl::buffer
const unsigned char * buffer() const
Return a pointer to internal buffer memory.
Definition: WiegandReaderImpl.cpp:198
FBuzzer.hpp
Leosac::Module::Wiegand::WiegandReaderImpl::topic_high_
std::string topic_high_
ZMQ topic-string for interrupt on HIGH gpio (high gpio's name)
Definition: WiegandReaderImpl.hpp:131
Leosac::Module::Wiegand::WiegandReaderImpl::buffer_
std::array< uint8_t, 16 > buffer_
Buffer to store incoming bits from high and low gpios.
Definition: WiegandReaderImpl.hpp:141
FLED.hpp
Leosac::Module::Wiegand::WiegandReaderImpl::operator=
WiegandReaderImpl & operator=(const WiegandReaderImpl &)=delete
Leosac::Module::Wiegand::WiegandReaderImpl::WiegandReaderImpl
WiegandReaderImpl(zmqpp::context &ctx, const std::string &reader_name, const std::string &data_high_pin, const std::string &data_low_pin, const std::string &green_led_name, const std::string &buzzer_name, std::unique_ptr< Strategy::WiegandStrategy > strategy)
Create a new implementation of a Wiegand Reader.
Definition: WiegandReaderImpl.cpp:31
Leosac::Module::Wiegand::WiegandReaderImpl::~WiegandReaderImpl
~WiegandReaderImpl()
Definition: WiegandReaderImpl.cpp:67
Leosac::Module::Wiegand::WiegandReaderImpl::bus_sub_
zmqpp::socket bus_sub_
Socket that allows the reader to listen to the application BUS.
Definition: WiegandReaderImpl.hpp:71
Leosac::Module::Wiegand::WiegandReaderImpl::name
const std::string & name() const
Returns the name of this reader.
Definition: WiegandReaderImpl.cpp:208
Leosac::Module::Wiegand::WiegandReaderImpl::name_
std::string name_
Name of the device (defined in configuration)
Definition: WiegandReaderImpl.hpp:151
Leosac::Module::Wiegand::WiegandReaderImpl::green_led_
std::unique_ptr< Hardware::FLED > green_led_
Facade to control the reader green led.
Definition: WiegandReaderImpl.hpp:156