fuuuuuuuu
This commit is contained in:
@@ -60,12 +60,14 @@ void OutputRequestHandler::handleRequest(HTTPServerRequest &request,
|
||||
{
|
||||
this->output_driver->deactivate_displays();
|
||||
this->output_driver->deactivate_all_lamps();
|
||||
this->output_driver->deactivate_all_flipper_relays();
|
||||
return;
|
||||
}
|
||||
|
||||
if(item_type == "activate")
|
||||
{
|
||||
this->output_driver->activate_displays();
|
||||
this->output_driver->activate_all_flipper_relays();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,6 +111,10 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseRequest(const std
|
||||
{
|
||||
return parseDisplay(item_name, action, score);
|
||||
}
|
||||
else if(item_type == "flippers")
|
||||
{
|
||||
return parseFlipper(item_name, action);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Poco::NotFoundException("No item type called " + item_type);
|
||||
@@ -249,6 +255,40 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseDisplay(const std
|
||||
return {};
|
||||
}
|
||||
|
||||
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseFlipper(const std::string& item_name, const std::string& action)
|
||||
{
|
||||
if(item_name == "")
|
||||
{
|
||||
Poco::JSON::Object response;
|
||||
response.set("flippers", this->output_driver->get_flippers());
|
||||
return response;
|
||||
}
|
||||
|
||||
auto opt_flipper = this->output_driver->get_flipper(item_name);
|
||||
|
||||
if(!opt_flipper)
|
||||
{
|
||||
throw new Poco::NotFoundException("No flipper with name \"" + item_name + "\"!");
|
||||
}
|
||||
|
||||
auto flipper = opt_flipper->get();
|
||||
|
||||
if(action == "activate")
|
||||
{
|
||||
flipper->activate();
|
||||
}
|
||||
else if(action == "deactivate")
|
||||
{
|
||||
flipper->deactivate();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Poco::NotFoundException("No action with name \"" + action + "\" on flippers!");
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<std::string> OutputRequestHandler::getPathSegments(Poco::URI uri)
|
||||
{
|
||||
std::vector<std::string> path_segments;
|
||||
|
||||
@@ -33,6 +33,7 @@ private:
|
||||
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);
|
||||
boost::optional<Poco::JSON::Object> parseFlipper(const std::string& item_name, const std::string& action);
|
||||
|
||||
std::vector<std::string> getPathSegments(Poco::URI uri);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user