Merge branch 'master' of github.com:swinginbird/flippr-code
This commit is contained in:
@@ -303,7 +303,7 @@
|
||||
},
|
||||
{
|
||||
"address" : 50,
|
||||
"name" : "Bonux Multiplier x50"
|
||||
"name" : "Bonus Multiplier x50"
|
||||
},
|
||||
{
|
||||
"address" : 51,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"flippers" :
|
||||
[
|
||||
{
|
||||
"address" : 59,
|
||||
"address" : 60,
|
||||
"name" : "Flipper Relay"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ void OutputRequestHandler::handleRequest(HTTPServerRequest &request,
|
||||
json_response->stringify(ostr);
|
||||
}
|
||||
}
|
||||
catch(const NotFoundException &e)
|
||||
catch(const Poco::NotFoundException &e)
|
||||
{
|
||||
response.setStatusAndReason(HTTPServerResponse::HTTP_NOT_FOUND, e.displayText());
|
||||
}
|
||||
@@ -92,6 +92,10 @@ void OutputRequestHandler::handleRequest(HTTPServerRequest &request,
|
||||
{
|
||||
response.setStatusAndReason(HTTPServerResponse::HTTP_BAD_REQUEST, e.displayText());
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
response.setStatusAndReason(HTTPServerResponse::HTTP_BAD_REQUEST, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseRequest(const std::string& item_type, const std::string& item_name, const std::string& action, const std::string& score)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
@@ -56,6 +58,7 @@ void DriverBoardPinController::deactivate(items::DriverBoardItem &driver_board_i
|
||||
|
||||
void DriverBoardPinController::select_address(uint8_t address)
|
||||
{
|
||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Select address " << std::to_string(address);
|
||||
address = address % 8;
|
||||
write_pin(this->address_pins[0], address & 0b001);
|
||||
write_pin(this->address_pins[1], address & 0b010);
|
||||
@@ -64,6 +67,7 @@ void DriverBoardPinController::select_address(uint8_t address)
|
||||
|
||||
void DriverBoardPinController::select_mux(uint8_t mux)
|
||||
{
|
||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Select mux " << std::to_string(mux);
|
||||
write_pin(this->mux_enable_pins[mux], 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,27 +129,47 @@ std::vector<std::shared_ptr<Solenoid>> OutputDriver::get_solenoids() const
|
||||
|
||||
boost::optional<std::shared_ptr<items::Lamp>> OutputDriver::get_lamp(const std::string &name) const
|
||||
{
|
||||
return this->lamps.find(name)->second;
|
||||
auto lamp = this->lamps.find(name);
|
||||
if(lamp == this->lamps.end()) {
|
||||
return boost::optional<std::shared_ptr<items::Lamp>>();
|
||||
}
|
||||
return lamp->second;
|
||||
}
|
||||
|
||||
boost::optional<std::shared_ptr<items::Solenoid>> OutputDriver::get_solenoid(const std::string &name) const
|
||||
{
|
||||
return this->solenoids.find(name)->second;
|
||||
auto solenoid = this->solenoids.find(name);
|
||||
if(solenoid == this->solenoids.end()) {
|
||||
return boost::optional<std::shared_ptr<items::Solenoid>>();
|
||||
}
|
||||
return solenoid->second;
|
||||
}
|
||||
|
||||
boost::optional<std::shared_ptr<items::Sound>> OutputDriver::get_sound(const std::string &name) const
|
||||
{
|
||||
return this->sounds.find(name)->second;
|
||||
auto sound = this->sounds.find(name);
|
||||
if(sound == this->sounds.end()) {
|
||||
return boost::optional<std::shared_ptr<items::Sound>>();
|
||||
}
|
||||
return sound->second;
|
||||
}
|
||||
|
||||
boost::optional<std::shared_ptr<items::Flipper>> OutputDriver::get_flipper(const std::string &name) const
|
||||
{
|
||||
return this->flippers.find(name)->second;
|
||||
auto flipper = this->flippers.find(name);
|
||||
if(flipper == this->flippers.end()) {
|
||||
return boost::optional<std::shared_ptr<items::Flipper>>();
|
||||
}
|
||||
return flipper->second;
|
||||
}
|
||||
|
||||
boost::optional<std::shared_ptr<items::Display>> OutputDriver::get_display(const std::string &name) const
|
||||
{
|
||||
return this->displays.find(name)->second;
|
||||
auto display = this->displays.find(name);
|
||||
if(display == this->displays.end()) {
|
||||
return boost::optional<std::shared_ptr<items::Display>>();
|
||||
}
|
||||
return display->second;
|
||||
}
|
||||
|
||||
void OutputDriver::shut_down_driver() const
|
||||
|
||||
Reference in New Issue
Block a user