working on big refactor

This commit is contained in:
Jonas Zeunert
2018-12-14 01:09:54 +01:00
parent f3100004b9
commit 2aee0f4f9d
67 changed files with 914 additions and 619 deletions

View File

@@ -0,0 +1,55 @@
/*
* Detector.cpp
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#include "Detector.h"
#include <iostream>
#include "utility/config.h"
namespace flippR_driver
{
namespace input
{
namespace impl
{
Detector::Detector(std::unique_ptr<InputPinController> input_gpio_interface, std::vector<std::shared_ptr<DistributingEvent>> events)
:
input_gpio_interface(std::move(input_gpio_interface)), events(std::move(events)), is_running(true)
{
this->detect_thread = std::thread(&Detector::detect, this);
CLOG(INFO, INPUT_LOGGER) << "Created Detector and started detecting!";
}
Detector::~Detector()
{
this->is_running = false;
this->detect_thread.join();
}
void Detector::detect()
{
while(this->is_running)
{
check_inputs();
}
}
void Detector::check_inputs()
{
for(auto &event : events)
{
input_gpio_interface->read_data(event->address) ? event->active() : event->inactive();
}
}
}
}
}