changed everything to impl
This commit is contained in:
@@ -8,10 +8,10 @@
|
|||||||
#ifndef _SRC_OUTPUT_IOUTPUTDRIVER_H_
|
#ifndef _SRC_OUTPUT_IOUTPUTDRIVER_H_
|
||||||
#define _SRC_OUTPUT_IOUTPUTDRIVER_H_
|
#define _SRC_OUTPUT_IOUTPUTDRIVER_H_
|
||||||
|
|
||||||
#include "output/items/ILamp.h"
|
#include "output/items/impl/Lamp.h"
|
||||||
#include "output/items/ISolenoid.h"
|
#include "output/items/Solenoid.h"
|
||||||
#include "output/items/IDisplay.h"
|
#include "output/items/Display.h"
|
||||||
#include "output/items/ISound.h"
|
#include "output/items/Sound.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -27,15 +27,15 @@ class OutputDriver
|
|||||||
public:
|
public:
|
||||||
virtual ~OutputDriver() = default;
|
virtual ~OutputDriver() = default;
|
||||||
|
|
||||||
virtual std::vector<std::shared_ptr<items::ILamp>> get_lamps() = 0;
|
virtual std::vector<std::shared_ptr<items::Lamp>> get_lamps() = 0;
|
||||||
virtual std::vector<std::shared_ptr<items::ISolenoid>> get_solenoids() = 0;
|
virtual std::vector<std::shared_ptr<items::Solenoid>> get_solenoids() = 0;
|
||||||
virtual std::vector<std::shared_ptr<items::ISound>> get_sounds() = 0;
|
virtual std::vector<std::shared_ptr<items::Sound>> get_sounds() = 0;
|
||||||
virtual std::vector<std::shared_ptr<items::IDisplay>> get_displays() = 0;
|
virtual std::vector<std::shared_ptr<items::Display>> get_displays() = 0;
|
||||||
|
|
||||||
virtual boost::optional<std::shared_ptr<items::ILamp>> get_lamp(std::string name) = 0;
|
virtual boost::optional<std::shared_ptr<items::Lamp>> get_lamp(std::string name) = 0;
|
||||||
virtual boost::optional<std::shared_ptr<items::ISolenoid>> get_solenoid(std::string name) = 0;
|
virtual boost::optional<std::shared_ptr<items::Solenoid>> get_solenoid(std::string name) = 0;
|
||||||
virtual boost::optional<std::shared_ptr<items::ISound>> get_sound(std::string name) = 0;
|
virtual boost::optional<std::shared_ptr<items::Sound>> get_sound(std::string name) = 0;
|
||||||
virtual boost::optional<std::shared_ptr<items::IDisplay>> get_display(char number) = 0;
|
virtual boost::optional<std::shared_ptr<items::Display>> get_display(char number) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace output */
|
} /* namespace output */
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef FLIPPR_DRIVER_IEIGHTDIGITDISPLAY_H
|
#ifndef FLIPPR_DRIVER_IEIGHTDIGITDISPLAY_H
|
||||||
#define FLIPPR_DRIVER_IEIGHTDIGITDISPLAY_H
|
#define FLIPPR_DRIVER_IEIGHTDIGITDISPLAY_H
|
||||||
|
|
||||||
#include "IOutputDisplay.h"
|
#include "OutputDisplay.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* ILamp.h
|
* Lamp.h
|
||||||
*
|
*
|
||||||
* Created on: Aug 7, 2018
|
* Created on: Aug 7, 2018
|
||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||||
@@ -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 "output/items/IItem.h"
|
#include "output/items/Item.h"
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
@@ -16,10 +16,10 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class ILamp
|
class Lamp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~ILamp()
|
~Lamp()
|
||||||
{};
|
{};
|
||||||
|
|
||||||
virtual void activate() = 0;
|
virtual void activate() = 0;
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef FLIPPR_DRIVER_ISEVENDIGITDISPLAY_H
|
#ifndef FLIPPR_DRIVER_ISEVENDIGITDISPLAY_H
|
||||||
#define FLIPPR_DRIVER_ISEVENDIGITDISPLAY_H
|
#define FLIPPR_DRIVER_ISEVENDIGITDISPLAY_H
|
||||||
|
|
||||||
#include "IOutputDisplay.h"
|
#include "OutputDisplay.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* ISolenoid.h
|
* Solenoid.h
|
||||||
*
|
*
|
||||||
* Created on: Aug 7, 2018
|
* Created on: Aug 7, 2018
|
||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||||
@@ -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 "output/items/IItem.h"
|
#include "output/items/Item.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -17,10 +17,10 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class ISolenoid
|
class Solenoid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~ISolenoid()
|
~Solenoid()
|
||||||
{};
|
{};
|
||||||
|
|
||||||
virtual void trigger() = 0;
|
virtual void trigger() = 0;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* ISound.h
|
* Sound.h
|
||||||
*
|
*
|
||||||
* Created on: Aug 2, 2018
|
* Created on: Aug 2, 2018
|
||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||||
@@ -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 "output/items/IItem.h"
|
#include "output/items/Item.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -17,11 +17,11 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class ISound
|
class Sound
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISound();
|
Sound();
|
||||||
virtual ~ISound();
|
virtual ~Sound();
|
||||||
|
|
||||||
virtual void play() = 0;
|
virtual void play() = 0;
|
||||||
};
|
};
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef FLIPPR_DRIVER_DISPLAYPINCONTROLLER_H
|
#ifndef FLIPPR_DRIVER_DISPLAYPINCONTROLLER_H
|
||||||
#define FLIPPR_DRIVER_DISPLAYPINCONTROLLER_H
|
#define FLIPPR_DRIVER_DISPLAYPINCONTROLLER_H
|
||||||
|
|
||||||
#include "items/IDisplay.h"
|
#include "output/items/Display.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ public:
|
|||||||
virtual void activate_displays() = 0;
|
virtual void activate_displays() = 0;
|
||||||
virtual void deactivate_displays() = 0;
|
virtual void deactivate_displays() = 0;
|
||||||
|
|
||||||
virtual void write_display(items::IDisplay &display) = 0;
|
virtual void write_display(items::Display &display) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ std::shared_ptr<OutputDriver> get_OutputDriver(std::istream &output_pin_config,
|
|||||||
auto displays = create_displays(display_config);
|
auto displays = create_displays(display_config);
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
std::vector<std::shared_ptr<items::IDisplay>> displays_vec;
|
std::vector<std::shared_ptr<items::Display>> displays_vec;
|
||||||
boost::copy(displays | boost::adaptors::map_values, std::back_inserter(displays_vec));
|
boost::copy(displays | boost::adaptors::map_values, std::back_inserter(displays_vec));
|
||||||
std::unique_ptr<DisplayController> display_controller(new impl::DisplayController(displays_vec, std::move(display_board_pin_controller)));
|
std::unique_ptr<DisplayController> display_controller(new impl::DisplayController(displays_vec, std::move(display_board_pin_controller)));
|
||||||
|
|
||||||
@@ -131,9 +131,9 @@ std::map<std::string, uint8_t> parse_pins_display_board(json &display_board_conf
|
|||||||
return pins_display;
|
return pins_display;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::ISolenoid>> create_solenoids(std::istream &solenoid_config, std::shared_ptr<DriverBoardPinController> &output_gpio_interface)
|
std::map<std::string, std::shared_ptr<items::Solenoid>> create_solenoids(std::istream &solenoid_config, std::shared_ptr<DriverBoardPinController> &output_gpio_interface)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids;
|
std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids;
|
||||||
|
|
||||||
json solenoids_json;
|
json solenoids_json;
|
||||||
solenoid_config >> solenoids_json;
|
solenoid_config >> solenoids_json;
|
||||||
@@ -145,12 +145,13 @@ std::map<std::string, std::shared_ptr<items::ISolenoid>> create_solenoids(std::i
|
|||||||
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->get_name(), solenoid);
|
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<DriverBoardPinController> &output_gpio_interface)
|
std::map<std::string, std::shared_ptr<items::Lamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<DriverBoardPinController> &output_gpio_interface)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::shared_ptr<items::ILamp>> lamps;
|
std::map<std::string, std::shared_ptr<items::Lamp>> lamps;
|
||||||
|
|
||||||
json lamps_json;
|
json lamps_json;
|
||||||
lamp_config >> lamps_json;
|
lamp_config >> lamps_json;
|
||||||
@@ -164,9 +165,9 @@ std::map<std::string, std::shared_ptr<items::ILamp>> create_lamps(std::istream &
|
|||||||
return lamps;
|
return lamps;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::ISound>> create_sounds(std::istream &sound_config, std::shared_ptr<SoundBoardPinController> &output_gpio_interface)
|
std::map<std::string, std::shared_ptr<items::Sound>> create_sounds(std::istream &sound_config, std::shared_ptr<SoundBoardPinController> &output_gpio_interface)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::shared_ptr<items::ISound>> sounds;
|
std::map<std::string, std::shared_ptr<items::Sound>> sounds;
|
||||||
|
|
||||||
json sounds_json;
|
json sounds_json;
|
||||||
sound_config >> sounds_json;
|
sound_config >> sounds_json;
|
||||||
@@ -196,7 +197,7 @@ std::chrono::milliseconds get_deactivation_time(nlohmann::json &json)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<DriverBoardPinController> &pin_controller, std::chrono::milliseconds &deactivation_time)
|
std::shared_ptr<items::impl::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<DriverBoardPinController> &pin_controller, std::chrono::milliseconds &deactivation_time)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -208,7 +209,7 @@ std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json,
|
|||||||
deactivation_time = get_deactivation_time(solenoid_json);
|
deactivation_time = get_deactivation_time(solenoid_json);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_shared<items::Solenoid>(pin_controller, address, name, deactivation_time);
|
return std::make_shared<items::impl::Solenoid>(pin_controller, address, name, deactivation_time);
|
||||||
}
|
}
|
||||||
catch(json::type_error &e)
|
catch(json::type_error &e)
|
||||||
{
|
{
|
||||||
@@ -217,13 +218,13 @@ 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<DriverBoardPinController> &pin_controller)
|
std::shared_ptr<items::impl::Lamp> create_lamp(nlohmann::json &lamp_json, std::shared_ptr<DriverBoardPinController> &pin_controller)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string name = lamp_json.at("name");
|
std::string name = lamp_json.at("name");
|
||||||
auto address = lamp_json.at("address").get<uint8_t>();
|
auto address = lamp_json.at("address").get<uint8_t>();
|
||||||
return std::make_shared<items::Lamp>(pin_controller, address, name);
|
return std::make_shared<items::impl::Lamp>(pin_controller, address, name);
|
||||||
}
|
}
|
||||||
catch(json::type_error &e)
|
catch(json::type_error &e)
|
||||||
{
|
{
|
||||||
@@ -232,14 +233,14 @@ 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<SoundBoardPinController> &pin_controller, std::chrono::milliseconds &deactivation_time)
|
std::shared_ptr<items::impl::Sound> create_sound(nlohmann::json &sound_json, std::shared_ptr<SoundBoardPinController> &pin_controller, std::chrono::milliseconds &deactivation_time)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto id = sound_json.at("id").get<uint>();
|
auto id = sound_json.at("id").get<uint>();
|
||||||
std::string description = sound_json.at("description");
|
std::string description = sound_json.at("description");
|
||||||
auto address = sound_json.at("address").get<uint8_t>();
|
auto address = sound_json.at("address").get<uint8_t>();
|
||||||
return std::make_shared<items::Sound>(pin_controller, address, description, deactivation_time, id);
|
return std::make_shared<items::impl::Sound>(pin_controller, address, description, deactivation_time, id);
|
||||||
}
|
}
|
||||||
catch(json::type_error &e)
|
catch(json::type_error &e)
|
||||||
{
|
{
|
||||||
@@ -247,9 +248,9 @@ std::shared_ptr<items::Sound> create_sound(nlohmann::json &sound_json, std::shar
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::map<char, std::shared_ptr<items::IDisplay>> create_displays(std::istream &display_config)
|
std::map<char, std::shared_ptr<items::Display>> create_displays(std::istream &display_config)
|
||||||
{
|
{
|
||||||
std::map<char, std::shared_ptr<items::IDisplay>> displays;
|
std::map<char, std::shared_ptr<items::Display>> displays;
|
||||||
|
|
||||||
return displays;
|
return displays;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#define flippR_driver_OUTPUTDRIVERFACTORY_H
|
#define flippR_driver_OUTPUTDRIVERFACTORY_H
|
||||||
|
|
||||||
#include "output/OutputDriver.h"
|
#include "output/OutputDriver.h"
|
||||||
#include "output/items/Solenoid.h"
|
#include "output/items/impl/Solenoid.h"
|
||||||
#include "output/items/Lamp.h"
|
#include "output/items/impl/Lamp.h"
|
||||||
#include "output/items/Sound.h"
|
#include "output/items/impl/Sound.h"
|
||||||
#include "output/DisplayBoardPinController.h"
|
#include "output/DisplayBoardPinController.h"
|
||||||
|
|
||||||
#include "json/json.hpp"
|
#include "json/json.hpp"
|
||||||
@@ -25,18 +25,18 @@ namespace OutputDriverFactory
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::map<std::string, std::shared_ptr<items::ISolenoid>> create_solenoids(std::istream &solenoid_config, std::shared_ptr<DriverBoardPinController> &pin_controller);
|
std::map<std::string, std::shared_ptr<items::Solenoid>> create_solenoids(std::istream &solenoid_config, std::shared_ptr<DriverBoardPinController> &pin_controller);
|
||||||
std::shared_ptr<items::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<DriverBoardPinController> &pin_controller, std::chrono::milliseconds &deactivation_time);
|
std::shared_ptr<items::impl::Solenoid> create_solenoid(nlohmann::json &solenoid_json, std::shared_ptr<DriverBoardPinController> &pin_controller, std::chrono::milliseconds &deactivation_time);
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::ILamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<DriverBoardPinController> &pin_controller);
|
std::map<std::string, std::shared_ptr<items::Lamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<DriverBoardPinController> &pin_controller);
|
||||||
std::shared_ptr<items::Lamp> create_lamp(nlohmann::json &lamp_json, std::shared_ptr<DriverBoardPinController> &pin_controller);
|
std::shared_ptr<items::impl::Lamp> create_lamp(nlohmann::json &lamp_json, std::shared_ptr<DriverBoardPinController> &pin_controller);
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::ISound>> create_sounds(std::istream &sound_config, std::shared_ptr<SoundBoardPinController> &pin_controller);
|
std::map<std::string, std::shared_ptr<items::Sound>> create_sounds(std::istream &sound_config, std::shared_ptr<SoundBoardPinController> &pin_controller);
|
||||||
std::shared_ptr<items::Sound> create_sound(nlohmann::json &sound_json, std::shared_ptr<SoundBoardPinController> &pin_controller, std::chrono::milliseconds &deactivation_time);
|
std::shared_ptr<items::impl::Sound> create_sound(nlohmann::json &sound_json, std::shared_ptr<SoundBoardPinController> &pin_controller, 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::map<char, std::shared_ptr<items::Display>> create_displays(std::istream &display_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_board(nlohmann::json &sound_board_config);
|
std::map<std::string, uint8_t> parse_pins_sound_board(nlohmann::json &sound_board_config);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef FLIPPR_DRIVER_OUTPUT_SOUNDBOARDPINCONTROLLER_H
|
#ifndef FLIPPR_DRIVER_OUTPUT_SOUNDBOARDPINCONTROLLER_H
|
||||||
#define FLIPPR_DRIVER_OUTPUT_SOUNDBOARDPINCONTROLLER_H
|
#define FLIPPR_DRIVER_OUTPUT_SOUNDBOARDPINCONTROLLER_H
|
||||||
|
|
||||||
#include "output/items/Sound.h"
|
#include "output/items/impl/Sound.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -19,8 +19,8 @@ namespace items
|
|||||||
class SoundBoardPinController
|
class SoundBoardPinController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void activate(const items::Sound &sound) = 0;
|
virtual void activate(const items::impl::Sound &sound) = 0;
|
||||||
virtual void deactivate(const items::Sound &sound) = 0;
|
virtual void deactivate(const items::impl::Sound &sound) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ void DisplayBoardPinController::deactivate_displays()
|
|||||||
write_pin(pins_display_board.at("run"), 0);
|
write_pin(pins_display_board.at("run"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayBoardPinController::write_display(items::IDisplay &display)
|
void DisplayBoardPinController::write_display(items::Display &display)
|
||||||
{
|
{
|
||||||
std::vector<char> content = display.get_content();
|
std::vector<char> content = display.get_content();
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
void activate_displays() override;
|
void activate_displays() override;
|
||||||
void deactivate_displays() override;
|
void deactivate_displays() override;
|
||||||
|
|
||||||
void write_display(items::IDisplay &display) override;
|
void write_display(items::Display &display) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void write_display_digit(const uint8_t display_address, const char &content, const uint8_t &position);
|
void write_display_digit(const uint8_t display_address, const char &content, const uint8_t &position);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace output
|
|||||||
namespace impl
|
namespace impl
|
||||||
{
|
{
|
||||||
|
|
||||||
DisplayController::DisplayController(std::vector<std::shared_ptr<items::IDisplay>> displays, std::unique_ptr<DisplayBoardPinController> pin_controller)
|
DisplayController::DisplayController(std::vector<std::shared_ptr<items::Display>> displays, std::unique_ptr<DisplayBoardPinController> pin_controller)
|
||||||
: displays(std::move(displays)), pin_controller(std::move(pin_controller)), is_running(true)
|
: displays(std::move(displays)), pin_controller(std::move(pin_controller)), is_running(true)
|
||||||
{
|
{
|
||||||
this->display_cycle_thread = std::thread(&DisplayController::cycle_displays, this);
|
this->display_cycle_thread = std::thread(&DisplayController::cycle_displays, this);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "output/items/IDisplay.h"
|
#include "output/items/Display.h"
|
||||||
#include "output/DisplayBoardPinController.h"
|
#include "output/DisplayBoardPinController.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
@@ -26,14 +26,14 @@ namespace impl
|
|||||||
class DisplayController : public output::DisplayController
|
class DisplayController : public output::DisplayController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DisplayController(std::vector<std::shared_ptr<items::IDisplay>> displays, std::unique_ptr<DisplayBoardPinController> pin_controller);
|
explicit DisplayController(std::vector<std::shared_ptr<items::Display>> displays, std::unique_ptr<DisplayBoardPinController> pin_controller);
|
||||||
~DisplayController() override;
|
~DisplayController() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void cycle_displays();
|
void cycle_displays();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::shared_ptr<items::IDisplay>> displays;
|
std::vector<std::shared_ptr<items::Display>> displays;
|
||||||
|
|
||||||
std::thread display_cycle_thread;
|
std::thread display_cycle_thread;
|
||||||
|
|
||||||
|
|||||||
@@ -19,62 +19,62 @@ namespace impl
|
|||||||
|
|
||||||
using namespace items;
|
using namespace items;
|
||||||
|
|
||||||
OutputDriver::OutputDriver(std::unique_ptr<output::DisplayController> display_controller, std::map<std::string, std::shared_ptr<ISolenoid>> solenoids, std::map<std::string, std::shared_ptr<ILamp>> lamps, std::map<std::string, std::shared_ptr<ISound>> sounds, std::map<char, std::shared_ptr<IDisplay>> displays)
|
OutputDriver::OutputDriver(std::unique_ptr<output::DisplayController> display_controller, std::map<std::string, std::shared_ptr<Solenoid>> solenoids, std::map<std::string, std::shared_ptr<Lamp>> lamps, std::map<std::string, std::shared_ptr<Sound>> sounds, std::map<char, std::shared_ptr<Display>> displays)
|
||||||
: display_controller(std::move(display_controller)), solenoids(std::move(solenoids)), lamps(std::move(lamps)), sounds(std::move(sounds)), displays(std::move(displays))
|
: display_controller(std::move(display_controller)), 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<Sound>> OutputDriver::get_sounds()
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<ISound>> sounds;
|
std::vector<std::shared_ptr<Sound>> sounds;
|
||||||
|
|
||||||
boost::copy(this->sounds | boost::adaptors::map_values, std::back_inserter(sounds));
|
boost::copy(this->sounds | boost::adaptors::map_values, std::back_inserter(sounds));
|
||||||
|
|
||||||
return sounds;
|
return sounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<IDisplay>> OutputDriver::get_displays()
|
std::vector<std::shared_ptr<Display>> OutputDriver::get_displays()
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<IDisplay>> displays;
|
std::vector<std::shared_ptr<Display>> displays;
|
||||||
|
|
||||||
boost::copy(this->displays | boost::adaptors::map_values, std::back_inserter(displays));
|
boost::copy(this->displays | boost::adaptors::map_values, std::back_inserter(displays));
|
||||||
|
|
||||||
return displays;
|
return displays;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<ILamp>> OutputDriver::get_lamps()
|
std::vector<std::shared_ptr<Lamp>> OutputDriver::get_lamps()
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<ILamp>> lamps;
|
std::vector<std::shared_ptr<Lamp>> lamps;
|
||||||
|
|
||||||
boost::copy(this->lamps | boost::adaptors::map_values, std::back_inserter(lamps));
|
boost::copy(this->lamps | boost::adaptors::map_values, std::back_inserter(lamps));
|
||||||
|
|
||||||
return lamps;
|
return lamps;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<ISolenoid>> OutputDriver::get_solenoids()
|
std::vector<std::shared_ptr<Solenoid>> OutputDriver::get_solenoids()
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<ISolenoid>> solenoids;
|
std::vector<std::shared_ptr<Solenoid>> solenoids;
|
||||||
|
|
||||||
boost::copy(this->solenoids | boost::adaptors::map_values, std::back_inserter(solenoids));
|
boost::copy(this->solenoids | boost::adaptors::map_values, std::back_inserter(solenoids));
|
||||||
|
|
||||||
return solenoids;
|
return solenoids;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::shared_ptr<items::ILamp>> OutputDriver::get_lamp(std::string name)
|
boost::optional<std::shared_ptr<items::Lamp>> 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)
|
boost::optional<std::shared_ptr<items::Solenoid>> OutputDriver::get_solenoid(std::string name)
|
||||||
{
|
{
|
||||||
return this->solenoids.find(name)->second;
|
return this->solenoids.find(name)->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::shared_ptr<items::ISound>> OutputDriver::get_sound(std::string name)
|
boost::optional<std::shared_ptr<items::Sound>> OutputDriver::get_sound(std::string name)
|
||||||
{
|
{
|
||||||
return this->sounds.find(name)->second;
|
return this->sounds.find(name)->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::shared_ptr<items::IDisplay>> OutputDriver::get_display(char number)
|
boost::optional<std::shared_ptr<items::Display>> OutputDriver::get_display(char number)
|
||||||
{
|
{
|
||||||
return this->displays.find(number)->second;
|
return this->displays.find(number)->second;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,28 +23,28 @@ namespace impl
|
|||||||
class OutputDriver : public output::OutputDriver
|
class OutputDriver : public output::OutputDriver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OutputDriver(std::unique_ptr<output::DisplayController> display_controller, 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::unique_ptr<output::DisplayController> display_controller, std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids, std::map<std::string, std::shared_ptr<items::Lamp>> lamps, std::map<std::string, std::shared_ptr<items::Sound>> sounds, std::map<char, std::shared_ptr<items::Display>> displays);
|
||||||
|
|
||||||
~OutputDriver() override = default;
|
~OutputDriver() override = default;
|
||||||
// todo what is flipper_relay ?
|
// todo what is flipper_relay ?
|
||||||
std::vector<std::shared_ptr<items::ILamp>> get_lamps() override;
|
std::vector<std::shared_ptr<items::Lamp>> get_lamps() override;
|
||||||
std::vector<std::shared_ptr<items::ISolenoid>> get_solenoids() override;
|
std::vector<std::shared_ptr<items::Solenoid>> get_solenoids() override;
|
||||||
std::vector<std::shared_ptr<items::ISound>> get_sounds() override;
|
std::vector<std::shared_ptr<items::Sound>> get_sounds() override;
|
||||||
std::vector<std::shared_ptr<items::IDisplay>> get_displays() override;
|
std::vector<std::shared_ptr<items::Display>> get_displays() override;
|
||||||
|
|
||||||
boost::optional<std::shared_ptr<items::ILamp>> get_lamp(std::string name) override;
|
boost::optional<std::shared_ptr<items::Lamp>> get_lamp(std::string name) override;
|
||||||
boost::optional<std::shared_ptr<items::ISolenoid>> get_solenoid(std::string name) override;
|
boost::optional<std::shared_ptr<items::Solenoid>> get_solenoid(std::string name) override;
|
||||||
boost::optional<std::shared_ptr<items::ISound>> get_sound(std::string name) override;
|
boost::optional<std::shared_ptr<items::Sound>> get_sound(std::string name) override;
|
||||||
boost::optional<std::shared_ptr<items::IDisplay>> get_display(char number) override;
|
boost::optional<std::shared_ptr<items::Display>> get_display(char number) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<output::DisplayController> display_controller;
|
std::unique_ptr<output::DisplayController> display_controller;
|
||||||
|
|
||||||
const std::map<std::string, std::shared_ptr<items::ILamp>> lamps;
|
const std::map<std::string, std::shared_ptr<items::Lamp>> lamps;
|
||||||
const std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids;
|
const std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids;
|
||||||
const std::map<std::string, std::shared_ptr<items::ISound>> sounds;
|
const std::map<std::string, std::shared_ptr<items::Sound>> sounds;
|
||||||
|
|
||||||
const std::map<char, std::shared_ptr<items::IDisplay>> displays;
|
const std::map<char, std::shared_ptr<items::Display>> displays;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ SoundBoardPinController::SoundBoardPinController(std::map<std::string, uint8_t>
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundBoardPinController::activate(const items::Sound &sound)
|
void SoundBoardPinController::activate(const items::impl::Sound &sound)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(*output_item_mutex);
|
std::lock_guard<std::mutex> guard(*output_item_mutex);
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ void SoundBoardPinController::activate(const items::Sound &sound)
|
|||||||
fire_sound(true);
|
fire_sound(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundBoardPinController::deactivate(const items::Sound &sound)
|
void SoundBoardPinController::deactivate(const items::impl::Sound &sound)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(*output_item_mutex);
|
std::lock_guard<std::mutex> guard(*output_item_mutex);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "output/OutputPinController.h"
|
#include "output/OutputPinController.h"
|
||||||
|
|
||||||
#include <output/items/Sound.h>
|
#include <output/items/impl/Sound.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
@@ -25,8 +25,8 @@ public:
|
|||||||
SoundBoardPinController(std::map<std::string, uint8_t> pins_sound, std::shared_ptr<std::mutex> output_item_mutex);
|
SoundBoardPinController(std::map<std::string, uint8_t> pins_sound, std::shared_ptr<std::mutex> output_item_mutex);
|
||||||
~SoundBoardPinController() override = default;
|
~SoundBoardPinController() override = default;
|
||||||
|
|
||||||
void activate(const items::Sound &sound) override;
|
void activate(const items::impl::Sound &sound) override;
|
||||||
void deactivate(const items::Sound &sound) override;
|
void deactivate(const items::impl::Sound &sound) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void write_sound_address(const uint8_t address) const;
|
void write_sound_address(const uint8_t address) const;
|
||||||
|
|||||||
@@ -5,12 +5,11 @@
|
|||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SRC_OUTPUT_DISPLAY_H_
|
#ifndef _SRC_OUTPUT_IDISPLAY_H_
|
||||||
#define _SRC_OUTPUT_DISPLAY_H_
|
#define _SRC_OUTPUT_IDISPLAY_H_
|
||||||
|
|
||||||
#include "IDisplay.h"
|
#include <vector>
|
||||||
|
#include <cstdint>
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -19,33 +18,17 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
template<int DigitCount>
|
class Display
|
||||||
class Display : public IDisplay
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
Display(int address, int id);
|
|
||||||
virtual ~Display() = default;
|
|
||||||
|
|
||||||
virtual void write_score(int score);
|
|
||||||
virtual void write_content(std::array<char, DigitCount> content);
|
|
||||||
|
|
||||||
std::vector<char> get_content() override;
|
|
||||||
uint8_t get_address() override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::array<char, DigitCount> content;
|
virtual ~Display() = default;
|
||||||
|
|
||||||
private:
|
virtual uint8_t get_address() = 0;
|
||||||
int address;
|
virtual std::vector<char> get_content() = 0;
|
||||||
|
|
||||||
std::string fit_string(std::string &score_string);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
} /* namespace output */
|
} /* namespace output */
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "Display.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
#ifndef FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
||||||
#define FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
#define FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
||||||
|
|
||||||
#include "output/items/Item.h"
|
#include "output/items/impl/Item.h"
|
||||||
|
|
||||||
#include <output/DriverBoardPinController.h>
|
#include <output/DriverBoardPinController.h>
|
||||||
|
|
||||||
@@ -18,11 +18,11 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class DriverBoardItem : public Item
|
class DriverBoardItem : public impl::Item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DriverBoardItem(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name) :
|
DriverBoardItem(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name) :
|
||||||
pin_controller(std::move(pin_controller)), Item(address, std::move(name)) {}
|
pin_controller(std::move(pin_controller)), impl::Item(address, std::move(name)) {}
|
||||||
|
|
||||||
~DriverBoardItem() override = default;
|
~DriverBoardItem() override = default;
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* IDisplay.h
|
|
||||||
*
|
|
||||||
* Created on: Aug 2, 2018
|
|
||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SRC_OUTPUT_IDISPLAY_H_
|
|
||||||
#define _SRC_OUTPUT_IDISPLAY_H_
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
namespace flippR_driver
|
|
||||||
{
|
|
||||||
namespace output
|
|
||||||
{
|
|
||||||
namespace items
|
|
||||||
{
|
|
||||||
|
|
||||||
class IDisplay
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual ~IDisplay() = default;
|
|
||||||
|
|
||||||
virtual uint8_t get_address() = 0;
|
|
||||||
virtual std::vector<char> get_content() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
} /* namespace output */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* ICabinetItem.h
|
|
||||||
*
|
|
||||||
* Created on: Aug 7, 2018
|
|
||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SRC_OUTPUT_ICABINETITEM_H_
|
|
||||||
#define _SRC_OUTPUT_ICABINETITEM_H_
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace flippR_driver
|
|
||||||
{
|
|
||||||
namespace output
|
|
||||||
{
|
|
||||||
namespace items
|
|
||||||
{
|
|
||||||
|
|
||||||
class IItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IItem() = default;
|
|
||||||
|
|
||||||
virtual uint8_t get_address() const = 0;
|
|
||||||
virtual std::string get_name() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,42 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
* CabinetItem.h
|
* ICabinetItem.h
|
||||||
*
|
*
|
||||||
* Created on: Aug 2, 2018
|
* Created on: Aug 7, 2018
|
||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SRC_OUTPUT_CABINETITEM_H_
|
#ifndef _SRC_OUTPUT_ICABINETITEM_H_
|
||||||
#define _SRC_OUTPUT_CABINETITEM_H_
|
#define _SRC_OUTPUT_ICABINETITEM_H_
|
||||||
|
|
||||||
#include "output/items/IItem.h"
|
#include <cstdint>
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class Item : public IItem
|
class Item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Item(uint8_t address, std::string name);
|
virtual ~Item() = default;
|
||||||
~Item() override = default;
|
|
||||||
|
|
||||||
uint8_t get_address() const override;
|
|
||||||
std::string get_name() const override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
const uint8_t address;
|
|
||||||
const std::string name;
|
|
||||||
|
|
||||||
|
virtual uint8_t get_address() const = 0;
|
||||||
|
virtual std::string get_name() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
} /* namespace output */
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
54
FlippR-Driver/src/output/items/impl/Display.h
Normal file
54
FlippR-Driver/src/output/items/impl/Display.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Display.h
|
||||||
|
*
|
||||||
|
* Created on: Aug 2, 2018
|
||||||
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SRC_OUTPUT_DISPLAY_H_
|
||||||
|
#define _SRC_OUTPUT_DISPLAY_H_
|
||||||
|
|
||||||
|
#include "output/items/Display.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
namespace flippR_driver
|
||||||
|
{
|
||||||
|
namespace output
|
||||||
|
{
|
||||||
|
namespace items
|
||||||
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
|
template<int DigitCount>
|
||||||
|
class Display : public items::Display
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Display(int address, int id);
|
||||||
|
virtual ~Display() = default;
|
||||||
|
|
||||||
|
virtual void write_score(int score);
|
||||||
|
virtual void write_content(std::array<char, DigitCount> content);
|
||||||
|
|
||||||
|
std::vector<char> get_content() override;
|
||||||
|
uint8_t get_address() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::array<char, DigitCount> content;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int address;
|
||||||
|
|
||||||
|
std::string fit_string(std::string &score_string);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* namespace output */
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "Display.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -7,13 +7,14 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
template<int DigitCount>
|
template<int DigitCount>
|
||||||
Display<DigitCount>::Display(int address, int id) :
|
Display<DigitCount>::Display(int address, int id) :
|
||||||
@@ -71,3 +72,4 @@ std::vector<char> Display<DigitCount>::get_content()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef FLIPPR_DRIVER_EIGHTDIGITDISPLAY_H
|
#ifndef FLIPPR_DRIVER_EIGHTDIGITDISPLAY_H
|
||||||
#define FLIPPR_DRIVER_EIGHTDIGITDISPLAY_H
|
#define FLIPPR_DRIVER_EIGHTDIGITDISPLAY_H
|
||||||
|
|
||||||
#include "IEightDigitDisplay"
|
#include "output/items/EightDigitDisplay.h"
|
||||||
|
|
||||||
namespace flippr_driver
|
namespace flippr_driver
|
||||||
{
|
{
|
||||||
@@ -13,10 +13,13 @@ namespace output
|
|||||||
{
|
{
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
class EightDigitDisplay : public Display<8>, IEightDigitDisplay;
|
class EightDigitDisplay : public Display<8>, IEightDigitDisplay;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif //FLIPPR_DRIVER_EIGHTDIGITDISPLAY_H
|
#endif //FLIPPR_DRIVER_EIGHTDIGITDISPLAY_H
|
||||||
@@ -4,16 +4,17 @@
|
|||||||
|
|
||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
Item::Item(uint8_t address, std::string name) :
|
Item::Item(uint8_t address, std::string name) :
|
||||||
address(address), name(std::move(name))
|
address(address), name(std::move(name))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
uint8_t Item::get_address() const
|
uint8_t Item::get_address() const
|
||||||
@@ -29,3 +30,4 @@ std::string Item::get_name() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
44
FlippR-Driver/src/output/items/impl/Item.h
Normal file
44
FlippR-Driver/src/output/items/impl/Item.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* CabinetItem.h
|
||||||
|
*
|
||||||
|
* Created on: Aug 2, 2018
|
||||||
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SRC_OUTPUT_CABINETITEM_H_
|
||||||
|
#define _SRC_OUTPUT_CABINETITEM_H_
|
||||||
|
|
||||||
|
#include "output/items/Item.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace flippR_driver
|
||||||
|
{
|
||||||
|
namespace output
|
||||||
|
{
|
||||||
|
namespace items
|
||||||
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
|
class Item : public items::Item
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Item(uint8_t address, std::string name);
|
||||||
|
~Item() override = default;
|
||||||
|
|
||||||
|
uint8_t get_address() const override;
|
||||||
|
std::string get_name() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const uint8_t address;
|
||||||
|
const std::string name;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* namespace output */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -7,15 +7,16 @@
|
|||||||
|
|
||||||
#include "Lamp.h"
|
#include "Lamp.h"
|
||||||
|
|
||||||
#include "output/OutputPinController.h"
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
Lamp::Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name) :
|
Lamp::Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name) :
|
||||||
DriverBoardItem(std::move(pin_controller), address, std::move(name)), activated(false)
|
DriverBoardItem(std::move(pin_controller), address, std::move(name)), activated(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ void Lamp::deactivate()
|
|||||||
pin_controller->deactivate(*this);
|
pin_controller->deactivate(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} /* namespace output */
|
} /* namespace output */
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
#ifndef _SRC_OUTPUT_LAMP_H_
|
#ifndef _SRC_OUTPUT_LAMP_H_
|
||||||
#define _SRC_OUTPUT_LAMP_H_
|
#define _SRC_OUTPUT_LAMP_H_
|
||||||
|
|
||||||
#include "output/items/ILamp.h"
|
#include "output/items/Lamp.h"
|
||||||
#include "DriverBoardItem.h"
|
#include "output/items/DriverBoardItem.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -17,8 +17,10 @@ namespace output
|
|||||||
{
|
{
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
class Lamp : public DriverBoardItem, public ILamp
|
class Lamp : public DriverBoardItem, public items::Lamp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name);
|
Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name);
|
||||||
@@ -32,6 +34,7 @@ private:
|
|||||||
bool activated;
|
bool activated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} /* namespace output */
|
} /* namespace output */
|
||||||
}
|
}
|
||||||
@@ -5,16 +5,21 @@
|
|||||||
#ifndef FLIPPR_DRIVER_SEVENDIGITDISPLAY_H
|
#ifndef FLIPPR_DRIVER_SEVENDIGITDISPLAY_H
|
||||||
#define FLIPPR_DRIVER_SEVENDIGITDISPLAY_H
|
#define FLIPPR_DRIVER_SEVENDIGITDISPLAY_H
|
||||||
|
|
||||||
|
#include "output/items/SevenDigitDisplay.h"
|
||||||
|
|
||||||
namespace flippr_driver
|
namespace flippr_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
class SevenDigitDisplay : public Display<7>, ISevenDigitDisplay;
|
class SevenDigitDisplay : public Display<7>, SevenDigitDisplay;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif //FLIPPR_DRIVER_SEVENDIGITDISPLAY_H
|
#endif //FLIPPR_DRIVER_SEVENDIGITDISPLAY_H
|
||||||
@@ -7,17 +7,18 @@
|
|||||||
|
|
||||||
#include "Solenoid.h"
|
#include "Solenoid.h"
|
||||||
|
|
||||||
#include "output/OutputPinController.h"
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
Solenoid::Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time):
|
Solenoid::Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time)
|
||||||
DriverBoardItem(std::move(pin_controller), address, std::move(name)), deactivation_time(deactivation_time)
|
:
|
||||||
|
DriverBoardItem(std::move(pin_controller), address, std::move(name)), deactivation_time(deactivation_time)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Solenoid::triggerTask()
|
void Solenoid::triggerTask()
|
||||||
@@ -34,6 +35,7 @@ void Solenoid::trigger()
|
|||||||
this->trigger_task = std::async(std::launch::async, &Solenoid::triggerTask, this);
|
this->trigger_task = std::async(std::launch::async, &Solenoid::triggerTask, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} /* namespace output */
|
} /* namespace output */
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
#ifndef _SRC_OUTPUT_SOLENOID_H_
|
#ifndef _SRC_OUTPUT_SOLENOID_H_
|
||||||
#define _SRC_OUTPUT_SOLENOID_H_
|
#define _SRC_OUTPUT_SOLENOID_H_
|
||||||
|
|
||||||
#include "output/items/ISolenoid.h"
|
#include "output/items/Solenoid.h"
|
||||||
#include "DriverBoardItem.h"
|
#include "output/items/DriverBoardItem.h"
|
||||||
|
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@@ -20,8 +20,10 @@ namespace output
|
|||||||
{
|
{
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
class Solenoid : public DriverBoardItem, public ISolenoid
|
class Solenoid : public DriverBoardItem, public items::Solenoid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
||||||
@@ -39,6 +41,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
} /* namespace output */
|
} /* namespace output */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,9 +15,12 @@ namespace output
|
|||||||
{
|
{
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
Sound::Sound(std::shared_ptr<SoundBoardPinController> pin_controller, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id) :
|
Sound::Sound(std::shared_ptr<SoundBoardPinController> pin_controller, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id)
|
||||||
pin_controller(std::move(pin_controller)), Item(address, std::move(name)), deactivation_time(deactivation_time), id(id)
|
:
|
||||||
|
pin_controller(std::move(pin_controller)), Item(address, std::move(name)), deactivation_time(deactivation_time), id(id)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Sound::play()
|
void Sound::play()
|
||||||
@@ -34,6 +37,7 @@ void Sound::playTask()
|
|||||||
pin_controller->deactivate(*this);
|
pin_controller->deactivate(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} /* namespace output */
|
} /* namespace output */
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
#ifndef _SRC_OUTPUT_SOUND_H_
|
#ifndef _SRC_OUTPUT_SOUND_H_
|
||||||
#define _SRC_OUTPUT_SOUND_H_
|
#define _SRC_OUTPUT_SOUND_H_
|
||||||
|
|
||||||
#include "output/items/ISound.h"
|
#include "output/items/Sound.h"
|
||||||
#include "output/items/Item.h"
|
#include "Item.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -25,8 +25,10 @@ class SoundBoardPinController;
|
|||||||
|
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
class Sound : public Item, public ISound
|
class Sound : public Item, public items::Sound
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
u_int id;
|
u_int id;
|
||||||
@@ -48,6 +50,7 @@ private:
|
|||||||
virtual void playTask();
|
virtual void playTask();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} /* namespace output */
|
} /* namespace output */
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
// testing purposes
|
// testing purposes
|
||||||
#define private public
|
#define private public
|
||||||
|
|
||||||
#include "output/items/Display.h"
|
#include "output/items/impl/Display.h"
|
||||||
|
|
||||||
using namespace flippR_driver::output;
|
using namespace flippR_driver::output;
|
||||||
using namespace fakeit;
|
using namespace fakeit;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// testing purposes
|
// testing purposes
|
||||||
#define private public
|
#define private public
|
||||||
|
|
||||||
#include "output/items/Lamp.h"
|
#include "output/items/impl/Lamp.h"
|
||||||
|
|
||||||
using namespace flippR_driver::output;
|
using namespace flippR_driver::output;
|
||||||
using namespace fakeit;
|
using namespace fakeit;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
// testing purposes
|
// testing purposes
|
||||||
#define private public
|
#define private public
|
||||||
|
|
||||||
#include "output/items/Solenoid.h"
|
#include "output/items/impl/Solenoid.h"
|
||||||
|
|
||||||
using namespace flippR_driver::output;
|
using namespace flippR_driver::output;
|
||||||
using namespace fakeit;
|
using namespace fakeit;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// testing purposes
|
// testing purposes
|
||||||
#define private public
|
#define private public
|
||||||
|
|
||||||
#include "output/items/Sound.h"
|
#include "output/items/impl/Sound.h"
|
||||||
|
|
||||||
using namespace flippR_driver::output;
|
using namespace flippR_driver::output;
|
||||||
using namespace fakeit;
|
using namespace fakeit;
|
||||||
|
|||||||
Reference in New Issue
Block a user