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