made some stuff working 😠 @Jonas

This commit is contained in:
Johannes Wendel
2019-04-25 00:46:44 +02:00
parent 218cb65dd4
commit 878b5f52ce
32 changed files with 781 additions and 731 deletions

View File

@@ -8,6 +8,10 @@
#ifndef INPUT_IMPL_EVENTNOTIFIER_H_
#define INPUT_IMPL_EVENTNOTIFIER_H_
#include <set>
#include <thread>
#include <mutex>
#include "input/EventNotifier.h"
#include "input/Event.h"
@@ -16,10 +20,6 @@
#include "utility/BlockingQueue.hpp"
#include "utility/IBlockingQueue.h"
#include <set>
#include <thread>
#include <mutex>
namespace flippR_driver
{

View File

@@ -8,13 +8,13 @@ namespace flippR_driver
{
namespace utility
{
using namespace nlohmann;
//using namespace nlohmann;
SocketHandler::SocketHandler(boost::asio::io_service &service, std::string socket_file) : socket(boost::asio::io_service{})
SocketHandler::SocketHandler(std::string socket_file)
{
this->socket.connect(socket_file);
//this->socket.connect(socket_file);
}
/*
SocketHandler::create_client(const std::string& socket_file)
{
this->socket.connect(socket_file);
@@ -31,6 +31,6 @@ void SocketHandler::write_to_socket(json &json)
boost::asio::write(this->socket, boost::asio::buffer(json_data, json_data.length()));
}
*/
}
}

View File

@@ -18,7 +18,7 @@ public:
SocketHandler(std::string socket_file);
protected:
boost::asio::local::stream_protocol::socket socket;
Poco::Net::Socket socket;
protected:
void write_to_socket(std::string &data);

View File

@@ -0,0 +1,44 @@
//
// Created by rhetenor on 27.11.18.
//
#include "InputSocketHandler.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include "json/json.hpp"
namespace flippR_driver
{
namespace utility
{
using namespace nlohmann;
InputSocketHandler::InputSocketHandler()
{}
void InputSocketHandler::handle(flippR_driver::input::Event &event)
{
json event_serialization = serialize_event(event);
// write_to_socket(event_serialization);
}
//json InputSocketHandler::serialize_event(input::Event &event)
//{
// json serialized_event = json("event");
//
// serialized_event["name"] = event.name;
//
// std::time_t activation_time = std::chrono::system_clock::to_time_t(event.last_activation);
// boost::posix_time::ptime posix_time = boost::posix_time::from_time_t(activation_time);
// serialized_event["activation_time"] = boost::posix_time::to_simple_string(posix_time); // todo learn to write time right
//
// serialized_event["priority"] = event.priority;
//
// return serialized_event;
//}
}
}

View File

@@ -1,43 +0,0 @@
//
// Created by rhetenor on 27.11.18.
//
#include "InputSocketHandler.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include "json.hpp"
namespace flippR_driver
{
namespace utility
{
using namespace nlohmann;
InputSocketHandler::InputSocketHandler(boost::asio::io_service &service, std::string socket_file) : SocketHandler(service, std::move(socket_file)) {}
void InputSocketHandler::handle(flippR_driver::input::Event &event)
{
json event_serialization = serialize_event(event);
write_to_socket(event_serialization);
}
json InputSocketHandler::serialize_event(input::Event &event)
{
json serialized_event = json("event");
serialized_event["name"] = event.name;
std::time_t activation_time = std::chrono::system_clock::to_time_t(event.last_activation);
boost::posix_time::ptime posix_time = boost::posix_time::from_time_t(activation_time);
serialized_event["activation_time"] = boost::posix_time::to_simple_string(posix_time); // todo learn to write time right
serialized_event["priority"] = event.priority;
return serialized_event;
}
}
}

View File

@@ -50,7 +50,8 @@ void OutputRequestHandler::handleRequest(HTTPServerRequest &request,
}
catch(const Poco::InvalidArgumentException &e)
{
response.setStatusAndReason(HTTPServerResponse::HTTP_REASON_BAD_REQUEST, e.displayText());
// TODO not compiling
// response.setStatusAndReason(HTTPServerResponse::HTTP_REASON_BAD_REQUEST, e.displayText());
}
}
@@ -162,8 +163,9 @@ void OutputRequestHandler::parseDisplay(const std::string& item_name, const std:
{
try
{
unsigned int score = std::stoi(score);
display->write_score(score);
//TODO not compiling
// unsigned int score = std::stoi(score);
// display->write_score(score);
}
catch(std::invalid_argument &e)
{

View File

@@ -15,7 +15,7 @@ namespace flippR_driver
namespace utility
{
class OutputRequestHandlerFactory :: public Poco::Net::HTTPRequestHandlerFactory
class OutputRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory
{
public:
explicit OutputRequestHandlerFactory(std::shared_ptr<output::OutputDriver> output_driver);

View File

@@ -5,7 +5,7 @@
#ifndef FLIPPR_DRIVER_OUTPUTSOCKETHANDLER_H
#define FLIPPR_DRIVER_OUTPUTSOCKETHANDLER_H
#include "SocketHandler.h"
#include "utility/SocketHandler.h"
#include "output/OutputDriver.h"
namespace flippR_driver