renamed impl to detail
This commit is contained in:
58
FlippR-Driver/src/output/items/detail/Display.h
Normal file
58
FlippR-Driver/src/output/items/detail/Display.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Display.h
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef FLIPPR_DRIVER_OUTPUT_ITEMS_IMPL_DISPLAY_H_
|
||||
#define FLIPPR_DRIVER_OUTPUT_ITEMS_IMPL_DISPLAY_H_
|
||||
|
||||
#include "output/items/OutputDisplay.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<int DigitCount>
|
||||
class Display : public items::OutputDisplay
|
||||
{
|
||||
public:
|
||||
Display(uint8_t address, uint8_t id);
|
||||
virtual ~Display() = default;
|
||||
|
||||
void write_score(uint score) override;
|
||||
void write_content(std::array<char, DigitCount> content);
|
||||
|
||||
std::vector<uint8_t> get_content() const override;
|
||||
uint8_t get_address() const override;
|
||||
uint8_t get_id() const override;
|
||||
|
||||
private:
|
||||
std::string fit_string(std::string &score_string);
|
||||
|
||||
public:
|
||||
std::array<char, DigitCount> content;
|
||||
|
||||
private:
|
||||
const uint8_t id;
|
||||
const uint8_t address;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
|
||||
#include "Display.hpp"
|
||||
|
||||
|
||||
#endif
|
||||
73
FlippR-Driver/src/output/items/detail/Display.hpp
Normal file
73
FlippR-Driver/src/output/items/detail/Display.hpp
Normal file
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// Created by rhetenor on 10.10.18.
|
||||
//
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<int DigitCount>
|
||||
Display<DigitCount>::Display(uint8_t address, uint8_t id) :
|
||||
address(address),
|
||||
id(id)
|
||||
{
|
||||
}
|
||||
|
||||
template<int DigitCount>
|
||||
uint8_t Display<DigitCount>::get_id() const
|
||||
{
|
||||
return this->id;
|
||||
}
|
||||
|
||||
template<int DigitCount>
|
||||
void Display<DigitCount>::write_score(uint score)
|
||||
{
|
||||
auto score_string = std::to_string(score);
|
||||
|
||||
std::copy(score_string.begin(), score_string.end(), 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;
|
||||
}
|
||||
|
||||
template <int DigitCount>
|
||||
std::vector<uint8_t> Display<DigitCount>::get_content() const
|
||||
{
|
||||
// todo: expensive?
|
||||
return std::vector<uint8_t>(content.begin(), content.end());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
46
FlippR-Driver/src/output/items/detail/EightDigitDisplay.h
Normal file
46
FlippR-Driver/src/output/items/detail/EightDigitDisplay.h
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// Created by rhetenor on 20.11.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_OUTPUT_ITEMS_IMPL_EIGHTDIGITDISPLAY_H
|
||||
#define FLIPPR_DRIVER_OUTPUT_ITEMS_IMPL_EIGHTDIGITDISPLAY_H
|
||||
|
||||
#include "output/items/detail/Display.h"
|
||||
|
||||
#include "output/items/EightDigitDisplay.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class EightDigitDisplay : public Display<8>, public items::EightDigitDisplay
|
||||
{
|
||||
public:
|
||||
EightDigitDisplay(uint8_t address, uint8_t id) :
|
||||
Display<8>(address, id) {}
|
||||
|
||||
void write_score(uint score) override
|
||||
{
|
||||
Display<8>::write_score(score);
|
||||
}
|
||||
|
||||
void write_content(std::array<char, 8> content) override
|
||||
{
|
||||
Display<8>::write_content(content);
|
||||
}
|
||||
|
||||
|
||||
~EightDigitDisplay() override = default;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //FLIPPR_DRIVER_EIGHTDIGITDISPLAY_H
|
||||
33
FlippR-Driver/src/output/items/detail/Item.cpp
Normal file
33
FlippR-Driver/src/output/items/detail/Item.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Created by rhetenor on 21.11.18.
|
||||
//
|
||||
|
||||
#include "Item.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
Item::Item(uint8_t address, std::string name) :
|
||||
address(address), name(std::move(name))
|
||||
{}
|
||||
|
||||
uint8_t Item::get_address() const
|
||||
{
|
||||
return this->address;
|
||||
}
|
||||
|
||||
std::string Item::get_name() const
|
||||
{
|
||||
return this->name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
44
FlippR-Driver/src/output/items/detail/Item.h
Normal file
44
FlippR-Driver/src/output/items/detail/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 detail
|
||||
{
|
||||
|
||||
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:
|
||||
uint8_t address;
|
||||
const std::string name;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
36
FlippR-Driver/src/output/items/detail/Lamp.cpp
Normal file
36
FlippR-Driver/src/output/items/detail/Lamp.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Lamp.cpp
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#include "Lamp.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
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)
|
||||
{}
|
||||
|
||||
void Lamp::activate()
|
||||
{
|
||||
pin_controller->activate(*this);
|
||||
}
|
||||
|
||||
void Lamp::deactivate()
|
||||
{
|
||||
pin_controller->deactivate(*this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
41
FlippR-Driver/src/output/items/detail/Lamp.h
Normal file
41
FlippR-Driver/src/output/items/detail/Lamp.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Lamp.h
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef _SRC_OUTPUT_LAMP_H_
|
||||
#define _SRC_OUTPUT_LAMP_H_
|
||||
|
||||
#include "output/items/Lamp.h"
|
||||
#include "output/items/DriverBoardItem.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class Lamp : public DriverBoardItem, public items::Lamp
|
||||
{
|
||||
public:
|
||||
Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name);
|
||||
~Lamp() override = default;
|
||||
|
||||
void activate() override;
|
||||
void deactivate() override;
|
||||
bool is_activated() override;
|
||||
|
||||
private:
|
||||
bool activated;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
44
FlippR-Driver/src/output/items/detail/SevenDigitDisplay.h
Normal file
44
FlippR-Driver/src/output/items/detail/SevenDigitDisplay.h
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Created by rhetenor on 20.11.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_SEVENDIGITDISPLAY_H
|
||||
#define FLIPPR_DRIVER_SEVENDIGITDISPLAY_H
|
||||
|
||||
#include "output/items/SevenDigitDisplay.h"
|
||||
|
||||
#include "output/items/detail/Display.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class SevenDigitDisplay : public Display<7>, public items::SevenDigitDisplay
|
||||
{
|
||||
public:
|
||||
SevenDigitDisplay(uint8_t address, uint8_t id) :
|
||||
Display<7>(address, id) {}
|
||||
|
||||
void write_score(uint score) override
|
||||
{
|
||||
Display<7>::write_score(score);
|
||||
}
|
||||
|
||||
void write_content(std::array<char, 7> content) override
|
||||
{
|
||||
Display<7>::write_content(content);
|
||||
}
|
||||
|
||||
~SevenDigitDisplay() override = default;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //FLIPPR_DRIVER_SEVENDIGITDISPLAY_H
|
||||
41
FlippR-Driver/src/output/items/detail/Solenoid.cpp
Normal file
41
FlippR-Driver/src/output/items/detail/Solenoid.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Solenoid.cpp
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#include "Solenoid.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
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)
|
||||
{}
|
||||
|
||||
void Solenoid::triggerTask()
|
||||
{
|
||||
pin_controller->activate(*this);
|
||||
|
||||
std::this_thread::sleep_for(deactivation_time);
|
||||
|
||||
pin_controller->deactivate(*this);
|
||||
}
|
||||
|
||||
void Solenoid::trigger()
|
||||
{
|
||||
this->trigger_task = std::async(std::launch::async, &Solenoid::triggerTask, this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
48
FlippR-Driver/src/output/items/detail/Solenoid.h
Normal file
48
FlippR-Driver/src/output/items/detail/Solenoid.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Solenoid.h
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef _SRC_OUTPUT_SOLENOID_H_
|
||||
#define _SRC_OUTPUT_SOLENOID_H_
|
||||
|
||||
#include "output/items/Solenoid.h"
|
||||
#include "output/items/DriverBoardItem.h"
|
||||
|
||||
#include <future>
|
||||
#include <chrono>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class Solenoid : public DriverBoardItem, public items::Solenoid
|
||||
{
|
||||
public:
|
||||
Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
~Solenoid() override = default;
|
||||
|
||||
void trigger() override;
|
||||
|
||||
private:
|
||||
virtual void triggerTask();
|
||||
|
||||
private:
|
||||
const std::chrono::milliseconds deactivation_time;
|
||||
|
||||
std::future<void> trigger_task;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
43
FlippR-Driver/src/output/items/detail/Sound.cpp
Normal file
43
FlippR-Driver/src/output/items/detail/Sound.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Sound.cpp
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#include "Sound.h"
|
||||
|
||||
#include <output/SoundBoardPinController.h>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
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)
|
||||
{}
|
||||
|
||||
void Sound::play()
|
||||
{
|
||||
this->play_task = std::async(std::launch::async, &Sound::playTask, this);
|
||||
}
|
||||
|
||||
void Sound::playTask()
|
||||
{
|
||||
pin_controller->activate(*this);
|
||||
|
||||
std::this_thread::sleep_for(deactivation_time);
|
||||
|
||||
pin_controller->deactivate(*this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
57
FlippR-Driver/src/output/items/detail/Sound.h
Normal file
57
FlippR-Driver/src/output/items/detail/Sound.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Sound.h
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef _SRC_OUTPUT_SOUND_H_
|
||||
#define _SRC_OUTPUT_SOUND_H_
|
||||
|
||||
#include "output/items/Sound.h"
|
||||
#include "Item.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <future>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class SoundBoardPinController;
|
||||
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class Sound : public Item, public items::Sound
|
||||
{
|
||||
public:
|
||||
u_int id;
|
||||
|
||||
public:
|
||||
Sound(std::shared_ptr<SoundBoardPinController> pin_controller, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id);
|
||||
~Sound() override = default;
|
||||
|
||||
void play() override;
|
||||
|
||||
private:
|
||||
const std::chrono::milliseconds deactivation_time;
|
||||
|
||||
const std::shared_ptr<SoundBoardPinController> pin_controller;
|
||||
|
||||
std::future<void> play_task;
|
||||
|
||||
private:
|
||||
virtual void playTask();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user