refactored everything

This commit is contained in:
Johannes Wendel
2018-11-09 01:16:35 +01:00
parent c53b6af33e
commit 3ea37e4e53
70 changed files with 202 additions and 177 deletions

View File

@@ -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)

View File

@@ -5,14 +5,14 @@
#include "PrintHandler.h"
#include <iostream>
PrintHandler::PrintHandler(std::shared_ptr<FlippR_Driver::Input::IInputDriver> driver) :
FlippR_Driver::Input::EventHandler(driver)
PrintHandler::PrintHandler(std::shared_ptr<flippR_driver::input::IInputDriver> 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";
}

View File

@@ -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 <memory>
#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<FlippR_Driver::Input::IInputDriver> driver);
PrintHandler(std::shared_ptr<flippR_driver::input::IInputDriver> 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

View File

@@ -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<Input::IInputDriver> driver = FlippR_Driver::get_InputDriver(input_config, matrix_config);
std::shared_ptr<input::IInputDriver> driver = flippR_driver::get_InputDriver(input_config, matrix_config);
PrintHandler* print_handler = new PrintHandler(driver);

View File

@@ -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 <fstream>
#include <memory>
#include "IInputDriver.h"
namespace FlippR_Driver
namespace flippR_driver
{
std::shared_ptr<Input::IInputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream);
std::shared_ptr<input::IInputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream);
}
#endif //FLIPPR_DRIVER_DRIVERFACTORY_H
#endif //flippR_driver_DRIVERFACTORY_H

View File

