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

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