dunno
This commit is contained in:
@@ -27,15 +27,18 @@ class OutputDriver
|
||||
public:
|
||||
virtual ~OutputDriver() = default;
|
||||
|
||||
virtual std::vector<std::shared_ptr<items::Lamp>> get_lamps() = 0;
|
||||
virtual std::vector<std::shared_ptr<items::Solenoid>> get_solenoids() = 0;
|
||||
virtual std::vector<std::shared_ptr<items::Sound>> get_sounds() = 0;
|
||||
virtual std::vector<std::shared_ptr<items::Display>> get_displays() = 0;
|
||||
virtual void activate_displays() const = 0;
|
||||
virtual void deactivate_displays() const = 0;
|
||||
|
||||
virtual boost::optional<std::shared_ptr<items::Lamp>> get_lamp(std::string name) = 0;
|
||||
virtual boost::optional<std::shared_ptr<items::Solenoid>> get_solenoid(std::string name) = 0;
|
||||
virtual boost::optional<std::shared_ptr<items::Sound>> get_sound(std::string name) = 0;
|
||||
virtual boost::optional<std::shared_ptr<items::Display>> get_display(char number) = 0;
|
||||
virtual std::vector<std::shared_ptr<items::Lamp>> get_lamps() const = 0;
|
||||
virtual std::vector<std::shared_ptr<items::Solenoid>> get_solenoids() const = 0;
|
||||
virtual std::vector<std::shared_ptr<items::Sound>> get_sounds() const = 0;
|
||||
virtual std::vector<std::shared_ptr<items::Display>> get_displays() const = 0;
|
||||
|
||||
virtual boost::optional<std::shared_ptr<items::Lamp>> get_lamp(const std::string &name) const = 0;
|
||||
virtual boost::optional<std::shared_ptr<items::Solenoid>> get_solenoid(const std::string &name) const = 0;
|
||||
virtual boost::optional<std::shared_ptr<items::Sound>> get_sound(const std::string &name) const = 0;
|
||||
virtual boost::optional<std::shared_ptr<items::Display>> get_display(uint8_t number) const = 0;
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace flippR_driver
|
||||
namespace input
|
||||
{
|
||||
|
||||
DistributingEvent::DistributingEvent(char address, int priority, std::string name,
|
||||
DistributingEvent::DistributingEvent(uint8_t address, int priority, std::string name,
|
||||
std::chrono::milliseconds bounce_time, std::shared_ptr<EventNotifier> event_notifier)
|
||||
:
|
||||
Event(address, priority, std::move(name)),
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace input
|
||||
class DistributingEvent : public Event
|
||||
{
|
||||
public:
|
||||
DistributingEvent(char address, int priority, std::string name,
|
||||
DistributingEvent(uint8_t address, int priority, std::string name,
|
||||
std::chrono::milliseconds bounce_time, std::shared_ptr<EventNotifier> event_notifier);
|
||||
|
||||
void active();
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace
|
||||
std::shared_ptr<DistributingEvent> create_event(json &json_event, std::shared_ptr<EventNotifier> event_notifier, int bounce_time)
|
||||
{
|
||||
std::string name = json_event.at("name");
|
||||
char address = json_event.at("address").get<uint8_t>();
|
||||
uint8_t address = json_event.at("address").get<uint8_t>();
|
||||
int priority = json_event.at("priority").get<uint8_t>();
|
||||
|
||||
set_individual_bounce_time(json_event, bounce_time);
|
||||
|
||||
@@ -17,6 +17,9 @@ class DisplayController
|
||||
|
||||
public:
|
||||
virtual ~DisplayController () = default;
|
||||
|
||||
virtual void activate_displays() const = 0;
|
||||
virtual void deactivate_displays() const = 0;
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
|
||||
@@ -248,9 +248,10 @@ std::shared_ptr<items::impl::Sound> create_sound(nlohmann::json &sound_json, std
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
std::map<char, std::shared_ptr<items::Display>> create_displays(std::istream &display_config)
|
||||
|
||||
std::map<uint8_t, std::shared_ptr<items::Display>> create_displays(std::istream &display_config)
|
||||
{
|
||||
std::map<char, std::shared_ptr<items::Display>> displays;
|
||||
std::map<uint8_t, std::shared_ptr<items::Display>> displays;
|
||||
|
||||
return displays;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OutputDriverFactory
|
||||
|
||||
std::chrono::milliseconds get_deactivation_time(nlohmann::json &json);
|
||||
|
||||
std::map<char, std::shared_ptr<items::Display>> create_displays(std::istream &display_config);
|
||||
std::map<uint8_t, std::shared_ptr<items::Display>> create_displays(std::istream &display_config);
|
||||
|
||||
std::map<std::string, uint8_t> parse_pins_driver_board(nlohmann::json &driver_board_config);
|
||||
std::map<std::string, uint8_t> parse_pins_sound_board(nlohmann::json &sound_board_config);
|
||||
|
||||
@@ -32,7 +32,7 @@ void DisplayBoardPinController::deactivate_displays() const
|
||||
|
||||
void DisplayBoardPinController::write_display(const items::Display &display) const
|
||||
{
|
||||
std::vector<char> content = display.get_content();
|
||||
std::vector<uint8_t> content = display.get_content();
|
||||
|
||||
for(uint8_t i = 0; i < content.size(); i++)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,16 @@ void DisplayController::cycle_displays() const
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayController::activate_displays() const
|
||||
{
|
||||
pin_controller->activate_displays();
|
||||
}
|
||||
|
||||
void DisplayController::deactivate_displays() const
|
||||
{
|
||||
pin_controller->deactivate_displays();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ public:
|
||||
explicit DisplayController(std::vector<std::shared_ptr<items::Display>> displays, std::unique_ptr<DisplayBoardPinController> pin_controller);
|
||||
~DisplayController() override;
|
||||
|
||||
void activate_displays() const override;
|
||||
void deactivate_displays() const override;
|
||||
|
||||
private:
|
||||
void cycle_displays() const;
|
||||
|
||||
|
||||
@@ -19,11 +19,21 @@ namespace impl
|
||||
|
||||
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<char, std::shared_ptr<Display>> 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<uint8_t, std::shared_ptr<Display>> displays)
|
||||
: display_controller(std::move(display_controller)), solenoids(std::move(solenoids)), lamps(std::move(lamps)), sounds(std::move(sounds)), displays(std::move(displays))
|
||||
{}
|
||||
|
||||
std::vector<std::shared_ptr<Sound>> OutputDriver::get_sounds()
|
||||
void OutputDriver::activate_displays() const
|
||||
{
|
||||
display_controller->activate_displays();
|
||||
}
|
||||
|
||||
void OutputDriver::deactivate_displays() const
|
||||
{
|
||||
display_controller->deactivate_displays();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Sound>> OutputDriver::get_sounds() const
|
||||
{
|
||||
std::vector<std::shared_ptr<Sound>> sounds;
|
||||
|
||||
@@ -32,7 +42,7 @@ std::vector<std::shared_ptr<Sound>> OutputDriver::get_sounds()
|
||||
return sounds;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Display>> OutputDriver::get_displays()
|
||||
std::vector<std::shared_ptr<Display>> OutputDriver::get_displays() const
|
||||
{
|
||||
std::vector<std::shared_ptr<Display>> displays;
|
||||
|
||||
@@ -41,7 +51,7 @@ std::vector<std::shared_ptr<Display>> OutputDriver::get_displays()
|
||||
return displays;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Lamp>> OutputDriver::get_lamps()
|
||||
std::vector<std::shared_ptr<Lamp>> OutputDriver::get_lamps() const
|
||||
{
|
||||
std::vector<std::shared_ptr<Lamp>> lamps;
|
||||
|
||||
@@ -50,7 +60,7 @@ std::vector<std::shared_ptr<Lamp>> OutputDriver::get_lamps()
|
||||
return lamps;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Solenoid>> OutputDriver::get_solenoids()
|
||||
std::vector<std::shared_ptr<Solenoid>> OutputDriver::get_solenoids() const
|
||||
{
|
||||
std::vector<std::shared_ptr<Solenoid>> solenoids;
|
||||
|
||||
@@ -74,7 +84,7 @@ boost::optional<std::shared_ptr<items::Sound>> OutputDriver::get_sound(const std
|
||||
return this->sounds.find(name)->second;
|
||||
}
|
||||
|
||||
boost::optional<std::shared_ptr<items::Display>> OutputDriver::get_display(uint8_tnumber) const
|
||||
boost::optional<std::shared_ptr<items::Display>> OutputDriver::get_display(uint8_t number) const
|
||||
{
|
||||
return this->displays.find(number)->second;
|
||||
}
|
||||
|
||||
@@ -23,19 +23,23 @@ namespace impl
|
||||
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<char, std::shared_ptr<items::Display>> displays);
|
||||
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<items::Display>> displays);
|
||||
|
||||
~OutputDriver() override = default;
|
||||
// todo what is flipper_relay ?
|
||||
std::vector<std::shared_ptr<items::Lamp>> get_lamps() override;
|
||||
std::vector<std::shared_ptr<items::Solenoid>> get_solenoids() override;
|
||||
std::vector<std::shared_ptr<items::Sound>> get_sounds() override;
|
||||
std::vector<std::shared_ptr<items::Display>> get_displays() override;
|
||||
|
||||
boost::optional<std::shared_ptr<items::Lamp>> get_lamp(const std::string &name) override;
|
||||
boost::optional<std::shared_ptr<items::Solenoid>> get_solenoid(const std::&string name) override;
|
||||
boost::optional<std::shared_ptr<items::Sound>> get_sound(const std::string &name) override;
|
||||
boost::optional<std::shared_ptr<items::Display>> get_display(uint8_tnumber) override;
|
||||
void activate_displays() const override;
|
||||
void deactivate_displays() const override;
|
||||
|
||||
// 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;
|
||||
@@ -44,7 +48,7 @@ private:
|
||||
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<char, std::shared_ptr<items::Display>> displays;
|
||||
const std::map<uint8_t, std::shared_ptr<items::Display>> displays;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
virtual ~Display() = default;
|
||||
|
||||
virtual uint8_t get_address() const = 0;
|
||||
virtual std::vector<char> get_content() const = 0;
|
||||
virtual std::vector<uint8_t> get_content() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ public:
|
||||
virtual ~Display() = default;
|
||||
|
||||
virtual void write_score(int score);
|
||||
virtual void write_content(std::array<char, DigitCount> content);
|
||||
virtual void write_content(std::array<uint8_t, DigitCount> content);
|
||||
|
||||
std::vector<char> get_content() const override;
|
||||
std::vector<uint8_t> get_content() const override;
|
||||
uint8_t get_address() const override;
|
||||
|
||||
public:
|
||||
std::array<char, DigitCount> content;
|
||||
std::array<uint8_t, DigitCount> content;
|
||||
|
||||
private:
|
||||
int address;
|
||||
|
||||
@@ -57,16 +57,16 @@ std::string Display<DigitCount>::fit_string(std::string& score_string)
|
||||
}
|
||||
|
||||
template<int DigitCount>
|
||||
void Display<DigitCount>::write_content( std::array<char, DigitCount> content)
|
||||
void Display<DigitCount>::write_content( std::array<uint8_t, DigitCount> content)
|
||||
{
|
||||
this->content = content;
|
||||
}
|
||||
|
||||
<int DigitCount>
|
||||
std::vector<char> Display<DigitCount>::get_content()
|
||||
std::vector<uint8_t> Display<DigitCount>::get_content()
|
||||
{
|
||||
// todo: expensive?
|
||||
return std::vector<char>(content, content + DigitCount);
|
||||
return std::vector<uint8_t>(content, content + DigitCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user