mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Move JsonProcessing from JsonClientConnection to own class (#444)
* update * Tell me why...
This commit is contained in:
@@ -50,7 +50,7 @@ Hyperion* Hyperion::getInstance()
|
||||
{
|
||||
if ( Hyperion::_hyperion == nullptr )
|
||||
throw std::runtime_error("Hyperion::getInstance used without call of Hyperion::initInstance before");
|
||||
|
||||
|
||||
return Hyperion::_hyperion;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt
|
||||
ss << index;
|
||||
}
|
||||
}
|
||||
Info(CORE_LOGGER, "ColorAdjustment '%s' => [%s]", QSTRING_CSTR(colorAdjustment->_id), ss.str().c_str());
|
||||
Info(CORE_LOGGER, "ColorAdjustment '%s' => [%s]", QSTRING_CSTR(colorAdjustment->_id), ss.str().c_str());
|
||||
}
|
||||
|
||||
return adjustment;
|
||||
@@ -190,7 +190,7 @@ LedString Hyperion::createLedString(const QJsonValue& ledsConfig, const ColorOrd
|
||||
const QString deviceOrderStr = colorOrderToString(deviceOrder);
|
||||
const QJsonArray & ledConfigArray = ledsConfig.toArray();
|
||||
int maxLedId = ledConfigArray.size();
|
||||
|
||||
|
||||
for (signed i = 0; i < ledConfigArray.size(); ++i)
|
||||
{
|
||||
const QJsonObject& index = ledConfigArray[i].toObject();
|
||||
@@ -325,7 +325,7 @@ LinearColorSmoothing * Hyperion::createColorSmoothing(const QJsonObject & smooth
|
||||
QString type = smoothingConfig["type"].toString("linear").toLower();
|
||||
LinearColorSmoothing * device = nullptr;
|
||||
type = "linear"; // TODO currently hardcoded type, delete it if we have more types
|
||||
|
||||
|
||||
if (type == "linear")
|
||||
{
|
||||
Info( CORE_LOGGER, "Creating linear smoothing");
|
||||
@@ -341,7 +341,7 @@ LinearColorSmoothing * Hyperion::createColorSmoothing(const QJsonObject & smooth
|
||||
{
|
||||
Error(CORE_LOGGER, "Smoothing disabled, because of unknown type '%s'.", QSTRING_CSTR(type));
|
||||
}
|
||||
|
||||
|
||||
device->setEnable(smoothingConfig["enable"].toBool(true));
|
||||
InfoIf(!device->enabled(), CORE_LOGGER,"Smoothing disabled");
|
||||
|
||||
@@ -414,11 +414,11 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
|
||||
_bonjourBrowser.browseForServiceType(QLatin1String("_hyperiond-http._tcp"));
|
||||
connect(&_bonjourBrowser, SIGNAL(currentBonjourRecordsChanged(const QList<BonjourRecord>&)),this, SLOT(currentBonjourRecordsChanged(const QList<BonjourRecord> &)));
|
||||
connect(&_bonjourResolver, SIGNAL(bonjourRecordResolved(const QHostInfo &, int)), this, SLOT(bonjourRecordResolved(const QHostInfo &, int)));
|
||||
|
||||
|
||||
// initialize the image processor factory
|
||||
_ledMAppingType = ImageProcessor::mappingTypeToInt(color["imageToLedMappingType"].toString());
|
||||
ImageProcessorFactory::getInstance().init(_ledString, qjsonConfig["blackborderdetector"].toObject(),_ledMAppingType );
|
||||
|
||||
|
||||
getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, _messageForwarder->forwardingEnabled());
|
||||
|
||||
// initialize leddevices
|
||||
@@ -438,7 +438,7 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
|
||||
|
||||
// create the effect engine
|
||||
_effectEngine = new EffectEngine(this,qjsonConfig["effects"].toObject() );
|
||||
|
||||
|
||||
const QJsonObject& device = qjsonConfig["device"].toObject();
|
||||
unsigned int hwLedCount = device["ledCount"].toInt(getLedCount());
|
||||
_hwLedCount = std::max(hwLedCount, getLedCount());
|
||||
@@ -450,9 +450,14 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
|
||||
QObject::connect(&_cTimer, SIGNAL(timeout()), this, SLOT(checkConfigState()));
|
||||
_cTimer.start(2000);
|
||||
|
||||
// pipe muxer signal for effect/color timerunner to hyperionStateChanged signal
|
||||
// pipe muxer signal for effect/color timerunner to hyperionStateChanged slot
|
||||
QObject::connect(&_muxer, &PriorityMuxer::timerunner, this, &Hyperion::hyperionStateChanged);
|
||||
|
||||
// prepare processing of hyperionStateChanged for forced serverinfo
|
||||
connect(&_fsi_timer, SIGNAL(timeout()), this, SLOT(hyperionStateChanged()));
|
||||
_fsi_timer.setSingleShot(true);
|
||||
_fsi_blockTimer.setSingleShot(true);
|
||||
|
||||
const QJsonObject & generalConfig = qjsonConfig["general"].toObject();
|
||||
_configVersionId = generalConfig["configVersion"].toInt(-1);
|
||||
|
||||
@@ -542,7 +547,7 @@ Hyperion::BonjourRegister Hyperion::getHyperionSessions()
|
||||
|
||||
void Hyperion::checkConfigState()
|
||||
{
|
||||
// Check config modifications
|
||||
// Check config modifications
|
||||
QFile f(_configFile);
|
||||
if (f.open(QFile::ReadOnly))
|
||||
{
|
||||
@@ -568,9 +573,9 @@ void Hyperion::checkConfigState()
|
||||
QFile file(_configFile);
|
||||
QFileInfo fileInfo(file);
|
||||
_configWrite = fileInfo.isWritable() && fileInfo.isReadable() ? true : false;
|
||||
|
||||
|
||||
if(_prevConfigWrite != _configWrite)
|
||||
{
|
||||
{
|
||||
emit hyperionStateChanged();
|
||||
_prevConfigWrite = _configWrite;
|
||||
}
|
||||
@@ -579,7 +584,7 @@ void Hyperion::checkConfigState()
|
||||
void Hyperion::registerPriority(const QString &name, const int priority/*, const QString &origin*/)
|
||||
{
|
||||
Info(_log, "Register new input source named '%s' for priority channel '%d'", QSTRING_CSTR(name), priority );
|
||||
|
||||
|
||||
for(auto key : _priorityRegister.keys())
|
||||
{
|
||||
WarningIf( ( key != name && _priorityRegister.value(key) == priority), _log,
|
||||
@@ -734,7 +739,7 @@ void Hyperion::clearall()
|
||||
|
||||
int Hyperion::getCurrentPriority() const
|
||||
{
|
||||
|
||||
|
||||
return _sourceAutoSelectEnabled || !_muxer.hasPriority(_currentSourcePriority) ? _muxer.getCurrentPriority() : _currentSourcePriority;
|
||||
}
|
||||
|
||||
@@ -784,6 +789,19 @@ void Hyperion::setLedMappingType(int mappingType)
|
||||
emit imageToLedsMappingChanged(mappingType);
|
||||
}
|
||||
|
||||
void Hyperion::hyperionStateChanged()
|
||||
{
|
||||
if(_fsi_blockTimer.isActive())
|
||||
{
|
||||
_fsi_timer.start(300);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit sendServerInfo();
|
||||
_fsi_blockTimer.start(250);
|
||||
}
|
||||
}
|
||||
|
||||
void Hyperion::update()
|
||||
{
|
||||
// Update the muxer, cleaning obsolete priorities
|
||||
@@ -817,13 +835,13 @@ void Hyperion::update()
|
||||
_ledStringColorOrder.insert(_ledStringColorOrder.begin() + led.index, led.colorOrder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// insert cloned leds into buffer
|
||||
for (Led& led : _ledStringClone.leds())
|
||||
{
|
||||
_ledBuffer.insert(_ledBuffer.begin() + led.index, _ledBuffer.at(led.clone));
|
||||
}
|
||||
|
||||
|
||||
int i = 0;
|
||||
for (ColorRgb& color : _ledBuffer)
|
||||
{
|
||||
@@ -861,7 +879,7 @@ void Hyperion::update()
|
||||
{
|
||||
_ledBuffer.resize(_hwLedCount, ColorRgb::BLACK);
|
||||
}
|
||||
|
||||
|
||||
// Write the data to the device
|
||||
if (_device->enabled())
|
||||
{
|
||||
@@ -869,7 +887,7 @@ void Hyperion::update()
|
||||
// feed smoothing in pause mode to maintain a smooth transistion back to smoth mode
|
||||
if (_deviceSmooth->enabled() || _deviceSmooth->pause())
|
||||
_deviceSmooth->setLedValues(_ledBuffer);
|
||||
|
||||
|
||||
if (! _deviceSmooth->enabled())
|
||||
_device->setLedValues(_ledBuffer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user