meeeeerging

This commit is contained in:
Jonas Zeunert
2018-11-09 13:07:36 +01:00
76 changed files with 495 additions and 307 deletions

View File

@@ -1,13 +0,0 @@
//
// Created by rhetenor on 19.10.18.
//
#ifndef FLIPPR_DRIVER_CABINETITEM_H
#define FLIPPR_DRIVER_CABINETITEM_H
class CabinetItem : IOutputItem
{
};
#endif //FLIPPR_DRIVER_CABINETITEM_H

View File

@@ -1,12 +0,0 @@
//
// Created by rhetenor on 10.10.18.
//
namespace FlippR_Driver
{
namespace output
{
}
}

View File

@@ -12,15 +12,15 @@
#include <array>
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
template <int DigitCount>
class Display : public IDisplay
class Display : public IDisplay<DigitCount>
{
public:
Display();
Display(int address, int id);
virtual ~Display() = default;
virtual int getID();
@@ -34,8 +34,17 @@ public:
private:
int address;
int id;
std::string fit_string(std::string& score_string);
};
using SevenDigitDisplay = Display<7>;
using EightDigitDisply = Display<8>;
} /* namespace output */
}
#endif
#include "Display.hpp"
#endif

View File

@@ -0,0 +1,63 @@
//
// Created by rhetenor on 10.10.18.
//
#include "utility/config.h"
#include <string>
#include <algorithm>
namespace flippR_driver
{
namespace output
{
template<int DigitCount>
Display<DigitCount>::Display(int address, int id) :
address(address),
id(id)
{
}
template<int DigitCount>
int Display<DigitCount>::getID()
{
return this->id;
}
template<int DigitCount>
void Display<DigitCount>::write_score(int score)
{
auto score_string = std::to_string(score);
auto score_c_string = this->fit_string(score_string).c_str();
std::copy(std::begin(score_c_string), std::end(score_c_string), std::begin(this->content));
}
template<int DigitCount>
std::string Display<DigitCount>::fit_string(std::string& score_string)
{
auto score_length = score_string.length();
if (score_length > DigitCount)
{
CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display";
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, '\0');
return score_string;
}
template<int DigitCount>
void Display<DigitCount>::write_content( std::array<char, DigitCount> content)
{
this->content = content;
}
}
}

View File

@@ -6,15 +6,16 @@
*/
#include "DisplayController.h"
#include "utility/IOutputGPIOInterface.h"
#include "utility/config.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
DisplayController::DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface)
DisplayController::DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface)
: displays(displays), output_gpio_interface(output_gpio_interface), is_running(true)
{
this->display_cycle_thread = std::thread(&DisplayController::cycle_displays, this);
@@ -33,9 +34,9 @@ void DisplayController::cycle_displays()
{
while(is_running)
{
for(auto& display : displays)
for(auto& display : this->displays)
{
}
}
}

View File

@@ -14,9 +14,9 @@
#include <thread>
#include "IDisplay.h"
#include "utilities/IOutputGPIOInterface.h"
#include "utility/IOutputGPIOInterface.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
@@ -24,7 +24,7 @@ namespace output
class DisplayController : public IDisplayController
{
public:
DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
explicit DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface);
~DisplayController();
private:
@@ -35,11 +35,11 @@ private:
std::thread display_cycle_thread;
std::shared_ptr<IOutputGPIOInterface> output_gpio_interface;
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
bool is_running;
};
}
}
#endif
#endif

View File

@@ -8,22 +8,28 @@
#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;
virtual void write() = 0;
private:
std::string fit_string(std::string& score_string);
};
} /* namespace output */
}
#endif
#endif

View File

@@ -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

View File

@@ -8,14 +8,12 @@
#ifndef _SRC_OUTPUT_ILAMP_H_
#define _SRC_OUTPUT_ILAMP_H_
#include "IOutputItem.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
class ILamp : public IOutputItem
class ILamp
{
};

View File

@@ -8,7 +8,7 @@
#ifndef _SRC_OUTPUT_IOUTPUTDRIVER_H_
#define _SRC_OUTPUT_IOUTPUTDRIVER_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -1,5 +1,5 @@
/*
* IOutputItem.h
* ICabinetItem.h
*
* Created on: Aug 7, 2018
* Author: rhetenor
@@ -9,17 +9,17 @@
#define _SRC_OUTPUT_ICABINETITEM_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
class IOutputItem
class ICabinetItem
{
virtual ~IOutputItem();
virtual bool isActivated() = 0;
virtual bool activate() = 0;
virtual bool deactivate() = 0;
virtual ~ICabinetItem();
virtual bool isActivated() = 0;
virtual bool activate() = 0;
virtual bool deactivate() = 0;
};
}

View File

@@ -8,14 +8,12 @@
#ifndef _SRC_OUTPUT_ISOLENOID_H_
#define _SRC_OUTPUT_ISOLENOID_H_
#include "IOutputItem.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
class ISolenoid : public IOutputItem
class ISolenoid
{
};

View File

@@ -8,13 +8,12 @@
#ifndef _SRC_OUTPUT_ISOUND_H_
#define _SRC_OUTPUT_ISOUND_H_
#include "IOutputItem.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
class ISound : public IOutputItem
class ISound
{
public:
ISound();

View File

@@ -7,12 +7,13 @@
#include "Lamp.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
Lamp::Lamp()
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
OutputItem(output_gpio_interface, address, name)
{
// TODO Auto-generated constructor stub
@@ -23,5 +24,15 @@ Lamp::~Lamp()
// TODO Auto-generated destructor stub
}
void Lamp::activate()
{
// activate
}
void Lamp::deactivate()
{
// deactivate
}
} /* namespace output */
}
}

