working on item rewrite
This commit is contained in:
@@ -90,7 +90,7 @@ file(GLOB_RECURSE SOURCES src/*.cpp)
|
||||
if(BUILD_SHARED_LIB)
|
||||
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
||||
else()
|
||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} cli/OutputInterpreter.cpp cli/OutputInterpreter.h)
|
||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} cli/OutputInterpreter.cpp cli/OutputInterpreter.h src/output/items/detail/DriverBoardItem.cpp src/output/items/detail/DriverBoardItem.h)
|
||||
endif(BUILD_SHARED_LIB)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef FLIPPR_DRIVER_OUTPUT_ITEMS_DISPLAY_H_
|
||||
#define FLIPPR_DRIVER_OUTPUT_ITEMS_DISPLAY_H_
|
||||
|
||||
#include <iosfwd>
|
||||
#include <iosfwd> // todo wtf?
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#ifndef _SRC_OUTPUT_ICABINETITEM_H_
|
||||
#define _SRC_OUTPUT_ICABINETITEM_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace flippR_driver
|
||||
@@ -23,7 +22,6 @@ class Item
|
||||
public:
|
||||
virtual ~Item() = default;
|
||||
|
||||
virtual uint8_t get_address() const = 0;
|
||||
virtual std::string get_name() const = 0;
|
||||
};
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#ifndef _SRC_OUTPUT_ILAMP_H_
|
||||
#define _SRC_OUTPUT_ILAMP_H_
|
||||
|
||||
#include "Item.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
@@ -15,7 +17,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
class Lamp
|
||||
class Lamp : public Item
|
||||
{
|
||||
public:
|
||||
virtual ~Lamp() = default;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#define _SRC_OUTPUT_ISOLENOID_H_
|
||||
|
||||
|
||||
#include "Item.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
@@ -16,7 +18,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
// todo get name? parent calss output_item?
|
||||
class Solenoid
|
||||
class Solenoid : public Item
|
||||
{
|
||||
public:
|
||||
virtual ~Solenoid() = default;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#ifndef _SRC_OUTPUT_ISOUND_H_
|
||||
#define _SRC_OUTPUT_ISOUND_H_
|
||||
|
||||
#include "Item.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
@@ -15,7 +17,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
class Sound
|
||||
class Sound : public Item
|
||||
{
|
||||
public:
|
||||
virtual ~Sound() = default;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef FLIPPR_DRIVER_DRIVERBOARDPINCONTROLLER_H
|
||||
#define FLIPPR_DRIVER_DRIVERBOARDPINCONTROLLER_H
|
||||
|
||||
#include "OutputPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
@@ -16,13 +17,11 @@ namespace items
|
||||
class DriverBoardItem;
|
||||
}
|
||||
|
||||
class DriverBoardPinController
|
||||
class DriverBoardPinController : public OutputPinController
|
||||
{
|
||||
public:
|
||||
virtual ~DriverBoardPinController() = default;
|
||||
|
||||
virtual void activate(items::DriverBoardItem &driver_board_item) = 0;
|
||||
virtual void deactivate(items::DriverBoardItem &driver_board_item) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -17,12 +17,19 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
namespace items
|
||||
{
|
||||
class DriverBoardItem;
|
||||
}
|
||||
class OutputPinController : public PinController
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~OutputPinController() = default;
|
||||
|
||||
virtual void activate(items::DriverBoardItem &driver_board_item) = 0;
|
||||
virtual void deactivate(items::DriverBoardItem &driver_board_item) = 0;
|
||||
|
||||
protected:
|
||||
static void initialize_i2c_address(uint8_t i2c_address, uint8_t pin_base);
|
||||
static void initialize_pins_output(uint8_t pin_base, std::map<std::string, uint8_t>::iterator begin, std::map<std::string, uint8_t>::iterator end);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef FLIPPR_DRIVER_OUTPUT_SOUNDBOARDPINCONTROLLER_H
|
||||
#define FLIPPR_DRIVER_OUTPUT_SOUNDBOARDPINCONTROLLER_H
|
||||
|
||||
#include "output/OutputPinController.h"
|
||||
#include "output/items/detail/Sound.h"
|
||||
|
||||
namespace flippR_driver
|
||||
@@ -12,13 +13,16 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
namespace items
|
||||
namespace items // todo include + fw decl??
|
||||
{
|
||||
class Sound;
|
||||
}
|
||||
class SoundBoardPinController
|
||||
class SoundBoardPinController : public OutputPinController
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void deactivate(items::DriverBoardItem &driver_board_item) = 0;
|
||||
|
||||
virtual void activate(const items::detail::Sound &sound) = 0;
|
||||
virtual void deactivate(const items::detail::Sound &sound) = 0;
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace output
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class DriverBoardPinController : public OutputPinController, public output::DriverBoardPinController
|
||||
class DriverBoardPinController : public output::DriverBoardPinController
|
||||
{
|
||||
public:
|
||||
DriverBoardPinController(std::map<std::string, uint8_t> pins_driver_board, std::shared_ptr<std::mutex> output_item_mutex);
|
||||
|
||||
@@ -18,14 +18,15 @@ namespace output
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class SoundBoardPinController : public OutputPinController, public output::SoundBoardPinController
|
||||
class SoundBoardPinController : public output::SoundBoardPinController
|
||||
{
|
||||
public:
|
||||
SoundBoardPinController(std::map<std::string, uint8_t> pins_sound, std::shared_ptr<std::mutex> output_item_mutex);
|
||||
~SoundBoardPinController() override = default;
|
||||
|
||||
void activate(const items::detail::Sound &sound) override;
|
||||
void deactivate(const items::detail::Sound &sound) override;
|
||||
|
||||
void activate(const items::detail::Sound &sound);
|
||||
void deactivate(const items::detail::Sound &sound);
|
||||
|
||||
private:
|
||||
void write_sound_address(uint8_t address) const;
|
||||
|
||||
@@ -5,10 +5,6 @@
|
||||
#ifndef FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
||||
#define FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
||||
|
||||
#include "output/items/detail/Item.h"
|
||||
|
||||
#include <output/DriverBoardPinController.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace flippR_driver
|
||||
@@ -18,16 +14,12 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
class DriverBoardItem : public detail::Item
|
||||
class DriverBoardItem
|
||||
{
|
||||
public:
|
||||
DriverBoardItem(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name) :
|
||||
pin_controller(std::move(pin_controller)), detail::Item(address, std::move(name)) {}
|
||||
virtual ~DriverBoardItem() = default;
|
||||
|
||||
~DriverBoardItem() override = default;
|
||||
|
||||
protected:
|
||||
const std::shared_ptr<DriverBoardPinController> pin_controller;
|
||||
virtual uint8_t get_address() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
16
FlippR-Driver/src/output/items/detail/DriverBoardItem.cpp
Normal file
16
FlippR-Driver/src/output/items/detail/DriverBoardItem.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Created by rhetenor on 5/6/19.
|
||||
//
|
||||
|
||||
#include "DriverBoardItem.h"
|
||||
|
||||
using namespace flippR_driver::output;
|
||||
|
||||
items::detail::DriverBoardItem::DriverBoardItem(std::shared_ptr<OutputPinController> pin_controller, const uint8_t address) :
|
||||
pin_controller(std::move(pin_controller)), address(address)
|
||||
{}
|
||||
|
||||
uint8_t items::detail::DriverBoardItem::get_address() const
|
||||
{
|
||||
return this->address;
|
||||
}
|
||||
43
FlippR-Driver/src/output/items/detail/DriverBoardItem.h
Normal file
43
FlippR-Driver/src/output/items/detail/DriverBoardItem.h
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Created by rhetenor on 5/6/19.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_DRIVERBOARDITEM_H
|
||||
#define FLIPPR_DRIVER_DRIVERBOARDITEM_H
|
||||
|
||||
#include "output/items/DriverBoardItem.h"
|
||||
|
||||
#include "output/OutputPinController.h"
|
||||
|
||||
#include <memory>
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class DriverBoardItem : public output::items::DriverBoardItem
|
||||
{
|
||||
public:
|
||||
DriverBoardItem(std::shared_ptr<OutputPinController> pin_controller, const uint8_t address);
|
||||
|
||||
~DriverBoardItem() override = default;
|
||||
|
||||
uint8_t get_address() const override;
|
||||
|
||||
protected:
|
||||
const uint8_t address;
|
||||
|
||||
const std::shared_ptr<OutputPinController> pin_controller;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //FLIPPR_DRIVER_DRIVERBOARDITEM_H
|
||||
@@ -25,14 +25,12 @@ namespace detail
|
||||
class Item : public items::Item
|
||||
{
|
||||
public:
|
||||
Item(uint8_t address, std::string name);
|
||||
Item(std::string name);
|
||||
~Item() override = default;
|
||||
|
||||
uint8_t get_address() const override;
|
||||
std::string get_name() const override;
|
||||
|
||||
protected:
|
||||
uint8_t address;
|
||||
const std::string name;
|
||||
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "Lamp.h"
|
||||
|
||||
#include <output/DriverBoardPinController.h>
|
||||
#include "utility/config.h"
|
||||
|
||||
namespace flippR_driver
|
||||
@@ -19,7 +20,7 @@ namespace detail
|
||||
{
|
||||
|
||||
Lamp::Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name) :
|
||||
DriverBoardItem(std::move(pin_controller), address, std::move(name)), activated(false)
|
||||
detail::Item(std::move(name)), DriverBoardItem(std::move(pin_controller), address), activated(false)
|
||||
{
|
||||
CLOG(INFO, OUTPUT_LOGGER) << "Created lamp " << name << " with address " << address;
|
||||
}
|
||||
@@ -27,13 +28,13 @@ DriverBoardItem(std::move(pin_controller), address, std::move(name)), activated(
|
||||
void Lamp::activate()
|
||||
{
|
||||
CLOG(INFO, OUTPUT_LOGGER) << "Activate lamp " << name;
|
||||
pin_controller->activate(*this);
|
||||
this->pin_controller->activate(*this);
|
||||
}
|
||||
|
||||
void Lamp::deactivate()
|
||||
{
|
||||
CLOG(INFO, OUTPUT_LOGGER) << "Deactivate lamp " << name;
|
||||
pin_controller->deactivate(*this);
|
||||
this->pin_controller->deactivate(*this);
|
||||
}
|
||||
|
||||
bool Lamp::is_activated()
|
||||
|
||||
@@ -9,18 +9,22 @@
|
||||
#define _SRC_OUTPUT_LAMP_H_
|
||||
|
||||
#include "output/items/Lamp.h"
|
||||
#include "output/items/DriverBoardItem.h"
|
||||
#include "output/items/detail/Item.h"
|
||||
#include "output/items/detail/DriverBoardItem.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class DriverBoardPinController;
|
||||
|
||||
namespace items
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class Lamp : public DriverBoardItem, public items::Lamp
|
||||
class Lamp : public detail::DriverBoardItem, public detail::Item, public items::Lamp
|
||||
{
|
||||
public:
|
||||
Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name);
|
||||
|
||||
@@ -19,8 +19,7 @@ namespace detail
|
||||
{
|
||||
|
||||
Solenoid::Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time)
|
||||
:
|
||||
DriverBoardItem(std::move(pin_controller), address, std::move(name)), deactivation_time(deactivation_time)
|
||||
: detail::Item(std::move(name)), DriverBoardItem(std::move(pin_controller), address), deactivation_time(deactivation_time)
|
||||
{
|
||||
CLOG(INFO, OUTPUT_LOGGER) << "Created solenoid " << name << " with address " << address;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
#define _SRC_OUTPUT_SOLENOID_H_
|
||||
|
||||
#include "output/items/Solenoid.h"
|
||||
#include "output/items/DriverBoardItem.h"
|
||||
#include "output/items/detail/Item.h"
|
||||
#include "output/items/detail/DriverBoardItem.h"
|
||||
|
||||
#include "output/DriverBoardPinController.h"
|
||||
|
||||
#include <future>
|
||||
#include <chrono>
|
||||
@@ -23,7 +26,7 @@ namespace items
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class Solenoid : public DriverBoardItem, public items::Solenoid
|
||||
class Solenoid : public DriverBoardItem, public detail::Item, public items::Solenoid
|
||||
{
|
||||
public:
|
||||
Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace detail
|
||||
|
||||
Sound::Sound(std::shared_ptr<SoundBoardPinController> pin_controller, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id)
|
||||
:
|
||||
pin_controller(std::move(pin_controller)), Item(address, std::move(name)), deactivation_time(deactivation_time), id(id)
|
||||
pin_controller(std::move(pin_controller)), detail::Item(std::move(name)), DriverBoardItem(pin_controller, address), deactivation_time(deactivation_time), id(id)
|
||||
{
|
||||
CLOG(INFO, OUTPUT_LOGGER) << "Created sound " << id << " with name " << name << " and address " << address;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "output/items/Sound.h"
|
||||
#include "Item.h"
|
||||
#include "DriverBoardItem.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -28,7 +29,7 @@ namespace items
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class Sound : public Item, public items::Sound
|
||||
class Sound : public detail::Item, public items::Sound, public detail::DriverBoardItem
|
||||
{
|
||||
public:
|
||||
u_int id;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// Created by rhetenor on 27.11.18.
|
||||
//
|
||||
|
||||
#include "SocketHandler.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
//using namespace nlohmann;
|
||||
|
||||
SocketHandler::SocketHandler(std::string socket_file)
|
||||
{
|
||||
//this->socket.connect(socket_file);
|
||||
}
|
||||
/*
|
||||
SocketHandler::create_client(const std::string& socket_file)
|
||||
{
|
||||
this->socket.connect(socket_file);
|
||||
}
|
||||
|
||||
SocketHandler::create_server(const std::string& socket_file)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SocketHandler::write_to_socket(json &json)
|
||||
{
|
||||
std::string json_data = json.dump();
|
||||
|
||||
boost::asio::write(this->socket, boost::asio::buffer(json_data, json_data.length()));
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// Created by rhetenor on 27.11.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_SOCKETHANDLER_H
|
||||
#define FLIPPR_DRIVER_SOCKETHANDLER_H
|
||||
|
||||
#include <Poco/Net/Socket.h>
|
||||
#include <Poco/JSON/JSON.h>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
class SocketHandler
|
||||
{
|
||||
public:
|
||||
SocketHandler(std::string socket_file);
|
||||
|
||||
protected:
|
||||
Poco::Net::Socket socket;
|
||||
|
||||
protected:
|
||||
void write_to_socket(std::string &data);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif //FLIPPR_DRIVER_SOCKETHANDLER_H
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
* Detector.h
|
||||
*
|
||||
* Created on: Jun 13, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#include "TcpServer.h"
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Detector.h
|
||||
*
|
||||
* Created on: Jun 13, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef FLIPPR_CODE_TCPSERVER_H
|
||||
#define FLIPPR_CODE_TCPSERVER_H
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
namespace networking
|
||||
{
|
||||
namespace input
|
||||
{
|
||||
|
||||
class TcpServer
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //FLIPPR_CODE_TCPSERVER_H
|
||||
@@ -1,5 +0,0 @@
|
||||
//
|
||||
// Created by rhetenor on 11.12.18.
|
||||
//
|
||||
|
||||
#include "OutputSocketHandler.h"
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// Created by rhetenor on 11.12.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_OUTPUTSOCKETHANDLER_H
|
||||
#define FLIPPR_DRIVER_OUTPUTSOCKETHANDLER_H
|
||||
|
||||
#include "utility/SocketHandler.h"
|
||||
#include "output/OutputDriver.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
class OutputSocketHandler : public SocketHandler
|
||||
{
|
||||
|
||||
OutputSocketHandler(std::unique_ptr<output::OutputDriver> output_driver);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif //FLIPPR_DRIVER_OUTPUTSOCKETHANDLER_H
|
||||
Reference in New Issue
Block a user