This commit is contained in:
Jonas Zeunert
2018-11-20 21:42:02 +01:00
9 changed files with 421 additions and 21 deletions

View File

@@ -14,9 +14,9 @@ namespace flippR_driver
namespace output
{
class ICabinetItem
class IOutputItem
{
virtual ~ICabinetItem();
virtual ~IOutputItem();
virtual bool isActivated() = 0;
virtual bool activate() = 0;
virtual bool deactivate() = 0;

View File

@@ -12,8 +12,9 @@ namespace flippR_driver
namespace output
{
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
OutputItem(output_gpio_interface, address, name)
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name, bool activated) :
OutputItem(output_gpio_interface, address, name),
activated(activated)
{
// TODO Auto-generated constructor stub

View File

@@ -18,7 +18,7 @@ namespace output
class Lamp : public OutputItem
{
public:
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name, bool activated = false);
virtual ~Lamp();
void activate();

View File

@@ -15,13 +15,13 @@ namespace flippR_driver
namespace output
{
OutputDriver::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::OutputDriver(std::map<std::string, std::shared_ptr<IOutputtItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds)
: cabinet_items(cabinet_items), displays(displays), sounds(sounds)
{}
std::vector<std::shared_ptr<ICabinetItem>> OutputDriver::get_cabinet_items()
std::vector<std::shared_ptr<IOutputtItem>> OutputDriver::get_cabinet_items()
{
std::vector<std::shared_ptr<ICabinetItem>> cabinet_items;
std::vector<std::shared_ptr<IOutputtItem>> cabinet_items;
boost::copy(this->cabinet_items | boost::adaptors::map_values, std::back_inserter(cabinet_items));
@@ -46,7 +46,7 @@ std::vector<std::shared_ptr<IDisplay>> OutputDriver::get_displays()
return displays;
}
std::shared_ptr<ICabinetItem> OutputDriver::get_cabinet_item(std::string name)
std::shared_ptr<IOutputtItem> OutputDriver::get_cabinet_item(std::string name)
{
return this->cabinet_items.find(name)->second;
}

View File

@@ -25,20 +25,20 @@ 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<IOutputtItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds);
virtual ~OutputDriver() = default;
std::vector<std::shared_ptr<ICabinetItem>> get_cabinet_items();
std::vector<std::shared_ptr<IOutputtItem>> 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<IOutputtItem> 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<std::string, std::shared_ptr<IOutputtItem>> cabinet_items;
std::map<char, std::shared_ptr<IDisplay>> displays;
std::map<std::string, std::shared_ptr<ISound>> sounds;
};

View File

@@ -8,9 +8,8 @@
#ifndef _SRC_OUTPUT_CABINETITEM_H_
#define _SRC_OUTPUT_CABINETITEM_H_
#include "ICabinetItem.h"
#include "IOutputItem.h"
#include "ActivationStrategy.h"
#include "utility/IOutputGPIOInterface.h"
#include <memory>
@@ -21,7 +20,7 @@ namespace flippR_driver
namespace output
{
class OutputItem : public ICabinetItem
class OutputItem : public IOutputItem
{
public:
OutputItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
@@ -31,8 +30,6 @@ protected:
int address, i2c_address, data_pin_address;
std::string name;
strategy::ActivationStrategy* strategy;
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
};

View File

@@ -11,8 +11,9 @@ namespace flippR_driver
{
namespace output {
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
OutputItem(output_gpio_interface, address, name)
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name, std::chrono::milliseconds deactivation_time) :
OutputItem(output_gpio_interface, address, name),
deactivation_time(deactivation_time)
{
// TODO Auto-generated constructor stub
@@ -30,5 +31,15 @@ void Solenoid::trigger()
// deactivate
}
void Solenoid::activate()
{
}
void Solenoid::deactivate()
{
}
} /* namespace output */
}

View File

@@ -10,6 +10,10 @@
#include "OutputItem.h"
#include <future>
#include <thread>
#include <chrono>
namespace flippR_driver
{
namespace output
@@ -18,11 +22,18 @@ namespace output
class Solenoid : public OutputItem
{
public:
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name, std::chrono::milliseconds deactivation_time);
virtual ~Solenoid();
//muss task sein
void trigger();
private:
std::future<void> wait_thread;
std::chrono::milliseconds deactivation_time;
void activate();
void deactivate();
};
} /* namespace output */