View File

@@ -10,7 +10,7 @@
#include "OutputItem.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
@@ -18,10 +18,17 @@ namespace output
class Lamp : public OutputItem
{
public:
Lamp();
virtual ~Lamp();
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
virtual ~Lamp();
void activate();
void deactivate();
bool is_activated();
private:
bool activated;
};
} /* namespace output */
}
#endif
#endif

View File

@@ -10,7 +10,7 @@
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -17,7 +17,7 @@
#include "IDisplay.h"
#include "ISound.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
@@ -25,10 +25,15 @@ namespace output
class OutputDriver : public IOutputDriver
{
public:
<<<<<<< HEAD
OutputDriver(std::map<std::string, std::shared_ptr<IOutputItem>> 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);
>>>>>>> be582e9f7f0d29518665a131afce24ca0a43386e
virtual ~OutputDriver() = default;
virtual ~OutputDriver() = default;
<<<<<<< HEAD
std::vector<std::shared_ptr<IOutputItem>> get_cabinet_items();
std::vector<std::shared_ptr<ISound>> get_sounds();
std::vector<std::shared_ptr<IDisplay>> get_displays();
@@ -41,8 +46,22 @@ private:
std::map<std::string, std::shared_ptr<IOutputItem>> cabinet_items;
std::map<char, std::shared_ptr<IDisplay>> displays;
std::map<std::string, std::shared_ptr<ISound>> sounds;
=======
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);
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;
>>>>>>> be582e9f7f0d29518665a131afce24ca0a43386e
};
} /* namespace output */
}
#endif
#endif

View File

@@ -4,7 +4,7 @@
#include "OutputDriverFactory.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{

View File

@@ -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

View File

@@ -1,5 +1,5 @@
/*
* OutputItem.h
* CabinetItem.h
*
* Created on: Aug 2, 2018
* Author: rhetenor
@@ -8,38 +8,34 @@
#ifndef _SRC_OUTPUT_CABINETITEM_H_
#define _SRC_OUTPUT_CABINETITEM_H_
#include "IOutputItem.h"
#include "ICabinetItem.h"
#include "ActivationStrategy.h"
#include "utility/IOutputGPIOInterface.h"
#include <memory>
#include <string>
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
using namespace utility;
class OutputItem : public IOutputItem
class OutputItem : public ICabinetItem
{
public:
OutputItem(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
OutputItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
virtual ~OutputItem();
bool isActivated();
public:
int address;
int priority;
protected:
int address, i2c_address, data_pin_address;
std::string name;
protected:
bool activated;
std::shared_ptr<IOutputGPIOInterface> output_gpio_interface;
strategy::ActivationStrategy* strategy;
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
};
} /* namespace output */
}
#endif
#endif

View File

@@ -7,18 +7,28 @@
#include "Solenoid.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output {
Solenoid::Solenoid() {
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
OutputItem(output_gpio_interface, address, name)
{
// TODO Auto-generated constructor stub
}
Solenoid::~Solenoid() {
Solenoid::~Solenoid()
{
// TODO Auto-generated destructor stub
}
void Solenoid::trigger()
{
// activate
// wait
// deactivate
}
} /* namespace output */
}

View File

@@ -8,20 +8,23 @@
#ifndef _SRC_OUTPUT_SOLENOID_H_
#define _SRC_OUTPUT_SOLENOID_H_
#include "ISolenoid.h.h"
#include "OutputItem.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
class Solenoid : public ISolenoid
class Solenoid : public OutputItem
{
public:
Solenoid();
virtual ~Solenoid();
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
virtual ~Solenoid();
//muss task sein
void trigger();
};
} /* namespace output */
}
#endif
#endif

View File

@@ -7,19 +7,21 @@
#include "Sound.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
Sound::Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name)
: output_gpio_interface(output_gpio_interface), address(address), name(name)
Sound::Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
output_gpio_interface(output_gpio_interface), address(address), name(name)
{}
void Sound::play()
{
this->output_gpio_interface->activate(this);
// this->output_gpio_interface->activate(this);
// wait
// deactivate()
}
} /* namespace output */
}
}

View File

@@ -13,9 +13,9 @@
#include <memory>
#include <string>
#include "utilities/IOutputGPIOInterface.h"
#include "utility/IOutputGPIOInterface.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace output
{
@@ -23,13 +23,13 @@ namespace output
class Sound : ISound
{
public:
Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
virtual ~Sound() = default;
virtual void play();
private:
std::shared_ptr<IOutputGPIOInterface> output_gpio_interface;
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
int address;
std::string name;
@@ -37,4 +37,4 @@ private:
} /* namespace output */
}
#endif
#endif