@@ -12,8 +12,8 @@
#include <string>
#include <chrono>
namespace FlippR_Driver {
namespace Input {
namespace flippR_driver {
namespace input {
class Event {
public:

View File

@@ -17,9 +17,9 @@
#include "IEventHandler.h"
#include "Event.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class EventHandler;

View File

@@ -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_ */

View File

@@ -11,9 +11,9 @@
#include "IEventHandler.h"
#include <memory>
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class IInputDriver {
public:

View File

@@ -5,10 +5,10 @@
#include "DriverFactory.h"
#include "input/InputDriverFactory.h"
namespace FlippR_Driver
namespace flippR_driver
{
std::shared_ptr<Input::IInputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream)
std::shared_ptr<input::IInputDriver> 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);
}
}
}

View File

@@ -12,9 +12,9 @@
#include "utility/config.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
Detector::Detector(std::unique_ptr<utility::IInputGPIOInterface> input_gpio_interface, std::vector<std::shared_ptr<DistributingEvent>> events) :

View File

@@ -25,9 +25,9 @@
#include "DistributingEvent.h"
#include "IEventNotifier.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class Detector : public IDetector

View File

@@ -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<IEventNotifier> 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<std::chrono::high_resolution_clock> now = std::chrono::high_resolution_clock::now();
std::chrono::milliseconds elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(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)
{

View File

@@ -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

View File

@@ -10,8 +10,8 @@
#include "Event.h"
namespace FlippR_Driver {
namespace Input {
namespace flippR_driver {
namespace input {
class ErrorEvent : public Event
{

View File

@@ -8,16 +8,16 @@
#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)

View File

@@ -7,9 +7,9 @@
#include "EventHandler.h"
#include "utility/config.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
EventHandler::EventHandler(std::shared_ptr<IInputDriver> input_driver) :

View File

@@ -11,9 +11,9 @@
#include "EventNotifier.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
EventNotifier::EventNotifier(utility::IBlockingQueue<Event>* queue) :

View File

@@ -21,9 +21,9 @@
#define HANDLER_TIMEOUT 2000
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class EventNotifier : public IEventNotifier

View File

@@ -9,9 +9,9 @@
#define SRC_INPUT_IDETECTOR_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class IDetector

View File

@@ -12,9 +12,9 @@
#include "IEventHandler.h"
#include <memory>
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class IEventNotifier

View File

@@ -10,9 +10,9 @@
#include <input/ErrorEvent.hpp>
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
InputDriver::InputDriver(std::shared_ptr<IEventNotifier> event_notifier, std::unique_ptr<IDetector> detector,

View File

@@ -13,9 +13,9 @@
#include "IInputDriver.h"
#include "IDetector.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class InputDriver : public IInputDriver

View File

@@ -16,13 +16,13 @@
#include "EventNotifier.h"
using namespace nlohmann;
using namespace FlippR_Driver::utility;
using namespace flippR_driver::utility;
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
std::shared_ptr<IInputDriver> InputDriverFactory::get_InputDriver(std::istream &input_config_stream, std::istream &matrix_config_stream)
std::shared_ptr<IInputDriver> 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<std
{
int global_bounce_time = matrix_config.at("global_bounce_time").get<json::number_integer_t>();
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<json::number_integer_t>();
@@ -73,7 +73,7 @@ void InputDriverFactory::create_input_events(json matrix_config, std::vector<std
events.push_back(event_ptr);
name_event_map.emplace(name, event_ptr);
}
catch (json::exception &e)
catch (json::exception &e)
{
CLOG(ERROR, INPUT_LOGGER) << "Matrix config-file corrupted: " << e.what();
exit(EXIT_FAILURE);

View File

@@ -18,9 +18,9 @@
#include "json/json.hpp"
#include "IEventNotifier.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class InputDriverFactory
{

View File

@@ -12,12 +12,12 @@
#include <array>
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
template <int DigitCount>
class Display : public IDisplay
class Display : public IDisplay<DigitCount>
{
public:
Display(int address, int id);
@@ -38,7 +38,13 @@ private:
std::string fit_string(std::string& score_string);
};
using SevenDigitDisplay = Display<7>;
using EightDigitDisply = Display<8>;
} /* namespace output */
}
#include "Display.hpp"
#endif

View File

@@ -2,14 +2,13 @@
// Created by rhetenor on 10.10.18.
//
#include "Display.h"
#include "utility/config.h"
#include <string>
#include <algorithm>
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
@@ -45,10 +44,12 @@ std::string Display<DigitCount>::fit_string(std::string& score_string)
if (score_length > DigitCount)
{
CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display";
return score_string.substr(score_length-DigitCount, score_length);
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, ' ');
score_string.insert(0, DigitCount-score_length, '\0');
return score_string;
}

View File

@@ -10,7 +10,7 @@
#include "utility/config.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -16,7 +16,7 @@
#include "IDisplay.h"
#include "utility/IOutputGPIOInterface.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -9,7 +9,7 @@
#define _SRC_OUTPUT_ICABINETITEM_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -8,18 +8,26 @@
#ifndef _SRC_OUTPUT_IDISPLAY_H_
#define _SRC_OUTPUT_IDISPLAY_H_
namespace FlippR_Driver
#include <array>
namespace flippR_driver
{
namespace output
{
class IDisplay
{
public:
IDisplay();
virtual ~IDisplay();
virtual void write_score(int score) = 0;
virtual void write_content(std::array<char, DigitCount> content) = 0;
virtual int getID() = 0;
private:
std::string fit_string(std::string& score_string);
};
} /* namespace output */

View File

@@ -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
#endif

View File

@@ -8,7 +8,7 @@
#ifndef _SRC_OUTPUT_ILAMP_H_
#define _SRC_OUTPUT_ILAMP_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -8,7 +8,7 @@
#ifndef _SRC_OUTPUT_IOUTPUTDRIVER_H_
#define _SRC_OUTPUT_IOUTPUTDRIVER_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -8,7 +8,7 @@
#ifndef _SRC_OUTPUT_ISOLENOID_H_
#define _SRC_OUTPUT_ISOLENOID_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -8,7 +8,7 @@
#ifndef _SRC_OUTPUT_ISOUND_H_
#define _SRC_OUTPUT_ISOUND_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -7,13 +7,13 @@
#include "Lamp.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
CabinetItem(output_gpio_interface, address, name)
OutputItem(output_gpio_interface, address, name)
{
// TODO Auto-generated constructor stub

View File

@@ -8,14 +8,14 @@
#ifndef _SRC_OUTPUT_LAMP_H_
#define _SRC_OUTPUT_LAMP_H_
#include "CabinetItem.h"
#include "OutputItem.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
class Lamp : public CabinetItem
class Lamp : public OutputItem
{
public:
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);

View File

@@ -10,7 +10,7 @@
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -17,7 +17,7 @@
#include "IDisplay.h"
#include "ISound.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
@@ -25,24 +25,24 @@ namespace output
class OutputDriver : public IOutputDriver
{
public:
OutputDriver(std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds);
OutputDriver(std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds);
virtual ~OutputDriver() = default;
virtual ~OutputDriver() = default;
std::vector<std::shared_ptr<ICabinetItem>> get_cabinet_items();
std::vector<std::shared_ptr<ISound>> get_sounds();
std::vector<std::shared_ptr<IDisplay>> get_displays();
std::vector<std::shared_ptr<ICabinetItem>> get_cabinet_items();
std::vector<std::shared_ptr<ISound>> get_sounds();
std::vector<std::shared_ptr<IDisplay>> get_displays();
std::shared_ptr<ICabinetItem> get_cabinet_item(std::string name);
std::shared_ptr<ISound> get_sound(std::string name);
std::shared_ptr<IDisplay> get_display(char number);
std::shared_ptr<ICabinetItem> get_cabinet_item(std::string name);
std::shared_ptr<ISound> get_sound(std::string name);
std::shared_ptr<IDisplay> get_display(char number);
private:
std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items;
std::map<char, std::shared_ptr<IDisplay>> displays;
std::map<std::string, std::shared_ptr<ISound>> sounds;
std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items;
std::map<char, std::shared_ptr<IDisplay>> displays;
std::map<std::string, std::shared_ptr<ISound>> sounds;
};
} /* namespace output */
}
#endif
#endif

View File

@@ -4,7 +4,7 @@
#include "OutputDriverFactory.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -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 <memory>
#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

View File

@@ -10,21 +10,22 @@
#include "ICabinetItem.h"
#include "ActivationStrategy.h"
#include "utility/IOutputGPIOInterface.h"
#include <memory>
#include <string>
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
class CabinetItem : public ICabinetItem
class OutputItem : public ICabinetItem
{
public:
CabinetItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
virtual ~CabinetItem();
OutputItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
virtual ~OutputItem();
virtual bool isActivated();
virtual bool activate();
@@ -35,6 +36,10 @@ protected:
std::string name;
bool activated;
strategy::ActivationStrategy* strategy;
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
};
} /* namespace output */

View File

@@ -7,12 +7,12 @@
#include "Solenoid.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output {
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
CabinetItem(output_gpio_interface, address, name)
OutputItem(output_gpio_interface, address, name)
{
// TODO Auto-generated constructor stub

View File

@@ -8,14 +8,14 @@
#ifndef _SRC_OUTPUT_SOLENOID_H_
#define _SRC_OUTPUT_SOLENOID_H_
#include "CabinetItem.h"
#include "OutputItem.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
class Solenoid : public CabinetItem
class Solenoid : public OutputItem
{
public:
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);

View File

@@ -7,7 +7,7 @@
#include "Sound.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -15,7 +15,7 @@
#include "utility/IOutputGPIOInterface.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -16,7 +16,7 @@
using namespace boost;
namespace FlippR_Driver
namespace flippR_driver
{
namespace utility
{

View File

@@ -12,7 +12,7 @@
#include "wiringPi/wiringPi.h"
#include "json/json.hpp"
namespace FlippR_Driver
namespace flippR_driver
{
namespace utility
{

View File

@@ -15,7 +15,7 @@
#include <mutex>
#include <fstream>
namespace FlippR_Driver
namespace flippR_driver
{
namespace utility
{

View File

@@ -8,7 +8,7 @@
#ifndef SRC_UTILITIES_IBLOCKINGQUEUE_H_
#define SRC_UTILITIES_IBLOCKINGQUEUE_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace utility
{

View File

@@ -8,7 +8,7 @@
#ifndef SRC_UTILITIES_IINPUTGPIOINTERFACE_H_
#define SRC_UTILITIES_IINPUTGPIOINTERFACE_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace utility
{

View File

@@ -2,18 +2,26 @@
// 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 <memory>
namespace flippR_driver
{
namespace utility
{
class IOutputGPIOInterface
{
public:
void activate(int address, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface);
void deactivate(int address,std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface);
};
}
}
#endif //FLIPPR_DRIVER_IOUTPUTGPIOINTERFACE_H
#endif //flippR_driver_IOUTPUTGPIOINTERFACE_H

View File

@@ -13,7 +13,7 @@
#include "easylogging/easylogging++.h"
#include "config.h"
#include <string>
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);

View File

@@ -12,7 +12,7 @@
#include "IInputGPIOInterface.h"
#include "GPIOInterface.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace utility
{

View File

@@ -11,7 +11,7 @@
INITIALIZE_EASYLOGGINGPP
#endif
namespace FlippR_Driver
namespace flippR_driver
{
namespace utility
{

View File

@@ -10,7 +10,7 @@
#include "config.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace utility
{

View File

@@ -11,7 +11,7 @@
#include "GPIOInterface.h"
#include <mcp23017.h>
namespace FlippR_Driver
namespace flippR_driver
{
namespace utility
{

View File

@@ -12,15 +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]

View File

@@ -23,8 +23,8 @@
using namespace fakeit;
using namespace FlippR_Driver;
using namespace Input;
using namespace flippR_driver;
using namespace input;
using namespace utility;

View File

@@ -18,7 +18,7 @@
using namespace fakeit;
using namespace FlippR_Driver::utility;
using namespace flippR_driver::utility;
SCENARIO("An EventHandler gets created", "[construction}")
{
@@ -26,15 +26,15 @@ SCENARIO("An EventHandler gets created", "[construction}")
{
LoggerFactory::CreateInputTestLogger();
Mock<FlippR_Driver::Input::IInputDriver> input_driver_mock;
Mock<flippR_driver::input::IInputDriver> 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<FlippR_Driver::Input::IInputDriver> driver_ptr(&input_driver_mock.get());
FlippR_Driver::Input::EventHandler handler(driver_ptr);
std::shared_ptr<flippR_driver::input::IInputDriver> driver_ptr(&input_driver_mock.get());
flippR_driver::input::EventHandler handler(driver_ptr);
THEN("It should register itself at the input_driver")
{

View File

@@ -20,8 +20,8 @@
#include "input/EventNotifier.h"
using namespace FlippR_Driver;
using namespace Input;
using namespace flippR_driver;
using namespace input;
using namespace fakeit;
using namespace utility;

View File

@@ -19,8 +19,8 @@
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}")
@@ -58,14 +58,14 @@ SCENARIO("An EventHandler [un]registers at the driver", "[un-register]")
{
LoggerFactory::CreateInputTestLogger();
Mock<FlippR_Driver::Input::IDetector> detector_mock;
Mock<flippR_driver::input::IDetector> detector_mock;
Fake(Dtor(detector_mock));
Mock<IEventHandler> event_handler_mock;
Fake(Method(event_handler_mock, handle));
Fake(Dtor(event_handler_mock));
Mock<FlippR_Driver::Input::IEventNotifier> event_notifier_mock;
Mock<flippR_driver::input::IEventNotifier> event_notifier_mock;
Fake(Method(event_notifier_mock, register_event_handler));
Fake(Method(event_notifier_mock, unregister_event_handler));
Fake(Dtor(event_notifier_mock));
@@ -105,13 +105,13 @@ SCENARIO("An Input Driver is created normally", "")
{
LoggerFactory::CreateInputTestLogger();
Mock<FlippR_Driver::Input::IDetector> detector_mock;
Mock<flippR_driver::input::IDetector> detector_mock;
Fake(Dtor(detector_mock));
Mock<IEventHandler> event_handler_mock;
Fake(Dtor(event_handler_mock));
Mock<FlippR_Driver::Input::IEventNotifier> event_notifier_mock;
Mock<flippR_driver::input::IEventNotifier> event_notifier_mock;
Fake(Dtor(event_notifier_mock));
std::shared_ptr<IEventNotifier> event_notifier_ptr(&event_notifier_mock.get());

View File

@@ -17,16 +17,16 @@
// testing purposes
#define private public
#include "output/Display.h"
#include "Display.h"
using namespace FlippR_Driver::output;
using namespace flippR_driver::output;
using namespace fakeit;
SCENARIO("Creating a Display object", "")
{
GIVEN("Just a Display with 7 digits")
{
Display<7> display(5,5);
SevenDigitDisplay display(5,5);
WHEN("A content is set for the display")
{
std::string content_string = "1234567";
@@ -43,7 +43,7 @@ SCENARIO("Creating a Display object", "")
display.write_score(12345);
THEN("The content should look like: \" 12345\" ")
{
std::string content_string = " 12345";
std::string content_string = "\0\012345";
std::array<char,7> content;
std::copy(content_string.begin(), content_string.end(), content.data());
@@ -51,14 +51,16 @@ SCENARIO("Creating a Display object", "")
}
}
WHEN("A score (12345678), which is longer than the digit is written")
display.write_score(12345678);
THEN("The content should look like: \"2345678\" ")
{
std::string content_string = "2345678";
std::array<char,7> content;
std::copy(content_string.begin(), content_string.end(), content.data());
display.write_score(12345678);
THEN("The content should look like: \"9999999\"-> highest number ")
{
std::string content_string = "9999999";
std::array<char,7> content;
std::copy(content_string.begin(), content_string.end(), content.data());
REQUIRE(display.content == content);
REQUIRE(display.content == content);
}
}
}
}

View File

@@ -16,7 +16,7 @@
#include "output/DisplayController.h"
using namespace FlippR_Driver::output;
using namespace flippR_driver::output;
using namespace fakeit;
SCENARIO("")

View File

@@ -16,7 +16,7 @@
#include "output/Lamp.h"
using namespace FlippR_Driver::output;
using namespace flippR_driver::output;
using namespace fakeit;
SCENARIO("")

View File

@@ -16,7 +16,7 @@
#include "output/OutputDriver.h"
using namespace FlippR_Driver::output;
using namespace flippR_driver::output;
using namespace fakeit;
SCENARIO("")

View File

@@ -17,9 +17,9 @@
// testing purposes
#define private public
#include "output/CabinetItem.h"
#include "../../src/output/OutputItem.h"
using namespace FlippR_Driver::output;
using namespace flippR_driver::output;
using namespace fakeit;
SCENARIO("")

View File

@@ -18,7 +18,7 @@
#include "output/Solenoid.h"
using namespace FlippR_Driver::output;
using namespace flippR_driver::output;
using namespace fakeit;
SCENARIO("")

View File

@@ -16,7 +16,7 @@
#include "output/Sound.h"
using namespace FlippR_Driver::output;
using namespace flippR_driver::output;
using namespace fakeit;
SCENARIO("")