mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Details coming soon.
This commit is contained in:
@@ -11,14 +11,10 @@
|
||||
#include <utils/JsonUtils.h>
|
||||
|
||||
LedDeviceRegistry LedDevice::_ledDeviceMap = LedDeviceRegistry();
|
||||
QString LedDevice::_activeDevice = "";
|
||||
int LedDevice::_ledCount = 0;
|
||||
int LedDevice::_ledRGBCount = 0;
|
||||
int LedDevice::_ledRGBWCount= 0;
|
||||
|
||||
LedDevice::LedDevice()
|
||||
: QObject()
|
||||
, _log(Logger::getInstance("LedDevice"))
|
||||
, _log(Logger::getInstance("LEDDEVICE"))
|
||||
, _ledBuffer(0)
|
||||
, _deviceReady(true)
|
||||
, _refresh_timer()
|
||||
@@ -77,6 +73,10 @@ void LedDevice::setActiveDevice(QString dev)
|
||||
|
||||
bool LedDevice::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
_colorOrder = deviceConfig["colorOrder"].toString("RGB");
|
||||
_activeDevice = deviceConfig["type"].toString("file").toLower();
|
||||
setLedCount(deviceConfig["currentLedCount"].toInt(1)); // property injected to reflect real led count
|
||||
|
||||
_latchTime_ms = deviceConfig["latchTime"].toInt(_latchTime_ms);
|
||||
_refresh_timer.setInterval( deviceConfig["rewriteTime"].toInt( _refresh_timer_interval) );
|
||||
if (_refresh_timer.interval() <= (signed)_latchTime_ms )
|
||||
|
@@ -13,20 +13,17 @@
|
||||
// following file is auto generated by cmake! it contains all available leddevice headers
|
||||
#include "LedDevice_headers.h"
|
||||
|
||||
LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig, const int ledCount)
|
||||
LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig)
|
||||
{
|
||||
Logger * log = Logger::getInstance("LedDevice");
|
||||
Logger * log = Logger::getInstance("LEDDEVICE");
|
||||
QJsonDocument config(deviceConfig);
|
||||
QString ss(config.toJson(QJsonDocument::Indented));
|
||||
|
||||
QString type = deviceConfig["type"].toString("UNSPECIFIED").toLower();
|
||||
|
||||
// set amount of led to leddevice
|
||||
LedDevice::setLedCount(ledCount);
|
||||
|
||||
#define REGISTER(className) LedDevice::addToDeviceMap(QString(#className).toLower(), LedDevice##className::construct);
|
||||
|
||||
// the REGISTER() calls are autogenerated by cmake.
|
||||
// the REGISTER() calls are autogenerated by cmake.
|
||||
#include "LedDevice_register.cpp"
|
||||
|
||||
#undef REGISTER
|
||||
@@ -40,12 +37,11 @@ LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig, const
|
||||
if (dev.first == type)
|
||||
{
|
||||
device = dev.second(deviceConfig);
|
||||
LedDevice::setActiveDevice(dev.first);
|
||||
Info(log,"LedDevice '%s' configured.", QSTRING_CSTR(dev.first));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (device == nullptr)
|
||||
{
|
||||
Error(log, "Dummy device used, because configured device '%s' is unknown", QSTRING_CSTR(type) );
|
||||
@@ -54,13 +50,13 @@ LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig, const
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
|
||||
|
||||
Error(log, "Dummy device used, because configured device '%s' throws error '%s'", QSTRING_CSTR(type), e.what());
|
||||
const QJsonObject dummyDeviceConfig;
|
||||
device = LedDeviceFile::construct(QJsonObject());
|
||||
}
|
||||
|
||||
device->open();
|
||||
|
||||
|
||||
return device;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ ProviderUdp::ProviderUdp()
|
||||
, _defaultHost("127.0.0.1")
|
||||
{
|
||||
_latchTime_ms = 1;
|
||||
_udpSocket = new QUdpSocket();
|
||||
_udpSocket = new QUdpSocket(this);
|
||||
}
|
||||
|
||||
ProviderUdp::~ProviderUdp()
|
||||
@@ -34,7 +34,7 @@ bool ProviderUdp::init(const QJsonObject &deviceConfig)
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
QString host = deviceConfig["host"].toString(_defaultHost);
|
||||
|
||||
|
||||
if (_address.setAddress(host) )
|
||||
{
|
||||
Debug( _log, "Successfully parsed %s as an ip address.", deviceConfig["host"].toString().toStdString().c_str());
|
||||
@@ -57,9 +57,9 @@ bool ProviderUdp::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
throw std::runtime_error("invalid target port");
|
||||
}
|
||||
|
||||
|
||||
Debug( _log, "UDP using %s:%d", _address.toString().toStdString().c_str() , _port );
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -1,11 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QUdpSocket>
|
||||
|
||||
// Hyperion includes
|
||||
#include <leddevice/LedDevice.h>
|
||||
#include <utils/Logger.h>
|
||||
|
||||
// qt
|
||||
#include <QHostAddress>
|
||||
|
||||
class QUdpSocket;
|
||||
|
||||
///
|
||||
/// The ProviderUdp implements an abstract base-class for LedDevices using UDP packets.
|
||||
///
|
||||
|
Reference in New Issue
Block a user