示例#1
0
void CueStack::insertStartValue(FadeChannel& fc, const QList<Universe *> ua)
{
    qDebug() << Q_FUNC_INFO;
    const QHash <FadeChannel,FadeChannel>& channels(m_fader->channels());
    if (channels.contains(fc) == true)
    {
        // GenericFader contains the channel so grab its current
        // value as the new starting value to get a smoother fade
        FadeChannel existing = channels[fc];
        fc.setStart(existing.current());
        fc.setCurrent(fc.start());
    }
    else
    {
        // GenericFader didn't have the channel. Grab the starting value from UniverseArray.
        quint32 uni = fc.universe();
        if (uni != Universe::invalid() && uni < (quint32)ua.count())
        {
            if (fc.group(doc()) != QLCChannel::Intensity)
                fc.setStart(ua[uni]->preGMValues()[fc.address()]);
            else
                fc.setStart(0); // HTP channels must start at zero
        }
        fc.setCurrent(fc.start());
    }
}
void GenericDMXSource::writeDMX(MasterTimer* timer, QList<Universe *> ua)
{
    Q_UNUSED(timer);

    m_mutex.lock();
    QMutableMapIterator <QPair<quint32,quint32>,uchar> it(m_values);
    while (it.hasNext() == true && m_outputEnabled == true)
    {
        it.next();

        FadeChannel fc;
        fc.setFixture(m_doc, it.key().first);
        fc.setChannel(it.key().second);

        QLCChannel::Group grp = fc.group(m_doc);
        quint32 address = fc.address();
        quint32 universe = fc.universe();

        if (address != QLCChannel::invalid())
            ua[universe]->write(address, it.value());
        if (grp != QLCChannel::Intensity)
            it.remove();
    }
    m_mutex.unlock();
}
示例#3
0
void FadeChannel_Test::address()
{
    Doc doc(this);
    Fixture* fxi = new Fixture(&doc);
    fxi->setAddress(400);
    fxi->setChannels(5);
    doc.addFixture(fxi);

    FadeChannel fc;
    fc.setChannel(2);
    QCOMPARE(fc.address(), quint32(2));

    fc.setFixture(&doc, fxi->id());
    QCOMPARE(fc.address(), quint32(402));

    fc.setFixture(&doc, 12345);
    QCOMPARE(fc.address(), QLCChannel::invalid());
}
示例#4
0
QMap <quint32,FadeChannel>
ChaserRunner::createFadeChannels(const UniverseArray* universes,
                                 QMap <quint32,FadeChannel>& zeroChannels) const
{
    QMap <quint32,FadeChannel> map;
    if (m_currentStep >= m_steps.size() || m_currentStep < 0)
        return map;

    Scene* scene = qobject_cast<Scene*> (m_steps.at(m_currentStep));
    Q_ASSERT(scene != NULL);

    // Put all current channels to a map of channels that will be faded to zero.
    // If the same channels are added to the new channel map, they are removed
    // from this zero map.
    zeroChannels = m_channelMap;

    QListIterator <SceneValue> it(scene->values());
    while (it.hasNext() == true)
    {
        SceneValue value(it.next());
        Fixture* fxi = m_doc->fixture(value.fxi);
        if (fxi == NULL || fxi->channel(value.channel) == NULL)
            continue;

        FadeChannel channel;
        channel.setAddress(fxi->universeAddress() + value.channel);
        channel.setGroup(fxi->channel(value.channel)->group());
        channel.setTarget(value.value);

        // Get starting value from universes. For HTP channels it's always 0.
        channel.setStart(uchar(universes->preGMValues()[channel.address()]));

        // Transfer last step's current value to current step's starting value.
        if (m_channelMap.contains(channel.address()) == true)
            channel.setStart(m_channelMap[channel.address()].current());
        channel.setCurrent(channel.start());

        // Append the channel to the channel map
        map[channel.address()] = channel;

        // Remove the channel from a map of to-be-zeroed channels since now it
        // has a new value to fade to.
        zeroChannels.remove(channel.address());
    }

    // All channels that were present in the previous step but are not present
    // in the current step will go through this zeroing process.
    QMutableMapIterator <quint32,FadeChannel> zit(zeroChannels);
    while (zit.hasNext() == true)
    {
        zit.next();
        FadeChannel& channel(zit.value());
        if (channel.current() == 0 || channel.group() != QLCChannel::Intensity)
        {
            // Remove all non-HTP channels and such HTP channels that are
            // already at zero. There's nothing to do for them.
            zit.remove();
        }
        else
        {
            // This HTP channel was present in the previous step, but is absent
            // in the current. It's nicer that we fade it back to zero, rather
            // than just let it drop straight to zero.
            channel.setStart(channel.current());
            channel.setTarget(0);
        }
    }

    return map;
}