works now?
This commit is contained in:
@@ -23,10 +23,10 @@ namespace flippR_driver::output::items {
|
|||||||
|
|
||||||
namespace flippR_driver::output {
|
namespace flippR_driver::output {
|
||||||
class DisplayController {
|
class DisplayController {
|
||||||
+DisplayController(std::vector<std::shared_ptr<items::IDisplay> > displays, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface)
|
+DisplayController(std::vector<std::shared_ptr<items::IDisplay> > displays, std::shared_ptr<utility::IOutputGPIOInterface> gpio_interface)
|
||||||
+~DisplayController()
|
+~DisplayController()
|
||||||
-is_running : bool
|
-is_running : bool
|
||||||
-output_gpio_interface : std::shared_ptr<utility::IOutputGPIOInterface>
|
-gpio_interface : std::shared_ptr<utility::IOutputGPIOInterface>
|
||||||
-display_cycle_thread : std::thread
|
-display_cycle_thread : std::thread
|
||||||
-displays : std::vector<std::shared_ptr<items::IDisplay> >
|
-displays : std::vector<std::shared_ptr<items::IDisplay> >
|
||||||
-cycle_displays() : void
|
-cycle_displays() : void
|
||||||
@@ -130,7 +130,7 @@ namespace flippR_driver::utility {
|
|||||||
|
|
||||||
namespace flippR_driver::output::items {
|
namespace flippR_driver::output::items {
|
||||||
class Lamp {
|
class Lamp {
|
||||||
+Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name)
|
+Lamp(std::shared_ptr<utility::IOutputGPIOInterface> gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name)
|
||||||
+~Lamp()
|
+~Lamp()
|
||||||
-activated : bool
|
-activated : bool
|
||||||
+is_activated() : bool
|
+is_activated() : bool
|
||||||
@@ -180,9 +180,9 @@ namespace flippR_driver::utility {
|
|||||||
|
|
||||||
namespace flippR_driver::output::items {
|
namespace flippR_driver::output::items {
|
||||||
class Item {
|
class Item {
|
||||||
+Item(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin_address, std::string name)
|
+Item(std::shared_ptr<utility::IOutputGPIOInterface> gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin_address, std::string name)
|
||||||
+~Item()
|
+~Item()
|
||||||
#output_gpio_interface : const std::shared_ptr<utility::IOutputGPIOInterface>
|
#gpio_interface : const std::shared_ptr<utility::IOutputGPIOInterface>
|
||||||
+name : const std::string
|
+name : const std::string
|
||||||
+address : const unsigned int
|
+address : const unsigned int
|
||||||
+data_pin_address : const unsigned int
|
+data_pin_address : const unsigned int
|
||||||
@@ -195,7 +195,7 @@ namespace flippR_driver::output::items {
|
|||||||
|
|
||||||
namespace flippR_driver::output::items {
|
namespace flippR_driver::output::items {
|
||||||
class Solenoid {
|
class 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)
|
+Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time)
|
||||||
+~Solenoid()
|
+~Solenoid()
|
||||||
-deactivation_time : std::chrono::milliseconds
|
-deactivation_time : std::chrono::milliseconds
|
||||||
-trigger_task : std::future<void>
|
-trigger_task : std::future<void>
|
||||||
@@ -207,7 +207,7 @@ namespace flippR_driver::output::items {
|
|||||||
|
|
||||||
namespace flippR_driver::output::items {
|
namespace flippR_driver::output::items {
|
||||||
class Sound {
|
class 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)
|
+Sound(std::shared_ptr<utility::IOutputGPIOInterface> gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time)
|
||||||
+~Sound()
|
+~Sound()
|
||||||
-deactivation_time : std::chrono::milliseconds
|
-deactivation_time : std::chrono::milliseconds
|
||||||
-play_task : std::future<void>
|
-play_task : std::future<void>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ void DisplayController::cycle_displays()
|
|||||||
{
|
{
|
||||||
for(auto& display : this->displays)
|
for(auto& display : this->displays)
|
||||||
{
|
{
|
||||||
output_gpio_interface.write_display(display);
|
output_gpio_interface->write_display(display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ class IItem
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~IItem();
|
virtual ~IItem();
|
||||||
virtual void activate() = 0;
|
|
||||||
virtual void deactivate() = 0;
|
|
||||||
|
|
||||||
virtual uint8_t get_address() = 0;
|
virtual uint8_t get_address() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace items
|
|||||||
Item::Item(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name) :
|
Item::Item(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name) :
|
||||||
address(address),
|
address(address),
|
||||||
name(name),
|
name(name),
|
||||||
output_gpio_interface(output_gpio_interface)
|
gpio_interface(output_gpio_interface)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
uint8_t Item::get_address()
|
uint8_t Item::get_address()
|
||||||
@@ -24,12 +24,12 @@ uint8_t Item::get_address()
|
|||||||
|
|
||||||
void Item::activate()
|
void Item::activate()
|
||||||
{
|
{
|
||||||
output_gpio_interface->activate_output_item(this);
|
gpio_interface->activate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item::deactivate()
|
void Item::deactivate()
|
||||||
{
|
{
|
||||||
output_gpio_interface->deactivate_output_item(this);
|
gpio_interface->deactivate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,17 +28,14 @@ public:
|
|||||||
Item(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
Item(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
||||||
virtual ~Item();
|
virtual ~Item();
|
||||||
|
|
||||||
virtual uint8_t get_address();
|
uint8_t get_address() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const uint8_t address;
|
const uint8_t address;
|
||||||
const std::string name;
|
const std::string name;
|
||||||
|
|
||||||
const std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
|
const std::shared_ptr<utility::IOutputGPIOInterface> gpio_interface;
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void activate();
|
|
||||||
virtual void deactivate();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,20 +14,20 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int i2c_address, unsigned int address, unsigned int data_pin, std::string name)
|
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name)
|
||||||
:
|
:
|
||||||
Item(output_gpio_interface, address, i2c_address, data_pin, name),
|
Item(output_gpio_interface, address, name),
|
||||||
activated(false)
|
activated(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Lamp::activate()
|
void Lamp::activate()
|
||||||
{
|
{
|
||||||
Item::activate();
|
gpio_interface->activate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lamp::deactivate()
|
void Lamp::deactivate()
|
||||||
{
|
{
|
||||||
Item::deactivate();
|
gpio_interface->deactivate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace items
|
|||||||
class Lamp : public Item, ILamp, IDriverBoardItem
|
class Lamp : public Item, ILamp, IDriverBoardItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
||||||
virtual ~Lamp() = default;
|
virtual ~Lamp() = default;
|
||||||
|
|
||||||
void activate();
|
void activate();
|
||||||
|
|||||||
@@ -16,18 +16,18 @@ namespace output
|
|||||||
namespace items
|
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):
|
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time):
|
||||||
Item(output_gpio_interface, address, i2c_address, data_pin, name),
|
Item(output_gpio_interface, address, name),
|
||||||
deactivation_time(deactivation_time)
|
deactivation_time(deactivation_time)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Solenoid::triggerTask()
|
void Solenoid::triggerTask()
|
||||||
{
|
{
|
||||||
Item::activate();
|
gpio_interface->activate(this);
|
||||||
|
|
||||||
std::this_thread::sleep_for(deactivation_time);
|
std::this_thread::sleep_for(deactivation_time);
|
||||||
|
|
||||||
Item::deactivate();
|
gpio_interface->deactivate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Solenoid::trigger()
|
void Solenoid::trigger()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace items
|
|||||||
class Solenoid : public Item, ISolenoid, IDriverBoardItem
|
class Solenoid : public Item, ISolenoid, IDriverBoardItem
|
||||||
{
|
{
|
||||||
public:
|
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);
|
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
||||||
virtual ~Solenoid() = default;
|
virtual ~Solenoid() = default;
|
||||||
|
|
||||||
void trigger();
|
void trigger();
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ void Sound::play()
|
|||||||
|
|
||||||
void Sound::playTask()
|
void Sound::playTask()
|
||||||
{
|
{
|
||||||
Item::activate();
|
gpio_interface->activate(this);
|
||||||
|
|
||||||
std::this_thread::sleep_for(deactivation_time);
|
std::this_thread::sleep_for(deactivation_time);
|
||||||
|
|
||||||
Item::deactivate();
|
gpio_interface->deactivate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
|
|
||||||
#include "IOutputGPIOInterface.h"
|
#include "IOutputGPIOInterface.h"
|
||||||
|
|
||||||
#include "output/items/IItem.h"
|
#include "output/items/IDriverBoardItem.h"
|
||||||
|
#include "output/items/ISoundItem.h"
|
||||||
|
#include "output/items/IDisplay.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
@@ -19,15 +20,17 @@ namespace utility
|
|||||||
class IOutputGPIOInterface
|
class IOutputGPIOInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//muss alles geschützt sein
|
virtual ~IOutputGPIOInterface(){};
|
||||||
void set_address(int i2c_address, int address);
|
|
||||||
void activate_pin(int i2c_address, int pin);
|
|
||||||
void deactivate_pin(int i2c_address, int pin);
|
|
||||||
|
|
||||||
void activate_output_item(output::items::IItem *item);
|
virtual void activate(output::items::IDriverBoardItem *driver_board_item) = 0;
|
||||||
void deactivate_output_item(output::items::IItem *item);
|
virtual void activate(output::items::ISoundItem *sound) = 0;
|
||||||
|
|
||||||
|
virtual void deactivate(output::items::IDriverBoardItem *driver_board_item) = 0;
|
||||||
|
virtual void deactivate(output::items::ISoundItem *sound) = 0;
|
||||||
|
|
||||||
|
virtual void write_display(output::items::IDisplay *display) = 0;
|
||||||
//Display gpio interface!
|
//Display gpio interface!
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,10 @@
|
|||||||
#ifndef SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
|
#ifndef SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
|
||||||
#define SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
|
#define SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
|
||||||
|
|
||||||
|
#include "IOutputGPIOInterface.h"
|
||||||
#include "GPIOInterface.h"
|
#include "GPIOInterface.h"
|
||||||
|
|
||||||
#include "output/items/IItem.h"
|
#include "output/items/IItem.h"
|
||||||
#include "output/items/IDriverBoardItem.h"
|
|
||||||
#include "output/items/ISoundItem.h"
|
|
||||||
#include "output/items/IDisplay.h"
|
|
||||||
|
|
||||||
#include "json/json.hpp"
|
#include "json/json.hpp"
|
||||||
|
|
||||||
@@ -25,7 +23,7 @@ namespace flippR_driver
|
|||||||
namespace utility
|
namespace utility
|
||||||
{
|
{
|
||||||
|
|
||||||
class OutputGPIOInterface : public GPIOInterface
|
class OutputGPIOInterface : public GPIOInterface, IOutputGPIOInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -33,13 +31,13 @@ public:
|
|||||||
|
|
||||||
virtual ~OutputGPIOInterface() = default;
|
virtual ~OutputGPIOInterface() = default;
|
||||||
|
|
||||||
void activate(output::items::IDriverBoardItem *driver_board_item);
|
virtual void activate(output::items::IDriverBoardItem *driver_board_item);
|
||||||
void activate(output::items::ISoundItem *sound);
|
virtual void activate(output::items::ISoundItem *sound);
|
||||||
|
|
||||||
void deactivate(output::items::IDriverBoardItem *driver_board_item);
|
virtual void deactivate(output::items::IDriverBoardItem *driver_board_item);
|
||||||
void deactivate(output::items::ISoundItem *sound);
|
virtual void deactivate(output::items::ISoundItem *sound);
|
||||||
|
|
||||||
void write_display(output::items::IDisplay &display);
|
virtual void write_display(output::items::IDisplay *display);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parse_output_config(nlohmann::json &output_config);
|
void parse_output_config(nlohmann::json &output_config);
|
||||||
|
|||||||
Reference in New Issue
Block a user