mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fix logger and led colors (#906)
This commit is contained in:
parent
773b47bf53
commit
d4b4158cb7
@ -1,7 +1,8 @@
|
||||
var conf_editor = null;
|
||||
var createdCont = false;
|
||||
performTranslation();
|
||||
requestLoggingStart();
|
||||
var conf_editor = null;
|
||||
var createdCont = false;
|
||||
|
||||
performTranslation();
|
||||
requestLoggingStart();
|
||||
|
||||
$(document).ready(function() {
|
||||
var messages;
|
||||
@ -160,7 +161,8 @@ $(document).ready(function() {
|
||||
toggleClass('#btn_autoscroll', "btn-success", "btn-danger");
|
||||
});
|
||||
}
|
||||
for(var idx=0; idx<messages.length; idx++)
|
||||
|
||||
for(var idx = 0; idx < messages.length; idx++)
|
||||
{
|
||||
var app_name = messages[idx].appName;
|
||||
var logger_name = messages[idx].loggerName;
|
||||
@ -169,17 +171,21 @@ $(document).ready(function() {
|
||||
var file_name = messages[idx].fileName;
|
||||
var msg = messages[idx].message;
|
||||
var level_string = messages[idx].levelString;
|
||||
var utime = messages[idx].utime;
|
||||
|
||||
var debug = "";
|
||||
|
||||
if(level_string == "DEBUG") {
|
||||
debug = "("+file_name+":"+line+":"+function_+"()) ";
|
||||
}
|
||||
|
||||
$("#logmessages").append("\n <code>"+"["+app_name+" "+logger_name+"] ("+level_string+") "+debug+msg+"</code>");
|
||||
var date = new Date(parseInt(utime));
|
||||
|
||||
$("#logmessages").append("\n <code>"+date.toISOString()+" ["+app_name+" "+logger_name+"] ("+level_string+") "+debug+msg+"</code>");
|
||||
loguplmess += "["+app_name+" "+logger_name+"] ("+level_string+") "+debug+msg+"\n";
|
||||
}
|
||||
if($("#btn_autoscroll").hasClass('btn-success')){
|
||||
|
||||
if($("#btn_autoscroll").hasClass('btn-success'))
|
||||
{
|
||||
$('#logmessages').stop().animate({
|
||||
scrollTop: $('#logmessages')[0].scrollHeight
|
||||
}, 800);
|
||||
|
@ -165,9 +165,9 @@ public:
|
||||
///
|
||||
/// @param[out] image The image that buffers the output
|
||||
///
|
||||
void toRgb(Image<ColorRgb>& image)
|
||||
void toRgb(Image<ColorRgb>& image) const
|
||||
{
|
||||
_d_ptr->toRgb(*(image.imageData()));
|
||||
_d_ptr->toRgb(*image._d_ptr);
|
||||
}
|
||||
|
||||
///
|
||||
@ -186,12 +186,10 @@ public:
|
||||
_d_ptr->clear();
|
||||
}
|
||||
|
||||
QSharedDataPointer<ImageData<Pixel_T>> imageData() const
|
||||
{
|
||||
return _d_ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
template<class T>
|
||||
friend class Image;
|
||||
|
||||
///
|
||||
/// Translate x and y coordinate to index of the underlying vector
|
||||
///
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
return _pixels;
|
||||
}
|
||||
|
||||
void toRgb(ImageData<ColorRgb>& image)
|
||||
void toRgb(ImageData<ColorRgb>& image) const
|
||||
{
|
||||
if (image.width() != _width || image.height() != _height)
|
||||
image.resize(_width, _height);
|
||||
|
@ -79,7 +79,7 @@ protected:
|
||||
~Logger();
|
||||
|
||||
private:
|
||||
void write(const Logger::T_LOG_MESSAGE & message) const;
|
||||
void write(const Logger::T_LOG_MESSAGE & message);
|
||||
|
||||
static QMutex MapLock;
|
||||
static QMap<QString,Logger*> LoggerMap;
|
||||
@ -106,7 +106,7 @@ public slots:
|
||||
void handleNewLogMessage(const Logger::T_LOG_MESSAGE&);
|
||||
|
||||
signals:
|
||||
void newLogMessage(Logger::T_LOG_MESSAGE);
|
||||
void newLogMessage(const Logger::T_LOG_MESSAGE&);
|
||||
|
||||
protected:
|
||||
LoggerManager();
|
||||
|
@ -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, ...)
|
||||
|
Loading…
Reference in New Issue
Block a user