Exemplo n.º 1
0
void Collection::start(MasterTimer* timer)
{
	Q_ASSERT(timer != NULL);

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

	m_childCount = 0;

	QListIterator <t_function_id> it(m_steps);
	while (it.hasNext() == true)
	{
		Function* function;
		function = doc->function(it.next());
		Q_ASSERT(function != NULL);

		m_childCountMutex.lock();
		m_childCount++;
		m_childCountMutex.unlock();

		connect(function, SIGNAL(stopped(t_function_id)),
			this, SLOT(slotChildStopped(t_function_id)));

		function->start(timer);
	}

	Function::start(timer);
}
Exemplo n.º 2
0
QString Script::handleStopFunction(const QList <QStringList>& tokens)
{
    qDebug() << Q_FUNC_INFO;

    if (tokens.size() > 1)
        return QString("Too many arguments");

    bool ok = false;
    quint32 id = tokens[0][1].toUInt(&ok);
    if (ok == false)
        return QString("Invalid function ID: %1").arg(tokens[0][1]);

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

    Function* function = doc->function(id);
    if (function != NULL)
    {
        if (function->stopped() == false)
            function->stop();
        else
            qWarning() << "Function (" << function->name() << ") is not running.";

        m_startedFunctions.removeAll(function);
        return QString();
    }
    else
    {
        return QString("No such function (ID %1)").arg(id);
    }
}
Exemplo n.º 3
0
void Collection::slotChildStopped(quint32 fid)
{
    Doc* doc = qobject_cast <Doc*> (parent());
    Q_ASSERT(doc != NULL);

    Function* function = doc->function(fid);
    disconnect(function, SIGNAL(stopped(quint32)),
               this, SLOT(slotChildStopped(quint32)));

    QMutexLocker locker(&m_functionListMutex);
    m_runningChildren.remove(fid);
}
Exemplo n.º 4
0
void Chaser::stopMemberAt(int index)
{
	Doc* doc = qobject_cast <Doc*> (parent());
	Q_ASSERT(doc != NULL);

	t_function_id fid = m_steps.at(index);
	Q_ASSERT(fid != Function::invalidId());

	Function* function = doc->function(fid);
	Q_ASSERT(function != NULL);

	function->stop(m_masterTimer);
}
Exemplo n.º 5
0
void Collection::postLoad()
{
    Doc* doc = qobject_cast <Doc*> (parent());
    Q_ASSERT(doc != NULL);

    /* Check that all member functions exist (nonexistent functions can
       be present only when a corrupted file has been loaded) */
    QMutableListIterator<quint32> it(m_functions);
    while (it.hasNext() == true)
    {
        /* Remove any nonexistent member functions */
        if (doc->function(it.next()) == NULL)
            it.remove();
    }
}
Exemplo n.º 6
0
void Collection::slotChildStopped(t_function_id fid)
{
	Doc* doc = qobject_cast <Doc*> (parent());
	Q_ASSERT(doc != NULL);

	Function* function;
	function = doc->function(fid);
	Q_ASSERT(function != NULL);

	disconnect(function, SIGNAL(stopped(t_function_id)),
		   this, SLOT(slotChildStopped(t_function_id)));

	m_childCountMutex.lock();
	m_childCount--;
	m_childCountMutex.unlock();
}
Exemplo n.º 7
0
QList <Function*> Chaser::stepFunctions() const
{
    Doc* doc = qobject_cast<Doc*> (parent());
    Q_ASSERT(doc != NULL);

    QList <Function*> list;
    QListIterator <t_function_id> it(m_steps);
    while (it.hasNext() == true)
    {
        Function* function = doc->function(it.next());
        if (function != NULL)
            list << function;
    }

    return list;
}
Exemplo n.º 8
0
void Collection::stop(MasterTimer* timer)
{
	Doc* doc = qobject_cast <Doc*> (parent());
	Q_ASSERT(doc != NULL);

	/* TODO: this stops these functions, regardless of whether they
	   were started by this collection or not */
	QListIterator <t_function_id> it(m_steps);
	while (it.hasNext() == true)
	{
		Function* function = doc->function(it.next());
		Q_ASSERT(function != NULL);
		function->stop(timer);
	}

	Function::stop(timer);
}
Exemplo n.º 9
0
bool Chaser::contains(quint32 functionId)
{
    Doc *doc = this->doc();
    Q_ASSERT(doc != NULL);

    foreach(ChaserStep step, m_steps)
    {
        Function *function = doc->function(step.fid);
        // contains() can be called during init, function may be NULL
        if (function == NULL)
            continue;

        if (function->id() == functionId)
            return true;
        if (function->contains(functionId))
            return true;
    }
Exemplo n.º 10
0
void Collection::write(MasterTimer* timer, QList<Universe *> universes)
{
    Q_UNUSED(universes);

    if (elapsed() == 0)
    {
        Doc* doc = qobject_cast <Doc*> (parent());
        Q_ASSERT(doc != NULL);

        QMutexLocker locker(&m_functionListMutex);
        QListIterator <quint32> it(m_functions);
        while (it.hasNext() == true)
        {
            Function* function = doc->function(it.next());
            Q_ASSERT(function != NULL);

            // Append the IDs of all functions started by this collection
            // to a set so that we can track which of them are still controlled
            // by this collection which are not.
            m_runningChildren << function->id();

            // Listen to the children's stopped signals so that this collection
            // can give up its rights to stop the function later.
            connect(function, SIGNAL(stopped(quint32)),
                    this, SLOT(slotChildStopped(quint32)));

            function->adjustAttribute(getAttributeValue(Function::Intensity), Function::Intensity);
            function->start(timer, true, 0, overrideFadeInSpeed(), overrideFadeOutSpeed(), overrideDuration());
        }
    }

    incrementElapsed();

    {
        QMutexLocker locker(&m_functionListMutex);
        if (m_runningChildren.size() > 0)
          return;
    }

    stop();
}
Exemplo n.º 11
0
void Collection::postRun(MasterTimer* timer, QList<Universe *> universes)
{
    Doc* doc = qobject_cast <Doc*> (parent());
    Q_ASSERT(doc != NULL);

    {
        QMutexLocker locker(&m_functionListMutex);
        /** Stop the member functions only if they have been started by this
            collection. */
        QSetIterator <quint32> it(m_runningChildren);
        while (it.hasNext() == true)
        {
            Function* function = doc->function(it.next());
            Q_ASSERT(function != NULL);
            function->stop();
        }

        m_runningChildren.clear();
    }

    Function::postRun(timer, universes);
}
Exemplo n.º 12
0
void Chaser::postLoad()
{
    if (m_legacyHoldBus != Bus::invalid())
    {
        quint32 value = Bus::instance()->value(m_legacyHoldBus);
        setDuration((value / MasterTimer::frequency()) * 1000);
    }

    Doc *doc = this->doc();
    Q_ASSERT(doc != NULL);

    QMutableListIterator <ChaserStep> it(m_steps);
    while (it.hasNext() == true)
    {
        ChaserStep step(it.next());
        Function *function = doc->function(step.fid);

        if (function == NULL)
            it.remove();
        else if (function->contains(id())) // forbid self-containment
            it.remove();
    }
}
Exemplo n.º 13
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();
}