reseting isreams
This commit is contained in:
@@ -15,6 +15,10 @@ set(CMAKE_CXX_STANDARD 14)
|
||||
# Boost configuration
|
||||
set(BOOST_COMPONENTS program_options thread timer chrono)
|
||||
|
||||
IF(NOT_PI)
|
||||
add_definitions(-DNOT_PI)
|
||||
message("Compiling not for Pi")
|
||||
ENDIF()
|
||||
|
||||
project(FlippR-Driver)
|
||||
|
||||
|
||||
@@ -2,17 +2,11 @@
|
||||
"deactivation_time_milliseconds" : 10,
|
||||
"port_extenders" :
|
||||
[
|
||||
<<<<<<< HEAD
|
||||
{
|
||||
"name" : "extender_0",
|
||||
"i2c_address" : 33,
|
||||
"pin_base" : 81
|
||||
}
|
||||
=======
|
||||
"name" : "extender_0",
|
||||
"i2c_address" : 33,
|
||||
"pin_base" : 81
|
||||
>>>>>>> aa1d6409ea18cff1ad4b0ef06804fcf5a521dee9
|
||||
],
|
||||
"fire_pin" :
|
||||
{
|
||||
|
||||
@@ -121,10 +121,10 @@ void FlippRServer::initialize_output_driver()
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
this->output_driver = flippR_driver::get_OutputDriver(lamp_config_stream,
|
||||
solenoid_config_stream,
|
||||
sound_config_stream,
|
||||
display_config_stream);
|
||||
this->output_driver = flippR_driver::get_OutputDriver(solenoid_config_stream,
|
||||
lamp_config_stream,
|
||||
sound_config_stream,
|
||||
display_config_stream);
|
||||
}
|
||||
|
||||
void FlippRServer::initialize_input_driver()
|
||||
@@ -156,6 +156,8 @@ int FlippRServer::main(const std::vector<std::string>& args)
|
||||
|
||||
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();
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "DriverFactory.h"
|
||||
|
||||
#include "utility/LoggerFactory.h"
|
||||
|
||||
#include "input/InputDriverFactory.h"
|
||||
#include "output/OutputDriverFactory.h"
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
#include "PinController.h"
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
#define NOT_PI
|
||||
#ifndef NOT_PI
|
||||
#include "wiringPi/wiringPi.h"
|
||||
#include "wiringPi/mcp23017.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NOT_PI
|
||||
#include "utility/wiringPiTesting.hpp"
|
||||
#endif
|
||||
|
||||
@@ -53,6 +53,7 @@ std::shared_ptr<OutputDriver> get_OutputDriver(std::istream& solenoid_config,
|
||||
|
||||
std::map<std::string, std::shared_ptr<items::Solenoid>> create_solenoids(std::istream & solenoid_config, std::shared_ptr<DriverBoardPinController> &pin_controller)
|
||||
{
|
||||
solenoid_config.clear();
|
||||
json solenoid_config_json;
|
||||
solenoid_config >> solenoid_config_json;
|
||||
|
||||
@@ -74,6 +75,7 @@ std::map<std::string, std::shared_ptr<items::Solenoid>> create_solenoids(std::is
|
||||
|
||||
std::shared_ptr<items::detail::Solenoid> create_solenoid(nlohmann::json &solenoid_json, nlohmann::json &port_extenders, std::shared_ptr<DriverBoardPinController> &pin_controller, std::chrono::milliseconds deactivation_time)
|
||||
{
|
||||
solenoid_json.clear();
|
||||
std::string config_file_name = "solenoid_config.json";
|
||||
|
||||
uint8_t pin_base = get_pin_base(solenoid_json, port_extenders, config_file_name);
|
||||
@@ -91,6 +93,7 @@ std::shared_ptr<items::detail::Solenoid> create_solenoid(nlohmann::json &solenoi
|
||||
|
||||
std::map<std::string, std::shared_ptr<items::Flipper>> create_flippers(std::istream &solenoid_config, std::shared_ptr<DriverBoardPinController> &pin_controller)
|
||||
{
|
||||
solenoid_config.clear();
|
||||
json solenoid_config_json;
|
||||
solenoid_config >> solenoid_config_json;
|
||||
|
||||
@@ -121,6 +124,7 @@ std::shared_ptr<items::detail::Flipper> create_flipper(nlohmann::json &flipper_j
|
||||
|
||||
std::map<std::string, std::shared_ptr<items::Lamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<DriverBoardPinController> &pin_controller)
|
||||
{
|
||||
lamp_config.clear();
|
||||
json lamp_config_json;
|
||||
lamp_config >> lamp_config_json;
|
||||
|
||||
@@ -152,6 +156,7 @@ std::shared_ptr<items::detail::Lamp> create_lamp(json &lamp_json, json & port_ex
|
||||
|
||||
std::map<std::string, std::shared_ptr<items::Sound>> create_sounds(std::istream &sound_config, std::shared_ptr<SoundBoardPinController> &pin_controller)
|
||||
{
|
||||
sound_config.clear();
|
||||
json sound_config_json;
|
||||
sound_config >> sound_config_json;
|
||||
|
||||
@@ -186,6 +191,7 @@ std::shared_ptr<items::detail::Sound> create_sound(json &sound_json, json &port_
|
||||
|
||||
uint8_t get_sound_fire_address(std::istream &sound_config)
|
||||
{
|
||||
sound_config.clear();
|
||||
json sound_config_json;
|
||||
sound_config >> sound_config_json;
|
||||
|
||||
@@ -200,6 +206,7 @@ uint8_t get_sound_fire_address(std::istream &sound_config)
|
||||
|
||||
std::map<std::string, uint8_t> parse_pins_display_board(std::istream &display_config)
|
||||
{
|
||||
display_config.clear();
|
||||
std::string config_file = "display_config.json";
|
||||
|
||||
json display_config_json;
|
||||
@@ -233,7 +240,7 @@ std::map<std::string, uint8_t> parse_pins_display_board(std::istream &display_co
|
||||
|
||||
std::vector<std::shared_ptr<items::OutputDisplay>> create_displays(std::istream &display_config)
|
||||
{
|
||||
|
||||
display_config.clear();
|
||||
json display_config_json;
|
||||
display_config >> display_config_json;
|
||||
|
||||
@@ -259,7 +266,7 @@ std::shared_ptr<items::OutputDisplay> create_display(json & display_json)
|
||||
return std::make_shared<items::detail::EightDigitDisplay>(address, id);
|
||||
|
||||
else if(digits == 7)
|
||||
return std::make_shared<items::detail::SevenDigitDisplay>(address, id);
|
||||
return std::make_shared<items::detail::SevenDigitDisplcreatay>(address, id);
|
||||
|
||||
else
|
||||
throw new std::logic_error("Display digits can either be 7 or 8");
|
||||
@@ -314,7 +321,6 @@ json get_element(const std::string & name, json & object, const std::string & fi
|
||||
try
|
||||
{
|
||||
sub_object = object.at(name);
|
||||
return sub_object;
|
||||
}
|
||||
catch(json::exception &e)
|
||||
{
|
||||
@@ -322,21 +328,23 @@ json get_element(const std::string & name, json & object, const std::string & fi
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return sub_object;
|
||||
}
|
||||
|
||||
template<typename type>
|
||||
type get_value(const std::string & name, json & object, const std::string & file_name)
|
||||
{
|
||||
type element;
|
||||
try
|
||||
{
|
||||
type element = object.at(name).get<type>();
|
||||
return element;
|
||||
element = object.at(name).get<type>();
|
||||
}
|
||||
catch(json::exception &e)
|
||||
{
|
||||
CLOG(ERROR, OUTPUT_LOGGER) << "File " << file_name << " seems to be corrupted at " << name << ": " << e.what();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user