diff --git a/FlippR-Driver/.gitignore b/FlippR-Driver/.gitignore index 85c2775..5f4398f 100644 --- a/FlippR-Driver/.gitignore +++ b/FlippR-Driver/.gitignore @@ -1,3 +1,4 @@ +.csettings/* build CMakeFiles CMakeCache.txt diff --git a/FlippR-Driver/cli/CMakeLists.txt b/FlippR-Driver/cli/CMakeLists.txt index 0611739..e8fa52e 100644 --- a/FlippR-Driver/cli/CMakeLists.txt +++ b/FlippR-Driver/cli/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.6.2) -project(FlippR_Driver_CLI) +project(flippR_driver_CLI) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/${OUTPUT_PATH}/cli) add_executable(${PROJECT_NAME} main.cpp PrintHandler.cpp) diff --git a/FlippR-Driver/cli/PrintHandler.cpp b/FlippR-Driver/cli/PrintHandler.cpp index 247947b..bb7dabf 100644 --- a/FlippR-Driver/cli/PrintHandler.cpp +++ b/FlippR-Driver/cli/PrintHandler.cpp @@ -5,14 +5,14 @@ #include "PrintHandler.h" #include -PrintHandler::PrintHandler(std::shared_ptr driver) : -FlippR_Driver::Input::EventHandler(driver) +PrintHandler::PrintHandler(std::shared_ptr driver) : +flippR_driver::input::EventHandler(driver) { } -void PrintHandler::handle(FlippR_Driver::Input::Event &event) +void PrintHandler::handle(flippR_driver::input::Event &event) { std::cout << "Event " << event.name << " (" << std::to_string(event.address) << ") occured!\n"; } \ No newline at end of file diff --git a/FlippR-Driver/cli/PrintHandler.h b/FlippR-Driver/cli/PrintHandler.h index c193bb0..d591eae 100644 --- a/FlippR-Driver/cli/PrintHandler.h +++ b/FlippR-Driver/cli/PrintHandler.h @@ -2,20 +2,20 @@ // Created by rhetenor on 13.09.18. // -#ifndef FLIPPR_DRIVER_PRINTHANDLER_H -#define FLIPPR_DRIVER_PRINTHANDLER_H +#ifndef flippR_driver_PRINTHANDLER_H +#define flippR_driver_PRINTHANDLER_H #include #include "EventHandler.h" #include "IInputDriver.h" -class PrintHandler : public FlippR_Driver::Input::EventHandler +class PrintHandler : public flippR_driver::input::EventHandler { public: - PrintHandler(std::shared_ptr driver); + PrintHandler(std::shared_ptr driver); - virtual void handle(FlippR_Driver::Input::Event& event) override; + virtual void handle(flippR_driver::input::Event& event) override; }; -#endif //FLIPPR_DRIVER_PRINTHANDLER_H +#endif //flippR_driver_PRINTHANDLER_H diff --git a/FlippR-Driver/cli/main.cpp b/FlippR-Driver/cli/main.cpp index a7674c4..90522e2 100644 --- a/FlippR-Driver/cli/main.cpp +++ b/FlippR-Driver/cli/main.cpp @@ -11,7 +11,7 @@ #include "PrintHandler.h" -using namespace FlippR_Driver; +using namespace flippR_driver; void siginthandler(int param) { @@ -45,7 +45,7 @@ int main (int argc, char *argv[]) exit(2); } - std::shared_ptr driver = FlippR_Driver::get_InputDriver(input_config, matrix_config); + std::shared_ptr driver = flippR_driver::get_InputDriver(input_config, matrix_config); PrintHandler* print_handler = new PrintHandler(driver); diff --git a/FlippR-Driver/contrib/ideen.txt b/FlippR-Driver/contrib/ideen.txt new file mode 100644 index 0000000..95eec6d --- /dev/null +++ b/FlippR-Driver/contrib/ideen.txt @@ -0,0 +1 @@ + input events entprellen über flanken statt zeit diff --git a/FlippR-Driver/include/DriverFactory.h b/FlippR-Driver/include/DriverFactory.h index cbe4340..e16b122 100644 --- a/FlippR-Driver/include/DriverFactory.h +++ b/FlippR-Driver/include/DriverFactory.h @@ -2,17 +2,17 @@ // Created by rhetenor on 13.09.18. // -#ifndef FLIPPR_DRIVER_DRIVERFACTORY_H -#define FLIPPR_DRIVER_DRIVERFACTORY_H +#ifndef flippR_driver_DRIVERFACTORY_H +#define flippR_driver_DRIVERFACTORY_H #include #include #include "IInputDriver.h" -namespace FlippR_Driver +namespace flippR_driver { - std::shared_ptr get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream); + std::shared_ptr get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream); } -#endif //FLIPPR_DRIVER_DRIVERFACTORY_H +#endif //flippR_driver_DRIVERFACTORY_H diff --git a/FlippR-Driver/include/Event.h b/FlippR-Driver/include/Event.h index 081f2e0..f14e58f 100644 --- a/FlippR-Driver/include/Event.h +++ b/FlippR-Driver/include/Event.h @@ -12,8 +12,8 @@ #include #include -namespace FlippR_Driver { - namespace Input { +namespace flippR_driver { + namespace input { class Event { public: diff --git a/FlippR-Driver/include/EventHandler.h b/FlippR-Driver/include/EventHandler.h index 3711653..5bda799 100644 --- a/FlippR-Driver/include/EventHandler.h +++ b/FlippR-Driver/include/EventHandler.h @@ -17,9 +17,9 @@ #include "IEventHandler.h" #include "Event.h" -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { class EventHandler; diff --git a/FlippR-Driver/include/IEventHandler.h b/FlippR-Driver/include/IEventHandler.h index 18b9041..5c52985 100644 --- a/FlippR-Driver/include/IEventHandler.h +++ b/FlippR-Driver/include/IEventHandler.h @@ -15,7 +15,7 @@ class IEventHandler public: virtual ~IEventHandler(){}; - virtual void handle(FlippR_Driver::Input::Event& event) = 0; + virtual void handle(flippR_driver::input::Event& event) = 0; }; #endif /* SRC_IEVENTHANDLER_H_ */ diff --git a/FlippR-Driver/include/IInputDriver.h b/FlippR-Driver/include/IInputDriver.h index 3ed4562..d3f1726 100644 --- a/FlippR-Driver/include/IInputDriver.h +++ b/FlippR-Driver/include/IInputDriver.h @@ -11,9 +11,9 @@ #include "IEventHandler.h" #include -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { class IInputDriver { public: diff --git a/FlippR-Driver/src/DriverFactory.cpp b/FlippR-Driver/src/DriverFactory.cpp index 702db9d..05bfc89 100644 --- a/FlippR-Driver/src/DriverFactory.cpp +++ b/FlippR-Driver/src/DriverFactory.cpp @@ -5,10 +5,10 @@ #include "DriverFactory.h" #include "input/InputDriverFactory.h" -namespace FlippR_Driver +namespace flippR_driver { - std::shared_ptr get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream) + std::shared_ptr get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream) { - return FlippR_Driver::Input::InputDriverFactory::get_InputDriver(input_config_stream, matrix_config_stream); + return flippR_driver::input::InputDriverFactory::get_InputDriver(input_config_stream, matrix_config_stream); } -} \ No newline at end of file +} diff --git a/FlippR-Driver/src/input/Detector.cpp b/FlippR-Driver/src/input/Detector.cpp index 146221a..ffe4274 100644 --- a/FlippR-Driver/src/input/Detector.cpp +++ b/FlippR-Driver/src/input/Detector.cpp @@ -10,14 +10,14 @@ #include #include -#include "utilities/config.h" +#include "utility/config.h" -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { -Detector::Detector(std::unique_ptr input_gpio_interface, std::vector> events) : +Detector::Detector(std::unique_ptr input_gpio_interface, std::vector> events) : input_gpio_interface(std::move(input_gpio_interface)), events(events), is_running(true) { this->detect_thread = std::thread(&Detector::detect, this); @@ -49,4 +49,4 @@ void Detector::check_inputs() } } -} \ No newline at end of file +} diff --git a/FlippR-Driver/src/input/Detector.h b/FlippR-Driver/src/input/Detector.h index b2cfe40..1b7f6fa 100644 --- a/FlippR-Driver/src/input/Detector.h +++ b/FlippR-Driver/src/input/Detector.h @@ -19,22 +19,22 @@ #include #include -#include "utilities/IInputGPIOInterface.h" +#include "utility/IInputGPIOInterface.h" #include "IDetector.h" #include "DistributingEvent.h" #include "IEventNotifier.h" -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { class Detector : public IDetector { public: - Detector(std::unique_ptr input_gpio_interface, std::vector> events); + Detector(std::unique_ptr input_gpio_interface, std::vector> events); ~Detector(); private: @@ -42,7 +42,7 @@ private: void check_inputs(); private: - std::unique_ptr input_gpio_interface; + std::unique_ptr input_gpio_interface; std::vector> events; @@ -52,4 +52,4 @@ private: } } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/input/DistributingEvent.cpp b/FlippR-Driver/src/input/DistributingEvent.cpp index dbbe61c..25603de 100644 --- a/FlippR-Driver/src/input/DistributingEvent.cpp +++ b/FlippR-Driver/src/input/DistributingEvent.cpp @@ -4,7 +4,7 @@ #include "DistributingEvent.h" -FlippR_Driver::Input::DistributingEvent::DistributingEvent(char address, int priority, std::string name, +flippR_driver::input::DistributingEvent::DistributingEvent(char address, int priority, std::string name, std::chrono::milliseconds bounce_time, std::shared_ptr event_notifier): Event(address, priority, name), bounce_time(bounce_time), @@ -12,12 +12,12 @@ FlippR_Driver::Input::DistributingEvent::DistributingEvent(char address, int pri activation_state(NOT_ACTIVATED) {} -void FlippR_Driver::Input::DistributingEvent::distribute() +void flippR_driver::input::DistributingEvent::distribute() { event_notifier->distribute_event(*this); } -void FlippR_Driver::Input::DistributingEvent::active() +void flippR_driver::input::DistributingEvent::active() { if(!is_bouncing()) { @@ -35,7 +35,7 @@ void FlippR_Driver::Input::DistributingEvent::active() } } -bool FlippR_Driver::Input::DistributingEvent::is_bouncing() +bool flippR_driver::input::DistributingEvent::is_bouncing() { std::chrono::time_point now = std::chrono::high_resolution_clock::now(); std::chrono::milliseconds elapsed_time = std::chrono::duration_cast(now - last_activation); @@ -43,7 +43,7 @@ bool FlippR_Driver::Input::DistributingEvent::is_bouncing() return elapsed_time < bounce_time; } -void FlippR_Driver::Input::DistributingEvent::inactive() +void flippR_driver::input::DistributingEvent::inactive() { if(activation_state == ACTIVATED) { diff --git a/FlippR-Driver/src/input/DistributingEvent.h b/FlippR-Driver/src/input/DistributingEvent.h index 9ed30ca..3cec71a 100644 --- a/FlippR-Driver/src/input/DistributingEvent.h +++ b/FlippR-Driver/src/input/DistributingEvent.h @@ -2,15 +2,15 @@ // Created by rhetenor on 21.09.18. // -#ifndef FLIPPR_DRIVER_DISTRIBUTINGEVENT_H -#define FLIPPR_DRIVER_DISTRIBUTINGEVENT_H +#ifndef flippR_driver_DISTRIBUTINGEVENT_H +#define flippR_driver_DISTRIBUTINGEVENT_H #include "Event.h" #include "IEventNotifier.h" -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { class DistributingEvent : public Event { @@ -45,4 +45,4 @@ private: } } -#endif //FLIPPR_DRIVER_DISTRIBUTINGEVENT_H +#endif //flippR_driver_DISTRIBUTINGEVENT_H diff --git a/FlippR-Driver/src/input/ErrorEvent.hpp b/FlippR-Driver/src/input/ErrorEvent.hpp index 55353a4..12f286d 100644 --- a/FlippR-Driver/src/input/ErrorEvent.hpp +++ b/FlippR-Driver/src/input/ErrorEvent.hpp @@ -10,15 +10,16 @@ #include "Event.h" -namespace FlippR_Driver { - namespace Input { +namespace flippR_driver { +namespace input { - class ErrorEvent : public Event { - public: - ErrorEvent() : - Event(0, 0, "ERROR") {} - }; - } +class ErrorEvent : public Event +{ +public: + ErrorEvent() : Event(0, 0, "ERROR") {} +}; + +} } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/input/Event.cpp b/FlippR-Driver/src/input/Event.cpp index 52c3ada..49b09f2 100644 --- a/FlippR-Driver/src/input/Event.cpp +++ b/FlippR-Driver/src/input/Event.cpp @@ -6,18 +6,18 @@ */ #include "Event.h" -#include "utilities/config.h" +#include "utility/config.h" -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { // todo unsigned char address Event::Event(char address, int priority, std::string name) : address(address), priority(priority), name(name) { - CLOG_IF(VLOG_IS_ON(HIGHEST_LOG_VERBOSITY), INFO, INPUT_LOGGER) << "Created event: " << name << ", address: " << address; + CLOG_IF(VLOG_IS_ON(0), INFO, INPUT_LOGGER) << "Created event: " << name << ", address: " << address; } bool operator==(const Event& left, const Event& right) @@ -26,4 +26,4 @@ bool operator==(const Event& left, const Event& right) } } -} \ No newline at end of file +} diff --git a/FlippR-Driver/src/input/EventHandler.cpp b/FlippR-Driver/src/input/EventHandler.cpp index c053113..6f16bc3 100644 --- a/FlippR-Driver/src/input/EventHandler.cpp +++ b/FlippR-Driver/src/input/EventHandler.cpp @@ -5,32 +5,32 @@ * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht */ #include "EventHandler.h" -#include "utilities/config.h" +#include "utility/config.h" -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { - EventHandler::EventHandler(std::shared_ptr input_driver) : - input_driver(input_driver) - { - this->input_driver->register_event_handler(this); +EventHandler::EventHandler(std::shared_ptr input_driver) : + input_driver(input_driver) +{ + this->input_driver->register_event_handler(this); - CLOG(INFO, INPUT_LOGGER) << "Created EventHandler"; - } + CLOG(INFO, INPUT_LOGGER) << "Created EventHandler"; +} - EventHandler::~EventHandler() - { - this->input_driver->unregister_event_handler(this); - this->input_driver = NULL; - } +EventHandler::~EventHandler() +{ + this->input_driver->unregister_event_handler(this); + this->input_driver = NULL; +} - // This function is intended to be non pure, if it is called when the derived class doesn't exist anymore - void EventHandler::handle(Event& event) - { - CLOG(WARNING, INPUT_LOGGER) << "Called EventHandler parent class"; - } +// This function is intended to be non pure, if it is called when the derived class doesn't exist anymore +void EventHandler::handle(Event& event) +{ + CLOG(WARNING, INPUT_LOGGER) << "Called EventHandler parent class"; +} } -} \ No newline at end of file +} diff --git a/FlippR-Driver/src/input/EventNotifier.cpp b/FlippR-Driver/src/input/EventNotifier.cpp index 00a786a..0e2025f 100644 --- a/FlippR-Driver/src/input/EventNotifier.cpp +++ b/FlippR-Driver/src/input/EventNotifier.cpp @@ -7,16 +7,16 @@ #include -#include "utilities/config.h" +#include "utility/config.h" #include "EventNotifier.h" -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { -EventNotifier::EventNotifier(IBlockingQueue* queue) : +EventNotifier::EventNotifier(utility::IBlockingQueue* queue) : is_running(true), event_queue(queue) { @@ -82,4 +82,4 @@ void EventNotifier::notify() } } -} \ No newline at end of file +} diff --git a/FlippR-Driver/src/input/EventNotifier.h b/FlippR-Driver/src/input/EventNotifier.h index 5d20a75..45d51d3 100644 --- a/FlippR-Driver/src/input/EventNotifier.h +++ b/FlippR-Driver/src/input/EventNotifier.h @@ -14,23 +14,23 @@ #include #include -#include "utilities/BlockingQueue.hpp" -#include "utilities/IBlockingQueue.h" +#include "utility/BlockingQueue.hpp" +#include "utility/IBlockingQueue.h" #include "Event.h" #include "EventHandler.h" #define HANDLER_TIMEOUT 2000 -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { class EventNotifier : public IEventNotifier { public: - EventNotifier(IBlockingQueue* queue); + EventNotifier(utility::IBlockingQueue* queue); ~EventNotifier(); void register_event_handler(IEventHandler* handler); @@ -42,7 +42,7 @@ private: void notify(); private: - IBlockingQueue* event_queue; + utility::IBlockingQueue* event_queue; std::set event_handlers; bool is_running; @@ -54,4 +54,4 @@ private: } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/input/IDetector.h b/FlippR-Driver/src/input/IDetector.h index 65966ac..5500d33 100644 --- a/FlippR-Driver/src/input/IDetector.h +++ b/FlippR-Driver/src/input/IDetector.h @@ -9,9 +9,9 @@ #define SRC_INPUT_IDETECTOR_H_ -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { class IDetector diff --git a/FlippR-Driver/src/input/IEventNotifier.h b/FlippR-Driver/src/input/IEventNotifier.h index 4353275..425fabf 100644 --- a/FlippR-Driver/src/input/IEventNotifier.h +++ b/FlippR-Driver/src/input/IEventNotifier.h @@ -12,9 +12,9 @@ #include "IEventHandler.h" #include -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { class IEventNotifier diff --git a/FlippR-Driver/src/input/InputDriver.cpp b/FlippR-Driver/src/input/InputDriver.cpp index 2897af0..04f8a35 100644 --- a/FlippR-Driver/src/input/InputDriver.cpp +++ b/FlippR-Driver/src/input/InputDriver.cpp @@ -6,13 +6,13 @@ */ #include "InputDriver.h" -#include "utilities/config.h" +#include "utility/config.h" #include -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { InputDriver::InputDriver(std::shared_ptr event_notifier, std::unique_ptr detector, @@ -42,9 +42,8 @@ std::shared_ptr InputDriver::get_event(std::string name) catch(std::out_of_range &e) { CLOG_N_TIMES(1, WARNING, OUTPUT_LOGGER) << "Did not found event " << name << " please check config file!"; - - return event; } + return event; } } diff --git a/FlippR-Driver/src/input/InputDriver.h b/FlippR-Driver/src/input/InputDriver.h index 02e27de..07781fd 100644 --- a/FlippR-Driver/src/input/InputDriver.h +++ b/FlippR-Driver/src/input/InputDriver.h @@ -13,9 +13,9 @@ #include "IInputDriver.h" #include "IDetector.h" -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { class InputDriver : public IInputDriver diff --git a/FlippR-Driver/src/input/InputDriverFactory.cpp b/FlippR-Driver/src/input/InputDriverFactory.cpp index 9f96e1f..a2dc396 100644 --- a/FlippR-Driver/src/input/InputDriverFactory.cpp +++ b/FlippR-Driver/src/input/InputDriverFactory.cpp @@ -8,21 +8,21 @@ #include "InputDriverFactory.h" -#include "utilities/config.h" +#include "utility/config.h" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" #include "InputDriver.h" #include "EventNotifier.h" using namespace nlohmann; +using namespace flippR_driver::utility; - -namespace FlippR_Driver +namespace flippR_driver { -namespace Input +namespace input { -std::shared_ptr InputDriverFactory::get_InputDriver(std::istream &input_config_stream, std::istream &matrix_config_stream) +std::shared_ptr InputDriverFactory::get_InputDriver(std::istream &input_config_stream, std::istream &matrix_config_stream) { LoggerFactory::CreateInputLogger(); @@ -52,9 +52,9 @@ void InputDriverFactory::create_input_events(json matrix_config, std::vector(); auto& event_array = matrix_config.at("input_matrix"); - for (auto &json_event : event_array) + for (auto &json_event : event_array) { - try + try { std::string name = json_event.at("name"); char address = json_event.at("address").get(); @@ -73,7 +73,7 @@ void InputDriverFactory::create_input_events(json matrix_config, std::vector -namespace FlippR_Driver +namespace flippR_driver { namespace output { template -class Display : public IDisplay +class Display : public IDisplay { public: - Display(); + Display(int address, int id); virtual ~Display() = default; virtual int getID(); @@ -34,8 +34,17 @@ public: private: int address; int id; + + std::string fit_string(std::string& score_string); }; +using SevenDigitDisplay = Display<7>; +using EightDigitDisply = Display<8>; + } /* namespace output */ } -#endif \ No newline at end of file + +#include "Display.hpp" + + +#endif diff --git a/FlippR-Driver/src/output/Display.hpp b/FlippR-Driver/src/output/Display.hpp new file mode 100644 index 0000000..8845a06 --- /dev/null +++ b/FlippR-Driver/src/output/Display.hpp @@ -0,0 +1,63 @@ +// +// Created by rhetenor on 10.10.18. +// + +#include "utility/config.h" + +#include +#include + + +namespace flippR_driver +{ +namespace output +{ + +template +Display::Display(int address, int id) : + address(address), + id(id) +{ +} + +template +int Display::getID() +{ + return this->id; +} + +template +void Display::write_score(int score) +{ + auto score_string = std::to_string(score); + + auto score_c_string = this->fit_string(score_string).c_str(); + + std::copy(std::begin(score_c_string), std::end(score_c_string), std::begin(this->content)); +} + +template +std::string Display::fit_string(std::string& score_string) +{ + auto score_length = score_string.length(); + + if (score_length > DigitCount) + { + CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display"; + std::string full_display; + // TODO mach mal schöner hier wird 9999 angezeigt wenn die zahl zu groß is + return full_display.insert(0, DigitCount, '9'); + } + + score_string.insert(0, DigitCount-score_length, '\0'); + return score_string; +} + +template +void Display::write_content( std::array content) +{ + this->content = content; +} + +} +} diff --git a/FlippR-Driver/src/output/DisplayController.cpp b/FlippR-Driver/src/output/DisplayController.cpp index 80b27c8..7d72418 100644 --- a/FlippR-Driver/src/output/DisplayController.cpp +++ b/FlippR-Driver/src/output/DisplayController.cpp @@ -6,15 +6,16 @@ */ #include "DisplayController.h" +#include "utility/IOutputGPIOInterface.h" #include "utility/config.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { -DisplayController::DisplayController(std::vector> displays, std::shared_ptr output_gpio_interface) +DisplayController::DisplayController(std::vector> displays, std::shared_ptr output_gpio_interface) : displays(displays), output_gpio_interface(output_gpio_interface), is_running(true) { this->display_cycle_thread = std::thread(&DisplayController::cycle_displays, this); @@ -33,9 +34,9 @@ void DisplayController::cycle_displays() { while(is_running) { - for(auto& display : displays) + for(auto& display : this->displays) { - + } } } diff --git a/FlippR-Driver/src/output/DisplayController.h b/FlippR-Driver/src/output/DisplayController.h index e55279b..97c8069 100644 --- a/FlippR-Driver/src/output/DisplayController.h +++ b/FlippR-Driver/src/output/DisplayController.h @@ -14,9 +14,9 @@ #include #include "IDisplay.h" -#include "utilities/IOutputGPIOInterface.h" +#include "utility/IOutputGPIOInterface.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { @@ -24,7 +24,7 @@ namespace output class DisplayController : public IDisplayController { public: - DisplayController(std::vector> displays, std::shared_ptr output_gpio_interface); + explicit DisplayController(std::vector> displays, std::shared_ptr output_gpio_interface); ~DisplayController(); private: @@ -35,11 +35,11 @@ private: std::thread display_cycle_thread; - std::shared_ptr output_gpio_interface; + std::shared_ptr output_gpio_interface; bool is_running; }; } } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/output/IDisplay.h b/FlippR-Driver/src/output/IDisplay.h index 362278a..1da90d7 100644 --- a/FlippR-Driver/src/output/IDisplay.h +++ b/FlippR-Driver/src/output/IDisplay.h @@ -8,22 +8,28 @@ #ifndef _SRC_OUTPUT_IDISPLAY_H_ #define _SRC_OUTPUT_IDISPLAY_H_ -namespace FlippR_Driver +#include + +namespace flippR_driver { namespace output { - class IDisplay { + public: IDisplay(); virtual ~IDisplay(); + virtual void write_score(int score) = 0; + virtual void write_content(std::array content) = 0; + virtual int getID() = 0; - virtual void write() = 0; +private: + std::string fit_string(std::string& score_string); }; } /* namespace output */ } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/output/IDisplayController.h b/FlippR-Driver/src/output/IDisplayController.h index 1fade72..ce55cdf 100644 --- a/FlippR-Driver/src/output/IDisplayController.h +++ b/FlippR-Driver/src/output/IDisplayController.h @@ -7,18 +7,19 @@ #ifndef _SRC_OUTPUT_IDISPLAYCONTROLLER_H_ #define _SRC_OUTPUT_IDISPLAYCONTROLLER_H_ -namespace FlippR_Driver +namespace flippR_driver { namespace output { class IDisplayController { + public: - IDisplayController(); - virtual ~IDisplayController(); + IDisplayController (); + virtual ~IDisplayController (); }; } /* namespace output */ } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/output/ILamp.h b/FlippR-Driver/src/output/ILamp.h index 95402be..0484183 100644 --- a/FlippR-Driver/src/output/ILamp.h +++ b/FlippR-Driver/src/output/ILamp.h @@ -8,14 +8,12 @@ #ifndef _SRC_OUTPUT_ILAMP_H_ #define _SRC_OUTPUT_ILAMP_H_ -#include "IOutputItem.h" - -namespace FlippR_Driver +namespace flippR_driver { namespace output { -class ILamp : public IOutputItem +class ILamp { }; diff --git a/FlippR-Driver/src/output/IOutputDriver.h b/FlippR-Driver/src/output/IOutputDriver.h index 81a3e9a..2cd3801 100644 --- a/FlippR-Driver/src/output/IOutputDriver.h +++ b/FlippR-Driver/src/output/IOutputDriver.h @@ -8,7 +8,7 @@ #ifndef _SRC_OUTPUT_IOUTPUTDRIVER_H_ #define _SRC_OUTPUT_IOUTPUTDRIVER_H_ -namespace FlippR_Driver +namespace flippR_driver { namespace output { diff --git a/FlippR-Driver/src/output/IOutputItem.h b/FlippR-Driver/src/output/IOutputItem.h index b7b68cb..fb82016 100644 --- a/FlippR-Driver/src/output/IOutputItem.h +++ b/FlippR-Driver/src/output/IOutputItem.h @@ -1,5 +1,5 @@ /* - * IOutputItem.h + * ICabinetItem.h * * Created on: Aug 7, 2018 * Author: rhetenor @@ -9,17 +9,17 @@ #define _SRC_OUTPUT_ICABINETITEM_H_ -namespace FlippR_Driver +namespace flippR_driver { namespace output { -class IOutputItem +class ICabinetItem { - virtual ~IOutputItem(); - virtual bool isActivated() = 0; - virtual bool activate() = 0; - virtual bool deactivate() = 0; + virtual ~ICabinetItem(); + virtual bool isActivated() = 0; + virtual bool activate() = 0; + virtual bool deactivate() = 0; }; } diff --git a/FlippR-Driver/src/output/ISolenoid.h b/FlippR-Driver/src/output/ISolenoid.h index 15b8738..8c69c48 100644 --- a/FlippR-Driver/src/output/ISolenoid.h +++ b/FlippR-Driver/src/output/ISolenoid.h @@ -8,14 +8,12 @@ #ifndef _SRC_OUTPUT_ISOLENOID_H_ #define _SRC_OUTPUT_ISOLENOID_H_ -#include "IOutputItem.h" - -namespace FlippR_Driver +namespace flippR_driver { namespace output { -class ISolenoid : public IOutputItem +class ISolenoid { }; diff --git a/FlippR-Driver/src/output/ISound.h b/FlippR-Driver/src/output/ISound.h index 37b602d..8c0676a 100644 --- a/FlippR-Driver/src/output/ISound.h +++ b/FlippR-Driver/src/output/ISound.h @@ -8,13 +8,12 @@ #ifndef _SRC_OUTPUT_ISOUND_H_ #define _SRC_OUTPUT_ISOUND_H_ -#include "IOutputItem.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { -class ISound : public IOutputItem +class ISound { public: ISound(); diff --git a/FlippR-Driver/src/output/Lamp.cpp b/FlippR-Driver/src/output/Lamp.cpp index 74d4c4b..4c5d99a 100644 --- a/FlippR-Driver/src/output/Lamp.cpp +++ b/FlippR-Driver/src/output/Lamp.cpp @@ -7,12 +7,13 @@ #include "Lamp.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { -Lamp::Lamp() +Lamp::Lamp(std::shared_ptr output_gpio_interface, int address, std::string name) : + OutputItem(output_gpio_interface, address, name) { // TODO Auto-generated constructor stub @@ -23,5 +24,15 @@ Lamp::~Lamp() // TODO Auto-generated destructor stub } +void Lamp::activate() +{ +// activate +} + +void Lamp::deactivate() +{ +// deactivate +} + } /* namespace output */ -} \ No newline at end of file +} diff --git a/FlippR-Driver/src/output/Lamp.h b/FlippR-Driver/src/output/Lamp.h index a081a37..b5f043f 100644 --- a/FlippR-Driver/src/output/Lamp.h +++ b/FlippR-Driver/src/output/Lamp.h @@ -10,7 +10,7 @@ #include "OutputItem.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { @@ -18,10 +18,17 @@ namespace output class Lamp : public OutputItem { public: - Lamp(); - virtual ~Lamp(); + Lamp(std::shared_ptr output_gpio_interface, int address, std::string name); + virtual ~Lamp(); + + void activate(); + void deactivate(); + bool is_activated(); + +private: + bool activated; }; } /* namespace output */ } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/output/OutputDriver.cpp b/FlippR-Driver/src/output/OutputDriver.cpp index 1036dc9..d0397ac 100644 --- a/FlippR-Driver/src/output/OutputDriver.cpp +++ b/FlippR-Driver/src/output/OutputDriver.cpp @@ -10,7 +10,7 @@ #include #include -namespace FlippR_Driver +namespace flippR_driver { namespace output { diff --git a/FlippR-Driver/src/output/OutputDriver.h b/FlippR-Driver/src/output/OutputDriver.h index 1864b8c..5eacce3 100644 --- a/FlippR-Driver/src/output/OutputDriver.h +++ b/FlippR-Driver/src/output/OutputDriver.h @@ -17,7 +17,7 @@ #include "IDisplay.h" #include "ISound.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { @@ -25,10 +25,15 @@ namespace output class OutputDriver : public IOutputDriver { public: +<<<<<<< HEAD OutputDriver(std::map> cabinet_items, std::map> displays, std::map> sounds); +======= + OutputDriver(std::map> cabinet_items, std::map> displays, std::map> sounds); +>>>>>>> be582e9f7f0d29518665a131afce24ca0a43386e - virtual ~OutputDriver() = default; + virtual ~OutputDriver() = default; +<<<<<<< HEAD std::vector> get_cabinet_items(); std::vector> get_sounds(); std::vector> get_displays(); @@ -41,8 +46,22 @@ private: std::map> cabinet_items; std::map> displays; std::map> sounds; +======= + std::vector> get_cabinet_items(); + std::vector> get_sounds(); + std::vector> get_displays(); + + std::shared_ptr get_cabinet_item(std::string name); + std::shared_ptr get_sound(std::string name); + std::shared_ptr get_display(char number); + +private: + std::map> cabinet_items; + std::map> displays; + std::map> sounds; +>>>>>>> be582e9f7f0d29518665a131afce24ca0a43386e }; } /* namespace output */ } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/output/OutputDriverFactory.cpp b/FlippR-Driver/src/output/OutputDriverFactory.cpp index 5fc8d1d..b6441e6 100644 --- a/FlippR-Driver/src/output/OutputDriverFactory.cpp +++ b/FlippR-Driver/src/output/OutputDriverFactory.cpp @@ -4,7 +4,7 @@ #include "OutputDriverFactory.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { diff --git a/FlippR-Driver/src/output/OutputDriverFactory.h b/FlippR-Driver/src/output/OutputDriverFactory.h index 91ebf02..640627d 100644 --- a/FlippR-Driver/src/output/OutputDriverFactory.h +++ b/FlippR-Driver/src/output/OutputDriverFactory.h @@ -2,14 +2,14 @@ // Created by rhetenor on 04.10.18. // -#ifndef FLIPPR_DRIVER_OUTPUTDRIVERFACTORY_H -#define FLIPPR_DRIVER_OUTPUTDRIVERFACTORY_H +#ifndef flippR_driver_OUTPUTDRIVERFACTORY_H +#define flippR_driver_OUTPUTDRIVERFACTORY_H #include #include "OutputDriver.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { @@ -21,4 +21,4 @@ public: } } -#endif //FLIPPR_DRIVER_OUTPUTDRIVERFACTORY_H +#endif //flippR_driver_OUTPUTDRIVERFACTORY_H diff --git a/FlippR-Driver/src/output/OutputItem.h b/FlippR-Driver/src/output/OutputItem.h index d853dee..228cf7b 100644 --- a/FlippR-Driver/src/output/OutputItem.h +++ b/FlippR-Driver/src/output/OutputItem.h @@ -1,5 +1,5 @@ /* - * OutputItem.h + * CabinetItem.h * * Created on: Aug 2, 2018 * Author: rhetenor @@ -8,38 +8,34 @@ #ifndef _SRC_OUTPUT_CABINETITEM_H_ #define _SRC_OUTPUT_CABINETITEM_H_ -#include "IOutputItem.h" +#include "ICabinetItem.h" +#include "ActivationStrategy.h" #include "utility/IOutputGPIOInterface.h" #include #include -namespace FlippR_Driver +namespace flippR_driver { namespace output { -using namespace utility; - -class OutputItem : public IOutputItem +class OutputItem : public ICabinetItem { public: - OutputItem(std::shared_ptr output_gpio_interface, int address, std::string name); + OutputItem(std::shared_ptr output_gpio_interface, int address, std::string name); virtual ~OutputItem(); - bool isActivated(); - -public: - int address; - int priority; +protected: + int address, i2c_address, data_pin_address; std::string name; -protected: - bool activated; - std::shared_ptr output_gpio_interface; + strategy::ActivationStrategy* strategy; + + std::shared_ptr output_gpio_interface; }; } /* namespace output */ } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/output/Solenoid.cpp b/FlippR-Driver/src/output/Solenoid.cpp index 6dbb635..a0f1c57 100644 --- a/FlippR-Driver/src/output/Solenoid.cpp +++ b/FlippR-Driver/src/output/Solenoid.cpp @@ -7,18 +7,28 @@ #include "Solenoid.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { -Solenoid::Solenoid() { +Solenoid::Solenoid(std::shared_ptr output_gpio_interface, int address, std::string name) : + OutputItem(output_gpio_interface, address, name) +{ // TODO Auto-generated constructor stub } -Solenoid::~Solenoid() { +Solenoid::~Solenoid() +{ // TODO Auto-generated destructor stub } +void Solenoid::trigger() +{ +// activate +// wait +// deactivate +} + } /* namespace output */ } diff --git a/FlippR-Driver/src/output/Solenoid.h b/FlippR-Driver/src/output/Solenoid.h index e7cd4a5..c3a25a6 100644 --- a/FlippR-Driver/src/output/Solenoid.h +++ b/FlippR-Driver/src/output/Solenoid.h @@ -8,20 +8,23 @@ #ifndef _SRC_OUTPUT_SOLENOID_H_ #define _SRC_OUTPUT_SOLENOID_H_ -#include "ISolenoid.h.h" +#include "OutputItem.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { -class Solenoid : public ISolenoid +class Solenoid : public OutputItem { public: - Solenoid(); - virtual ~Solenoid(); + Solenoid(std::shared_ptr output_gpio_interface, int address, std::string name); + virtual ~Solenoid(); + + //muss task sein + void trigger(); }; } /* namespace output */ } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/output/Sound.cpp b/FlippR-Driver/src/output/Sound.cpp index 8f9b81c..7f28239 100644 --- a/FlippR-Driver/src/output/Sound.cpp +++ b/FlippR-Driver/src/output/Sound.cpp @@ -7,19 +7,21 @@ #include "Sound.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { -Sound::Sound(std::shared_ptr output_gpio_interface, int address, std::string name) - : output_gpio_interface(output_gpio_interface), address(address), name(name) +Sound::Sound(std::shared_ptr output_gpio_interface, int address, std::string name) : + output_gpio_interface(output_gpio_interface), address(address), name(name) {} void Sound::play() { - this->output_gpio_interface->activate(this); +// this->output_gpio_interface->activate(this); +// wait +// deactivate() } } /* namespace output */ -} \ No newline at end of file +} diff --git a/FlippR-Driver/src/output/Sound.h b/FlippR-Driver/src/output/Sound.h index a6a7939..2d4b35d 100644 --- a/FlippR-Driver/src/output/Sound.h +++ b/FlippR-Driver/src/output/Sound.h @@ -13,9 +13,9 @@ #include #include -#include "utilities/IOutputGPIOInterface.h" +#include "utility/IOutputGPIOInterface.h" -namespace FlippR_Driver +namespace flippR_driver { namespace output { @@ -23,13 +23,13 @@ namespace output class Sound : ISound { public: - Sound(std::shared_ptr output_gpio_interface, int address, std::string name); + Sound(std::shared_ptr output_gpio_interface, int address, std::string name); virtual ~Sound() = default; virtual void play(); private: - std::shared_ptr output_gpio_interface; + std::shared_ptr output_gpio_interface; int address; std::string name; @@ -37,4 +37,4 @@ private: } /* namespace output */ } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/utility/BlockingQueue.hpp b/FlippR-Driver/src/utility/BlockingQueue.hpp index 84e1fb4..ec955fd 100644 --- a/FlippR-Driver/src/utility/BlockingQueue.hpp +++ b/FlippR-Driver/src/utility/BlockingQueue.hpp @@ -16,7 +16,7 @@ using namespace boost; -namespace FlippR_Driver +namespace flippR_driver { namespace utility { diff --git a/FlippR-Driver/src/utility/DisplayGPIOInterface.cpp b/FlippR-Driver/src/utility/DisplayGPIOInterface.cpp new file mode 100644 index 0000000..5523a75 --- /dev/null +++ b/FlippR-Driver/src/utility/DisplayGPIOInterface.cpp @@ -0,0 +1,20 @@ +/* + * DisplayGPIOInterface.cpp + * + * Created on: Nov 9, 2018 + * Author: johannes + */ + +#include "DisplayGPIOInterface.h" + +DisplayGPIOInterface::DisplayGPIOInterface() +{ + // TODO Auto-generated constructor stub + +} + +DisplayGPIOInterface::~DisplayGPIOInterface() +{ + // TODO Auto-generated destructor stub +} + diff --git a/FlippR-Driver/src/utility/DisplayGPIOInterface.h b/FlippR-Driver/src/utility/DisplayGPIOInterface.h new file mode 100644 index 0000000..ad79e35 --- /dev/null +++ b/FlippR-Driver/src/utility/DisplayGPIOInterface.h @@ -0,0 +1,19 @@ +/* + * DisplayGPIOInterface.h + * + * Created on: Nov 9, 2018 + * Author: johannes + */ + +#ifndef SRC_UTILITY_DISPLAYGPIOINTERFACE_H_ +#define SRC_UTILITY_DISPLAYGPIOINTERFACE_H_ + +class DisplayGPIOInterface +{ +public: + DisplayGPIOInterface(); + virtual + ~DisplayGPIOInterface(); +}; + +#endif /* SRC_UTILITY_DISPLAYGPIOINTERFACE_H_ */ diff --git a/FlippR-Driver/src/utility/GPIOInterface.cpp b/FlippR-Driver/src/utility/GPIOInterface.cpp index a14eb2a..6e87a5e 100644 --- a/FlippR-Driver/src/utility/GPIOInterface.cpp +++ b/FlippR-Driver/src/utility/GPIOInterface.cpp @@ -12,7 +12,7 @@ #include "wiringPi/wiringPi.h" #include "json/json.hpp" -namespace FlippR_Driver +namespace flippR_driver { namespace utility { diff --git a/FlippR-Driver/src/utility/GPIOInterface.h b/FlippR-Driver/src/utility/GPIOInterface.h index 4cc409f..3822fdd 100644 --- a/FlippR-Driver/src/utility/GPIOInterface.h +++ b/FlippR-Driver/src/utility/GPIOInterface.h @@ -15,7 +15,7 @@ #include #include -namespace FlippR_Driver +namespace flippR_driver { namespace utility { diff --git a/FlippR-Driver/src/utility/IBlockingQueue.h b/FlippR-Driver/src/utility/IBlockingQueue.h index f4eebec..1db1f67 100644 --- a/FlippR-Driver/src/utility/IBlockingQueue.h +++ b/FlippR-Driver/src/utility/IBlockingQueue.h @@ -8,7 +8,7 @@ #ifndef SRC_UTILITIES_IBLOCKINGQUEUE_H_ #define SRC_UTILITIES_IBLOCKINGQUEUE_H_ -namespace FlippR_Driver +namespace flippR_driver { namespace utility { diff --git a/FlippR-Driver/src/utility/IInputGPIOInterface.h b/FlippR-Driver/src/utility/IInputGPIOInterface.h index 02c7ce2..b1ddf9a 100644 --- a/FlippR-Driver/src/utility/IInputGPIOInterface.h +++ b/FlippR-Driver/src/utility/IInputGPIOInterface.h @@ -8,7 +8,7 @@ #ifndef SRC_UTILITIES_IINPUTGPIOINTERFACE_H_ #define SRC_UTILITIES_IINPUTGPIOINTERFACE_H_ -namespace FlippR_Driver +namespace flippR_driver { namespace utility { diff --git a/FlippR-Driver/src/utility/IOutputGPIOInterface.h b/FlippR-Driver/src/utility/IOutputGPIOInterface.h index 3b443d6..177d5c5 100644 --- a/FlippR-Driver/src/utility/IOutputGPIOInterface.h +++ b/FlippR-Driver/src/utility/IOutputGPIOInterface.h @@ -2,19 +2,30 @@ // Created by rhetenor on 10.10.18. // -#ifndef FLIPPR_DRIVER_IOUTPUTGPIOINTERFACE_H -#define FLIPPR_DRIVER_IOUTPUTGPIOINTERFACE_H +#ifndef flippR_driver_IOUTPUTGPIOINTERFACE_H +#define flippR_driver_IOUTPUTGPIOINTERFACE_H -namespace FlippR_Driver +#include "OutputItem.h" +#include "IOutputGPIOInterface.h" + +#include + +namespace flippR_driver { namespace utility { class IOutputGPIOInterface { +public: + //muss alles geschützt sein + void set_address(int i2c_address, int address); + void activate_pin(int i2c_address, int pin); + void deactivate_pin(int i2c_address, int pin); + //Display gpio interface! }; } } -#endif //FLIPPR_DRIVER_IOUTPUTGPIOINTERFACE_H +#endif //flippR_driver_IOUTPUTGPIOINTERFACE_H diff --git a/FlippR-Driver/src/utility/InputGPIOInterface.cpp b/FlippR-Driver/src/utility/InputGPIOInterface.cpp index 91d50e7..0f97507 100644 --- a/FlippR-Driver/src/utility/InputGPIOInterface.cpp +++ b/FlippR-Driver/src/utility/InputGPIOInterface.cpp @@ -13,7 +13,7 @@ #include "easylogging/easylogging++.h" #include "config.h" #include -namespace FlippR_Driver +namespace flippR_driver { namespace utility { @@ -46,7 +46,7 @@ void InputGPIOInterface::write_col(char data) write_pin(this->col_address_C, data & 0b100); } -InputGPIOInterface::InputGPIOInterface(std::istream &input_config_stream) +InputGPIOInterface::inputGPIOInterface(std::istream &input_config_stream) { init_members(input_config_stream); diff --git a/FlippR-Driver/src/utility/InputGPIOInterface.h b/FlippR-Driver/src/utility/InputGPIOInterface.h index 289b5db..2e0cc3b 100644 --- a/FlippR-Driver/src/utility/InputGPIOInterface.h +++ b/FlippR-Driver/src/utility/InputGPIOInterface.h @@ -12,7 +12,7 @@ #include "IInputGPIOInterface.h" #include "GPIOInterface.h" -namespace FlippR_Driver +namespace flippR_driver { namespace utility { diff --git a/FlippR-Driver/src/utility/LoggerFactory.cpp b/FlippR-Driver/src/utility/LoggerFactory.cpp index d294cec..f5d4cca 100644 --- a/FlippR-Driver/src/utility/LoggerFactory.cpp +++ b/FlippR-Driver/src/utility/LoggerFactory.cpp @@ -11,7 +11,7 @@ INITIALIZE_EASYLOGGINGPP #endif -namespace FlippR_Driver +namespace flippR_driver { namespace utility { diff --git a/FlippR-Driver/src/utility/LoggerFactory.h b/FlippR-Driver/src/utility/LoggerFactory.h index cf152f6..d76ca76 100644 --- a/FlippR-Driver/src/utility/LoggerFactory.h +++ b/FlippR-Driver/src/utility/LoggerFactory.h @@ -10,20 +10,20 @@ #include "config.h" -namespace FlippR_Driver +namespace flippR_driver { namespace utility { namespace LoggerFactory { -void CreateInputTestLogger(el::Level level = el::Level::Global); + void CreateInputTestLogger(el::Level level = el::Level::Global); -void CreateInputLogger(el::Level level = el::Level::Info); + void CreateInputLogger(el::Level level = el::Level::Info); -void CreateOutputLogger(el::Level level = el::Level::Info); + void CreateOutputLogger(el::Level level = el::Level::Info); }; } } -#endif \ No newline at end of file +#endif diff --git a/FlippR-Driver/src/utility/OutputGPIOInterface.h b/FlippR-Driver/src/utility/OutputGPIOInterface.h index 9f53c70..0195e69 100644 --- a/FlippR-Driver/src/utility/OutputGPIOInterface.h +++ b/FlippR-Driver/src/utility/OutputGPIOInterface.h @@ -14,7 +14,7 @@ #include -namespace FlippR_Driver +namespace flippR_driver { namespace utility { diff --git a/FlippR-Driver/src/utility/config.h b/FlippR-Driver/src/utility/config.h index 547a4e9..26295d9 100644 --- a/FlippR-Driver/src/utility/config.h +++ b/FlippR-Driver/src/utility/config.h @@ -12,13 +12,9 @@ #define LOGGER_FILE "driver.log" -#define DRIVER_CONF_FILE "/var/log/flippr_driver.conf" - -#define HIGHEST_LOG_VERBOSITY 10 - #define INPUT_MATRIX_SIZE 8 #define INPUT_SLEEP_DURATION_NANO 800 #define PULLDOWN false -#define HIGHEST_INPUT_EVENT_PRIORITY 0 +#define VALID_DISPLAY_CHARACTERS [1,2,3,4,5,6,7,8,9,0,\0] diff --git a/FlippR-Driver/tests/input/TestDetector.cpp b/FlippR-Driver/tests/input/TestDetector.cpp index ddc5154..e27c802 100644 --- a/FlippR-Driver/tests/input/TestDetector.cpp +++ b/FlippR-Driver/tests/input/TestDetector.cpp @@ -18,13 +18,14 @@ #include "input/IEventNotifier.h" #include "input/DistributingEvent.h" #include "input/Detector.h" -#include "utilities/LoggerFactory.h" -#include "utilities/InputGPIOInterface.h" +#include "utility/LoggerFactory.h" +#include "utility/InputGPIOInterface.h" using namespace fakeit; -using namespace FlippR_Driver; -using namespace Input; +using namespace flippR_driver; +using namespace input; +using namespace utility; SCENARIO("Creating a Detector object", "") @@ -42,11 +43,11 @@ SCENARIO("Creating a Detector object", "") Fake(Dtor(event_notifier_mock)); When(Method(event_notifier_mock, distribute_event)).AlwaysReturn(); - std::map> events; + std::vector> events; WHEN("Detector is created") { - Detector detector(std::unique_ptr(&gpio_interface_mock.get()), events, std::shared_ptr(&event_notifier_mock.get())); + Detector detector(std::unique_ptr(&gpio_interface_mock.get()), events); THEN("a thread should be created") { REQUIRE(typeid(detector.detect_thread).hash_code() == typeid(std::thread).hash_code()); @@ -75,16 +76,16 @@ SCENARIO("There are events at the input", "") DistributingEvent event2(2, '2', "event 2", std::chrono::milliseconds(0), event_notifier); DistributingEvent event3(3, '3', "event 3", std::chrono::milliseconds(0), event_notifier); - std::map> events; + std::vector> events; auto event2ptr = std::make_shared(event2); - events.insert(std::make_pair(1, std::make_shared(event1))); - events.insert(std::make_pair(2, event2ptr)); - events.insert(std::make_pair(3, std::make_shared(event3))); + events.push_back(std::make_shared(event1)); + events.push_back(event2ptr); + events.push_back(std::make_shared(event3)); WHEN("an event can be found at gpio interface") { - Detector detector(std::unique_ptr(&gpio_interface_mock.get()), events, std::shared_ptr(&event_notifier_mock.get())); + Detector detector(std::unique_ptr(&gpio_interface_mock.get()), events); std::this_thread::sleep_for(std::chrono::milliseconds(50)); THEN("the event should be distributed") { @@ -116,15 +117,15 @@ SCENARIO("There are events at the input but no suitable event in map", "") DistributingEvent event2(2, '2', "event 2", std::chrono::milliseconds(0), event_notifier); DistributingEvent event3(3, '3', "event 3", std::chrono::milliseconds(0), event_notifier); - std::map> events; + std::vector> events; - events.insert(std::make_pair(1, std::make_shared(event1))); - events.insert(std::make_pair(2, std::make_shared(event2))); - events.insert(std::make_pair(3, std::make_shared(event3))); + events.push_back(std::make_shared(event1)); + events.push_back(std::make_shared(event2)); + events.push_back(std::make_shared(event3)); WHEN("an event can be found at gpio interface") { - Detector detector(std::unique_ptr(&gpio_interface_mock.get()), events, std::shared_ptr(&event_notifier_mock.get())); + Detector detector(std::unique_ptr(&gpio_interface_mock.get()), events); std::this_thread::sleep_for(std::chrono::milliseconds(10)); THEN("the event should be distributed") { diff --git a/FlippR-Driver/tests/input/TestEventHandler.cpp b/FlippR-Driver/tests/input/TestEventHandler.cpp index 0fa5252..8ab26d9 100644 --- a/FlippR-Driver/tests/input/TestEventHandler.cpp +++ b/FlippR-Driver/tests/input/TestEventHandler.cpp @@ -8,7 +8,7 @@ #include "catch.hpp" #include "fakeit.hpp" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" #include "EventHandler.h" #include "IInputDriver.h" @@ -18,6 +18,7 @@ using namespace fakeit; +using namespace flippR_driver::utility; SCENARIO("An EventHandler gets created", "[construction}") { @@ -25,15 +26,15 @@ SCENARIO("An EventHandler gets created", "[construction}") { LoggerFactory::CreateInputTestLogger(); - Mock input_driver_mock; + Mock input_driver_mock; Fake(Dtor(input_driver_mock)); When(Method(input_driver_mock, register_event_handler)).AlwaysReturn(); When(Method(input_driver_mock, unregister_event_handler)).AlwaysReturn(); WHEN("the event handler gets created") { - std::shared_ptr driver_ptr(&input_driver_mock.get()); - FlippR_Driver::Input::EventHandler handler(driver_ptr); + std::shared_ptr driver_ptr(&input_driver_mock.get()); + flippR_driver::input::EventHandler handler(driver_ptr); THEN("It should register itself at the input_driver") { diff --git a/FlippR-Driver/tests/input/TestEventNotifier.cpp b/FlippR-Driver/tests/input/TestEventNotifier.cpp index ac22069..709d398 100644 --- a/FlippR-Driver/tests/input/TestEventNotifier.cpp +++ b/FlippR-Driver/tests/input/TestEventNotifier.cpp @@ -10,9 +10,9 @@ #include "fakeit.hpp" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" #include "IEventHandler.h" -#include "utilities/IBlockingQueue.h" +#include "utility/IBlockingQueue.h" // testing purposes @@ -20,9 +20,10 @@ #include "input/EventNotifier.h" -using namespace FlippR_Driver; -using namespace Input; +using namespace flippR_driver; +using namespace input; using namespace fakeit; +using namespace utility; SCENARIO("An EventNotifier gets created", "[construction]") { diff --git a/FlippR-Driver/tests/input/TestInputDriver.cpp b/FlippR-Driver/tests/input/TestInputDriver.cpp index 3677acb..0aebf36 100644 --- a/FlippR-Driver/tests/input/TestInputDriver.cpp +++ b/FlippR-Driver/tests/input/TestInputDriver.cpp @@ -7,7 +7,7 @@ #include "catch.hpp" #include "fakeit.hpp" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" // testing purposes #define private public @@ -19,8 +19,9 @@ using namespace fakeit; -using namespace FlippR_Driver; -using namespace Input; +using namespace flippR_driver; +using namespace input; +using namespace utility; SCENARIO("An InputDriver gets created", "[construction}") { @@ -57,14 +58,14 @@ SCENARIO("An EventHandler [un]registers at the driver", "[un-register]") { LoggerFactory::CreateInputTestLogger(); - Mock detector_mock; + Mock detector_mock; Fake(Dtor(detector_mock)); Mock event_handler_mock; Fake(Method(event_handler_mock, handle)); Fake(Dtor(event_handler_mock)); - Mock event_notifier_mock; + Mock event_notifier_mock; Fake(Method(event_notifier_mock, register_event_handler)); Fake(Method(event_notifier_mock, unregister_event_handler)); Fake(Dtor(event_notifier_mock)); @@ -104,13 +105,13 @@ SCENARIO("An Input Driver is created normally", "") { LoggerFactory::CreateInputTestLogger(); - Mock detector_mock; + Mock detector_mock; Fake(Dtor(detector_mock)); Mock event_handler_mock; Fake(Dtor(event_handler_mock)); - Mock event_notifier_mock; + Mock event_notifier_mock; Fake(Dtor(event_notifier_mock)); std::shared_ptr event_notifier_ptr(&event_notifier_mock.get()); diff --git a/FlippR-Driver/tests/output/TestDisplay.cpp b/FlippR-Driver/tests/output/TestDisplay.cpp index 68a8739..bdda1e4 100644 --- a/FlippR-Driver/tests/output/TestDisplay.cpp +++ b/FlippR-Driver/tests/output/TestDisplay.cpp @@ -11,19 +11,57 @@ #include "catch.hpp" #include "fakeit.hpp" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" // testing purposes #define private public -#include "output/Display.h" +#include "Display.h" -using namespace output; +using namespace flippR_driver::output; using namespace fakeit; -SCENARIO("") +SCENARIO("Creating a Display object", "") { + GIVEN("Just a Display with 7 digits") + { + SevenDigitDisplay display(5,5); + WHEN("A content is set for the display") + { + std::string content_string = "1234567"; + std::array content; + std::copy(content_string.begin(), content_string.end(), content.data()); + display.write_content(content); + THEN("This content should be set for the display") + { + REQUIRE(content == display.content); + } + } + WHEN("A score (12345) within the size of the display is written") + { + display.write_score(12345); + THEN("The content should look like: \" 12345\" ") + { + std::string content_string = "\0\012345"; + std::array content; + std::copy(content_string.begin(), content_string.end(), content.data()); + REQUIRE(display.content == content); + } + } + WHEN("A score (12345678), which is longer than the digit is written") + { + display.write_score(12345678); + THEN("The content should look like: \"9999999\"-> highest number ") + { + std::string content_string = "9999999"; + std::array content; + std::copy(content_string.begin(), content_string.end(), content.data()); + + REQUIRE(display.content == content); + } + } + } } diff --git a/FlippR-Driver/tests/output/TestDisplayController.cpp b/FlippR-Driver/tests/output/TestDisplayController.cpp index 744c8c8..ab4e4ca 100644 --- a/FlippR-Driver/tests/output/TestDisplayController.cpp +++ b/FlippR-Driver/tests/output/TestDisplayController.cpp @@ -8,7 +8,7 @@ #include "catch.hpp" #include "fakeit.hpp" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" // testing purposes @@ -16,7 +16,7 @@ #include "output/DisplayController.h" -using namespace output; +using namespace flippR_driver::output; using namespace fakeit; SCENARIO("") diff --git a/FlippR-Driver/tests/output/TestLamp.cpp b/FlippR-Driver/tests/output/TestLamp.cpp index 22d29a0..08070d5 100644 --- a/FlippR-Driver/tests/output/TestLamp.cpp +++ b/FlippR-Driver/tests/output/TestLamp.cpp @@ -8,7 +8,7 @@ #include "catch.hpp" #include "fakeit.hpp" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" // testing purposes @@ -16,7 +16,7 @@ #include "output/Lamp.h" -using namespace output; +using namespace flippR_driver::output; using namespace fakeit; SCENARIO("") diff --git a/FlippR-Driver/tests/output/TestOutputDriver.cpp b/FlippR-Driver/tests/output/TestOutputDriver.cpp index 4c88805..04ef307 100644 --- a/FlippR-Driver/tests/output/TestOutputDriver.cpp +++ b/FlippR-Driver/tests/output/TestOutputDriver.cpp @@ -8,7 +8,7 @@ #include "catch.hpp" #include "fakeit.hpp" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" // testing purposes @@ -16,7 +16,7 @@ #include "output/OutputDriver.h" -using namespace output; +using namespace flippR_driver::output; using namespace fakeit; SCENARIO("") diff --git a/FlippR-Driver/tests/output/TestCabinetItem.cpp b/FlippR-Driver/tests/output/TestOutputItem.cpp similarity index 66% rename from FlippR-Driver/tests/output/TestCabinetItem.cpp rename to FlippR-Driver/tests/output/TestOutputItem.cpp index c41c579..c84f75b 100644 --- a/FlippR-Driver/tests/output/TestCabinetItem.cpp +++ b/FlippR-Driver/tests/output/TestOutputItem.cpp @@ -11,15 +11,15 @@ #include "catch.hpp" #include "fakeit.hpp" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" // testing purposes #define private public -#include "output/OutputItem.h" +#include "../../src/output/OutputItem.h" -using namespace output; +using namespace flippR_driver::output; using namespace fakeit; SCENARIO("") diff --git a/FlippR-Driver/tests/output/TestSolenoid.cpp b/FlippR-Driver/tests/output/TestSolenoid.cpp index 5d5213a..b420d9a 100644 --- a/FlippR-Driver/tests/output/TestSolenoid.cpp +++ b/FlippR-Driver/tests/output/TestSolenoid.cpp @@ -10,7 +10,7 @@ #include "catch.hpp" #include "fakeit.hpp" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" // testing purposes @@ -18,7 +18,7 @@ #include "output/Solenoid.h" -using namespace output; +using namespace flippR_driver::output; using namespace fakeit; SCENARIO("") diff --git a/FlippR-Driver/tests/output/TestSound.cpp b/FlippR-Driver/tests/output/TestSound.cpp index 3a1de79..8442d48 100644 --- a/FlippR-Driver/tests/output/TestSound.cpp +++ b/FlippR-Driver/tests/output/TestSound.cpp @@ -8,7 +8,7 @@ #include "catch.hpp" #include "fakeit.hpp" -#include "utilities/LoggerFactory.h" +#include "utility/LoggerFactory.h" // testing purposes @@ -16,7 +16,7 @@ #include "output/Sound.h" -using namespace output; +using namespace flippR_driver::output; using namespace fakeit; SCENARIO("")