hmmm dunno if this is better
This commit is contained in:
@@ -7,9 +7,10 @@
|
|||||||
|
|
||||||
#include "IOutputGPIOInterface.h"
|
#include "IOutputGPIOInterface.h"
|
||||||
|
|
||||||
#include "output/items/IItem.h"
|
#include "output/items/DriverBoardItem.h"
|
||||||
#include "output/items/ISoundItem.h"
|
#include "output/items/SoundItem.h"
|
||||||
#include "output/items/IDisplay.h"
|
#include "output/items/IDisplay.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
@@ -22,11 +23,11 @@ class IOutputGPIOInterface
|
|||||||
public:
|
public:
|
||||||
virtual ~IOutputGPIOInterface() = default;
|
virtual ~IOutputGPIOInterface() = default;
|
||||||
|
|
||||||
virtual void activate(items::IItem *driver_board_item) = 0;
|
virtual void activate(items::DriverBoardItem *driver_board_item) = 0;
|
||||||
virtual void activate(items::ISoundItem *sound) = 0;
|
virtual void activate(items::SoundItem *sound) = 0;
|
||||||
|
|
||||||
virtual void deactivate(items::IItem *driver_board_item) = 0;
|
virtual void deactivate(items::DriverBoardItem *driver_board_item) = 0;
|
||||||
virtual void deactivate(items::ISoundItem *sound) = 0;
|
virtual void deactivate(items::SoundItem *sound) = 0;
|
||||||
|
|
||||||
virtual void write_display(std::shared_ptr<output::items::IDisplay> display) = 0;
|
virtual void write_display(std::shared_ptr<output::items::IDisplay> display) = 0;
|
||||||
//Display gpio interface!
|
//Display gpio interface!
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "OutputDriverFactory.h"
|
#include "OutputDriverFactory.h"
|
||||||
|
|
||||||
#include "OutputDriver.h"
|
#include "OutputDriver.h"
|
||||||
|
#include "OutputGPIOInterface.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,8 +9,9 @@
|
|||||||
#include "output/items/Solenoid.h"
|
#include "output/items/Solenoid.h"
|
||||||
#include "output/items/Lamp.h"
|
#include "output/items/Lamp.h"
|
||||||
#include "output/items/Sound.h"
|
#include "output/items/Sound.h"
|
||||||
#include "OutputGPIOInterface.h"
|
#include "IOutputGPIOInterface.h"
|
||||||
|
|
||||||
|
#include "json/json.hpp"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ namespace flippR_driver
|
|||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
using namespace output::items;
|
using namespace output::items;
|
||||||
using namespace nlohmann;
|
|
||||||
|
|
||||||
OutputGPIOInterface::OutputGPIOInterface(std::map<std::string, uint8_t> pins_driver_board, std::map<std::string, uint8_t> pins_sound, std::map<std::string, uint8_t> pins_display)
|
OutputGPIOInterface::OutputGPIOInterface(std::map<std::string, uint8_t> pins_driver_board, std::map<std::string, uint8_t> pins_sound, std::map<std::string, uint8_t> pins_display)
|
||||||
: pins_driver_board(std::move(pins_driver_board)), pins_sound(std::move(pins_sound)), pins_display(std::move(pins_display))
|
: pins_driver_board(std::move(pins_driver_board)), pins_sound(std::move(pins_sound)), pins_display(std::move(pins_display))
|
||||||
@@ -45,7 +44,7 @@ void OutputGPIOInterface::initialize_i2c_addresses()
|
|||||||
mcp23017Setup(pins_display.at("pin_base"), pins_display.at("i2c_address"));
|
mcp23017Setup(pins_display.at("pin_base"), pins_display.at("i2c_address"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputGPIOInterface::activate(output::items::ISoundItem *sound)
|
void OutputGPIOInterface::activate(items::SoundItem *sound)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||||
|
|
||||||
@@ -54,7 +53,7 @@ void OutputGPIOInterface::activate(output::items::ISoundItem *sound)
|
|||||||
fire_sound(true);
|
fire_sound(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputGPIOInterface::activate(output::items::IItem *driver_board_item)
|
void OutputGPIOInterface::activate(items::DriverBoardItem *driver_board_item)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ void OutputGPIOInterface::activate(output::items::IItem *driver_board_item)
|
|||||||
write_data(true);
|
write_data(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputGPIOInterface::deactivate(output::items::IItem *driver_board_item)
|
void OutputGPIOInterface::deactivate(items::DriverBoardItem *driver_board_item)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||||
|
|
||||||
@@ -72,7 +71,7 @@ void OutputGPIOInterface::deactivate(output::items::IItem *driver_board_item)
|
|||||||
write_data(false);
|
write_data(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputGPIOInterface::deactivate(output::items::ISoundItem *sound)
|
void OutputGPIOInterface::deactivate(items::SoundItem *sound)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include "output/items/IItem.h"
|
#include "output/items/IItem.h"
|
||||||
|
|
||||||
#include "json/json.hpp"
|
|
||||||
|
|
||||||
#include <mcp23017.h>
|
#include <mcp23017.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@@ -32,11 +31,11 @@ public:
|
|||||||
|
|
||||||
~OutputGPIOInterface() override = default;
|
~OutputGPIOInterface() override = default;
|
||||||
|
|
||||||
void activate(items::IItem *driver_board_item) override;
|
void activate(items::DriverBoardItem *driver_board_item) override;
|
||||||
void activate(items::ISoundItem *sound) override;
|
void activate(items::SoundItem *sound) override;
|
||||||
|
|
||||||
void deactivate(items::IItem *driver_board_item) override;
|
void deactivate(items::DriverBoardItem *driver_board_item) override;
|
||||||
void deactivate(items::ISoundItem *sound) override;
|
void deactivate(items::SoundItem *sound) override;
|
||||||
|
|
||||||
void write_display(std::shared_ptr<output::items::IDisplay> display) override;
|
void write_display(std::shared_ptr<output::items::IDisplay> display) override;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
#ifndef FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
||||||
#define FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
#define FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
||||||
|
|
||||||
#include "output/items/IItem.h"
|
#include "output/items/Item.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@@ -16,10 +16,14 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class IDriverBoardItem : public IItem
|
class DriverBoardItem : public Item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~IDriverBoardItem() override = default;
|
DriverBoardItem(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name) :
|
||||||
|
Item(output_gpio_interface, address, name) {}
|
||||||
|
~DriverBoardItem() override = default;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by rhetenor on 23.11.18.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef FLIPPR_DRIVER_ISOUNDITEM_H
|
|
||||||
#define FLIPPR_DRIVER_ISOUNDITEM_H
|
|
||||||
|
|
||||||
#include "IItem.h"
|
|
||||||
namespace flippR_driver
|
|
||||||
{
|
|
||||||
namespace output
|
|
||||||
{
|
|
||||||
namespace items
|
|
||||||
{
|
|
||||||
|
|
||||||
class ISoundItem : public IItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
~ISoundItem() override = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //FLIPPR_DRIVER_ISOUNDITEM_H
|
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include "output/items/IItem.h"
|
#include "output/items/IItem.h"
|
||||||
|
|
||||||
#include "output/IOutputGPIOInterface.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -19,6 +17,9 @@ namespace flippR_driver
|
|||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class IOutputGPIOInterface;
|
||||||
|
|
||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "Lamp.h"
|
#include "Lamp.h"
|
||||||
|
|
||||||
|
#include "output/IOutputGPIOInterface.h"
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
@@ -14,10 +15,8 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
Lamp::Lamp(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name)
|
Lamp::Lamp(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name) :
|
||||||
:
|
DriverBoardItem(std::move(output_gpio_interface), address, std::move(name)), activated(false)
|
||||||
Item(std::move(output_gpio_interface), address, std::move(name)),
|
|
||||||
activated(false)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Lamp::activate()
|
void Lamp::activate()
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
#ifndef _SRC_OUTPUT_LAMP_H_
|
#ifndef _SRC_OUTPUT_LAMP_H_
|
||||||
#define _SRC_OUTPUT_LAMP_H_
|
#define _SRC_OUTPUT_LAMP_H_
|
||||||
|
|
||||||
#include "Item.h"
|
|
||||||
#include "output/items/ILamp.h"
|
#include "output/items/ILamp.h"
|
||||||
|
#include "DriverBoardItem.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
@@ -18,7 +18,7 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class Lamp : public Item, public ILamp
|
class Lamp : public DriverBoardItem, public ILamp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Lamp(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
Lamp(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include "Solenoid.h"
|
#include "Solenoid.h"
|
||||||
|
|
||||||
|
#include "output/IOutputGPIOInterface.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
@@ -15,8 +17,7 @@ namespace items
|
|||||||
{
|
{
|
||||||
|
|
||||||
Solenoid::Solenoid(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time):
|
Solenoid::Solenoid(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time):
|
||||||
Item(std::move(output_gpio_interface), address, std::move(name)),
|
DriverBoardItem(std::move(output_gpio_interface), address, std::move(name)), deactivation_time(deactivation_time)
|
||||||
deactivation_time(deactivation_time)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Solenoid::triggerTask()
|
void Solenoid::triggerTask()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#define _SRC_OUTPUT_SOLENOID_H_
|
#define _SRC_OUTPUT_SOLENOID_H_
|
||||||
|
|
||||||
#include "output/items/ISolenoid.h"
|
#include "output/items/ISolenoid.h"
|
||||||
#include "Item.h"
|
#include "DriverBoardItem.h"
|
||||||
|
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@@ -21,7 +21,7 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class Solenoid : public Item, public ISolenoid
|
class Solenoid : public DriverBoardItem, public ISolenoid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Solenoid(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
Solenoid(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
|
||||||
|
#include "output/IOutputGPIOInterface.h"
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
@@ -15,9 +17,7 @@ namespace items
|
|||||||
{
|
{
|
||||||
|
|
||||||
Sound::Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id) :
|
Sound::Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id) :
|
||||||
Item(std::move(output_gpio_interface), address, std::move(name)),
|
SoundItem(std::move(output_gpio_interface), address, std::move(name)), deactivation_time(deactivation_time), id(id)
|
||||||
deactivation_time(deactivation_time),
|
|
||||||
id(id)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Sound::play()
|
void Sound::play()
|
||||||
|
|||||||
@@ -9,16 +9,13 @@
|
|||||||
#define _SRC_OUTPUT_SOUND_H_
|
#define _SRC_OUTPUT_SOUND_H_
|
||||||
|
|
||||||
#include "output/items/ISound.h"
|
#include "output/items/ISound.h"
|
||||||
#include "output/items/ISoundItem.h"
|
#include "output/items/SoundItem.h"
|
||||||
|
|
||||||
#include "Item.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <future>
|
#include <future>
|
||||||
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
namespace output
|
||||||
@@ -26,7 +23,7 @@ namespace output
|
|||||||
namespace items
|
namespace items
|
||||||
{
|
{
|
||||||
|
|
||||||
class Sound : public ISound, public Item, public ISoundItem
|
class Sound : public SoundItem, public ISound
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
u_int id;
|
u_int id;
|
||||||
@@ -35,9 +32,6 @@ public:
|
|||||||
Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id);
|
Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id);
|
||||||
~Sound() override = default;
|
~Sound() override = default;
|
||||||
|
|
||||||
std::string get_name() override;
|
|
||||||
uint8_t get_address() override;
|
|
||||||
|
|
||||||
void play() override;
|
void play() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
29
FlippR-Driver/src/output/items/SoundItem.h
Normal file
29
FlippR-Driver/src/output/items/SoundItem.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// Created by rhetenor on 23.11.18.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef FLIPPR_DRIVER_ISOUNDITEM_H
|
||||||
|
#define FLIPPR_DRIVER_ISOUNDITEM_H
|
||||||
|
|
||||||
|
#include "Item.h"
|
||||||
|
|
||||||
|
namespace flippR_driver
|
||||||
|
{
|
||||||
|
namespace output
|
||||||
|
{
|
||||||
|
namespace items
|
||||||
|
{
|
||||||
|
|
||||||
|
class SoundItem : public Item
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SoundItem(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name) :
|
||||||
|
Item(output_gpio_interface, address, name) {}
|
||||||
|
~SoundItem() override = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //FLIPPR_DRIVER_ISOUNDITEM_H
|
||||||
Reference in New Issue
Block a user