reafectored stuff and corrected shit to make everything compiling
This commit is contained in:
@@ -15,7 +15,7 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface)
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<items::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);
|
||||
@@ -36,7 +36,7 @@ void DisplayController::cycle_displays()
|
||||
{
|
||||
for(auto& display : this->displays)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
|
||||
#include "IDisplay.h"
|
||||
#include "items/IDisplay.h"
|
||||
#include "utility/IOutputGPIOInterface.h"
|
||||
|
||||
namespace flippR_driver
|
||||
@@ -24,14 +24,14 @@ namespace output
|
||||
class DisplayController : public IDisplayController
|
||||
{
|
||||
public:
|
||||
explicit DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface);
|
||||
explicit DisplayController(std::vector<std::shared_ptr<items::IDisplay>> displays, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface);
|
||||
~DisplayController();
|
||||
|
||||
private:
|
||||
void cycle_displays();
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<IDisplay>> displays;
|
||||
std::vector<std::shared_ptr<items::IDisplay>> displays;
|
||||
|
||||
std::thread display_cycle_thread;
|
||||
|
||||
|
||||
@@ -15,18 +15,12 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
using namespace items;
|
||||
|
||||
OutputDriver::OutputDriver(std::map<std::string, std::shared_ptr<ISolenoid>> solenoids, std::map<std::string, std::shared_ptr<ILamp>> lamps, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds)
|
||||
: solenoids(solenoids), lamps(lamps), displays(displays), sounds(sounds)
|
||||
{}
|
||||
|
||||
std::vector<std::shared_ptr<IOutputtItem>> OutputDriver::get_cabinet_items()
|
||||
{
|
||||
std::vector<std::shared_ptr<IOutputtItem>> cabinet_items;
|
||||
|
||||
boost::copy(this->cabinet_items | boost::adaptors::map_values, std::back_inserter(cabinet_items));
|
||||
|
||||
return cabinet_items;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ISound>> OutputDriver::get_sounds()
|
||||
{
|
||||
@@ -46,9 +40,22 @@ std::vector<std::shared_ptr<IDisplay>> OutputDriver::get_displays()
|
||||
return displays;
|
||||
}
|
||||
|
||||
std::shared_ptr<IOutputtItem> OutputDriver::get_cabinet_item(std::string name)
|
||||
std::vector<std::shared_ptr<ILamp>> OutputDriver::get_lamps()
|
||||
{
|
||||
return this->cabinet_items.find(name)->second;
|
||||
std::vector<std::shared_ptr<ILamp>> lamps;
|
||||
|
||||
boost::copy(this->lamps | boost::adaptors::map_values, std::back_inserter(lamps));
|
||||
|
||||
return lamps;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ISolenoid>> OutputDriver::get_solenoids()
|
||||
{
|
||||
std::vector<std::shared_ptr<ISolenoid>> solenoids;
|
||||
|
||||
boost::copy(this->solenoids | boost::adaptors::map_values, std::back_inserter(solenoids));
|
||||
|
||||
return solenoids;
|
||||
}
|
||||
|
||||
std::shared_ptr<ISound> OutputDriver::get_sound(std::string name)
|
||||
@@ -61,5 +68,15 @@ std::shared_ptr<IDisplay> OutputDriver::get_display(char number)
|
||||
return this->displays.find(number)->second;
|
||||
}
|
||||
|
||||
std::shared_ptr<ILamp> OutputDriver::get_lamp(std::string name)
|
||||
{
|
||||
return this->lamps.find(name)->second;
|
||||
}
|
||||
|
||||
std::shared_ptr<ISolenoid> OutputDriver::get_solenoid(std::string name)
|
||||
{
|
||||
return this->solenoids.find(name)->second;
|
||||
}
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,15 +9,16 @@
|
||||
#define _SRC_OUTPUT_OUTPUTDRIVER_H_
|
||||
|
||||
#include "output/IOutputDriver.h"
|
||||
|
||||
#include "output/items/ILamp.h"
|
||||
#include "output/items/ISolenoid.h"
|
||||
#include "output/items/IDisplay.h"
|
||||
#include "output/items/ISound.h"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "ILamp.h"
|
||||
#include "ISolenoid.h"
|
||||
#include "IDisplay.h"
|
||||
#include "ISound.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
@@ -26,25 +27,25 @@ namespace output
|
||||
class OutputDriver : public IOutputDriver
|
||||
{
|
||||
public:
|
||||
OutputDriver(std::map<std::string, std::shared_ptr<ISolenoid>> solenoids, std::map<std::string, std::shared_ptr<ILamp>> lamps, 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<items::ISolenoid>> solenoids, std::map<std::string, std::shared_ptr<items::ILamp>> lamps, std::map<char, std::shared_ptr<items::IDisplay>> displays, std::map<std::string, std::shared_ptr<items::ISound>> sounds);
|
||||
|
||||
virtual ~OutputDriver() = default;
|
||||
|
||||
std::vector<std::shared_ptr<ILamp>> get_lamps();
|
||||
std::vector<std::shared_ptr<ISolenoid>> get_solenoids();
|
||||
std::vector<std::shared_ptr<ISound>> get_sounds();
|
||||
std::vector<std::shared_ptr<IDisplay>> get_displays();
|
||||
std::vector<std::shared_ptr<items::ILamp>> get_lamps();
|
||||
std::vector<std::shared_ptr<items::ISolenoid>> get_solenoids();
|
||||
std::vector<std::shared_ptr<items::ISound>> get_sounds();
|
||||
std::vector<std::shared_ptr<items::IDisplay>> get_displays();
|
||||
|
||||
std::shared_ptr<ILamp> get_lamp(std::string name);
|
||||
std::shared_ptr<ISolenoid> get_solenoid(std::string name);
|
||||
std::shared_ptr<ISound> get_sound(std::string name);
|
||||
std::shared_ptr<IDisplay> get_display(char number);
|
||||
std::shared_ptr<items::ILamp> get_lamp(std::string name);
|
||||
std::shared_ptr<items::ISolenoid> get_solenoid(std::string name);
|
||||
std::shared_ptr<items::ISound> get_sound(std::string name);
|
||||
std::shared_ptr<items::IDisplay> get_display(char number);
|
||||
|
||||
private:
|
||||
std::map<std::string, std::shared_ptr<ILamp>> lamps;
|
||||
std::map<std::string, std::shared_ptr<ISolenoid>> solenoids;
|
||||
std::map<char, std::shared_ptr<IDisplay>> displays;
|
||||
std::map<std::string, std::shared_ptr<ISound>> sounds;
|
||||
std::map<std::string, std::shared_ptr<items::ILamp>> lamps;
|
||||
std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids;
|
||||
std::map<char, std::shared_ptr<items::IDisplay>> displays;
|
||||
std::map<std::string, std::shared_ptr<items::ISound>> sounds;
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace items
|
||||
{
|
||||
|
||||
template<int DigitCount>
|
||||
class Display : public IDisplay<DigitCount>
|
||||
class Display : public IDisplay
|
||||
{
|
||||
public:
|
||||
Display(int address, int id);
|
||||
|
||||
@@ -18,13 +18,14 @@ namespace items
|
||||
|
||||
class IOutputItem
|
||||
{
|
||||
public:
|
||||
virtual ~IOutputItem();
|
||||
virtual bool activate() = 0;
|
||||
virtual bool deactivate() = 0;
|
||||
virtual void activate() = 0;
|
||||
virtual void deactivate() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define _SRC_OUTPUT_LAMP_H_
|
||||
|
||||
#include "OutputItem.h"
|
||||
#include "../../../include/output/output_items/ILamp.h"
|
||||
#include "output/items/ILamp.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
|
||||
@@ -36,8 +36,8 @@ protected:
|
||||
const std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
|
||||
|
||||
protected:
|
||||
void activate();
|
||||
void deactivate();
|
||||
virtual void activate();
|
||||
virtual void deactivate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "Solenoid.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
@@ -14,10 +16,9 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time)
|
||||
:
|
||||
OutputItem(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
deactivation_time(deactivation_time)
|
||||
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time):
|
||||
OutputItem(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
deactivation_time(deactivation_time)
|
||||
{}
|
||||
|
||||
void Solenoid::triggerTask()
|
||||
@@ -31,7 +32,7 @@ void Solenoid::triggerTask()
|
||||
|
||||
void Solenoid::trigger()
|
||||
{
|
||||
std::async(std::launch::async, &Solenoid::triggerTask);
|
||||
this->trigger_task = std::async(std::launch::async, &Solenoid::triggerTask, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,11 +8,10 @@
|
||||
#ifndef _SRC_OUTPUT_SOLENOID_H_
|
||||
#define _SRC_OUTPUT_SOLENOID_H_
|
||||
|
||||
#include "output/items/ISolenoid.h"
|
||||
#include "OutputItem.h"
|
||||
#include "../../../include/output/output_items/ISolenoid.h"
|
||||
|
||||
#include <future>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
namespace flippR_driver
|
||||
@@ -22,7 +21,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
class Solenoid : public ISolenoid, OutputItem
|
||||
class Solenoid : public OutputItem, ISolenoid
|
||||
{
|
||||
public:
|
||||
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
@@ -33,10 +32,14 @@ public:
|
||||
private:
|
||||
std::chrono::milliseconds deactivation_time;
|
||||
|
||||
std::future<void> trigger_task;
|
||||
|
||||
private:
|
||||
virtual void triggerTask();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Sound.h"
|
||||
|
||||
#include <future>
|
||||
#include <thread>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
@@ -16,15 +16,14 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
Sound::Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name)
|
||||
:
|
||||
OutputItem(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
deactivation_time(deactivation_time)
|
||||
Sound::Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time) :
|
||||
OutputItem(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
deactivation_time(deactivation_time)
|
||||
{}
|
||||
|
||||
void Sound::play()
|
||||
{
|
||||
std::async(std::launch::async, &Sound::playTask);
|
||||
this->play_task = std::async(std::launch::async, &Sound::playTask, this);
|
||||
}
|
||||
|
||||
void Sound::playTask()
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
#ifndef _SRC_OUTPUT_SOUND_H_
|
||||
#define _SRC_OUTPUT_SOUND_H_
|
||||
|
||||
#include "../../../include/output/output_items/ISound.h"
|
||||
#include "output/items/ISound.h"
|
||||
#include "OutputItem.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <future>
|
||||
|
||||
#include "utility/IOutputGPIOInterface.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
@@ -33,6 +35,8 @@ public:
|
||||
private:
|
||||
std::chrono::milliseconds deactivation_time;
|
||||
|
||||
std::future<void> play_task;
|
||||
|
||||
private:
|
||||
virtual void playTask();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user