Files
flippr-code/FlippR-Driver/src/input/impl/Detector.cpp
Jonas Zeunert 57ec8fda79 consting things
2018-12-14 03:43:13 +01:00

56 lines
980 B
C++

/*
* 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() const
{
while(this->is_running)
{
check_inputs();
}
}
void Detector::check_inputs() const
{
for(auto &event : events)
{
input_gpio_interface->read_data(event->address) ? event->active() : event->inactive();
}
}
}
}
}