forked from Sepanta/console-emulator
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
998 B
39 lines
998 B
#include "model/Led.h"
|
|
#include "QDebug"
|
|
|
|
Led::Led()
|
|
{
|
|
_hasLed = false;
|
|
}
|
|
|
|
/*************************************************************************************************/
|
|
Led::Led(char functionCode)
|
|
{
|
|
_functionCode = functionCode;
|
|
_hasLed = true;
|
|
}
|
|
|
|
/*************************************************************************************************/
|
|
void Led::newData(QByteArray data, Logger* _logger)
|
|
{
|
|
if(data[FUNCTION_CODE] != _functionCode)
|
|
{
|
|
return;
|
|
}
|
|
try {
|
|
if(!(data[LED_COLOR] == static_cast<char>(LED_OFF) ||
|
|
data[LED_COLOR] == static_cast<char>(LED_COLOR_WHITE) ||
|
|
data[LED_COLOR] == static_cast<char>(LED_COLOR_GREEN)))
|
|
{
|
|
throw std::runtime_error("Led state color is not correct");
|
|
}
|
|
if(data[FUNCTION_CODE] == _functionCode)
|
|
{
|
|
emit ledChanged(data[LED_COLOR]);
|
|
}
|
|
}
|
|
catch(const std::exception& e)
|
|
{
|
|
_logger->log(e.what());
|
|
}
|
|
}
|
|
|