Did big refactoring and further adapted OutputDriverFactory as well as uptuput dricer to new board layouts.
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#include <thread>
|
||||
#include "output/DisplayBoardPinController.h"
|
||||
|
||||
#include "DisplayBoardPinController.h"
|
||||
#include <thread>
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
DisplayBoardPinController::DisplayBoardPinController(std::map<std::string, uint8_t> pins_display) :
|
||||
pins_display_board(std::move(pins_display))
|
||||
@@ -77,6 +75,5 @@ void DisplayBoardPinController::run_display(uint8_t address) const
|
||||
write_pin(pins_display_board.at("display_select_" + std::to_string(address)), 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_OUTPUT_IMPL_DISPLAYPINCONTROLLER_H
|
||||
#define FLIPPR_DRIVER_OUTPUT_IMPL_DISPLAYPINCONTROLLER_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "output/DisplayBoardPinController.h"
|
||||
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class DisplayBoardPinController : public output::DisplayBoardPinController
|
||||
{
|
||||
public:
|
||||
explicit DisplayBoardPinController(std::map<std::string, uint8_t> pins_display);
|
||||
~DisplayBoardPinController() override = default;
|
||||
|
||||
void activate_displays() const override;
|
||||
void deactivate_displays() const override;
|
||||
|
||||
void write_display(const items::OutputDisplay &display) const override;
|
||||
|
||||
private:
|
||||
void write_display_digit(uint8_t display_address, uint8_t content, uint8_t position) const;
|
||||
void select_display_segment(uint8_t digit) const;
|
||||
void select_display_digit(uint8_t content) const;
|
||||
void run_display(uint8_t address) const;
|
||||
|
||||
private:
|
||||
const std::map<std::string, uint8_t> pins_display_board;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //FLIPPR_DRIVER_DISPLAYPINCONTROLLER_H
|
||||
@@ -5,7 +5,7 @@
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#include "DisplayController.h"
|
||||
#include "output/DisplayController.h"
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
@@ -13,8 +13,6 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<items::OutputDisplay>> displays, std::unique_ptr<DisplayBoardPinController> pin_controller)
|
||||
: displays(std::move(displays)), pin_controller(std::move(pin_controller)), is_running(true)
|
||||
@@ -58,4 +56,3 @@ void DisplayController::deactivate_displays() const
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* DisplayController.h
|
||||
*
|
||||
* Created on: Aug 7, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef _SRC_OUTPUT_DISPLAYCONTROLLER_H_
|
||||
#define _SRC_OUTPUT_DISPLAYCONTROLLER_H_
|
||||
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
|
||||
#include "output/DisplayController.h"
|
||||
|
||||
#include "output/items/OutputDisplay.h"
|
||||
#include "output/DisplayBoardPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class DisplayController : public output::DisplayController
|
||||
{
|
||||
public:
|
||||
explicit DisplayController(std::vector<std::shared_ptr<items::OutputDisplay>> displays, std::unique_ptr<DisplayBoardPinController> pin_controller);
|
||||
~DisplayController() override;
|
||||
|
||||
void activate_displays() const override;
|
||||
void deactivate_displays() const override;
|
||||
|
||||
private:
|
||||
void cycle_displays() const;
|
||||
|
||||
private:
|
||||
const std::vector<std::shared_ptr<items::OutputDisplay>> displays;
|
||||
|
||||
const std::shared_ptr<DisplayBoardPinController> pin_controller;
|
||||
|
||||
std::thread display_cycle_thread;
|
||||
bool is_running;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <thread>
|
||||
|
||||
#include "OutputDriver.h"
|
||||
#include "output/OutputDriver.h"
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
@@ -17,13 +17,18 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
using namespace items;
|
||||
|
||||
OutputDriver::OutputDriver(std::unique_ptr<output::DisplayController> display_controller, std::map<std::string, std::shared_ptr<Solenoid>> solenoids, std::map<std::string, std::shared_ptr<Lamp>> lamps, std::map<std::string, std::shared_ptr<Sound>> sounds, std::map<uint8_t, std::shared_ptr<items::Display>> displays)
|
||||
: display_controller(std::move(display_controller)), solenoids(std::move(solenoids)), lamps(std::move(lamps)), sounds(std::move(sounds)), displays(std::move(displays))
|
||||
OutputDriver::OutputDriver(std::unique_ptr<output::DisplayController> display_controller, std::map<std::string, std::shared_ptr<Solenoid>> solenoids,
|
||||
std::map<std::string, std::shared_ptr<Lamp>> lamps, std::map<std::string, std::shared_ptr<Sound>> sounds,
|
||||
std::map<std::string, std::shared_ptr<items::Flipper>> flippers, std::map<uint8_t, std::shared_ptr<items::Display>> displays):
|
||||
display_controller(std::move(display_controller)),
|
||||
solenoids(std::move(solenoids)),
|
||||
lamps(std::move(lamps)),
|
||||
sounds(std::move(sounds)),
|
||||
flippers(std::move(flippers)),
|
||||
displays(std::move(displays))
|
||||
{
|
||||
CLOG(INFO, OUTPUT_LOGGER) << "Created OutputDriver";
|
||||
}
|
||||
@@ -61,6 +66,16 @@ void OutputDriver::rotate_all_lamps() const
|
||||
}
|
||||
}
|
||||
|
||||
void OutputDriver::activate_all_flipper_relays() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OutputDriver::deactivate_all_flipper_relays() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Sound>> OutputDriver::get_sounds() const
|
||||
{
|
||||
std::vector<std::shared_ptr<Sound>> sounds;
|
||||
@@ -89,6 +104,15 @@ std::vector<std::shared_ptr<Lamp>> OutputDriver::get_lamps() const
|
||||
return lamps;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<items::Flipper>> OutputDriver::get_flippers() const
|
||||
{
|
||||
std::vector<std::shared_ptr<Flipper>> flippers;
|
||||
|
||||
boost::copy(this->flippers | boost::adaptors::map_values, std::back_inserter(flippers));
|
||||
|
||||
return flippers;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Solenoid>> OutputDriver::get_solenoids() const
|
||||
{
|
||||
std::vector<std::shared_ptr<Solenoid>> solenoids;
|
||||
@@ -113,6 +137,11 @@ boost::optional<std::shared_ptr<items::Sound>> OutputDriver::get_sound(const std
|
||||
return this->sounds.find(name)->second;
|
||||
}
|
||||
|
||||
boost::optional<std::shared_ptr<items::Flipper>> OutputDriver::get_flipper(const std::string &name) const
|
||||
{
|
||||
return this->flippers.find(name)->second;
|
||||
}
|
||||
|
||||
boost::optional<std::shared_ptr<items::Display>> OutputDriver::get_display(uint8_t number) const
|
||||
{
|
||||
return this->displays.find(number)->second;
|
||||
@@ -121,4 +150,3 @@ boost::optional<std::shared_ptr<items::Display>> OutputDriver::get_display(uint8
|
||||
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* OutputDriver.h
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef _SRC_OUTPUT_OUTPUTDRIVER_H_
|
||||
#define _SRC_OUTPUT_OUTPUTDRIVER_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "output/OutputDriver.h"
|
||||
#include "output/DisplayController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class OutputDriver : public output::OutputDriver
|
||||
{
|
||||
public:
|
||||
OutputDriver(std::unique_ptr<output::DisplayController> display_controller, std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids,
|
||||
std::map<std::string, std::shared_ptr<items::Lamp>> lamps, std::map<std::string, std::shared_ptr<items::Sound>> sounds,
|
||||
std::map<uint8_t, std::shared_ptr<output::items::Display>> displays);
|
||||
|
||||
~OutputDriver() override = default;
|
||||
|
||||
void activate_displays() const override;
|
||||
void deactivate_displays() const override;
|
||||
|
||||
void activate_all_lamps() const override;
|
||||
void deactivate_all_lamps() const override;
|
||||
void rotate_all_lamps() const override;
|
||||
|
||||
void activate_flipper_relay();
|
||||
void activate_top_flipper_relay();
|
||||
void deactivate_flipper_relay();
|
||||
void deactivate_top_flipper_relay();
|
||||
|
||||
// todo driver board run for activate/deactivate?
|
||||
// todo what is flipper_relay ?
|
||||
std::vector<std::shared_ptr<items::Lamp>> get_lamps() const override;
|
||||
std::vector<std::shared_ptr<items::Solenoid>> get_solenoids() const override;
|
||||
std::vector<std::shared_ptr<items::Sound>> get_sounds() const override;
|
||||
std::vector<std::shared_ptr<items::Display>> get_displays() const override;
|
||||
|
||||
boost::optional<std::shared_ptr<items::Lamp>> get_lamp(const std::string &name) const override;
|
||||
boost::optional<std::shared_ptr<items::Solenoid>> get_solenoid(const std::string &name) const override;
|
||||
boost::optional<std::shared_ptr<items::Sound>> get_sound(const std::string &name) const override;
|
||||
boost::optional<std::shared_ptr<items::Display>> get_display(uint8_t number) const override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<output::DisplayController> display_controller;
|
||||
|
||||
const std::map<std::string, std::shared_ptr<items::Lamp>> lamps;
|
||||
const std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids;
|
||||
const std::map<std::string, std::shared_ptr<items::Sound>> sounds;
|
||||
|
||||
const std::map<uint8_t, std::shared_ptr<items::Display>> displays;
|
||||
};
|
||||
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#include "SoundBoardPinController.h"
|
||||
#include "output/SoundBoardPinController.h"
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
@@ -10,8 +10,6 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
SoundBoardPinController::SoundBoardPinController(std::shared_ptr<std::mutex> output_item_mutex, const uint8_t & fire_address) :
|
||||
output_item_mutex(std::move(output_item_mutex)),
|
||||
@@ -64,4 +62,3 @@ void SoundBoardPinController::write_pin(const uint8_t & pin, const bool & value)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_OUTPUT_IMPL_SOUNDBOARDPINCONTROLLER_H
|
||||
#define FLIPPR_DRIVER_OUTPUT_IMPL_SOUNDBOARDPINCONTROLLER_H
|
||||
|
||||
#include "output/SoundBoardPinController.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class SoundBoardPinController : public output::SoundBoardPinController
|
||||
{
|
||||
public:
|
||||
SoundBoardPinController(std::shared_ptr<std::mutex> output_item_mutex, const uint8_t & fire_address);
|
||||
~SoundBoardPinController() override = default;
|
||||
|
||||
void activate(const items::detail::Sound &sound) override;
|
||||
void deactivate(const items::detail::Sound &sound) override;
|
||||
|
||||
private:
|
||||
void write_sound_address(const uint8_t & address) const;
|
||||
void fire_sound() const;
|
||||
|
||||
void write_pin(const uint8_t & pin, const bool & value) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<std::mutex> output_item_mutex;
|
||||
|
||||
uint8_t fire_address;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //FLIPPR_DRIVER_SOUNDBOARDPINCONTROLLER_H
|
||||
Reference in New Issue
Block a user