60 lines
1.2 KiB
C++
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 pin-base " << int(pin_base) << " and address " << int(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 */
|
|
}
|