示例#1
0
void Chaser::arm()
{
    Doc* doc = qobject_cast <Doc*> (parent());
    Q_ASSERT(doc != NULL);
    m_runner = new ChaserRunner(doc, stepFunctions(), busID(), direction(), runOrder());
    resetElapsed();
}
示例#2
0
void Function::postRun(MasterTimer* timer, UniverseArray* universes)
{
    Q_UNUSED(timer);
    Q_UNUSED(universes);

    m_stopMutex.lock();
    resetElapsed();
    m_stop = true;
    m_functionStopped.wakeAll();
    m_stopMutex.unlock();
    emit stopped(m_id);
}
示例#3
0
void RGBMatrix::tap()
{
    if (stopped() == false)
    {
        FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup());
        // Filter out taps that are too close to each other
        if (grp != NULL && uint(m_roundTime->elapsed()) >= (duration() / 4))
        {
            roundCheck(grp->size());
            resetElapsed();
        }
    }
}
示例#4
0
void Function::postRun(MasterTimer* timer, UniverseArray* universes)
{
    Q_UNUSED(timer);
    Q_UNUSED(universes);

    m_stopMutex.lock();
    resetElapsed();
    resetIntensity();
    m_stop = true;
    m_overrideFadeInSpeed = defaultSpeed();
    m_overrideFadeOutSpeed = defaultSpeed();
    m_overrideDuration = defaultSpeed();
    m_functionStopped.wakeAll();
    m_stopMutex.unlock();

    m_running = false;
    emit stopped(m_id);
}
示例#5
0
void Function::postRun(MasterTimer* timer, UniverseArray* universes)
{
    Q_UNUSED(timer);
    Q_UNUSED(universes);

    qDebug() << "Function postRun. ID: " << m_id;
    m_stopMutex.lock();
    resetElapsed();
    resetAttributes();
    m_stop = true;
    //m_overrideFadeInSpeed = defaultSpeed();
    //m_overrideFadeOutSpeed = defaultSpeed();
    //m_overrideDuration = defaultSpeed();
    m_functionStopped.wakeAll();
    m_stopMutex.unlock();

    m_running = false;
    emit stopped(m_id);
}
示例#6
0
void RGBMatrix::roundCheck(const QSize& size)
{
    QMutexLocker algorithmLocker(&m_algorithmMutex);
    if (m_algorithm == NULL)
        return;

    if (runOrder() == PingPong)
    {
        if (m_direction == Forward && (m_step + 1) == m_algorithm->rgbMapStepCount(size))
        {
            m_direction = Backward;
            m_step = m_algorithm->rgbMapStepCount(size) - 2;
            if (m_endColor.isValid())
                m_stepColor = m_endColor;

            updateStepColor(m_step);
        }
        else if (m_direction == Backward && (m_step - 1) < 0)
        {
            m_direction = Forward;
            m_step = 1;
            m_stepColor = m_startColor;
            updateStepColor(m_step);
        }
        else
        {
            if (m_direction == Forward)
                m_step++;
            else
                m_step--;
            updateStepColor(m_step);
        }
    }
    else if (runOrder() == SingleShot)
    {
        if (m_direction == Forward)
        {
            if (m_step >= m_algorithm->rgbMapStepCount(size) - 1)
                stop();
            else
            {
                m_step++;
                updateStepColor(m_step);
            }
        }
        else
        {
            if (m_step <= 0)
                stop();
            else
            {
                m_step--;
                updateStepColor(m_step);
            }
        }
    }
    else
    {
        if (m_direction == Forward)
        {
            if (m_step >= m_algorithm->rgbMapStepCount(size) - 1)
            {
                m_step = 0;
                m_stepColor = m_startColor;
            }
            else
            {
                m_step++;
                updateStepColor(m_step);
            }
        }
        else
        {
            if (m_step <= 0)
            {
                m_step = m_algorithm->rgbMapStepCount(size) - 1;
                if (m_endColor.isValid())
                    m_stepColor = m_endColor;
            }
            else
            {
                m_step--;
                updateStepColor(m_step);
            }
        }
    }

    m_roundTime->restart();
    resetElapsed();
}
示例#7
0
void RGBMatrix::write(MasterTimer* timer, QList<Universe *> universes)
{
    Q_UNUSED(timer);

    {
        QMutexLocker algorithmLocker(&m_algorithmMutex);
        if (m_group == NULL)
        {
            // No fixture group to control
            stop(FunctionParent::master());
            return;
        }

        // No time to do anything.
        if (duration() == 0)
            return;

        // Invalid/nonexistent script
        if (m_algorithm == NULL || m_algorithm->apiVersion() == 0)
            return;

        if (isPaused() == false)
        {
            // Get a new map every time elapsed is reset to zero
            if (elapsed() < MasterTimer::tick())
            {
                if (tempoType() == Beats)
                    m_stepBeatDuration = beatsToTime(duration(), timer->beatTimeDuration());

                //qDebug() << "RGBMatrix step" << m_stepHandler->currentStepIndex() << ", color:" << QString::number(m_stepHandler->stepColor().rgb(), 16);
                RGBMap map = m_algorithm->rgbMap(m_group->size(), m_stepHandler->stepColor().rgb(), m_stepHandler->currentStepIndex());
                updateMapChannels(map, m_group);
            }
        }
    }

    // Run the generic fader that takes care of fading in/out individual channels
    m_fader->write(universes, isPaused());

    if (isPaused() == false)
    {
        // Increment the ms elapsed time
        incrementElapsed();

        /* Check if we need to change direction, stop completely or go to next step
         * The cases are:
         * 1- time tempo type: act normally, on ms elapsed time
         * 2- beat tempo type, beat occurred: check if the elapsed beats is a multiple of
         *    the step beat duration. If so, proceed to the next step
         * 3- beat tempo type, not beat: if the ms elapsed time reached the step beat
         *    duration in ms, and the ms time to the next beat is not less than 1/16 of
         *    the step beat duration in ms, then proceed to the next step. If the ms time to the
         *    next beat is less than 1/16 of the step beat duration in ms, then defer the step
         *    change to case #2, to resync the matrix to the next beat
         */
        if (tempoType() == Time && elapsed() >= duration())
        {
            roundCheck();
        }
        else if (tempoType() == Beats)
        {
            if (timer->isBeat())
            {
                incrementElapsedBeats();
                qDebug() << "Elapsed beats:" << elapsedBeats() << ", time elapsed:" << elapsed() << ", step time:" << m_stepBeatDuration;
                if (elapsedBeats() % duration() == 0)
                {
                    roundCheck();
                    resetElapsed();
                }
            }
            else if (elapsed() >= m_stepBeatDuration && (uint)timer->timeToNextBeat() > m_stepBeatDuration / 16)
            {
                qDebug() << "Elapsed exceeded";
                roundCheck();
            }
        }
    }
}
示例#8
0
void EFX::arm()
{
    int serialNumber = 0;

    Doc* doc = qobject_cast <Doc*> (parent());
    Q_ASSERT(doc != NULL);

    QListIterator <EFXFixture*> it(m_fixtures);
    while (it.hasNext() == true)
    {
        EFXFixture* ef = it.next();
        Q_ASSERT(ef != NULL);

        ef->setSerialNumber(serialNumber++);

        /* If fxi == NULL, the fixture has been destroyed */
        Fixture* fxi = doc->fixture(ef->fixture());
        if (fxi == NULL)
            continue;

        /* If this fixture has no mode, it's a generic dimmer that
           can't do pan&tilt anyway. */
        const QLCFixtureMode* mode = fxi->fixtureMode();
        if (mode == NULL)
            continue;

        QList <quint32> intensityChannels;

        /* Find exact channel numbers for MSB/LSB pan and tilt */
        for (quint32 i = 0; i < quint32(mode->channels().size()); i++)
        {
            QLCChannel* ch = mode->channel(i);
            Q_ASSERT(ch != NULL);

            if (ch->group() == QLCChannel::Pan)
            {
                if (ch->controlByte() == QLCChannel::MSB)
                    ef->setMsbPanChannel(fxi->universeAddress() + i);
                else if (ch->controlByte() == QLCChannel::LSB)
                    ef->setLsbPanChannel(fxi->universeAddress() + i);
            }
            else if (ch->group() == QLCChannel::Tilt)
            {
                if (ch->controlByte() == QLCChannel::MSB)
                    ef->setMsbTiltChannel(fxi->universeAddress() + i);
                else if (ch->controlByte() == QLCChannel::LSB)
                    ef->setLsbTiltChannel(fxi->universeAddress() + i);
            }
            else if (ch->group() == QLCChannel::Intensity &&
                     ch->colour() == QLCChannel::NoColour) // Don't touch RGB/CMY channels
            {
                if (ch->searchCapability(/*D*/"immer", false) != NULL ||
                    ch->searchCapability(/*I*/"ntensity", false) != NULL)
                {
                    intensityChannels << (fxi->universeAddress() + i);
                }
            }
        }

        ef->setIntensityChannels(intensityChannels);
        ef->setFadeBus(fadeBusID());
    }

    Q_ASSERT(m_fader == NULL);
    m_fader = new GenericFader;

    resetElapsed();
}
示例#9
0
void EFX::arm()
{
	class Scene* startScene = NULL;
	class Scene* stopScene = NULL;
	int serialNumber = 0;

	Doc* doc = qobject_cast <Doc*> (parent());
	Q_ASSERT(doc != NULL);

	/* Initialization scene */
	if (m_startSceneID != Function::invalidId() &&
	    m_startSceneEnabled == true)
	{
		startScene = static_cast <class Scene*>
			(doc->function(m_startSceneID));
	}

	/* De-initialization scene */
	if (m_stopSceneID != Function::invalidId() &&
	    m_stopSceneEnabled == true)
	{
		stopScene = static_cast <class Scene*>
			(doc->function(m_stopSceneID));
	}

	QListIterator <EFXFixture*> it(m_fixtures);
	while (it.hasNext() == true)
	{
		EFXFixture* ef = it.next();
		Q_ASSERT(ef != NULL);

		ef->setSerialNumber(serialNumber++);
		ef->setStartScene(startScene);
		ef->setStopScene(stopScene);

		/* If fxi == NULL, the fixture has been destroyed */
		Fixture* fxi = doc->fixture(ef->fixture());
		if (fxi == NULL)
			continue;

		/* If this fixture has no mode, it's a generic dimmer that
		   can't do pan&tilt anyway. */
		const QLCFixtureMode* mode = fxi->fixtureMode();
		if (mode == NULL)
			continue;

		/* Find exact channel numbers for MSB/LSB pan and tilt */
		for (t_channel i = 0; i < mode->channels().size(); i++)
		{
			QLCChannel* ch = mode->channel(i);
			Q_ASSERT(ch != NULL);

			if (ch->group() == KQLCChannelGroupPan)
			{
				if (ch->controlByte() == 0)
				{
					ef->setMsbPanChannel(
						fxi->universeAddress() + i);
				}
				else if (ch->controlByte() == 1)
				{
					ef->setLsbPanChannel(
						fxi->universeAddress() + i);
				}
			}
			else if (ch->group() == KQLCChannelGroupTilt)
			{
				if (ch->controlByte() == 0)
				{
					ef->setMsbTiltChannel(
						fxi->universeAddress() + i);
				}
				else if (ch->controlByte() == 1)
				{
					ef->setLsbTiltChannel(
						fxi->universeAddress() + i);
				}
			}
		}
	}

	/* Choose a point calculation function depending on the algorithm */
	if (m_algorithm == KCircleAlgorithmName)
		pointFunc = circlePoint;
	else if (m_algorithm == KEightAlgorithmName)
		pointFunc = eightPoint;
	else if (m_algorithm == KLineAlgorithmName)
		pointFunc = linePoint;
	else if (m_algorithm == KTriangleAlgorithmName)
		pointFunc = trianglePoint;
	else if (m_algorithm == KDiamondAlgorithmName)
		pointFunc = diamondPoint;
	else if (m_algorithm == KLissajousAlgorithmName)
		pointFunc = lissajousPoint;
	else
		pointFunc = circlePoint; // Fallback

	resetElapsed();
}