Files
flippr-code/FlippR-Driver/src/output/items/detail/Lamp.cpp
2019-10-29 14:27:13 +01:00

60 lines
1.2 KiB
C++

/*
* Lamp.cpp
*
* Created on: Aug 2, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#include "Lamp.h"
#include <output/DriverBoardPinController.h>
#include "utility/config.h"
namespace flippR_driver
{
namespace output
{
namespace items
{
namespace detail
{
Lamp::Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name) :
detail::Item(std::move(name)),
DriverBoardItem(pin_controller, address, pin_base),
pin_controller(std::move(pin_controller)),
activated(false),
activation_time(10)
{
CLOG(INFO, OUTPUT_LOGGER) << "Created lamp " << name << " with address " << address;
}
void Lamp::activate()
{
CLOG(INFO, OUTPUT_LOGGER) << "Activate lamp " << name;
this->activated = true;
this->pin_controller->activate(*this);
}
void Lamp::deactivate()
{
CLOG(INFO, OUTPUT_LOGGER) << "Deactivate lamp " << name;
this->activated = false;
this->pin_controller->deactivate(*this);
}
bool Lamp::is_activated()
{
return this->activated;
}
std::chrono::milliseconds Lamp::get_activation_time() const
{
return this->activation_time;
}
}
}
} /* namespace output */
}