erased some codesmells
This commit is contained in:
@@ -18,7 +18,7 @@ namespace output
|
||||
using namespace items;
|
||||
|
||||
OutputDriver::OutputDriver(std::map<std::string, std::shared_ptr<ISolenoid>> solenoids, std::map<std::string, std::shared_ptr<ILamp>> lamps, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds)
|
||||
: solenoids(solenoids), lamps(lamps), displays(displays), sounds(sounds)
|
||||
: solenoids(std::move(solenoids)), lamps(std::move(lamps)), displays(std::move(displays)), sounds(std::move(sounds))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class OutputDriver : public IOutputDriver
|
||||
public:
|
||||
OutputDriver(std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids, std::map<std::string, std::shared_ptr<items::ILamp>> lamps, std::map<char, std::shared_ptr<items::IDisplay>> displays, std::map<std::string, std::shared_ptr<items::ISound>> sounds);
|
||||
|
||||
virtual ~OutputDriver() = default;
|
||||
~OutputDriver() override = default;
|
||||
// todo what is flipper_relay ?
|
||||
std::vector<std::shared_ptr<items::ILamp>> get_lamps() override;
|
||||
std::vector<std::shared_ptr<items::ISolenoid>> get_solenoids() override;
|
||||
|
||||
@@ -15,7 +15,7 @@ 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)
|
||||
: pins_driver_board(pins_driver_board), pins_sound(pins_sound), pins_display(pins_display)
|
||||
: pins_driver_board(std::move(pins_driver_board)), pins_sound(std::move(pins_sound)), pins_display(std::move(pins_display))
|
||||
{
|
||||
initialize_i2c_addresses();
|
||||
|
||||
@@ -51,7 +51,7 @@ void OutputGPIOInterface::activate(output::items::ISoundItem *sound)
|
||||
|
||||
write_sound_address(sound->get_address());
|
||||
|
||||
fire_sound(1);
|
||||
fire_sound(true);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::activate(output::items::IDriverBoardItem *driver_board_item)
|
||||
@@ -60,7 +60,7 @@ void OutputGPIOInterface::activate(output::items::IDriverBoardItem *driver_board
|
||||
|
||||
write_driver_board_address(driver_board_item->get_address());
|
||||
|
||||
write_data(1);
|
||||
write_data(true);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::deactivate(output::items::IDriverBoardItem *driver_board_item)
|
||||
@@ -69,7 +69,7 @@ void OutputGPIOInterface::deactivate(output::items::IDriverBoardItem *driver_boa
|
||||
|
||||
write_driver_board_address(driver_board_item->get_address());
|
||||
|
||||
write_data(0);
|
||||
write_data(false);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::deactivate(output::items::ISoundItem *sound)
|
||||
@@ -78,7 +78,7 @@ void OutputGPIOInterface::deactivate(output::items::ISoundItem *sound)
|
||||
|
||||
write_sound_address(sound->get_address());
|
||||
|
||||
fire_sound(0);
|
||||
fire_sound(false);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::write_driver_board_address(uint8_t address)
|
||||
@@ -107,9 +107,9 @@ void OutputGPIOInterface::select_latch(uint8_t latch)
|
||||
if(latch > 8)
|
||||
latch -= 8;
|
||||
|
||||
write_pin(pins_driver_board.at("latch-select-A"), latch & 0b001);
|
||||
write_pin(pins_driver_board.at("latch-select-B"), latch & 0b010);
|
||||
write_pin(pins_driver_board.at("latch-select-C"), latch & 0b100);
|
||||
write_pin(pins_driver_board.at("latch-select-A"), latch & 0b001u);
|
||||
write_pin(pins_driver_board.at("latch-select-B"), latch & 0b010u);
|
||||
write_pin(pins_driver_board.at("latch-select-C"), latch & 0b100u);
|
||||
|
||||
}
|
||||
|
||||
@@ -120,20 +120,20 @@ void OutputGPIOInterface::write_data(bool data)
|
||||
|
||||
void OutputGPIOInterface::select_pin(uint8_t pin)
|
||||
{
|
||||
write_pin(pins_driver_board.at("pin-select-A"), pin & 0b001);
|
||||
write_pin(pins_driver_board.at("pin-select-B"), pin & 0b010);
|
||||
write_pin(pins_driver_board.at("pin-select-C"), pin & 0b100);
|
||||
write_pin(pins_driver_board.at("pin-select-A"), pin & 0b001u);
|
||||
write_pin(pins_driver_board.at("pin-select-B"), pin & 0b010u);
|
||||
write_pin(pins_driver_board.at("pin-select-C"), pin & 0b100u);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::write_sound_address(uint8_t address)
|
||||
{
|
||||
write_pin(pins_sound.at("A"), address & 0b0000001);
|
||||
write_pin(pins_sound.at("B"), address & 0b0000010);
|
||||
write_pin(pins_sound.at("C"), address & 0b0000100);
|
||||
write_pin(pins_sound.at("D"), address & 0b0001000);
|
||||
write_pin(pins_sound.at("E"), address & 0b0010000);
|
||||
write_pin(pins_sound.at("F"), address & 0b0100000);
|
||||
write_pin(pins_sound.at("G"), address & 0b1000000);
|
||||
write_pin(pins_sound.at("A"), address & 0b0000001u);
|
||||
write_pin(pins_sound.at("B"), address & 0b0000010u);
|
||||
write_pin(pins_sound.at("C"), address & 0b0000100u);
|
||||
write_pin(pins_sound.at("D"), address & 0b0001000u);
|
||||
write_pin(pins_sound.at("E"), address & 0b0010000u);
|
||||
write_pin(pins_sound.at("F"), address & 0b0100000u);
|
||||
write_pin(pins_sound.at("G"), address & 0b1000000u);
|
||||
}
|
||||
|
||||
void OutputGPIOInterface::fire_sound(bool fire)
|
||||
|
||||
@@ -29,7 +29,7 @@ class OutputGPIOInterface : public GPIOInterface, IOutputGPIOInterface
|
||||
public:
|
||||
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);
|
||||
|
||||
virtual ~OutputGPIOInterface() = default;
|
||||
~OutputGPIOInterface() override = default;
|
||||
|
||||
void activate(items::IDriverBoardItem *driver_board_item) override;
|
||||
void activate(items::ISoundItem *sound) override;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace items
|
||||
class IDriverBoardItem : public IItem
|
||||
{
|
||||
public:
|
||||
virtual ~IDriverBoardItem() = default;
|
||||
~IDriverBoardItem() override = default;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace items
|
||||
|
||||
Item::Item(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name) :
|
||||
address(address),
|
||||
name(name),
|
||||
gpio_interface(output_gpio_interface)
|
||||
name(std::move(name)),
|
||||
gpio_interface(std::move(output_gpio_interface))
|
||||
{}
|
||||
|
||||
uint8_t Item::get_address()
|
||||
|
||||
@@ -26,7 +26,7 @@ class Item : public IItem
|
||||
{
|
||||
public:
|
||||
Item(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
||||
virtual ~Item() = default;
|
||||
~Item() override = default;
|
||||
|
||||
uint8_t get_address() override;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace items
|
||||
|
||||
Lamp::Lamp(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name)
|
||||
:
|
||||
Item(output_gpio_interface, address, name),
|
||||
Item(std::move(output_gpio_interface), address, std::move(name)),
|
||||
activated(false)
|
||||
{}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ class Lamp : public Item, ILamp, IDriverBoardItem
|
||||
{
|
||||
public:
|
||||
Lamp(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
||||
virtual ~Lamp() = default;
|
||||
~Lamp() override = default;
|
||||
|
||||
void activate();
|
||||
void deactivate();
|
||||
bool is_activated();
|
||||
void activate() override;
|
||||
void deactivate() override;
|
||||
bool is_activated() override;
|
||||
|
||||
private:
|
||||
bool activated;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace items
|
||||
{
|
||||
|
||||
Solenoid::Solenoid(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time):
|
||||
Item(output_gpio_interface, address, name),
|
||||
Item(std::move(output_gpio_interface), address, std::move(name)),
|
||||
deactivation_time(deactivation_time)
|
||||
{}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ class Solenoid : public Item, ISolenoid, IDriverBoardItem
|
||||
{
|
||||
public:
|
||||
Solenoid(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
virtual ~Solenoid() = default;
|
||||
~Solenoid() override = default;
|
||||
|
||||
void trigger();
|
||||
void trigger() override;
|
||||
|
||||
private:
|
||||
std::chrono::milliseconds deactivation_time;
|
||||
|
||||
@@ -15,7 +15,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) :
|
||||
Item(output_gpio_interface, address, name),
|
||||
Item(std::move(output_gpio_interface), address, std::move(name)),
|
||||
deactivation_time(deactivation_time),
|
||||
id(id)
|
||||
{}
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
|
||||
public:
|
||||
Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id);
|
||||
virtual ~Sound() = default;
|
||||
~Sound() override = default;
|
||||
|
||||
void play() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user