enough for today
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
#ifndef _SRC_OUTPUT_ILAMP_H_
|
#ifndef _SRC_OUTPUT_ILAMP_H_
|
||||||
#define _SRC_OUTPUT_ILAMP_H_
|
#define _SRC_OUTPUT_ILAMP_H_
|
||||||
|
|
||||||
#include "IItem.h"
|
#include "output/items/IItem.h"
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
@@ -16,7 +16,7 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class ILamp : public IItem
|
class ILamp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~ILamp()
|
~ILamp()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#ifndef _SRC_OUTPUT_ISOLENOID_H_
|
#ifndef _SRC_OUTPUT_ISOLENOID_H_
|
||||||
#define _SRC_OUTPUT_ISOLENOID_H_
|
#define _SRC_OUTPUT_ISOLENOID_H_
|
||||||
|
|
||||||
#include "IItem.h"
|
#include "output/items/IItem.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class ISolenoid : public IItem
|
class ISolenoid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~ISolenoid()
|
~ISolenoid()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#ifndef _SRC_OUTPUT_ISOUND_H_
|
#ifndef _SRC_OUTPUT_ISOUND_H_
|
||||||
#define _SRC_OUTPUT_ISOUND_H_
|
#define _SRC_OUTPUT_ISOUND_H_
|
||||||
|
|
||||||
#include "IItem.h"
|
#include "output/items/IItem.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class ISound : public IItem
|
class ISound
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISound();
|
ISound();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace flippR_driver
|
|||||||
namespace input
|
namespace input
|
||||||
{
|
{
|
||||||
|
|
||||||
class InputGPIOInterface : public IInputGPIOInterface, GPIOInterface
|
class InputGPIOInterface : public IInputGPIOInterface, public GPIOInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit InputGPIOInterface(std::map<std::string, uint8_t> pins);
|
explicit InputGPIOInterface(std::map<std::string, uint8_t> pins);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ using namespace nlohmann;
|
|||||||
|
|
||||||
std::shared_ptr<IOutputDriver> get_OutputDriver(std::istream &output_pin_config, std::istream &solenoid_config, std::istream &lamp_config, std::istream &sound_config, std::istream &display_config)
|
std::shared_ptr<IOutputDriver> get_OutputDriver(std::istream &output_pin_config, std::istream &solenoid_config, std::istream &lamp_config, std::istream &sound_config, std::istream &display_config)
|
||||||
{
|
{
|
||||||
auto output_gpio_interface = create_OutputGPIOInterface(output_pin_config);
|
std::shared_ptr<IOutputGPIOInterface> output_gpio_interface = std::shared_ptr<IOutputGPIOInterface>(create_OutputGPIOInterface(output_pin_config));
|
||||||
|
|
||||||
auto solenoids = create_solenoids(solenoid_config, output_gpio_interface);
|
auto solenoids = create_solenoids(solenoid_config, output_gpio_interface);
|
||||||
auto lamps = create_lamps(lamp_config, output_gpio_interface);
|
auto lamps = create_lamps(lamp_config, output_gpio_interface);
|
||||||
@@ -32,16 +32,14 @@ std::shared_ptr<IOutputDriver> get_OutputDriver(std::istream &output_pin_config,
|
|||||||
return std::make_shared<OutputDriver>(solenoids, lamps, sounds, displays);
|
return std::make_shared<OutputDriver>(solenoids, lamps, sounds, displays);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<OutputGPIOInterface> create_OutputGPIOInterface(std::istream &output_pin_config)
|
IOutputGPIOInterface* create_OutputGPIOInterface(std::istream &output_pin_config)
|
||||||
{
|
{
|
||||||
json output_config;
|
json output_config;
|
||||||
output_pin_config >> output_config;
|
output_pin_config >> output_config;
|
||||||
|
|
||||||
return std::make_shared<OutputGPIOInterface>(
|
return new OutputGPIOInterface(parse_pins_driver_board(output_config.at("driver_board")),
|
||||||
parse_pins_driver_board(output_config.at("driver_board")),
|
|
||||||
parse_pins_sound(output_config.at("sound_board")),
|
parse_pins_sound(output_config.at("sound_board")),
|
||||||
parse_pins_sound(output_config.at("display_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> parse_pins_driver_board(json &driver_board_config)
|
||||||
@@ -93,7 +91,7 @@ std::map<std::string, uint8_t> parse_pins_display(json &display_board_config)
|
|||||||
return std::map<std::string, uint8_t>();
|
return std::map<std::string, uint8_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::ISolenoid>> create_solenoids(std::istream &solenoid_config, std::shared_ptr<OutputGPIOInterface> output_gpio_interface)
|
std::map<std::string, std::shared_ptr<items::ISolenoid>> create_solenoids(std::istream &solenoid_config, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids;
|
std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids;
|
||||||
|
|
||||||
@@ -105,12 +103,12 @@ std::map<std::string, std::shared_ptr<items::ISolenoid>> create_solenoids(std::i
|
|||||||
for(auto &solenoid_json : solenoids_json)
|
for(auto &solenoid_json : solenoids_json)
|
||||||
{
|
{
|
||||||
auto solenoid = create_solenoid(solenoid_json, output_gpio_interface, deactivation_time);
|
auto solenoid = create_solenoid(solenoid_json, output_gpio_interface, deactivation_time);
|
||||||
solenoids.emplace(solenoid->Item::get_name(), solenoid_json);
|
solenoids.emplace(solenoid->get_name(), solenoid);
|
||||||
}
|
}
|
||||||
return solenoids;
|
return solenoids;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::ILamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<OutputGPIOInterface> output_gpio_interface)
|
std::map<std::string, std::shared_ptr<items::ILamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::shared_ptr<items::ILamp>> lamps;
|
std::map<std::string, std::shared_ptr<items::ILamp>> lamps;
|
||||||
|
|
||||||
@@ -120,13 +118,13 @@ std::map<std::string, std::shared_ptr<items::ILamp>> create_lamps(std::istream &
|
|||||||
for(auto &lamp_json : lamps_json)
|
for(auto &lamp_json : lamps_json)
|
||||||
{
|
{
|
||||||
auto lamp = create_lamp(lamp_json, output_gpio_interface);
|
auto lamp = create_lamp(lamp_json, output_gpio_interface);
|
||||||
lamps.emplace(lamp->Item::get_name(), lamp);
|
lamps.emplace(lamp->get_name(), lamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return lamps;
|
return lamps;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::ISound>> create_sounds(std::istream &sound_config, std::shared_ptr<OutputGPIOInterface> output_gpio_interface)
|
std::map<std::string, std::shared_ptr<items::ISound>> create_sounds(std::istream &sound_config, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::shared_ptr<items::ISound>> sounds;
|
std::map<std::string, std::shared_ptr<items::ISound>> sounds;
|
||||||
|
|
||||||
@@ -138,7 +136,7 @@ std::map<std::string, std::shared_ptr<items::ISound>> create_sounds(std::istream
|
|||||||
for(auto &sound_json : sounds_json)
|
for(auto &sound_json : sounds_json)
|
||||||
{
|
{
|
||||||
auto sound = create_sound(sound_json, output_gpio_interface, deactivation_time);
|
auto sound = create_sound(sound_json, output_gpio_interface, deactivation_time);
|
||||||
sounds.emplace(sound->Item::get_name(), sound);
|
sounds.emplace(sound->get_name(), sound);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sounds;
|
return sounds;
|
||||||
@@ -157,7 +155,7 @@ std::chrono::milliseconds get_deactivation_time(nlohmann::json &json)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<OutputGPIOInterface> output_gpio_interface, std::chrono::milliseconds deactivation_time)
|
std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, std::chrono::milliseconds deactivation_time)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -171,7 +169,7 @@ std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<items::Sound> create_sound(nlohmann::json &sound_json, std::shared_ptr<OutputGPIOInterface> &output_gpio_interface, std::chrono::milliseconds deactivation_time)
|
std::shared_ptr<items::Sound> create_sound(nlohmann::json &sound_json, std::shared_ptr<IOutputGPIOInterface> &output_gpio_interface, std::chrono::milliseconds deactivation_time)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,20 +23,20 @@ namespace OutputDriverFactory
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::map<std::string, std::shared_ptr<items::ISolenoid>> create_solenoids(std::istream &solenoid_config, std::shared_ptr<OutputGPIOInterface> output_gpio_interface);
|
std::map<std::string, std::shared_ptr<items::ISolenoid>> create_solenoids(std::istream &solenoid_config, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
|
||||||
std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<OutputGPIOInterface> output_gpio_interface, std::chrono::milliseconds deactivation_time);
|
std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, std::chrono::milliseconds deactivation_time);
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::ILamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<OutputGPIOInterface> output_gpio_interface);
|
std::map<std::string, std::shared_ptr<items::ILamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
|
||||||
std::shared_ptr<items::Lamp> create_lamp(nlohmann::json &lamp_json, std::shared_ptr<OutputGPIOInterface> output_gpio_interface);
|
std::shared_ptr<items::Lamp> create_lamp(nlohmann::json &lamp_json, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::ISound>> create_sounds(std::istream &sound_config, std::shared_ptr<OutputGPIOInterface> output_gpio_interface);
|
std::map<std::string, std::shared_ptr<items::ISound>> create_sounds(std::istream &sound_config, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
|
||||||
std::shared_ptr<items::Sound> create_sound(nlohmann::json &sound_json, std::shared_ptr<OutputGPIOInterface> output_gpio_interface, std::chrono::milliseconds deactivation_time);
|
std::shared_ptr<items::Sound> create_sound(nlohmann::json &sound_json, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, std::chrono::milliseconds deactivation_time);
|
||||||
|
|
||||||
std::chrono::milliseconds get_deactivation_time(nlohmann::json &json);
|
std::chrono::milliseconds get_deactivation_time(nlohmann::json &json);
|
||||||
|
|
||||||
std::map<char, std::shared_ptr<items::IDisplay>> create_displays(std::istream &display_config, std::shared_ptr<OutputGPIOInterface> output_gpio_interface);
|
std::map<char, std::shared_ptr<items::IDisplay>> create_displays(std::istream &display_config, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
|
||||||
|
|
||||||
std::shared_ptr<OutputGPIOInterface> create_OutputGPIOInterface(std::istream &output_pin_config);
|
IOutputGPIOInterface* create_OutputGPIOInterface(std::istream &output_pin_config);
|
||||||
std::map<std::string, uint8_t> parse_pins_driver_board(nlohmann::json &driver_board_config);
|
std::map<std::string, uint8_t> parse_pins_driver_board(nlohmann::json &driver_board_config);
|
||||||
std::map<std::string, uint8_t> parse_pins_sound(nlohmann::json &sound_board_config);
|
std::map<std::string, uint8_t> parse_pins_sound(nlohmann::json &sound_board_config);
|
||||||
std::map<std::string, uint8_t> parse_pins_display(nlohmann::json &display_board_config);
|
std::map<std::string, uint8_t> parse_pins_display(nlohmann::json &display_board_config);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace flippR_driver
|
|||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
|
|
||||||
class OutputGPIOInterface : public GPIOInterface, IOutputGPIOInterface
|
class OutputGPIOInterface : public GPIOInterface, public IOutputGPIOInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace items
|
|||||||
class Solenoid : public Item, public ISolenoid
|
class Solenoid : public Item, public ISolenoid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Solenoid(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
Solenoid(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
||||||
~Solenoid() override = default;
|
~Solenoid() override = default;
|
||||||
|
|
||||||
void trigger() override;
|
void trigger() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user