refactored outpugpiointerface
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "GPIOInterface.h"
|
#include "GPIOInterface.h"
|
||||||
|
|
||||||
#include "config.h"
|
#include "utility/config.h"
|
||||||
|
|
||||||
#include "wiringPi/wiringPi.h"
|
#include "wiringPi/wiringPi.h"
|
||||||
#include "json/json.hpp"
|
#include "json/json.hpp"
|
||||||
@@ -17,8 +17,6 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace utility
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPIOInterface
|
class GPIOInterface
|
||||||
{
|
{
|
||||||
@@ -43,7 +41,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "utility/IInputGPIOInterface.h"
|
#include "IInputGPIOInterface.h"
|
||||||
|
|
||||||
#include "IDetector.h"
|
#include "IDetector.h"
|
||||||
#include "DistributingEvent.h"
|
#include "DistributingEvent.h"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include "Detector.h"
|
#include "Detector.h"
|
||||||
#include "input/IInputDriver.h"
|
#include "input/IInputDriver.h"
|
||||||
|
|
||||||
#include "utility/InputGPIOInterface.h"
|
#include "InputGPIOInterface.h"
|
||||||
#include "json/json.hpp"
|
#include "json/json.hpp"
|
||||||
#include "IEventNotifier.h"
|
#include "IEventNotifier.h"
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "InputGPIOInterface.h"
|
#include "InputGPIOInterface.h"
|
||||||
#include "json/json.hpp"
|
#include "json/json.hpp"
|
||||||
#include "easylogging/easylogging++.h"
|
#include "easylogging/easylogging++.h"
|
||||||
#include "config.h"
|
#include "utility/config.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DisplayController.h"
|
#include "DisplayController.h"
|
||||||
#include "utility/IOutputGPIOInterface.h"
|
#include "IOutputGPIOInterface.h"
|
||||||
|
|
||||||
#include "utility/config.h"
|
#include "utility/config.h"
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "items/IDisplay.h"
|
#include "items/IDisplay.h"
|
||||||
#include "utility/IOutputGPIOInterface.h"
|
#include "IOutputGPIOInterface.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace utility
|
namespace output
|
||||||
{
|
{
|
||||||
|
|
||||||
class IOutputGPIOInterface
|
class IOutputGPIOInterface
|
||||||
@@ -8,6 +8,77 @@ namespace flippR_driver
|
|||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
|
namespace OutputDriverFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
using namespace nlohmann;
|
||||||
|
|
||||||
|
std::shared_ptr<OutputGPIOInterface> createOutputGPIOInterface(std::istream &output_gpio_config)
|
||||||
|
{
|
||||||
|
json output_config;
|
||||||
|
output_gpio_config >> output_config;
|
||||||
|
|
||||||
|
return std::make_shared<OutputGPIOInterface>(
|
||||||
|
parse_pins_driver_board(output_config.at("driver_board")),
|
||||||
|
parse_pins_sound(output_config.at("sound_board")),
|
||||||
|
parse_pins_sound(output_config.at("display_board"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, uint8_t> parse_pins_driver_board(json &driver_board_config)
|
||||||
|
{
|
||||||
|
std::map<std::string, uint8_t> pins_driver_board;
|
||||||
|
|
||||||
|
pins_driver_board["i2c_address"] = driver_board_config.at("i2c_address").get<uint8_t>();
|
||||||
|
pins_driver_board["pin_base"] = driver_board_config.at("pin_base").get<uint8_t>();
|
||||||
|
pins_driver_board["data"] = driver_board_config.at("data").get<uint8_t>();
|
||||||
|
pins_driver_board["CL"] = driver_board_config.at("CL").get<uint8_t>();
|
||||||
|
|
||||||
|
json pin_select = driver_board_config.at("pin-select");
|
||||||
|
pins_driver_board["pin-select-A"] = pin_select.at("A").get<uint8_t>();
|
||||||
|
pins_driver_board["pin-select-B"] = pin_select.at("B").get<uint8_t>();
|
||||||
|
pins_driver_board["pin-select-C"] = pin_select.at("C").get<uint8_t>();
|
||||||
|
|
||||||
|
json latch_select = driver_board_config.at("latch-select");
|
||||||
|
pins_driver_board["mux1"] = latch_select.at("mux1").get<uint8_t>();
|
||||||
|
pins_driver_board["mux2"] = latch_select.at("mux2").get<uint8_t>();
|
||||||
|
pins_driver_board["latch-select-A"] = latch_select.at("A").get<uint8_t>();
|
||||||
|
pins_driver_board["latch-select-B"] = latch_select.at("B").get<uint8_t>();
|
||||||
|
pins_driver_board["latch-select-C"] = latch_select.at("C").get<uint8_t>();
|
||||||
|
|
||||||
|
return pins_driver_board;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, uint8_t> parse_pins_sound(json &sound_board_config)
|
||||||
|
{
|
||||||
|
std::map<std::string, uint8_t> pins_sound;
|
||||||
|
|
||||||
|
pins_sound["i2c_address"] = sound_board_config.at("i2c_address").get<uint8_t>();
|
||||||
|
pins_sound["pin_base"] = sound_board_config.at("pin_base").get<uint8_t>();
|
||||||
|
pins_sound["fire"] = sound_board_config.at("fire").get<uint8_t>();
|
||||||
|
|
||||||
|
json sound_address = sound_board_config.at("sound_address");
|
||||||
|
pins_sound["A"] = sound_address.at("A").get<uint8_t>();
|
||||||
|
pins_sound["B"] = sound_address.at("B").get<uint8_t>();
|
||||||
|
pins_sound["C"] = sound_address.at("C").get<uint8_t>();
|
||||||
|
pins_sound["D"] = sound_address.at("D").get<uint8_t>();
|
||||||
|
pins_sound["E"] = sound_address.at("E").get<uint8_t>();
|
||||||
|
pins_sound["F"] = sound_address.at("F").get<uint8_t>();
|
||||||
|
pins_sound["G"] = sound_address.at("G").get<uint8_t>();
|
||||||
|
|
||||||
|
return pins_sound;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, uint8_t> parse_pins_display(json &display_board_config)
|
||||||
|
{
|
||||||
|
return std::map<std::string, uint8_t>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,16 +8,25 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "OutputDriver.h"
|
#include "OutputDriver.h"
|
||||||
|
#include "OutputGPIOInterface.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
class OutputDriverFactory
|
namespace OutputDriverFactory
|
||||||
{
|
{
|
||||||
public:
|
static std::shared_ptr<OutputDriver> getOutputDriver(std::istream &output_gpio_config, std::istream &output_config);
|
||||||
static std::shared_ptr <OutputDriver> getOutputDriver(std::ifstream &output_gpio_config, std::ifstream &output_config);
|
|
||||||
};
|
namespace
|
||||||
|
{
|
||||||
|
static std::shared_ptr<OutputGPIOInterface> createOutputGPIOInterface(std::istream &output_gpio_config);
|
||||||
|
|
||||||
|
static std::map<std::string, uint8_t> parse_pins_driver_board(nlohmann::json &driver_board_config);
|
||||||
|
static std::map<std::string, uint8_t> parse_pins_sound(nlohmann::json &sound_board_config);
|
||||||
|
static std::map<std::string, uint8_t> parse_pins_display(nlohmann::json &display_board_config);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,71 +9,19 @@
|
|||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace utility
|
namespace output
|
||||||
{
|
{
|
||||||
using namespace output::items;
|
using namespace output::items;
|
||||||
using namespace nlohmann;
|
using namespace nlohmann;
|
||||||
|
|
||||||
OutputGPIOInterface::OutputGPIOInterface(std::istream &output_config_stream)
|
OutputGPIOInterface::OutputGPIOInterface(std::map<std::string, uint8_t> pins_driver_board, std::map<std::string, uint8_t> pins_sound, std::map<std::string, uint8_t> pins_display)
|
||||||
|
: pins_driver_board(pins_driver_board), pins_sound(pins_sound), pins_display(pins_display)
|
||||||
{
|
{
|
||||||
json output_config;
|
|
||||||
output_config_stream >> output_config;
|
|
||||||
|
|
||||||
parse_output_config(output_config);
|
|
||||||
|
|
||||||
initialize_i2c_addresses();
|
initialize_i2c_addresses();
|
||||||
|
|
||||||
initialize_pins();
|
initialize_pins();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputGPIOInterface::parse_output_config(json &output_config)
|
|
||||||
{
|
|
||||||
parse_pins_driver_board(output_config.at("driver_board"));
|
|
||||||
parse_pins_sound(output_config.at("sound_board"));
|
|
||||||
parse_pins_sound(output_config.at("display_board"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputGPIOInterface::parse_pins_driver_board(json &driver_board_config)
|
|
||||||
{
|
|
||||||
this->pins_driver_board["i2c_address"] = driver_board_config.at("i2c_address").get<uint8_t>();
|
|
||||||
this->pins_driver_board["pin_base"] = driver_board_config.at("pin_base").get<uint8_t>();
|
|
||||||
this->pins_driver_board["data"] = driver_board_config.at("data").get<uint8_t>();
|
|
||||||
this->pins_driver_board["CL"] = driver_board_config.at("CL").get<uint8_t>();
|
|
||||||
|
|
||||||
json pin_select = driver_board_config.at("pin-select");
|
|
||||||
this->pins_driver_board["pin-select-A"] = pin_select.at("A").get<uint8_t>();
|
|
||||||
this->pins_driver_board["pin-select-B"] = pin_select.at("B").get<uint8_t>();
|
|
||||||
this->pins_driver_board["pin-select-C"] = pin_select.at("C").get<uint8_t>();
|
|
||||||
|
|
||||||
json latch_select = driver_board_config.at("latch-select");
|
|
||||||
this->pins_driver_board["mux1"] = latch_select.at("mux1").get<uint8_t>();
|
|
||||||
this->pins_driver_board["mux2"] = latch_select.at("mux2").get<uint8_t>();
|
|
||||||
this->pins_driver_board["latch-select-A"] = latch_select.at("A").get<uint8_t>();
|
|
||||||
this->pins_driver_board["latch-select-B"] = latch_select.at("B").get<uint8_t>();
|
|
||||||
this->pins_driver_board["latch-select-C"] = latch_select.at("C").get<uint8_t>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputGPIOInterface::parse_pins_sound(json &sound_board_config)
|
|
||||||
{
|
|
||||||
this->pins_sound["i2c_address"] = sound_board_config.at("i2c_address").get<uint8_t>();
|
|
||||||
this->pins_sound["pin_base"] = sound_board_config.at("pin_base").get<uint8_t>();
|
|
||||||
this->pins_sound["fire"] = sound_board_config.at("fire").get<uint8_t>();
|
|
||||||
|
|
||||||
json sound_address = sound_board_config.at("sound_address");
|
|
||||||
this->pins_sound["A"] = sound_address.at("A").get<uint8_t>();
|
|
||||||
this->pins_sound["B"] = sound_address.at("B").get<uint8_t>();
|
|
||||||
this->pins_sound["C"] = sound_address.at("C").get<uint8_t>();
|
|
||||||
this->pins_sound["D"] = sound_address.at("D").get<uint8_t>();
|
|
||||||
this->pins_sound["E"] = sound_address.at("E").get<uint8_t>();
|
|
||||||
this->pins_sound["F"] = sound_address.at("F").get<uint8_t>();
|
|
||||||
this->pins_sound["G"] = sound_address.at("G").get<uint8_t>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputGPIOInterface::parse_pins_display(json &display_board_config)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputGPIOInterface::initialize_pins()
|
void OutputGPIOInterface::initialize_pins()
|
||||||
{
|
{
|
||||||
// Since this are all outputs we just initialize everything as output conveniently
|
// Since this are all outputs we just initialize everything as output conveniently
|
||||||
@@ -20,14 +20,14 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace utility
|
namespace output
|
||||||
{
|
{
|
||||||
|
|
||||||
class OutputGPIOInterface : public GPIOInterface, IOutputGPIOInterface
|
class OutputGPIOInterface : public GPIOInterface, IOutputGPIOInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OutputGPIOInterface(std::istream &output_config_stream);
|
OutputGPIOInterface(std::map<std::string, uint8_t> pins_driver_board, std::map<std::string, uint8_t> pins_sound, std::map<std::string, uint8_t> pins_display);
|
||||||
|
|
||||||
virtual ~OutputGPIOInterface() = default;
|
virtual ~OutputGPIOInterface() = default;
|
||||||
|
|
||||||
@@ -40,11 +40,6 @@ public:
|
|||||||
virtual void write_display(output::items::IDisplay *display);
|
virtual void write_display(output::items::IDisplay *display);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parse_output_config(nlohmann::json &output_config);
|
|
||||||
void parse_pins_driver_board(nlohmann::json &driver_board_config);
|
|
||||||
void parse_pins_sound(nlohmann::json &sound_board_config);
|
|
||||||
void parse_pins_display(nlohmann::json &display_board_config);
|
|
||||||
|
|
||||||
void initialize_i2c_addresses();
|
void initialize_i2c_addresses();
|
||||||
|
|
||||||
void initialize_pins();
|
void initialize_pins();
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "IItem.h"
|
#include "IItem.h"
|
||||||
|
|
||||||
#include "utility/IOutputGPIOInterface.h"
|
#include "output/IOutputGPIOInterface.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* DisplayGPIOInterface.cpp
|
|
||||||
*
|
|
||||||
* Created on: Nov 9, 2018
|
|
||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "DisplayGPIOInterface.h"
|
|
||||||
namespace flippR_driver
|
|
||||||
{
|
|
||||||
namespace utility
|
|
||||||
{
|
|
||||||
|
|
||||||
DisplayGPIOInterface::DisplayGPIOInterface()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DisplayGPIOInterface::~DisplayGPIOInterface()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated destructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* DisplayGPIOInterface.h
|
|
||||||
*
|
|
||||||
* Created on: Nov 9, 2018
|
|
||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SRC_UTILITY_DISPLAYGPIOINTERFACE_H_
|
|
||||||
#define SRC_UTILITY_DISPLAYGPIOINTERFACE_H_
|
|
||||||
|
|
||||||
namespace flippR_driver
|
|
||||||
{
|
|
||||||
namespace utility
|
|
||||||
{
|
|
||||||
|
|
||||||
class DisplayGPIOInterface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DisplayGPIOInterface();
|
|
||||||
virtual
|
|
||||||
~DisplayGPIOInterface();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SRC_UTILITY_DISPLAYGPIOINTERFACE_H_ */
|
|
||||||
Reference in New Issue
Block a user