working on big refactor
This commit is contained in:
@@ -1,45 +1,24 @@
|
||||
/*
|
||||
* DisplayController.h
|
||||
*
|
||||
* Created on: Aug 7, 2018
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef _SRC_OUTPUT_DISPLAYCONTROLLER_H_
|
||||
#define _SRC_OUTPUT_DISPLAYCONTROLLER_H_
|
||||
|
||||
#include "IDisplayController.h"
|
||||
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
|
||||
#include "items/IDisplay.h"
|
||||
#include "IOutputGPIOInterface.h"
|
||||
|
||||
#ifndef _SRC_OUTPUT_IDISPLAYCONTROLLER_H_
|
||||
#define _SRC_OUTPUT_IDISPLAYCONTROLLER_H_
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class DisplayController : public IDisplayController
|
||||
class DisplayController
|
||||
{
|
||||
|
||||
public:
|
||||
explicit DisplayController(std::vector<std::shared_ptr<items::IDisplay>> displays, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
|
||||
~DisplayController() override;
|
||||
|
||||
private:
|
||||
void cycle_displays();
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<items::IDisplay>> displays;
|
||||
|
||||
std::thread display_cycle_thread;
|
||||
|
||||
std::shared_ptr<IOutputGPIOInterface> output_gpio_interface;
|
||||
|
||||
bool is_running;
|
||||
virtual ~DisplayController () = default;
|
||||
};
|
||||
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
|
||||
5
FlippR-Driver/src/output/DisplayPinController.cpp
Normal file
5
FlippR-Driver/src/output/DisplayPinController.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#include "DisplayPinController.h"
|
||||
13
FlippR-Driver/src/output/DisplayPinController.h
Normal file
13
FlippR-Driver/src/output/DisplayPinController.h
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_DISPLAYPINCONTROLLER_H
|
||||
#define FLIPPR_DRIVER_DISPLAYPINCONTROLLER_H
|
||||
|
||||
class DisplayPinController
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
#endif //FLIPPR_DRIVER_DISPLAYPINCONTROLLER_H
|
||||
24
FlippR-Driver/src/output/DriverBoardPinController.h
Normal file
24
FlippR-Driver/src/output/DriverBoardPinController.h
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Created by rhetenor on 13.12.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_DRIVERBOARDPINCONTROLLER_H
|
||||
#define FLIPPR_DRIVER_DRIVERBOARDPINCONTROLLER_H
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class DriverBoardPinController
|
||||
{
|
||||
public:
|
||||
virtual ~DriverBoardPinController() = default;
|
||||
|
||||
virtual void activate(items::DriverBoardItem *driver_board_item) = 0;
|
||||
virtual void deactivate(items::DriverBoardItem *driver_board_item) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif //FLIPPR_DRIVER_DRIVERBOARDPINCONTROLLER_H
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* IDisplayController.h
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef _SRC_OUTPUT_IDISPLAYCONTROLLER_H_
|
||||
#define _SRC_OUTPUT_IDISPLAYCONTROLLER_H_
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class IDisplayController
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~IDisplayController () = default;
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
@@ -4,8 +4,10 @@
|
||||
|
||||
#include "OutputDriverFactory.h"
|
||||
|
||||
#include "OutputDriver.h"
|
||||
#include "OutputGPIOInterface.h"
|
||||
#include "utility/LoggerFactory.h"
|
||||
|
||||
#include "output/impl/OutputDriver.h"
|
||||
#include "output/impl/OutputPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
@@ -19,9 +21,11 @@ namespace
|
||||
|
||||
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<OutputDriver> 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<IOutputGPIOInterface> output_gpio_interface = std::shared_ptr<IOutputGPIOInterface>(create_OutputGPIOInterface(output_pin_config));
|
||||
utility::LoggerFactory::CreateOutputLogger();
|
||||
|
||||
std::shared_ptr<OutputPinController> output_gpio_interface = std::shared_ptr<OutputPinController>(create_OutputGPIOInterface(output_pin_config));
|
||||
|
||||
auto solenoids = create_solenoids(solenoid_config, output_gpio_interface);
|
||||
auto lamps = create_lamps(lamp_config, output_gpio_interface);
|
||||
@@ -32,7 +36,7 @@ std::shared_ptr<IOutputDriver> get_OutputDriver(std::istream &output_pin_config,
|
||||
return std::make_shared<OutputDriver>(solenoids, lamps, sounds, displays);
|
||||
}
|
||||
|
||||
IOutputGPIOInterface* create_OutputGPIOInterface(std::istream &output_pin_config)
|
||||
OutputPinController* create_OutputGPIOInterface(std::istream &output_pin_config)
|
||||
{
|
||||
json output_config;
|
||||
output_pin_config >> output_config;
|
||||
@@ -46,52 +50,74 @@ 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>();
|
||||
try
|
||||
{
|
||||
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>();
|
||||
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>();
|
||||
}
|
||||
catch(json::exception &e)
|
||||
{
|
||||
CLOG(ERROR, OUTPUT_LOGGER) << "Output pin config file at driver_board corrupted: " << e.what();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
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;
|
||||
try
|
||||
{
|
||||
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>();
|
||||
|
||||
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>();
|
||||
|
||||
json sound_address = sound_board_config.at("sound_address_select");
|
||||
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>();
|
||||
}
|
||||
catch(json::exception &e)
|
||||
{
|
||||
CLOG(ERROR, OUTPUT_LOGGER) << "Output pin config file at sound_board corrupted: " << e.what();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return pins_sound;
|
||||
}
|
||||
|
||||
std::map<std::string, uint8_t> parse_pins_display(json &display_board_config)
|
||||
{
|
||||
return std::map<std::string, uint8_t>();
|
||||
std::map<std::string, uint8_t> pins_display;
|
||||
try
|
||||
{
|
||||
pins_display["run"] = display_board_config.at("run");
|
||||
}
|
||||
catch(json::exception &e)
|
||||
{
|
||||
CLOG(ERROR, OUTPUT_LOGGER) << "Output pin config file at display_board corrupted: " << e.what();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
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>> create_solenoids(std::istream &solenoid_config, std::shared_ptr<OutputPinController> output_gpio_interface)
|
||||
{
|
||||
std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids;
|
||||
|
||||
@@ -108,7 +134,7 @@ std::map<std::string, std::shared_ptr<items::ISolenoid>> create_solenoids(std::i
|
||||
return solenoids;
|
||||
}
|
||||
|
||||
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>> create_lamps(std::istream &lamp_config, std::shared_ptr<OutputPinController> output_gpio_interface)
|
||||
{
|
||||
std::map<std::string, std::shared_ptr<items::ILamp>> lamps;
|
||||
|
||||
@@ -124,7 +150,7 @@ std::map<std::string, std::shared_ptr<items::ILamp>> create_lamps(std::istream &
|
||||
return lamps;
|
||||
}
|
||||
|
||||
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>> create_sounds(std::istream &sound_config, std::shared_ptr<OutputPinController> output_gpio_interface)
|
||||
{
|
||||
std::map<std::string, std::shared_ptr<items::ISound>> sounds;
|
||||
|
||||
@@ -156,7 +182,7 @@ std::chrono::milliseconds get_deactivation_time(nlohmann::json &json)
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, std::chrono::milliseconds deactivation_time)
|
||||
std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<OutputPinController> output_gpio_interface, std::chrono::milliseconds deactivation_time)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -177,7 +203,7 @@ std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json,
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<items::Lamp> create_lamp(nlohmann::json &lamp_json, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface)
|
||||
std::shared_ptr<items::Lamp> create_lamp(nlohmann::json &lamp_json, std::shared_ptr<OutputPinController> output_gpio_interface)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -192,7 +218,7 @@ std::shared_ptr<items::Lamp> create_lamp(nlohmann::json &lamp_json, std::shared_
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<items::Sound> create_sound(nlohmann::json &sound_json, std::shared_ptr<IOutputGPIOInterface> &output_gpio_interface, std::chrono::milliseconds deactivation_time)
|
||||
std::shared_ptr<items::Sound> create_sound(nlohmann::json &sound_json, std::shared_ptr<OutputPinController> &output_gpio_interface, std::chrono::milliseconds deactivation_time)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#ifndef flippR_driver_OUTPUTDRIVERFACTORY_H
|
||||
#define flippR_driver_OUTPUTDRIVERFACTORY_H
|
||||
|
||||
#include "output/IOutputDriver.h"
|
||||
#include "output/OutputDriver.h"
|
||||
#include "output/items/Solenoid.h"
|
||||
#include "output/items/Lamp.h"
|
||||
#include "output/items/Sound.h"
|
||||
#include "IOutputGPIOInterface.h"
|
||||
#include "OutputPinController.h"
|
||||
|
||||
#include "json/json.hpp"
|
||||
#include <memory>
|
||||
@@ -20,24 +20,24 @@ namespace output
|
||||
{
|
||||
namespace OutputDriverFactory
|
||||
{
|
||||
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<OutputDriver> get_OutputDriver(std::istream &output_pin_config, std::istream &solenoid_config, std::istream &lamp_config, std::istream &sound_config, std::istream &display_config);
|
||||
|
||||
namespace
|
||||
{
|
||||
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<IOutputGPIOInterface> output_gpio_interface, std::chrono::milliseconds deactivation_time);
|
||||
std::map<std::string, std::shared_ptr<items::ISolenoid>> create_solenoids(std::istream &solenoid_config, std::shared_ptr<OutputPinController> output_gpio_interface);
|
||||
std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<OutputPinController> 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<IOutputGPIOInterface> 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::ILamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<OutputPinController> output_gpio_interface);
|
||||
std::shared_ptr<items::Lamp> create_lamp(nlohmann::json &lamp_json, std::shared_ptr<OutputPinController> 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<IOutputGPIOInterface> output_gpio_interface, std::chrono::milliseconds deactivation_time);
|
||||
std::map<std::string, std::shared_ptr<items::ISound>> create_sounds(std::istream &sound_config, std::shared_ptr<OutputPinController> output_gpio_interface);
|
||||
std::shared_ptr<items::Sound> create_sound(nlohmann::json &sound_json, std::shared_ptr<OutputPinController> output_gpio_interface, std::chrono::milliseconds deactivation_time);
|
||||
|
||||
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<IOutputGPIOInterface> output_gpio_interface);
|
||||
std::map<char, std::shared_ptr<items::IDisplay>> create_displays(std::istream &display_config, std::shared_ptr<OutputPinController> output_gpio_interface);
|
||||
|
||||
IOutputGPIOInterface* create_OutputGPIOInterface(std::istream &output_pin_config);
|
||||
OutputPinController* 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_sound(nlohmann::json &sound_board_config);
|
||||
std::map<std::string, uint8_t> parse_pins_display(nlohmann::json &display_board_config);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef flippR_driver_IOUTPUTGPIOINTERFACE_H
|
||||
#define flippR_driver_IOUTPUTGPIOINTERFACE_H
|
||||
|
||||
#include "IOutputGPIOInterface.h"
|
||||
#include "OutputPinController.h"
|
||||
|
||||
#include "output/items/DriverBoardItem.h"
|
||||
#include "output/items/Sound.h"
|
||||
@@ -18,16 +18,11 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
class IOutputGPIOInterface
|
||||
class OutputPinController
|
||||
{
|
||||
public:
|
||||
virtual ~IOutputGPIOInterface() = default;
|
||||
virtual ~OutputPinController() = default;
|
||||
|
||||
virtual void activate(items::DriverBoardItem *driver_board_item) = 0;
|
||||
virtual void activate(items::Item *sound) = 0;
|
||||
|
||||
virtual void deactivate(items::DriverBoardItem *driver_board_item) = 0;
|
||||
virtual void deactivate(items::Item *sound) = 0;
|
||||
|
||||
virtual void write_display(items::IDisplay &display) = 0;
|
||||
//Display gpio interface!
|
||||
25
FlippR-Driver/src/output/SoundBoardPinController.h
Normal file
25
FlippR-Driver/src/output/SoundBoardPinController.h
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_SOUNDPINCONTROLLER_H
|
||||
#define FLIPPR_DRIVER_SOUNDPINCONTROLLER_H
|
||||
|
||||
#include "OutputPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class SoundBoardPinController : public OutputPinController
|
||||
{
|
||||
public:
|
||||
virtual void activate(const items::Sound &sound) = 0;
|
||||
virtual void deactivate(const items::Sound &sound) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif //FLIPPR_DRIVER_SOUNDPINCONTROLLER_H
|
||||
@@ -13,9 +13,11 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<items::IDisplay>> displays, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface)
|
||||
: displays(std::move(displays)), output_gpio_interface(std::move(output_gpio_interface)), is_running(true)
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<items::IDisplay>> displays, std::shared_ptr<OutputPinController> output_gpio_interface)
|
||||
: displays(std::move(displays)), output_gpio_interface(std::move(output_gpio_interface)), is_running(true)
|
||||
{
|
||||
this->display_cycle_thread = std::thread(&DisplayController::cycle_displays, this);
|
||||
|
||||
@@ -42,3 +44,4 @@ void DisplayController::cycle_displays()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
47
FlippR-Driver/src/output/impl/DisplayController.h
Normal file
47
FlippR-Driver/src/output/impl/DisplayController.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* DisplayController.h
|
||||
*
|
||||
* Created on: Aug 7, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef _SRC_OUTPUT_DISPLAYCONTROLLER_H_
|
||||
#define _SRC_OUTPUT_DISPLAYCONTROLLER_H_
|
||||
|
||||
#include "output/DisplayController.h"
|
||||
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
|
||||
#include "output/items/IDisplay.h"
|
||||
#include "output/OutputPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
class DisplayController : public output::DisplayController
|
||||
{
|
||||
public:
|
||||
explicit DisplayController(std::vector<std::shared_ptr<items::IDisplay>> displays, std::shared_ptr<OutputPinController> output_gpio_interface);
|
||||
~DisplayController() override;
|
||||
|
||||
private:
|
||||
void cycle_displays();
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<items::IDisplay>> displays;
|
||||
|
||||
std::thread display_cycle_thread;
|
||||
|
||||
std::shared_ptr<OutputPinController> output_gpio_interface;
|
||||
|
||||
bool is_running;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
85
FlippR-Driver/src/output/impl/DriverBoardPinController.cpp
Normal file
85
FlippR-Driver/src/output/impl/DriverBoardPinController.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#include "DriverBoardPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
void DriverBoardPinController::activate(items::DriverBoardItem *driver_board_item)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||
|
||||
write_driver_board_address(driver_board_item->get_address());
|
||||
|
||||
write_data(true);
|
||||
}
|
||||
|
||||
void DriverBoardPinController::deactivate(items::DriverBoardItem *driver_board_item)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||
|
||||
write_driver_board_address(driver_board_item->get_address());
|
||||
|
||||
write_data(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DriverBoardPinController::write_driver_board_address(uint8_t address)
|
||||
{
|
||||
int latch = address / 8;
|
||||
int pin = address % 8;
|
||||
|
||||
select_mux(latch);
|
||||
|
||||
select_latch(latch);
|
||||
|
||||
select_pin(pin);
|
||||
}
|
||||
|
||||
void DriverBoardPinController::select_mux(uint8_t latch)
|
||||
{
|
||||
bool mux1 = latch / 8;
|
||||
|
||||
write_pin(pins_driver_board.at("mux1"), mux1);
|
||||
write_pin(pins_driver_board.at("mux2"), !mux1);
|
||||
}
|
||||
|
||||
void DriverBoardPinController::select_latch(uint8_t latch)
|
||||
{
|
||||
// todo not nice
|
||||
if(latch > 8)
|
||||
latch -= 8;
|
||||
|
||||
write_pin(pins_driver_board.at("latch-select-A"), latch & 0b001u);
|
||||
write_pin(pins_driver_board.at("latch-select-B"), latch & 0b010u);
|
||||
write_pin(pins_driver_board.at("latch-select-C"), latch & 0b100u);
|
||||
|
||||
}
|
||||
|
||||
void DriverBoardPinController::write_data(bool data)
|
||||
{
|
||||
write_pin(pins_driver_board.at("data"), data);
|
||||
}
|
||||
|
||||
void DriverBoardPinController::select_pin(uint8_t pin)
|
||||
{
|
||||
write_pin(pins_driver_board.at("pin-select-A"), pin & 0b001u);
|
||||
write_pin(pins_driver_board.at("pin-select-B"), pin & 0b010u);
|
||||
write_pin(pins_driver_board.at("pin-select-C"), pin & 0b100u);
|
||||
}
|
||||
|
||||
void DriverBoardPinController::write_pin(uint8_t pin, bool value)
|
||||
{
|
||||
PinController::write_pin(pins_driver_board.at("pin_base") + pin, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
49
FlippR-Driver/src/output/impl/DriverBoardPinController.h
Normal file
49
FlippR-Driver/src/output/impl/DriverBoardPinController.h
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_OUTPUT_IMPL_DRIVERBOARDPINCONTROLLER_H
|
||||
#define FLIPPR_DRIVER_OUTPUT_IMPL_DRIVERBOARDPINCONTROLLER_H
|
||||
|
||||
#include "PinController.h"
|
||||
#include "output/DriverBoardPinController.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
class DriverBoardPinController : public PinController, public output::DriverBoardPinController
|
||||
{
|
||||
public:
|
||||
DriverBoardPinController(std::map<std::string, uint8_t> pins_driver_board, std::shared_ptr<std::mutex> output_item_mutex);
|
||||
~DriverBoardPinController() override = default;
|
||||
|
||||
virtual void activate(items::DriverBoardItem *driver_board_item) = 0;
|
||||
virtual void deactivate(items::DriverBoardItem *driver_board_item) = 0;
|
||||
|
||||
private:
|
||||
void write_driver_board_address(uint8_t address);
|
||||
void select_mux(uint8_t latch);
|
||||
void select_latch(uint8_t latch);
|
||||
void select_pin(uint8_t pin);
|
||||
void write_data(bool data);
|
||||
|
||||
void write_pin(uint8_t pin, bool value);
|
||||
|
||||
private:
|
||||
std::shared_ptr<std::mutex> output_item_mutex;
|
||||
|
||||
const std::map<std::string, uint8_t> pins_driver_board;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //FLIPPR_DRIVER_DRIVERBOARDPINCONTROLLER_H
|
||||
@@ -14,6 +14,8 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
using namespace items;
|
||||
|
||||
@@ -21,7 +23,6 @@ OutputDriver::OutputDriver(std::map<std::string, std::shared_ptr<ISolenoid>> sol
|
||||
: solenoids(std::move(solenoids)), lamps(std::move(lamps)), sounds(std::move(sounds)), displays(std::move(displays))
|
||||
{}
|
||||
|
||||
|
||||
std::vector<std::shared_ptr<ISound>> OutputDriver::get_sounds()
|
||||
{
|
||||
std::vector<std::shared_ptr<ISound>> sounds;
|
||||
@@ -60,7 +61,7 @@ std::vector<std::shared_ptr<ISolenoid>> OutputDriver::get_solenoids()
|
||||
|
||||
boost::optional<std::shared_ptr<items::ILamp>> OutputDriver::get_lamp(std::string name)
|
||||
{
|
||||
return this->lamps.find(name)->second;
|
||||
return this->lamps.find(name)->second;
|
||||
}
|
||||
|
||||
boost::optional<std::shared_ptr<items::ISolenoid>> OutputDriver::get_solenoid(std::string name)
|
||||
@@ -78,6 +79,6 @@ boost::optional<std::shared_ptr<items::IDisplay>> OutputDriver::get_display(char
|
||||
return this->displays.find(number)->second;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef _SRC_OUTPUT_OUTPUTDRIVER_H_
|
||||
#define _SRC_OUTPUT_OUTPUTDRIVER_H_
|
||||
|
||||
#include "output/IOutputDriver.h"
|
||||
#include "output/OutputDriver.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -16,11 +16,13 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
class OutputDriver : public IOutputDriver
|
||||
class OutputDriver : public output::OutputDriver
|
||||
{
|
||||
public:
|
||||
OutputDriver(std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids, std::map<std::string, std::shared_ptr<items::ILamp>> lamps, std::map<std::string, std::shared_ptr<items::ISound>> sounds, std::map<char, std::shared_ptr<items::IDisplay>> displays);
|
||||
OutputDriver(std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids, std::map<std::string, std::shared_ptr<items::ILamp>> lamps, std::map<std::string, std::shared_ptr<items::ISound>> sounds, std::map<char, std::shared_ptr<items::IDisplay>> displays);
|
||||
|
||||
~OutputDriver() override = default;
|
||||
// todo what is flipper_relay ?
|
||||
@@ -38,10 +40,11 @@ private:
|
||||
const std::map<std::string, std::shared_ptr<items::ILamp>> lamps;
|
||||
const std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids;
|
||||
const std::map<std::string, std::shared_ptr<items::ISound>> sounds;
|
||||
|
||||
|
||||
const std::map<char, std::shared_ptr<items::IDisplay>> displays;
|
||||
};
|
||||
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
@@ -5,7 +5,7 @@
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#include "OutputGPIOInterface.h"
|
||||
#include "OutputPinController.h"
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
using namespace output::items;
|
||||
|
||||
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)
|
||||
@@ -35,7 +38,7 @@ void OutputGPIOInterface::initialize_all_pins(uint8_t pin_base)
|
||||
{
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
GPIOInterface::initialize_output_pin(pin_base + i);
|
||||
PinController::initialize_output_pin(pin_base + i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,101 +49,7 @@ void OutputGPIOInterface::initialize_i2c_addresses()
|
||||
mcp23017Setup(pins_display.at("pin_base"), pins_display.at("i2c_address"));
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::activate(items::Item *sound)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||
|
||||
write_sound_address(sound->get_address());
|
||||
|
||||
fire_sound(true);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::activate(items::DriverBoardItem *driver_board_item)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||
|
||||
write_driver_board_address(driver_board_item->get_address());
|
||||
|
||||
write_data(true);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::deactivate(items::DriverBoardItem *driver_board_item)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||
|
||||
write_driver_board_address(driver_board_item->get_address());
|
||||
|
||||
write_data(false);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::deactivate(items::Item *sound)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||
|
||||
write_sound_address(sound->get_address());
|
||||
|
||||
fire_sound(false);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::write_driver_board_address(uint8_t address)
|
||||
{
|
||||
int latch = address / 8;
|
||||
int pin = address % 8;
|
||||
|
||||
select_mux(latch);
|
||||
|
||||
select_latch(latch);
|
||||
|
||||
select_pin(pin);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::select_mux(uint8_t latch)
|
||||
{
|
||||
bool mux1 = latch / 8;
|
||||
|
||||
write_pin(pins_driver_board.at("mux1"), mux1);
|
||||
write_pin(pins_driver_board.at("mux2"), !mux1);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::select_latch(uint8_t latch)
|
||||
{
|
||||
// todo not nice
|
||||
if(latch > 8)
|
||||
latch -= 8;
|
||||
|
||||
write_pin(pins_driver_board.at("latch-select-A"), latch & 0b001u);
|
||||
write_pin(pins_driver_board.at("latch-select-B"), latch & 0b010u);
|
||||
write_pin(pins_driver_board.at("latch-select-C"), latch & 0b100u);
|
||||
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::write_data(bool data)
|
||||
{
|
||||
write_pin(pins_driver_board.at("data"), data);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::select_pin(uint8_t pin)
|
||||
{
|
||||
write_pin(pins_driver_board.at("pin-select-A"), pin & 0b001u);
|
||||
write_pin(pins_driver_board.at("pin-select-B"), pin & 0b010u);
|
||||
write_pin(pins_driver_board.at("pin-select-C"), pin & 0b100u);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::write_sound_address(uint8_t address)
|
||||
{
|
||||
write_pin(pins_sound.at("A"), address & 0b0000001u);
|
||||
write_pin(pins_sound.at("B"), address & 0b0000010u);
|
||||
write_pin(pins_sound.at("C"), address & 0b0000100u);
|
||||
write_pin(pins_sound.at("D"), address & 0b0001000u);
|
||||
write_pin(pins_sound.at("E"), address & 0b0010000u);
|
||||
write_pin(pins_sound.at("F"), address & 0b0100000u);
|
||||
write_pin(pins_sound.at("G"), address & 0b1000000u);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::fire_sound(bool fire)
|
||||
{
|
||||
GPIOInterface::write_pin(pins_sound.at("fire"), fire);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::write_display(IDisplay &display)
|
||||
{
|
||||
@@ -161,7 +70,7 @@ void OutputGPIOInterface::write_display_digit(const uint8_t display_address, con
|
||||
|
||||
run_display(display_address);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(DISPLAY_SLEEP_TIME_MILLISECONDS));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(DISPLAY_SLEEP_TIME_MILLI));
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::select_display_segment(const uint8_t &segment)
|
||||
@@ -196,5 +105,7 @@ void OutputGPIOInterface::deactivate_displays()
|
||||
write_pin(pins_display.at("run"), 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@
|
||||
#ifndef SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
|
||||
#define SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
|
||||
|
||||
#include "IOutputGPIOInterface.h"
|
||||
#include "GPIOInterface.h"
|
||||
#include "output/OutputPinController.h"
|
||||
#include "PinController.h"
|
||||
|
||||
#include <mcp23017.h>
|
||||
#include <mutex>
|
||||
@@ -18,19 +18,19 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
class OutputGPIOInterface : public GPIOInterface, public IOutputGPIOInterface
|
||||
class OutputGPIOInterface : public PinController, public output::OutputPinController
|
||||
{
|
||||
|
||||
public:
|
||||
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);
|
||||
OutputGPIOInterface(, std::map<std::string, uint8_t> pins_sound, std::map<std::string, uint8_t> pins_display);
|
||||
|
||||
~OutputGPIOInterface() override = default;
|
||||
|
||||
void activate(items::DriverBoardItem *driver_board_item) override;
|
||||
void activate(items::Item *sound) override;
|
||||
|
||||
void deactivate(items::DriverBoardItem *driver_board_item) override;
|
||||
void deactivate(items::Item *sound) override;
|
||||
|
||||
void activate_displays();
|
||||
@@ -48,23 +48,12 @@ private:
|
||||
void initialize_pins();
|
||||
void initialize_all_pins(uint8_t pin_base);
|
||||
|
||||
void write_driver_board_address(uint8_t address);
|
||||
void select_mux(uint8_t latch);
|
||||
void select_latch(uint8_t latch);
|
||||
void select_pin(uint8_t pin);
|
||||
void write_data(bool data);
|
||||
|
||||
void write_sound_address(uint8_t address);
|
||||
void fire_sound(bool fire);
|
||||
|
||||
private:
|
||||
std::mutex output_item_mutex;
|
||||
|
||||
const std::map<std::string, uint8_t> pins_driver_board;
|
||||
const std::map<std::string, uint8_t> pins_sound;
|
||||
const std::map<std::string, uint8_t> pins_display;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
56
FlippR-Driver/src/output/impl/SoundBoardPinController.cpp
Normal file
56
FlippR-Driver/src/output/impl/SoundBoardPinController.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#include "SoundBoardPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
void SoundBoardPinController::activate(items::Sound &sound)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||
|
||||
write_sound_address(sound->get_address());
|
||||
|
||||
fire_sound(true);
|
||||
}
|
||||
|
||||
void SoundBoardPinController::deactivate(items::Sound &sound)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||
|
||||
write_sound_address(sound->get_address());
|
||||
|
||||
fire_sound(false);
|
||||
}
|
||||
|
||||
|
||||
void SoundBoardPinController::write_sound_address(uint8_t address)
|
||||
{
|
||||
write_pin(pins_sound.at("A"), address & 0b0000001u);
|
||||
write_pin(pins_sound.at("B"), address & 0b0000010u);
|
||||
write_pin(pins_sound.at("C"), address & 0b0000100u);
|
||||
write_pin(pins_sound.at("D"), address & 0b0001000u);
|
||||
write_pin(pins_sound.at("E"), address & 0b0010000u);
|
||||
write_pin(pins_sound.at("F"), address & 0b0100000u);
|
||||
write_pin(pins_sound.at("G"), address & 0b1000000u);
|
||||
}
|
||||
|
||||
void SoundBoardPinController::fire_sound(bool fire)
|
||||
{
|
||||
PinController::write_pin(pins_sound.at("fire"), fire);
|
||||
}
|
||||
|
||||
void SoundBoardPinController::write_pin(uint8_t pin, bool value)
|
||||
{
|
||||
PinController::write_pin(pins_sound.at("pin_base") + pin, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
45
FlippR-Driver/src/output/impl/SoundBoardPinController.h
Normal file
45
FlippR-Driver/src/output/impl/SoundBoardPinController.h
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_SOUNDBOARDPINCONTROLLER_H
|
||||
#define FLIPPR_DRIVER_SOUNDBOARDPINCONTROLLER_H
|
||||
|
||||
#include <map>
|
||||
#include "output/SoundBoardPinController.h"
|
||||
|
||||
#include "PinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
class SoundBoardPinController : public PinController, public output::SoundBoardPinController
|
||||
{
|
||||
public:
|
||||
SoundBoardPinController();
|
||||
~SoundBoardPinController() override = default;
|
||||
|
||||
void activate(const items::Sound &sound) override;
|
||||
void deactivate(const items::Sound &sound) override;
|
||||
|
||||
private:
|
||||
void write_sound_address(uint8_t address);
|
||||
void fire_sound(bool fire);
|
||||
|
||||
void write_pin(uint8_t pin, bool value);
|
||||
|
||||
private:
|
||||
std::shared_ptr<std::mutex> output_item_mutex;
|
||||
|
||||
const std::map<std::string, uint8_t> pins_sound;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //FLIPPR_DRIVER_SOUNDBOARDPINCONTROLLER_H
|
||||
@@ -19,10 +19,10 @@ namespace items
|
||||
class DriverBoardItem : public Item
|
||||
{
|
||||
public:
|
||||
DriverBoardItem(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name) :
|
||||
DriverBoardItem(std::shared_ptr<OutputPinController> output_gpio_interface, uint8_t address, std::string name) :
|
||||
Item(std::move(output_gpio_interface), address, std::move(name)) {}
|
||||
~DriverBoardItem() override = default;
|
||||
|
||||
~DriverBoardItem() override = default;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
Item::Item(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name) :
|
||||
Item::Item(std::shared_ptr<OutputPinController> output_gpio_interface, uint8_t address, std::string name) :
|
||||
address(address),
|
||||
name(std::move(name)),
|
||||
gpio_interface(std::move(output_gpio_interface))
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
class IOutputGPIOInterface;
|
||||
class OutputPinController;
|
||||
|
||||
namespace items
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace items
|
||||
class Item : public IItem
|
||||
{
|
||||
public:
|
||||
Item(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
||||
Item(std::shared_ptr<OutputPinController> output_gpio_interface, uint8_t address, std::string name);
|
||||
~Item() override = default;
|
||||
|
||||
uint8_t get_address() override;
|
||||
@@ -36,7 +36,7 @@ protected:
|
||||
const uint8_t address;
|
||||
const std::string name;
|
||||
|
||||
const std::shared_ptr<IOutputGPIOInterface> gpio_interface;
|
||||
const std::shared_ptr<OutputPinController> gpio_interface;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Lamp.h"
|
||||
|
||||
#include "output/IOutputGPIOInterface.h"
|
||||
#include "output/OutputPinController.h"
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
@@ -15,7 +15,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
Lamp::Lamp(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name) :
|
||||
Lamp::Lamp(std::shared_ptr<OutputPinController> output_gpio_interface, uint8_t address, std::string name) :
|
||||
DriverBoardItem(std::move(output_gpio_interface), address, std::move(name)), activated(false)
|
||||
{}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace items
|
||||
class Lamp : public DriverBoardItem, public ILamp
|
||||
{
|
||||
public:
|
||||
Lamp(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
||||
Lamp(std::shared_ptr<OutputPinController> output_gpio_interface, uint8_t address, std::string name);
|
||||
~Lamp() override = default;
|
||||
|
||||
void activate() override;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Solenoid.h"
|
||||
|
||||
#include "output/IOutputGPIOInterface.h"
|
||||
#include "output/OutputPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
Solenoid::Solenoid(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time):
|
||||
Solenoid::Solenoid(std::shared_ptr<OutputPinController> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time):
|
||||
DriverBoardItem(std::move(output_gpio_interface), address, std::move(name)), deactivation_time(deactivation_time)
|
||||
{}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace items
|
||||
class Solenoid : public DriverBoardItem, public ISolenoid
|
||||
{
|
||||
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<OutputPinController> output_gpio_interface, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
~Solenoid() override = default;
|
||||
|
||||
void trigger() override;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Sound.h"
|
||||
|
||||
#include "output/IOutputGPIOInterface.h"
|
||||
#include "output/OutputPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
Sound::Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id) :
|
||||
Sound::Sound(std::shared_ptr<OutputPinController> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id) :
|
||||
Item(std::move(output_gpio_interface), address, std::move(name)), deactivation_time(deactivation_time), id(id)
|
||||
{}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
u_int id;
|
||||
|
||||
public:
|
||||
Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id);
|
||||
Sound(std::shared_ptr<OutputPinController> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id);
|
||||
~Sound() override = default;
|
||||
|
||||
void play() override;
|
||||
|
||||
Reference in New Issue
Block a user