works now?
This commit is contained in:
@@ -21,8 +21,6 @@ class IItem
|
||||
{
|
||||
public:
|
||||
virtual ~IItem();
|
||||
virtual void activate() = 0;
|
||||
virtual void deactivate() = 0;
|
||||
|
||||
virtual uint8_t get_address() = 0;
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace items
|
||||
Item::Item(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name) :
|
||||
address(address),
|
||||
name(name),
|
||||
output_gpio_interface(output_gpio_interface)
|
||||
gpio_interface(output_gpio_interface)
|
||||
{}
|
||||
|
||||
uint8_t Item::get_address()
|
||||
@@ -24,12 +24,12 @@ uint8_t Item::get_address()
|
||||
|
||||
void Item::activate()
|
||||
{
|
||||
output_gpio_interface->activate_output_item(this);
|
||||
gpio_interface->activate(this);
|
||||
}
|
||||
|
||||
void Item::deactivate()
|
||||
{
|
||||
output_gpio_interface->deactivate_output_item(this);
|
||||
gpio_interface->deactivate(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,17 +28,14 @@ public:
|
||||
Item(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
||||
virtual ~Item();
|
||||
|
||||
virtual uint8_t get_address();
|
||||
uint8_t get_address() override;
|
||||
|
||||
protected:
|
||||
const uint8_t address;
|
||||
const std::string name;
|
||||
|
||||
const std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
|
||||
const std::shared_ptr<utility::IOutputGPIOInterface> gpio_interface;
|
||||
|
||||
protected:
|
||||
virtual void activate();
|
||||
virtual void deactivate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -14,20 +14,20 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int i2c_address, unsigned int address, unsigned int data_pin, std::string name)
|
||||
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name)
|
||||
:
|
||||
Item(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
Item(output_gpio_interface, address, name),
|
||||
activated(false)
|
||||
{}
|
||||
|
||||
void Lamp::activate()
|
||||
{
|
||||
Item::activate();
|
||||
gpio_interface->activate(this);
|
||||
}
|
||||
|
||||
void Lamp::deactivate()
|
||||
{
|
||||
Item::deactivate();
|
||||
gpio_interface->deactivate(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace items
|
||||
class Lamp : public Item, ILamp, IDriverBoardItem
|
||||
{
|
||||
public:
|
||||
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
||||
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name);
|
||||
virtual ~Lamp() = default;
|
||||
|
||||
void activate();
|
||||
|
||||
@@ -16,18 +16,18 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time):
|
||||
Item(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time):
|
||||
Item(output_gpio_interface, address, name),
|
||||
deactivation_time(deactivation_time)
|
||||
{}
|
||||
|
||||
void Solenoid::triggerTask()
|
||||
{
|
||||
Item::activate();
|
||||
gpio_interface->activate(this);
|
||||
|
||||
std::this_thread::sleep_for(deactivation_time);
|
||||
|
||||
Item::deactivate();
|
||||
gpio_interface->deactivate(this);
|
||||
}
|
||||
|
||||
void Solenoid::trigger()
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace items
|
||||
class Solenoid : public Item, ISolenoid, IDriverBoardItem
|
||||
{
|
||||
public:
|
||||
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
virtual ~Solenoid() = default;
|
||||
|
||||
void trigger();
|
||||
|
||||
@@ -28,11 +28,11 @@ void Sound::play()
|
||||
|
||||
void Sound::playTask()
|
||||
{
|
||||
Item::activate();
|
||||
gpio_interface->activate(this);
|
||||
|
||||
std::this_thread::sleep_for(deactivation_time);
|
||||
|
||||
Item::deactivate();
|
||||
gpio_interface->deactivate(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user