Merge branch 'master' of https://github.com/swinginbird/flippr-code
This commit is contained in:
Binary file not shown.
9
FlippR-Driver/cli/networking/server_config.json
Normal file
9
FlippR-Driver/cli/networking/server_config.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"input-config" :"../../contrib/json_example/input/Input_Pin_Config.json",
|
||||||
|
"matrix-config" :"../../contrib/json_example/input/Input_Matrix_Config.json",
|
||||||
|
"lamp-config" :"../../contrib/json_example/output/Lamp_Config.json",
|
||||||
|
"solenoid-config" :"../../contrib/json_example/output/Solenoid_Config.json",
|
||||||
|
"sound-config" :"../../contrib/json_example/output/Sound_Config.json",
|
||||||
|
"display-config" :"../../contrib/json_example/output/Display_Config.json",
|
||||||
|
"lamp-config" :"../../contrib/json_example/output/Lamp_Config.json"
|
||||||
|
}
|
||||||
@@ -344,6 +344,6 @@
|
|||||||
"address" : "76",
|
"address" : "76",
|
||||||
"description" : "speech 1: \"you're good! but i'm still the champ!\"",
|
"description" : "speech 1: \"you're good! but i'm still the champ!\"",
|
||||||
"extender" : "extender_0"
|
"extender" : "extender_0"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,10 +128,10 @@ void FlippRServer::initialize_output_driver()
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->output_driver = flippR_driver::get_OutputDriver(lamp_config_stream,
|
this->output_driver = flippR_driver::get_OutputDriver(solenoid_config_stream,
|
||||||
solenoid_config_stream,
|
lamp_config_stream,
|
||||||
sound_config_stream,
|
sound_config_stream,
|
||||||
display_config_stream);
|
display_config_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlippRServer::initialize_input_driver()
|
void FlippRServer::initialize_input_driver()
|
||||||
@@ -155,10 +155,20 @@ void FlippRServer::initialize_input_driver()
|
|||||||
|
|
||||||
int FlippRServer::main(const std::vector<std::string>& args)
|
int FlippRServer::main(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if(!help_requested)
|
if(help_requested)
|
||||||
{
|
return Application::EXIT_OK;
|
||||||
waitForTerminationRequest();
|
|
||||||
}
|
std::unique_ptr<HTTPServer> output_server(this->build_output_server());
|
||||||
|
output_server->start();
|
||||||
|
|
||||||
|
std::unique_ptr<TCPServer> input_server(this->build_input_server());
|
||||||
|
|
||||||
|
logger().information("Server running!");
|
||||||
|
|
||||||
|
waitForTerminationRequest();
|
||||||
|
this->output_driver->deactivate_all_lamps();
|
||||||
|
this->output_driver->deactivate_displays();
|
||||||
|
output_server->stop();
|
||||||
return Application::EXIT_OK;
|
return Application::EXIT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "DriverFactory.h"
|
#include "DriverFactory.h"
|
||||||
|
|
||||||
|
#include "utility/LoggerFactory.h"
|
||||||
|
|
||||||
#include "input/InputDriverFactory.h"
|
#include "input/InputDriverFactory.h"
|
||||||
#include "output/OutputDriverFactory.h"
|
#include "output/OutputDriverFactory.h"
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
#include "PinController.h"
|
#include "PinController.h"
|
||||||
|
|
||||||
#include "utility/config.h"
|
#include "utility/config.h"
|
||||||
|
#define NOT_PI
|
||||||
#ifndef NOT_PI
|
#ifndef NOT_PI
|
||||||
#include "wiringPi/wiringPi.h"
|
#include "wiringPi/wiringPi.h"
|
||||||
#include "wiringPi/mcp23017.h"
|
#include "wiringPi/mcp23017.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NOT_PI
|
#ifdef NOT_PI
|
||||||
#include "utility/wiringPiTesting.hpp"
|
#include "utility/wiringPiTesting.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -314,7 +314,6 @@ json get_element(const std::string & name, json & object, const std::string & fi
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
sub_object = object.at(name);
|
sub_object = object.at(name);
|
||||||
return sub_object;
|
|
||||||
}
|
}
|
||||||
catch(json::exception &e)
|
catch(json::exception &e)
|
||||||
{
|
{
|
||||||
@@ -322,21 +321,23 @@ json get_element(const std::string & name, json & object, const std::string & fi
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return sub_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename type>
|
template<typename type>
|
||||||
type get_value(const std::string & name, json & object, const std::string & file_name)
|
type get_value(const std::string & name, json & object, const std::string & file_name)
|
||||||
{
|
{
|
||||||
|
type element;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
type element = object.at(name).get<type>();
|
element = object.at(name).get<type>();
|
||||||
return element;
|
|
||||||
}
|
}
|
||||||
catch(json::exception &e)
|
catch(json::exception &e)
|
||||||
{
|
{
|
||||||
CLOG(ERROR, OUTPUT_LOGGER) << "File " << file_name << " seems to be corrupted at " << name << ": " << e.what();
|
CLOG(ERROR, OUTPUT_LOGGER) << "File " << file_name << " seems to be corrupted at " << name << ": " << e.what();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user