Leosac  0.8.0
Open Source Access Control
LedBuzzerImpl.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 "LedBuzzerSM.hpp"
24 #include "tools/log.hpp"
25 #include <chrono>
26 #include <zmqpp/zmqpp.hpp>
27 
28 namespace Leosac
29 {
30 namespace Module
31 {
32 namespace LedBuzzer
33 {
38 {
39  public:
45  LedBuzzerImpl(zmqpp::context &ctx, const std::string &led_name,
46  const std::string &gpio_name, int blink_duration, int blink_speed);
47 
51  zmqpp::socket &frontend();
52 
56  void handle_message();
57 
62  std::chrono::system_clock::time_point next_update();
63 
69  void update();
70 
71  private:
76  zmqpp::message send_to_backend(zmqpp::message &msg);
77 
82  void send_state();
83 
89  bool start_blink(zmqpp::message *msg);
90 
91  zmqpp::context &ctx_;
92 
96  zmqpp::socket frontend_;
97 
101  zmqpp::socket backend_;
102 
109 
112 
118 };
119 }
120 }
121 }
FGPIO.hpp
Leosac::Module::LedBuzzer::LedBuzzerImpl::ctx_
zmqpp::context & ctx_
Definition: LedBuzzerImpl.hpp:91
Leosac::Module::LedBuzzer::LedBuzzerImpl::default_blink_speed_
int64_t default_blink_speed_
Definition: LedBuzzerImpl.hpp:111
Leosac::Module::LedBuzzer::LedBuzzerImpl::stmachine_
LedBuzzerSM stmachine_
Our state machine that handle blinking, blinking in pattern or doing nothing.
Definition: LedBuzzerImpl.hpp:117
Leosac::Module::LedBuzzer::LedBuzzerImpl::default_blink_duration_
int64_t default_blink_duration_
Definition: LedBuzzerImpl.hpp:110
Leosac::Module::LedBuzzer::LedBuzzerImpl
Implementation class, for use by the LED module only.
Definition: LedBuzzerImpl.hpp:37
Leosac::Module::LedBuzzer::LedBuzzerImpl::next_update
std::chrono::system_clock::time_point next_update()
Time point of the next wanted update.
Definition: LedBuzzerImpl.cpp:89
Leosac::Module::LedBuzzer::LedBuzzerImpl::update
void update()
Update the object.
Definition: LedBuzzerImpl.cpp:83
Leosac::Hardware::FGPIO
A Facade to a GPIO object.
Definition: FGPIO.hpp:45
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Module::LedBuzzer::LedBuzzerImpl::send_state
void send_state()
Write the current state of the LED device (according to specs) to the frontend_ socket.
Definition: LedBuzzerImpl.cpp:125
LedBuzzerSM.hpp
Leosac::Module::LedBuzzer::LedBuzzerImpl::handle_message
void handle_message()
Message received on the rep_ socket.
Definition: LedBuzzerImpl.cpp:47
Leosac::Module::LedBuzzer::LedBuzzerImpl::frontend
zmqpp::socket & frontend()
Return the frontend_ socket.
Definition: LedBuzzerImpl.cpp:42
Leosac::Module::LedBuzzer::LedBuzzerImpl::send_to_backend
zmqpp::message send_to_backend(zmqpp::message &msg)
Send a message to the backend object (used for ON, OFF, TOGGLE).
Definition: LedBuzzerImpl.cpp:94
Leosac::Module::LedBuzzer::LedBuzzerImpl::start_blink
bool start_blink(zmqpp::message *msg)
Start blinking, this stores the blink_end timepoint and send commands for blinking to happen.
Definition: LedBuzzerImpl.cpp:103
Leosac::Module::LedBuzzer::LedBuzzerImpl::frontend_
zmqpp::socket frontend_
REP socket to receive LED command.
Definition: LedBuzzerImpl.hpp:96
Leosac::Module::LedBuzzer::LedBuzzerImpl::gpio_
Hardware::FGPIO gpio_
Facade to the GPIO we use with this LED.
Definition: LedBuzzerImpl.hpp:108
Leosac::Module::LedBuzzer::LedBuzzerImpl::backend_
zmqpp::socket backend_
REQ socket to the backend GPIO.
Definition: LedBuzzerImpl.hpp:101
log.hpp
Leosac::Module::LedBuzzer::LedBuzzerImpl::LedBuzzerImpl
LedBuzzerImpl(zmqpp::context &ctx, const std::string &led_name, const std::string &gpio_name, int blink_duration, int blink_speed)
Definition: LedBuzzerImpl.cpp:25
Leosac::Module::LedBuzzer::LedBuzzerSM
boost::msm::back::state_machine< SM::LedBuzzerSM_ > LedBuzzerSM
Definition: LedBuzzerSM.hpp:331