Leosac  0.8.0
Open Source Access Control
TestAndResetModule.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 
23 #include "modules/BaseModule.hpp"
24 
25 namespace Leosac
26 {
27 namespace Module
28 {
35 namespace TestAndReset
36 {
37 
39 {
40  public:
41  explicit TestAndResetModule(zmqpp::context &ctx, zmqpp::socket *pipe,
42  const boost::property_tree::ptree &cfg,
43  CoreUtilsPtr utils);
44 
45  TestAndResetModule(const TestAndResetModule &) = delete;
49 
50  virtual ~TestAndResetModule();
51 
52  private:
53  void process_config();
54 
60  void run_test_sequence();
61 
62  void handle_bus_msg();
63 
67  void test_sequence();
68 
73  bool has_reset_card(const std::string &card_id) const;
74 
78  zmqpp::socket kernel_sock_;
79 
83  zmqpp::socket sub_;
84 
89  std::map<std::string, std::string> device_reset_card_;
90 
94  std::map<std::string, std::string> device_test_card_;
95 
99  std::unique_ptr<Hardware::FLED> test_led_;
100 
104  std::unique_ptr<Hardware::FLED> test_buzzer_;
105 
110 
111  bool promisc_;
112 };
113 }
114 }
115 }
Leosac::Module::BaseModule
Base class for module implementation.
Definition: BaseModule.hpp:110
Leosac::Module::TestAndReset::TestAndResetModule::run_test_sequence
void run_test_sequence()
Do some stuff to let the user known something happened.
Definition: TestAndResetModule.cpp:134
Leosac::Module::TestAndReset::TestAndResetModule
Definition: TestAndResetModule.hpp:38
Leosac::Module::TestAndReset::TestAndResetModule::run_on_start_
bool run_on_start_
Play the sequence on module startup.
Definition: TestAndResetModule.hpp:109
BaseModule.hpp
Leosac::Module::TestAndReset::TestAndResetModule::TestAndResetModule
TestAndResetModule(zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
Definition: TestAndResetModule.cpp:31
Leosac::Module::TestAndReset::TestAndResetModule::test_sequence
void test_sequence()
Do some stuff to let the user known the test card was read.
Leosac::Module::TestAndReset::TestAndResetModule::device_test_card_
std::map< std::string, std::string > device_test_card_
Map a device name to the test card.
Definition: TestAndResetModule.hpp:94
Leosac::Module::TestAndReset::TestAndResetModule::kernel_sock_
zmqpp::socket kernel_sock_
REQ socket to kernel.
Definition: TestAndResetModule.hpp:78
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Module::TestAndReset::TestAndResetModule::has_reset_card
bool has_reset_card(const std::string &card_id) const
Search the device_reset_card_ map for an entry whose value is card_id;.
Definition: TestAndResetModule.cpp:151
Leosac::Module::TestAndReset::TestAndResetModule::process_config
void process_config()
Definition: TestAndResetModule.cpp:51
Leosac::Module::TestAndReset::TestAndResetModule::~TestAndResetModule
virtual ~TestAndResetModule()
Definition: TestAndResetModule.cpp:27
Leosac::Module::TestAndReset::TestAndResetModule::promisc_
bool promisc_
Definition: TestAndResetModule.hpp:111
Leosac::Module::TestAndReset::TestAndResetModule::test_led_
std::unique_ptr< Hardware::FLED > test_led_
Led device for test card.
Definition: TestAndResetModule.hpp:99
Leosac::Module::TestAndReset::TestAndResetModule::operator=
TestAndResetModule & operator=(const TestAndResetModule &)=delete
Leosac::Module::TestAndReset::TestAndResetModule::device_reset_card_
std::map< std::string, std::string > device_reset_card_
Map a device name to the reset card, since one device can support one reset card currently.
Definition: TestAndResetModule.hpp:89
Leosac::Module::TestAndReset::TestAndResetModule::test_buzzer_
std::unique_ptr< Hardware::FLED > test_buzzer_
Buzzer device for test card.
Definition: TestAndResetModule.hpp:104
Leosac::Module::TestAndReset::TestAndResetModule::handle_bus_msg
void handle_bus_msg()
Definition: TestAndResetModule.cpp:93
Leosac::Module::TestAndReset::TestAndResetModule::sub_
zmqpp::socket sub_
Sub socket on the BUS.
Definition: TestAndResetModule.hpp:83
FLED.hpp
Leosac::CoreUtilsPtr
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35