wrote display stuff and refactored thousend things
This commit is contained in:
@@ -10,14 +10,14 @@
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
|
||||
#include "utilities/config.h"
|
||||
#include "utility/config.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
{
|
||||
namespace Input
|
||||
{
|
||||
|
||||
Detector::Detector(std::unique_ptr<IInputGPIOInterface> input_gpio_interface, std::vector<std::shared_ptr<DistributingEvent>> events) :
|
||||
Detector::Detector(std::unique_ptr<utility::IInputGPIOInterface> input_gpio_interface, std::vector<std::shared_ptr<DistributingEvent>> 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()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "utilities/IInputGPIOInterface.h"
|
||||
#include "utility/IInputGPIOInterface.h"
|
||||
|
||||
#include "IDetector.h"
|
||||
#include "DistributingEvent.h"
|
||||
@@ -34,7 +34,7 @@ class Detector : public IDetector
|
||||
{
|
||||
|
||||
public:
|
||||
Detector(std::unique_ptr<IInputGPIOInterface> input_gpio_interface, std::vector<std::shared_ptr<DistributingEvent>> events);
|
||||
Detector(std::unique_ptr<utility::IInputGPIOInterface> input_gpio_interface, std::vector<std::shared_ptr<DistributingEvent>> events);
|
||||
~Detector();
|
||||
|
||||
private:
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
void check_inputs();
|
||||
|
||||
private:
|
||||
std::unique_ptr<IInputGPIOInterface> input_gpio_interface;
|
||||
std::unique_ptr<utility::IInputGPIOInterface> input_gpio_interface;
|
||||
|
||||
std::vector<std::shared_ptr<DistributingEvent>> events;
|
||||
|
||||
@@ -52,4 +52,4 @@ private:
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -11,14 +11,15 @@
|
||||
#include "Event.h"
|
||||
|
||||
namespace FlippR_Driver {
|
||||
namespace Input {
|
||||
namespace Input {
|
||||
|
||||
class ErrorEvent : public Event {
|
||||
public:
|
||||
ErrorEvent() :
|
||||
Event(0, 0, "ERROR") {}
|
||||
};
|
||||
}
|
||||
class ErrorEvent : public Event
|
||||
{
|
||||
public:
|
||||
ErrorEvent() : Event(0, 0, "ERROR") {}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
#include "Event.h"
|
||||
|
||||
#include "utilities/config.h"
|
||||
#include "utility/config.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
{
|
||||
@@ -26,4 +26,4 @@ bool operator==(const Event& left, const Event& right)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 Input
|
||||
{
|
||||
|
||||
EventHandler::EventHandler(std::shared_ptr<IInputDriver> input_driver) :
|
||||
input_driver(input_driver)
|
||||
{
|
||||
this->input_driver->register_event_handler(this);
|
||||
EventHandler::EventHandler(std::shared_ptr<IInputDriver> 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";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include "utilities/config.h"
|
||||
#include "utility/config.h"
|
||||
|
||||
#include "EventNotifier.h"
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace FlippR_Driver
|
||||
namespace Input
|
||||
{
|
||||
|
||||
EventNotifier::EventNotifier(IBlockingQueue<Event>* queue) :
|
||||
EventNotifier::EventNotifier(utility::IBlockingQueue<Event>* queue) :
|
||||
is_running(true),
|
||||
event_queue(queue)
|
||||
{
|
||||
@@ -82,4 +82,4 @@ void EventNotifier::notify()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
#include "utilities/BlockingQueue.hpp"
|
||||
#include "utilities/IBlockingQueue.h"
|
||||
#include "utility/BlockingQueue.hpp"
|
||||
#include "utility/IBlockingQueue.h"
|
||||
#include "Event.h"
|
||||
#include "EventHandler.h"
|
||||
|
||||
@@ -30,7 +30,7 @@ class EventNotifier : public IEventNotifier
|
||||
{
|
||||
|
||||
public:
|
||||
EventNotifier(IBlockingQueue<Event>* queue);
|
||||
EventNotifier(utility::IBlockingQueue<Event>* queue);
|
||||
~EventNotifier();
|
||||
|
||||
void register_event_handler(IEventHandler* handler);
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
void notify();
|
||||
|
||||
private:
|
||||
IBlockingQueue<Event>* event_queue;
|
||||
utility::IBlockingQueue<Event>* event_queue;
|
||||
std::set<IEventHandler*> event_handlers;
|
||||
|
||||
bool is_running;
|
||||
@@ -54,4 +54,4 @@ private:
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
#include "InputDriver.h"
|
||||
|
||||
#include "utilities/config.h"
|
||||
#include "utility/config.h"
|
||||
|
||||
#include <input/ErrorEvent.hpp>
|
||||
|
||||
@@ -42,9 +42,8 @@ std::shared_ptr<Event> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
|
||||
#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
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "Detector.h"
|
||||
#include "IInputDriver.h"
|
||||
|
||||
#include "utilities/InputGPIOInterface.h"
|
||||
#include "utility/InputGPIOInterface.h"
|
||||
#include "json/json.hpp"
|
||||
#include "IEventNotifier.h"
|
||||
|
||||
@@ -36,4 +36,4 @@ private:
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "ICabinetItem.h"
|
||||
|
||||
#include "utilities/IOutputGPIOInterface.h"
|
||||
#include "utility/IOutputGPIOInterface.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -23,7 +23,7 @@ namespace output
|
||||
class CabinetItem : public ICabinetItem
|
||||
{
|
||||
public:
|
||||
CabinetItem(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
CabinetItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
virtual ~CabinetItem();
|
||||
|
||||
virtual bool isActivated();
|
||||
@@ -39,4 +39,4 @@ protected:
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -2,11 +2,53 @@
|
||||
// Created by rhetenor on 10.10.18.
|
||||
//
|
||||
|
||||
#include "Display.h"
|
||||
#include "utility/config.h"
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace FlippR_Driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
template<int DigitCount>
|
||||
Display<DigitCount>::Display(int address, int id) :
|
||||
address(address),
|
||||
id(id)
|
||||
{
|
||||
}
|
||||
|
||||
template<int DigitCount>
|
||||
int Display<DigitCount>::getID()
|
||||
{
|
||||
return this->id;
|
||||
}
|
||||
|
||||
template<int DigitCount>
|
||||
void Display<DigitCount>::write_score(int score)
|
||||
{
|
||||
auto score_string = std::to_string(score);
|
||||
auto score_length = score_string.length();
|
||||
if (score_length > DigitCount)
|
||||
{
|
||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display";
|
||||
this->content = score_string.substr(score_length-DigitCount,score_length);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string spaces;
|
||||
std::generate_n(spaces.begin(), DigitCount-score_length, []{return " ";});
|
||||
this->content = spaces + score_string;
|
||||
}
|
||||
|
||||
template<int DigitCount>
|
||||
void Display<DigitCount>::write_content( std::array<char, DigitCount> content)
|
||||
{
|
||||
this->content = content;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ template <int DigitCount>
|
||||
class Display : public IDisplay
|
||||
{
|
||||
public:
|
||||
Display();
|
||||
Display(int address, int id);
|
||||
virtual ~Display() = default;
|
||||
|
||||
virtual int getID();
|
||||
@@ -38,4 +38,5 @@ private:
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace FlippR_Driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface)
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface)
|
||||
: displays(displays), output_gpio_interface(output_gpio_interface), is_running(true)
|
||||
{
|
||||
this->display_cycle_thread = std::thread(&DisplayController::cycle_displays, this);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace output
|
||||
class DisplayController : public IDisplayController
|
||||
{
|
||||
public:
|
||||
explicit DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
|
||||
explicit DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface);
|
||||
~DisplayController();
|
||||
|
||||
private:
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
|
||||
std::thread display_cycle_thread;
|
||||
|
||||
std::shared_ptr<IOutputGPIOInterface> output_gpio_interface;
|
||||
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
|
||||
|
||||
bool is_running;
|
||||
};
|
||||
|
||||
@@ -20,10 +20,8 @@ public:
|
||||
virtual ~IDisplay();
|
||||
|
||||
virtual int getID() = 0;
|
||||
|
||||
virtual void write() = 0;
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace FlippR_Driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
Lamp::Lamp()
|
||||
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
|
||||
CabinetItem(output_gpio_interface, address, name)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
@@ -24,4 +25,4 @@ Lamp::~Lamp()
|
||||
}
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace output
|
||||
class Lamp : public CabinetItem
|
||||
{
|
||||
public:
|
||||
Lamp();
|
||||
virtual ~Lamp();
|
||||
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
virtual ~Lamp();
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -11,12 +11,15 @@ namespace FlippR_Driver
|
||||
{
|
||||
namespace output {
|
||||
|
||||
Solenoid::Solenoid() {
|
||||
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
|
||||
CabinetItem(output_gpio_interface, address, name)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
}
|
||||
|
||||
Solenoid::~Solenoid() {
|
||||
Solenoid::~Solenoid()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace output
|
||||
class Solenoid : public CabinetItem
|
||||
{
|
||||
public:
|
||||
Solenoid();
|
||||
virtual ~Solenoid();
|
||||
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
virtual ~Solenoid();
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -12,14 +12,14 @@ namespace FlippR_Driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
Sound::Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name)
|
||||
: output_gpio_interface(output_gpio_interface), address(address), name(name)
|
||||
Sound::Sound(std::shared_ptr<utility::IOutputGPIOInterface> 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);
|
||||
}
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "utilities/IOutputGPIOInterface.h"
|
||||
#include "utility/IOutputGPIOInterface.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
{
|
||||
@@ -23,13 +23,13 @@ namespace output
|
||||
class Sound : ISound
|
||||
{
|
||||
public:
|
||||
Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
virtual ~Sound() = default;
|
||||
|
||||
virtual void play();
|
||||
|
||||
private:
|
||||
std::shared_ptr<IOutputGPIOInterface> output_gpio_interface;
|
||||
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
|
||||
|
||||
int address;
|
||||
std::string name;
|
||||
@@ -37,4 +37,4 @@ private:
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace utility
|
||||
|
||||
class IOutputGPIOInterface
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ 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
|
||||
#endif
|
||||
|
||||
@@ -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 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<char, std::shared_ptr<DistributingEvent>> events;
|
||||
std::vector<std::shared_ptr<DistributingEvent>> events;
|
||||
|
||||
WHEN("Detector is created")
|
||||
{
|
||||
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events, std::shared_ptr<IEventNotifier>(&event_notifier_mock.get()));
|
||||
Detector detector(std::unique_ptr<IInputGPIOInterface>(&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<char, std::shared_ptr<DistributingEvent>> events;
|
||||
std::vector<std::shared_ptr<DistributingEvent>> events;
|
||||
|
||||
auto event2ptr = std::make_shared<DistributingEvent>(event2);
|
||||
events.insert(std::make_pair(1, std::make_shared<DistributingEvent>(event1)));
|
||||
events.insert(std::make_pair(2, event2ptr));
|
||||
events.insert(std::make_pair(3, std::make_shared<DistributingEvent>(event3)));
|
||||
events.push_back(std::make_shared<DistributingEvent>(event1));
|
||||
events.push_back(event2ptr);
|
||||
events.push_back(std::make_shared<DistributingEvent>(event3));
|
||||
|
||||
WHEN("an event can be found at gpio interface")
|
||||
{
|
||||
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events, std::shared_ptr<IEventNotifier>(&event_notifier_mock.get()));
|
||||
Detector detector(std::unique_ptr<IInputGPIOInterface>(&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<char, std::shared_ptr<DistributingEvent>> events;
|
||||
std::vector<std::shared_ptr<DistributingEvent>> events;
|
||||
|
||||
events.insert(std::make_pair(1, std::make_shared<DistributingEvent>(event1)));
|
||||
events.insert(std::make_pair(2, std::make_shared<DistributingEvent>(event2)));
|
||||
events.insert(std::make_pair(3, std::make_shared<DistributingEvent>(event3)));
|
||||
events.push_back(std::make_shared<DistributingEvent>(event1));
|
||||
events.push_back(std::make_shared<DistributingEvent>(event2));
|
||||
events.push_back(std::make_shared<DistributingEvent>(event3));
|
||||
|
||||
WHEN("an event can be found at gpio interface")
|
||||
{
|
||||
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events, std::shared_ptr<IEventNotifier>(&event_notifier_mock.get()));
|
||||
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
THEN("the event should be distributed")
|
||||
{
|
||||
|
||||
@@ -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}")
|
||||
{
|
||||
|
||||
@@ -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
|
||||
@@ -23,6 +23,7 @@
|
||||
using namespace FlippR_Driver;
|
||||
using namespace Input;
|
||||
using namespace fakeit;
|
||||
using namespace utility;
|
||||
|
||||
SCENARIO("An EventNotifier gets created", "[construction]")
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "catch.hpp"
|
||||
#include "fakeit.hpp"
|
||||
#include "utilities/LoggerFactory.h"
|
||||
#include "utility/LoggerFactory.h"
|
||||
|
||||
// testing purposes
|
||||
#define private public
|
||||
@@ -21,6 +21,7 @@
|
||||
using namespace fakeit;
|
||||
using namespace FlippR_Driver;
|
||||
using namespace Input;
|
||||
using namespace utility;
|
||||
|
||||
SCENARIO("An InputDriver gets created", "[construction}")
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "catch.hpp"
|
||||
#include "fakeit.hpp"
|
||||
|
||||
#include "utilities/LoggerFactory.h"
|
||||
#include "utility/LoggerFactory.h"
|
||||
|
||||
|
||||
// testing purposes
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "output/CabinetItem.h"
|
||||
|
||||
using namespace output;
|
||||
using namespace FlippR_Driver::output;
|
||||
using namespace fakeit;
|
||||
|
||||
SCENARIO("")
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "catch.hpp"
|
||||
#include "fakeit.hpp"
|
||||
|
||||
#include "utilities/LoggerFactory.h"
|
||||
#include "utility/LoggerFactory.h"
|
||||
|
||||
|
||||
// testing purposes
|
||||
@@ -19,11 +19,47 @@
|
||||
|
||||
#include "output/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")
|
||||
{
|
||||
Display<7> display(5,5);
|
||||
WHEN("A content is set for the display")
|
||||
{
|
||||
std::string content_string = "1234567";
|
||||
std::array<char,7> 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 = " 12345";
|
||||
std::array<char,7> 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: \"2345678\" ")
|
||||
{
|
||||
std::string content_string = "2345678";
|
||||
std::array<char,7> content;
|
||||
std::copy(content_string.begin(), content_string.end(), content.data());
|
||||
|
||||
REQUIRE(display.content == content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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("")
|
||||
|
||||
@@ -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("")
|
||||
|
||||
@@ -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("")
|
||||
|
||||
@@ -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("")
|
||||
|
||||
@@ -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("")
|
||||
|
||||
Reference in New Issue
Block a user