From 2505a8b00f56af8bf4cbe43b46cd874919800dfc Mon Sep 17 00:00:00 2001 From: Massimo Callegari Date: Fri, 29 Nov 2024 11:18:00 +0100 Subject: [PATCH] engine: more cross universe fixes --- engine/src/genericdmxsource.cpp | 19 ++++++++++++++----- engine/src/scene.cpp | 15 +++++++++------ ui/src/simpledeskengine.cpp | 12 +++++++++++- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/engine/src/genericdmxsource.cpp b/engine/src/genericdmxsource.cpp index 0a61691dd0..e29f5f0e92 100644 --- a/engine/src/genericdmxsource.cpp +++ b/engine/src/genericdmxsource.cpp @@ -24,6 +24,8 @@ #include "universe.h" #include "doc.h" +#include + GenericDMXSource::GenericDMXSource(Doc* doc) : m_doc(doc) , m_outputEnabled(false) @@ -116,15 +118,22 @@ void GenericDMXSource::writeDMX(MasterTimer* timer, QList ua) if (fixture == NULL) continue; - quint32 universe = fixture->universe(); - QSharedPointer fader = m_fadersMap.value(universe, QSharedPointer()); + quint32 channelIndex = it.key().second; + int universeIndex = floor((fixture->universeAddress() + channelIndex) / 512); + + if (universeIndex >= ua.count()) + continue; + + Universe *universe = ua[universeIndex]; + + QSharedPointer fader = m_fadersMap.value(universe->id(), QSharedPointer()); if (fader.isNull()) { - fader = ua[universe]->requestFader(); - m_fadersMap[universe] = fader; + fader = universe->requestFader(); + m_fadersMap[universe->id()] = fader; } - FadeChannel *fc = fader->getChannelFader(m_doc, ua[universe], fixture->id(), it.key().second); + FadeChannel *fc = fader->getChannelFader(m_doc, universe, fixture->id(), channelIndex); fc->setCurrent(it.value()); fc->setTarget(it.value()); } diff --git a/engine/src/scene.cpp b/engine/src/scene.cpp index 25f6350554..7942c8cdcf 100644 --- a/engine/src/scene.cpp +++ b/engine/src/scene.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -711,24 +712,26 @@ void Scene::processValue(MasterTimer *timer, QList ua, uint fadeIn, S if (fixture == NULL) return; - quint32 universe = fixture->universe(); - if (universe == Universe::invalid()) + int universeIndex = floor((fixture->universeAddress() + scv.channel) / 512); + if (universeIndex >= ua.count()) return; - QSharedPointer fader = m_fadersMap.value(universe, QSharedPointer()); + Universe *universe = ua.at(universeIndex); + + QSharedPointer fader = m_fadersMap.value(universe->id(), QSharedPointer()); if (fader.isNull()) { - fader = ua[universe]->requestFader(); + fader = universe->requestFader(); fader->adjustIntensity(getAttributeValue(Intensity)); fader->setBlendMode(blendMode()); fader->setName(name()); fader->setParentFunctionID(id()); fader->setParentIntensity(getAttributeValue(ParentIntensity)); fader->setHandleSecondary(true); - m_fadersMap[universe] = fader; + m_fadersMap[universe->id()] = fader; } - FadeChannel *fc = fader->getChannelFader(doc(), ua[universe], scv.fxi, scv.channel); + FadeChannel *fc = fader->getChannelFader(doc(), universe, scv.fxi, scv.channel); int chIndex = fc->channelIndex(scv.channel); /** If a blend Function has been set, check if this channel needs to diff --git a/ui/src/simpledeskengine.cpp b/ui/src/simpledeskengine.cpp index ee3d8506e4..724ff54901 100644 --- a/ui/src/simpledeskengine.cpp +++ b/ui/src/simpledeskengine.cpp @@ -318,6 +318,7 @@ void SimpleDeskEngine::writeDMX(MasterTimer *timer, QList ua) FadeChannel fc = it.value(); Fixture *fixture = m_doc->fixture(fc.fixture()); quint32 chIndex = fc.channel(); + if (fixture != NULL) { const QLCChannel *ch = fixture->channel(chIndex); @@ -325,7 +326,12 @@ void SimpleDeskEngine::writeDMX(MasterTimer *timer, QList ua) { qDebug() << "Restoring default value of fixture" << fixture->id() << "channel" << chIndex << "value" << ch->defaultValue(); - ua[universe]->setChannelDefaultValue(fixture->address() + chIndex, ch->defaultValue()); + chIndex += fixture->address(); + + if (fixture->crossUniverse() && chIndex > 511) + chIndex -= 512; + + ua[universe]->setChannelDefaultValue(chIndex, ch->defaultValue()); } } } @@ -344,6 +350,10 @@ void SimpleDeskEngine::writeDMX(MasterTimer *timer, QList ua) Fixture *fixture = m_doc->fixture(fc.fixture()); quint32 chIndex = fc.channel(); fader->remove(&fc); + + if (fixture->crossUniverse() && channel > 511) + channel -= 512; + ua[universe]->reset(channel & 0x01FF, 1); if (fixture != NULL) {