restored OUtputPinController

This commit is contained in:
Jonas Zeunert
2019-05-06 21:31:17 +02:00
parent bc583a5a92
commit 1b90bf7518
12 changed files with 103 additions and 9 deletions

View File

@@ -0,0 +1,48 @@
//
// Created by rhetenor on 3/6/19.
//
#ifndef FLIPPR_CODE_OUTPUTREQUESTHANDLER_H
#define FLIPPR_CODE_OUTPUTREQUESTHANDLER_H
#include <Poco/Net/HTTPRequestHandler.h>
#include <Poco/URI.h>
#include <Poco/JSON/JSON.h>
#include <memory>
#include <boost/optional.hpp>
#include <Poco/JSON/Object.h>
#include "output/OutputDriver.h"
namespace flippR_driver
{
namespace utility
{
class OutputRequestHandler : public Poco::Net::HTTPRequestHandler
{
public:
OutputRequestHandler(std::shared_ptr<output::OutputDriver> output_driver);
void handleRequest(Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response) override;
private:
boost::optional<Poco::JSON::Object> parseRequest(const std::string& item_type, const std::string& item_name, const std::string& action, const std::string& score = 0);
boost::optional<Poco::JSON::Object> parseSolenoid(const std::string& item_name, const std::string& action);
boost::optional<Poco::JSON::Object> parseLamp(const std::string& item_name, const std::string& action);
boost::optional<Poco::JSON::Object> parseSound(const std::string& item_name, const std::string& action);
boost::optional<Poco::JSON::Object> parseDisplay(const std::string& item_name, const std::string& action, const std::string& score);
std::vector<std::string> getPathSegments(Poco::URI uri);
private:
std::shared_ptr<output::OutputDriver> output_driver;
};
}
}
#endif //FLIPPR_CODE_OUTPUTREQUESTHANDLER_H