mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Fix logger and led colors (#906)
This commit is contained in:
@@ -1053,7 +1053,7 @@ void JsonAPI::handleLoggingCommand(const QJsonObject &message, const QString &co
|
||||
if (!_streaming_logging_activated)
|
||||
{
|
||||
_streaming_logging_reply["command"] = command + "-update";
|
||||
connect(LoggerManager::getInstance(), SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), this, SLOT(incommingLogMessage(Logger::T_LOG_MESSAGE)));
|
||||
connect(LoggerManager::getInstance(), &LoggerManager::newLogMessage, this, &JsonAPI::incommingLogMessage);
|
||||
Debug(_log, "log streaming activated for client %s", _peerAddress.toStdString().c_str()); // needed to trigger log sending
|
||||
}
|
||||
}
|
||||
@@ -1061,7 +1061,7 @@ void JsonAPI::handleLoggingCommand(const QJsonObject &message, const QString &co
|
||||
{
|
||||
if (_streaming_logging_activated)
|
||||
{
|
||||
disconnect(LoggerManager::getInstance(), SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), this, 0);
|
||||
disconnect(LoggerManager::getInstance(), &LoggerManager::newLogMessage, this, &JsonAPI::incommingLogMessage);
|
||||
_streaming_logging_activated = false;
|
||||
Debug(_log, "log streaming deactivated for client %s", _peerAddress.toStdString().c_str());
|
||||
}
|
||||
@@ -1561,6 +1561,7 @@ void JsonAPI::incommingLogMessage(const Logger::T_LOG_MESSAGE &msg)
|
||||
message["fileName"] = logBuffer->at(i).fileName;
|
||||
message["message"] = logBuffer->at(i).message;
|
||||
message["levelString"] = logBuffer->at(i).levelString;
|
||||
message["utime"] = QString::number(logBuffer->at(i).utime);
|
||||
|
||||
messageArray.append(message);
|
||||
}
|
||||
@@ -1574,6 +1575,7 @@ void JsonAPI::incommingLogMessage(const Logger::T_LOG_MESSAGE &msg)
|
||||
message["fileName"] = msg.fileName;
|
||||
message["message"] = msg.message;
|
||||
message["levelString"] = msg.levelString;
|
||||
message["utime"] = QString::number(msg.utime);
|
||||
|
||||
messageArray.append(message);
|
||||
}
|
||||
|
@@ -379,8 +379,18 @@ void Hyperion::setColor(const int priority, const std::vector<ColorRgb> &ledColo
|
||||
_effectEngine->channelCleared(priority);
|
||||
|
||||
// create full led vector from single/multiple colors
|
||||
size_t size = _ledString.leds().size();
|
||||
std::vector<ColorRgb> newLedColors;
|
||||
std::copy_n(ledColors.begin(), _ledString.leds().size(), std::back_inserter(newLedColors));
|
||||
while (true)
|
||||
{
|
||||
for (const auto &entry : ledColors)
|
||||
{
|
||||
newLedColors.emplace_back(entry);
|
||||
if (newLedColors.size() == size)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
end:
|
||||
|
||||
if (getPriorityInfo(priority).componentId != hyperion::COMP_COLOR)
|
||||
clear(priority);
|
||||
|
@@ -243,9 +243,10 @@ QJsonObject LedDeviceWled::getProperties(const QJsonObject& params)
|
||||
return properties;
|
||||
}
|
||||
|
||||
void LedDeviceWled::identify(const QJsonObject& params)
|
||||
void LedDeviceWled::identify(const QJsonObject& /*params*/)
|
||||
{
|
||||
Debug(_log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
||||
#if 0
|
||||
Debug(_log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData());
|
||||
QJsonObject properties;
|
||||
|
||||
// Get Nanoleaf device properties
|
||||
@@ -281,6 +282,7 @@ void LedDeviceWled::identify(const QJsonObject& params)
|
||||
// Warning (_log, "%s identification failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int LedDeviceWled::write(const std::vector<ColorRgb> &ledValues)
|
||||
|
@@ -9,6 +9,10 @@
|
||||
#include <QNetworkInterface>
|
||||
#include <QNetworkConfigurationManager>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
#include <QRandomGenerator>
|
||||
#endif
|
||||
|
||||
static const QString SSDP_HYPERION_ST("urn:hyperion-project.org:device:basic:1");
|
||||
|
||||
SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, const QString& name, QObject * parent)
|
||||
@@ -162,7 +166,11 @@ void SSDPHandler::handleMSearchRequest(const QString& target, const QString& mx,
|
||||
if (ok)
|
||||
{
|
||||
/* Pick a random delay between 0 and MX seconds */
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
int randomDelay = QRandomGenerator::global()->generate() % (maxDelay * 1000);
|
||||
#else
|
||||
int randomDelay = qrand() % (maxDelay * 1000);
|
||||
#endif
|
||||
QTimer::singleShot(randomDelay, respond);
|
||||
}
|
||||
else
|
||||
|
@@ -155,7 +155,7 @@ Logger::~Logger()
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::write(const Logger::T_LOG_MESSAGE & message) const
|
||||
void Logger::write(const Logger::T_LOG_MESSAGE & message)
|
||||
{
|
||||
QString location;
|
||||
if (message.level == Logger::DEBUG)
|
||||
@@ -179,6 +179,8 @@ void Logger::write(const Logger::T_LOG_MESSAGE & message) const
|
||||
.arg(message.message)
|
||||
.toStdString()
|
||||
<< std::endl;
|
||||
|
||||
newLogMessage(message);
|
||||
}
|
||||
|
||||
void Logger::Message(LogLevel level, const char* sourceFile, const char* func, unsigned int line, const char* fmt, ...)
|
||||
|
Reference in New Issue
Block a user