コード例 #1
0
ファイル: fixture.cpp プロジェクト: ming-hai/qlcplus
void Fixture::setChannels(quint32 channels)
{
    if (m_fixtureDef == NULL && m_fixtureMode == NULL)
    {
        QLCFixtureDef *fixtureDef = genericDimmerDef(channels);
        QLCFixtureMode *fixtureMode = genericDimmerMode(fixtureDef, channels);
        setFixtureDefinition(fixtureDef, fixtureMode);
    }
    else
    {
        if ((quint32)m_fixtureMode->channels().size() != channels)
        {
            QLCFixtureDef *fixtureDef = genericDimmerDef(channels);
            QLCFixtureMode *fixtureMode = genericDimmerMode(fixtureDef, channels);
            setFixtureDefinition(fixtureDef, fixtureMode);
        }
    }

    m_channels = channels;

    emit changed(m_id);
}
コード例 #2
0
ファイル: fixture.cpp プロジェクト: speakman/qlc
bool Fixture::loadXML(const QDomElement* root,
		      const QLCFixtureDefCache& fixtureDefCache)
{
	const QLCFixtureDef* fixtureDef = NULL;
	const QLCFixtureMode* fixtureMode = NULL;
	QString manufacturer;
	QString model;
	QString modeName;
	QString name;
	t_fixture_id id = KInvalidFixtureID;
	t_channel universe = 0;
	t_channel address = 0;
	t_channel channels = 0;

	QDomElement tag;
	QDomNode node;

	Q_ASSERT(root != NULL);

	if (root->tagName() != KXMLFixture)
	{
		qDebug() << "Fixture node not found!";
		return false;
	}

	node = root->firstChild();
	while (node.isNull() == false)
	{
		tag = node.toElement();
		
		if (tag.tagName() == KXMLQLCFixtureDefManufacturer)
		{
			manufacturer = tag.text();
		}
		else if (tag.tagName() == KXMLQLCFixtureDefModel)
		{
			model = tag.text();
		}
		else if (tag.tagName() == KXMLQLCFixtureMode)
		{
			modeName = tag.text();
		}
		else if (tag.tagName() == KXMLFixtureID)
		{
			id = tag.text().toInt();
		}
		else if (tag.tagName() == KXMLFixtureName)
		{
			name = tag.text();
		}
		else if (tag.tagName() == KXMLFixtureUniverse)
		{
			universe = tag.text().toInt();
		}
		else if (tag.tagName() == KXMLFixtureAddress)
		{
			address = tag.text().toInt();
		}
		else if (tag.tagName() == KXMLFixtureChannels)
		{
			channels = tag.text().toInt();
		}
		else
		{
			qDebug() << "Unknown fixture instance tag:"
				 << tag.tagName();
		}

		node = node.nextSibling();
	}

	/* Find the given fixture definition */
	fixtureDef = fixtureDefCache.fixtureDef(manufacturer, model);
	if (fixtureDef == NULL)
	{
		qDebug() << QString("No fixture definition for [%1 - %2]")
					.arg(manufacturer).arg(model);
	}
	else
	{
		/* Find the given fixture mode */
		fixtureMode = fixtureDef->mode(modeName);
		if (fixtureMode == NULL)
		{
			qDebug() << QString("Fixture mode [%1] for [%2 - %3] "
					    "not found!").arg(modeName)
					    .arg(manufacturer).arg(model);
			/* Set this also NULL so that a generic dimmer will be
			   created instead as a backup. */
			fixtureDef = NULL;
		}
	}

	/* Number of channels */
	if (channels <= 0 || channels > KFixtureChannelsMax)
	{
		qDebug() << QString("Fixture [%1] channels %2 out of bounds "
				"(%3 - %4).").arg(name).arg(channels).arg(1)
				.arg(KFixtureChannelsMax);
		channels = KFixtureChannelsMax;
	}

	/* Make sure that address is something sensible */
	if (address > 511 || address + (channels - 1) > 511)
	{
		qDebug() << QString("Fixture channel range %1 - %2 out of DMX "
				    "bounds (%3 - %4).").arg(address)
				    .arg(address + channels).arg(0).arg(511);
		address = 0;
	}

	/* Make sure that universe is something sensible */
	if (universe >= KUniverseCount)
	{
		qDebug() << QString("Fixture universe %1 out of bounds "
				    "(%2 - %3).").arg(universe).arg(0)
				    .arg(KUniverseCount - 1);
		universe = 0;
	}

	/* Check that we have a sensible ID, otherwise we can't continue */
	if (id < 0 || id >= KFixtureArraySize)
	{
		qDebug() << QString("Fixture ID %1 out of bounds (%2 - %3).")
				    .arg(id).arg(0).arg(KFixtureArraySize - 1);
		return false;
	}

	if (fixtureDef != NULL && fixtureMode != NULL)
	{
		/* Assign fixtureDef & mode only if BOTH are not NULL */
		setFixtureDefinition(fixtureDef, fixtureMode);
	}
	else
	{
		/* Otherwise set just the channel count */
		setChannels(channels);
	}

	setAddress(address);
	setUniverse(universe);
	setName(name);
	
	return true;
}
コード例 #3
0
ファイル: fixture.cpp プロジェクト: offtools/qlcplus
bool Fixture::loadXML(const QDomElement& root, Doc *doc,
                      const QLCFixtureDefCache* fixtureDefCache)
{
    QLCFixtureDef* fixtureDef = NULL;
    QLCFixtureMode* fixtureMode = NULL;
    QString manufacturer;
    QString model;
    QString modeName;
    QString name;
    quint32 id = Fixture::invalidId();
    quint32 universe = 0;
    quint32 address = 0;
    quint32 channels = 0;
    quint32 width = 0, height = 0;
    QList<int> excludeList;
    QList<int> forcedHTP;
    QList<int> forcedLTP;
    QList<quint32>modifierIndices;
    QList<ChannelModifier *>modifierPointers;

    if (root.tagName() != KXMLFixture)
    {
        qWarning() << Q_FUNC_INFO << "Fixture node not found";
        return false;
    }

    QDomNode node = root.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();

        if (tag.tagName() == KXMLQLCFixtureDefManufacturer)
        {
            manufacturer = tag.text();
        }
        else if (tag.tagName() == KXMLQLCFixtureDefModel)
        {
            model = tag.text();
        }
        else if (tag.tagName() == KXMLQLCFixtureMode)
        {
            modeName = tag.text();
        }
        else if (tag.tagName() == KXMLQLCPhysicalDimensionsWeight)
        {
            width = tag.text().toUInt();
        }
        else if (tag.tagName() == KXMLQLCPhysicalDimensionsHeight)
        {
            height = tag.text().toUInt();
        }
        else if (tag.tagName() == KXMLFixtureID)
        {
            id = tag.text().toUInt();
        }
        else if (tag.tagName() == KXMLFixtureName)
        {
            name = tag.text();
        }
        else if (tag.tagName() == KXMLFixtureUniverse)
        {
            universe = tag.text().toInt();
        }
        else if (tag.tagName() == KXMLFixtureAddress)
        {
            address = tag.text().toInt();
        }
        else if (tag.tagName() == KXMLFixtureChannels)
        {
            channels = tag.text().toInt();
        }
        else if (tag.tagName() == KXMLFixtureExcludeFade)
        {
            QString list = tag.text();
            QStringList values = list.split(",");

            for (int i = 0; i < values.count(); i++)
                excludeList.append(values.at(i).toInt());
        }
        else if (tag.tagName() == KXMLFixtureForcedHTP)
        {
            QString list = tag.text();
            QStringList values = list.split(",");

            for (int i = 0; i < values.count(); i++)
                forcedHTP.append(values.at(i).toInt());
        }
        else if (tag.tagName() == KXMLFixtureForcedLTP)
        {
            QString list = tag.text();
            QStringList values = list.split(",");

            for (int i = 0; i < values.count(); i++)
                forcedLTP.append(values.at(i).toInt());
        }
        else if (tag.tagName() == KXMLFixtureChannelModifier)
        {
            if (tag.hasAttribute(KXMLFixtureChannelIndex) &&
                tag.hasAttribute(KXMLFixtureModifierName))
            {
                quint32 chIdx = tag.attribute(KXMLFixtureChannelIndex).toUInt();
                QString modName = tag.attribute(KXMLFixtureModifierName);
                ChannelModifier *chMod = doc->modifiersCache()->modifier(modName);
                if (chMod != NULL)
                {
                    modifierIndices.append(chIdx);
                    modifierPointers.append(chMod);
                }
            }
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown fixture tag:" << tag.tagName();
        }

        node = node.nextSibling();
    }

    /* Find the given fixture definition, unless its a generic dimmer */
    if (model != KXMLFixtureGeneric && model != KXMLFixtureRGBPanel)
    {
        fixtureDef = fixtureDefCache->fixtureDef(manufacturer, model);
        if (fixtureDef == NULL)
        {
            doc->appendToErrorLog(QString("No fixture definition found for <%1> <%2>")
                                  .arg(manufacturer)
                                  .arg(model));
        }
        else
        {
            /* Find the given fixture mode */
            fixtureMode = fixtureDef->mode(modeName);
            if (fixtureMode == NULL)
            {
                doc->appendToErrorLog(QString("Fixture mode <%1> not found for <%2> <%3>")
                                      .arg(modeName).arg(manufacturer).arg(model));

                /* Set this also NULL so that a generic dimmer will be
                   created instead as a backup. */
                fixtureDef = NULL;
            }
        }
    }

    /* Number of channels */
    if (channels <= 0)
    {
        doc->appendToErrorLog(QString("%1 channels of fixture <%2> are our of bounds")
                              .arg(QString::number(channels))
                              .arg(name));
        channels = 1;
    }

    /* Make sure that address is something sensible */
    if (address > 511 || address + (channels - 1) > 511)
    {
        doc->appendToErrorLog(QString("Fixture address range %1-%2 is out of DMX bounds")
                              .arg(QString::number(address))
                              .arg(QString::number(address + channels - 1)));
        address = 0;
    }

    /* Check that the invalid ID is not used */
    if (id == Fixture::invalidId())
    {
        qWarning() << Q_FUNC_INFO << "Fixture ID" << id << "is not allowed.";
        return false;
    }

    if (model == KXMLFixtureRGBPanel)
    {
        Components components = RGB;
        int compNum = 3;
        if (modeName == "BGR")
        {
            components = BGR;
        }
        else if (modeName == "RGBW")
        {
            components = RGBW;
            compNum = 4;
        }
        else if (modeName == "RGBWW")
        {
            components = RGBWW;
            compNum = 5;
        }
        fixtureDef = genericRGBPanelDef(channels / compNum, components);
        fixtureMode = genericRGBPanelMode(fixtureDef, components, width, height);
    }

    if (fixtureDef != NULL && fixtureMode != NULL)
    {
        /* Assign fixtureDef & mode only if BOTH are not NULL */
        setFixtureDefinition(fixtureDef, fixtureMode);
    }
    else
    {
        /* Otherwise set just the channel count */
        setChannels(channels);
    }

    setAddress(address);
    setUniverse(universe);
    setName(name);
    setExcludeFadeChannels(excludeList);
    setForcedHTPChannels(forcedHTP);
    setForcedLTPChannels(forcedLTP);
    for (int i = 0; i < modifierIndices.count(); i++)
        setChannelModifier(modifierIndices.at(i), modifierPointers.at(i));
    setID(id);

    return true;
}
コード例 #4
0
ファイル: fixture.cpp プロジェクト: glocklueng/qlc
bool Fixture::loadXML(const QDomElement& root,
                      const QLCFixtureDefCache* fixtureDefCache)
{
    const QLCFixtureDef* fixtureDef = NULL;
    const QLCFixtureMode* fixtureMode = NULL;
    QString manufacturer;
    QString model;
    QString modeName;
    QString name;
    quint32 id = Fixture::invalidId();
    quint32 universe = 0;
    quint32 address = 0;
    quint32 channels = 0;

    if (root.tagName() != KXMLFixture)
    {
        qWarning() << Q_FUNC_INFO << "Fixture node not found";
        return false;
    }

    QDomNode node = root.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();

        if (tag.tagName() == KXMLQLCFixtureDefManufacturer)
        {
            manufacturer = tag.text();
        }
        else if (tag.tagName() == KXMLQLCFixtureDefModel)
        {
            model = tag.text();
        }
        else if (tag.tagName() == KXMLQLCFixtureMode)
        {
            modeName = tag.text();
        }
        else if (tag.tagName() == KXMLFixtureID)
        {
            id = tag.text().toUInt();
        }
        else if (tag.tagName() == KXMLFixtureName)
        {
            name = tag.text();
        }
        else if (tag.tagName() == KXMLFixtureUniverse)
        {
            universe = tag.text().toInt();
        }
        else if (tag.tagName() == KXMLFixtureAddress)
        {
            address = tag.text().toInt();
        }
        else if (tag.tagName() == KXMLFixtureChannels)
        {
            channels = tag.text().toInt();
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown fixture tag:" << tag.tagName();
        }

        node = node.nextSibling();
    }

    /* Find the given fixture definition, unless its a generic dimmer */
    if (manufacturer != KXMLFixtureGeneric && model != KXMLFixtureGeneric)
    {
        fixtureDef = fixtureDefCache->fixtureDef(manufacturer, model);
        if (fixtureDef == NULL)
        {
            qWarning() << Q_FUNC_INFO << "No fixture definition for"
                       << manufacturer << model;
        }
        else
        {
            /* Find the given fixture mode */
            fixtureMode = fixtureDef->mode(modeName);
            if (fixtureMode == NULL)
            {
                qWarning() << Q_FUNC_INFO << "Fixture mode" << modeName
                           << "for" << manufacturer << model << "not found";

                /* Set this also NULL so that a generic dimmer will be
                   created instead as a backup. */
                fixtureDef = NULL;
            }
        }
    }

    /* Number of channels */
    if (channels <= 0)
    {
        qWarning() << Q_FUNC_INFO << "Fixture" << name << "channels"
                   << channels << "out of bounds";
        channels = 1;
    }

    /* Make sure that address is something sensible */
    if (address > 511 || address + (channels - 1) > 511)
    {
        qWarning() << Q_FUNC_INFO << "Fixture address range" << address << "-"
                   << address + channels - 1 << "out of DMX bounds";
        address = 0;
    }

    /* Check that the invalid ID is not used */
    if (id == Fixture::invalidId())
    {
        qWarning() << Q_FUNC_INFO << "Fixture ID" << id << "is not allowed.";
        return false;
    }

    if (fixtureDef != NULL && fixtureMode != NULL)
    {
        /* Assign fixtureDef & mode only if BOTH are not NULL */
        setFixtureDefinition(fixtureDef, fixtureMode);
    }
    else
    {
        /* Otherwise set just the channel count */
        setChannels(channels);
    }

    setAddress(address);
    setUniverse(universe);
    setName(name);
    setID(id);

    return true;
}