refactored everything
This commit is contained in:
@@ -12,12 +12,12 @@
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
template <int DigitCount>
|
||||
class Display : public IDisplay
|
||||
class Display : public IDisplay<DigitCount>
|
||||
{
|
||||
public:
|
||||
Display(int address, int id);
|
||||
@@ -38,7 +38,13 @@ private:
|
||||
std::string fit_string(std::string& score_string);
|
||||
};
|
||||
|
||||
using SevenDigitDisplay = Display<7>;
|
||||
using EightDigitDisply = Display<8>;
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
|
||||
#include "Display.hpp"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
// Created by rhetenor on 10.10.18.
|
||||
//
|
||||
|
||||
#include "Display.h"
|
||||
#include "utility/config.h"
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
@@ -45,10 +44,12 @@ std::string Display<DigitCount>::fit_string(std::string& score_string)
|
||||
if (score_length > DigitCount)
|
||||
{
|
||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display";
|
||||
return score_string.substr(score_length-DigitCount, score_length);
|
||||
std::string full_display;
|
||||
// TODO mach mal schöner hier wird 9999 angezeigt wenn die zahl zu groß is
|
||||
return full_display.insert(0, DigitCount, '9');
|
||||
}
|
||||
|
||||
score_string.insert(0, DigitCount-score_length, ' ');
|
||||
score_string.insert(0, DigitCount-score_length, '\0');
|
||||
return score_string;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "IDisplay.h"
|
||||
#include "utility/IOutputGPIOInterface.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define _SRC_OUTPUT_ICABINETITEM_H_
|
||||
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
@@ -8,18 +8,26 @@
|
||||
#ifndef _SRC_OUTPUT_IDISPLAY_H_
|
||||
#define _SRC_OUTPUT_IDISPLAY_H_
|
||||
|
||||
namespace FlippR_Driver
|
||||
#include <array>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class IDisplay
|
||||
{
|
||||
|
||||
public:
|
||||
IDisplay();
|
||||
virtual ~IDisplay();
|
||||
|
||||
virtual void write_score(int score) = 0;
|
||||
virtual void write_content(std::array<char, DigitCount> content) = 0;
|
||||
|
||||
virtual int getID() = 0;
|
||||
|
||||
private:
|
||||
std::string fit_string(std::string& score_string);
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
|
||||
@@ -7,18 +7,19 @@
|
||||
|
||||
#ifndef _SRC_OUTPUT_IDISPLAYCONTROLLER_H_
|
||||
#define _SRC_OUTPUT_IDISPLAYCONTROLLER_H_
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class IDisplayController
|
||||
{
|
||||
|
||||
public:
|
||||
IDisplayController();
|
||||
virtual ~IDisplayController();
|
||||
IDisplayController ();
|
||||
virtual ~IDisplayController ();
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef _SRC_OUTPUT_ILAMP_H_
|
||||
#define _SRC_OUTPUT_ILAMP_H_
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef _SRC_OUTPUT_IOUTPUTDRIVER_H_
|
||||
#define _SRC_OUTPUT_IOUTPUTDRIVER_H_
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef _SRC_OUTPUT_ISOLENOID_H_
|
||||
#define _SRC_OUTPUT_ISOLENOID_H_
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef _SRC_OUTPUT_ISOUND_H_
|
||||
#define _SRC_OUTPUT_ISOUND_H_
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
|
||||
#include "Lamp.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
|
||||
CabinetItem(output_gpio_interface, address, name)
|
||||
OutputItem(output_gpio_interface, address, name)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
#ifndef _SRC_OUTPUT_LAMP_H_
|
||||
#define _SRC_OUTPUT_LAMP_H_
|
||||
|
||||
#include "CabinetItem.h"
|
||||
#include "OutputItem.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class Lamp : public CabinetItem
|
||||
class Lamp : public OutputItem
|
||||
{
|
||||
public:
|
||||
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "IDisplay.h"
|
||||
#include "ISound.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
@@ -25,24 +25,24 @@ namespace output
|
||||
class OutputDriver : public IOutputDriver
|
||||
{
|
||||
public:
|
||||
OutputDriver(std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds);
|
||||
OutputDriver(std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds);
|
||||
|
||||
virtual ~OutputDriver() = default;
|
||||
virtual ~OutputDriver() = default;
|
||||
|
||||
std::vector<std::shared_ptr<ICabinetItem>> get_cabinet_items();
|
||||
std::vector<std::shared_ptr<ISound>> get_sounds();
|
||||
std::vector<std::shared_ptr<IDisplay>> get_displays();
|
||||
std::vector<std::shared_ptr<ICabinetItem>> get_cabinet_items();
|
||||
std::vector<std::shared_ptr<ISound>> get_sounds();
|
||||
std::vector<std::shared_ptr<IDisplay>> get_displays();
|
||||
|
||||
std::shared_ptr<ICabinetItem> get_cabinet_item(std::string name);
|
||||
std::shared_ptr<ISound> get_sound(std::string name);
|
||||
std::shared_ptr<IDisplay> get_display(char number);
|
||||
std::shared_ptr<ICabinetItem> get_cabinet_item(std::string name);
|
||||
std::shared_ptr<ISound> get_sound(std::string name);
|
||||
std::shared_ptr<IDisplay> get_display(char number);
|
||||
|
||||
private:
|
||||
std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items;
|
||||
std::map<char, std::shared_ptr<IDisplay>> displays;
|
||||
std::map<std::string, std::shared_ptr<ISound>> sounds;
|
||||
std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items;
|
||||
std::map<char, std::shared_ptr<IDisplay>> displays;
|
||||
std::map<std::string, std::shared_ptr<ISound>> sounds;
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "OutputDriverFactory.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// Created by rhetenor on 04.10.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_OUTPUTDRIVERFACTORY_H
|
||||
#define FLIPPR_DRIVER_OUTPUTDRIVERFACTORY_H
|
||||
#ifndef flippR_driver_OUTPUTDRIVERFACTORY_H
|
||||
#define flippR_driver_OUTPUTDRIVERFACTORY_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "OutputDriver.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
@@ -21,4 +21,4 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#endif //FLIPPR_DRIVER_OUTPUTDRIVERFACTORY_H
|
||||
#endif //flippR_driver_OUTPUTDRIVERFACTORY_H
|
||||
|
||||
@@ -10,21 +10,22 @@
|
||||
|
||||
#include "ICabinetItem.h"
|
||||
|
||||
#include "ActivationStrategy.h"
|
||||
#include "utility/IOutputGPIOInterface.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class CabinetItem : public ICabinetItem
|
||||
class OutputItem : public ICabinetItem
|
||||
{
|
||||
public:
|
||||
CabinetItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
virtual ~CabinetItem();
|
||||
OutputItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
virtual ~OutputItem();
|
||||
|
||||
virtual bool isActivated();
|
||||
virtual bool activate();
|
||||
@@ -35,6 +36,10 @@ protected:
|
||||
std::string name;
|
||||
|
||||
bool activated;
|
||||
|
||||
strategy::ActivationStrategy* strategy;
|
||||
|
||||
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
#include "Solenoid.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output {
|
||||
|
||||
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
|
||||
CabinetItem(output_gpio_interface, address, name)
|
||||
OutputItem(output_gpio_interface, address, name)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
#ifndef _SRC_OUTPUT_SOLENOID_H_
|
||||
#define _SRC_OUTPUT_SOLENOID_H_
|
||||
|
||||
#include "CabinetItem.h"
|
||||
#include "OutputItem.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class Solenoid : public CabinetItem
|
||||
class Solenoid : public OutputItem
|
||||
{
|
||||
public:
|
||||
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Sound.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "utility/IOutputGPIOInterface.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user