コード例 #1
0
void QLCChannel_Test::group()
{
	QLCChannel* channel = new QLCChannel();
	QVERIFY(channel->group() == KQLCChannelGroupIntensity);

	channel->setGroup("TestGroup");
	QVERIFY(channel->group() == "TestGroup");

	delete channel;
}
コード例 #2
0
void VCXYPadFixture::arm()
{
	Fixture* fxi = NULL;

	fxi = _app->doc()->fixture(m_fixture);
	if (fxi == NULL)
	{
		m_xLSB = KChannelInvalid;
		m_xMSB = KChannelInvalid;
		m_yLSB = KChannelInvalid;
		m_yMSB = KChannelInvalid;
	}
	else
	{
		const QLCFixtureMode* mode = NULL;
		QLCChannel* ch = NULL;

		/* If this fixture has no mode, it's a generic dimmer that
		   can't do pan&tilt anyway. */
		mode = fxi->fixtureMode();
		if (mode == NULL)
		{
			m_xLSB = KChannelInvalid;
			m_xMSB = KChannelInvalid;
			m_yLSB = KChannelInvalid;
			m_yMSB = KChannelInvalid;
			
			return;
		}

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

			if (ch->group() == KQLCChannelGroupPan)
			{
				if (ch->controlByte() == 0)
					m_xMSB = fxi->universeAddress() + i;
				else if (ch->controlByte() == 1)
					m_xLSB = fxi->universeAddress() + i;
			}
			else if (ch->group() == KQLCChannelGroupTilt)
			{
				if (ch->controlByte() == 0)
					m_yMSB = fxi->universeAddress() + i;
				else if (ch->controlByte() == 1)
					m_yLSB = fxi->universeAddress() + i;
			}
		}
	}
}
コード例 #3
0
ファイル: qlcchannel_test.cpp プロジェクト: alexpaulzor/qlc
void QLCChannel_Test::group()
{
    QLCChannel* channel = new QLCChannel();
    QVERIFY(channel->group() == QLCChannel::Intensity);

    channel->setGroup(QLCChannel::Beam);
    QVERIFY(channel->group() == QLCChannel::Beam);

    channel->setGroup(QLCChannel::Group(31337));
    QVERIFY(channel->group() == QLCChannel::Group(31337));

    delete channel;
}
コード例 #4
0
ファイル: fixtureeditor.cpp プロジェクト: speakman/qlc
void QLCFixtureEditor::refreshChannelList()
{
	QLCChannel* ch = NULL;
	QTreeWidgetItem* item = NULL;
	QString str;

	m_channelList->clear();

	// Fill channels list
	QListIterator <QLCChannel*> it(*m_fixtureDef->channels());
	while (it.hasNext() == true)
	{
		ch = it.next();

		item = new QTreeWidgetItem(m_channelList);
		item->setText(KChannelsColumnName, ch->name());
		item->setText(KChannelsColumnGroup, ch->group());

		// Store the channel pointer to the listview as a string
		str.sprintf("%lu", (unsigned long) ch);
		item->setText(KChannelsColumnPointer, str);
	}
	
	slotChannelListSelectionChanged(m_channelList->currentItem());
}
コード例 #5
0
ファイル: fixtureeditor.cpp プロジェクト: lelazary/qlcplus
void QLCFixtureEditor::updateModeItem(const QLCFixtureMode* mode,
                                      QTreeWidgetItem* item)
{
    Q_ASSERT(mode != NULL);
    Q_ASSERT(item != NULL);

    item->setText(MODE_COL_NAME, mode->name());
    item->setData(MODE_COL_NAME, PROP_PTR, (qulonglong) mode);
    item->setText(MODE_COL_CHS, QString::number(mode->channels().size()));
    if (mode->heads().size() > 0)
        item->setText(MODE_COL_HEAD, QString::number(mode->heads().size()));
    else
        item->setText(MODE_COL_HEAD, QString());

    /* Destroy the existing list of children */
    QList <QTreeWidgetItem*> children(item->takeChildren());
    foreach (QTreeWidgetItem* child, children)
    delete child;

    /* Put all mode channels as non-selectable sub items */
    for (int i = 0; i < mode->channels().size(); i++)
    {
        QLCChannel* ch = mode->channel(i);
        Q_ASSERT(ch != NULL);

        QTreeWidgetItem* chitem = new QTreeWidgetItem(item);
        chitem->setText(MODE_COL_NAME, ch->name());
        chitem->setIcon(MODE_COL_NAME, ch->getIconFromGroup(ch->group()));
        chitem->setText(MODE_COL_CHS, QString("%1").arg(i + 1));
        chitem->setFlags(0); /* No selection etc. */
    }
}
コード例 #6
0
void QLCChannel_Test::loadWrongRoot()
{
    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly | QIODevice::Text);
    QXmlStreamWriter xmlWriter(&buffer);

    xmlWriter.writeStartElement("Chanel");
    xmlWriter.writeAttribute("Name", "Channel1");

    xmlWriter.writeStartElement("Group");
    xmlWriter.writeAttribute("Byte", "1");
    xmlWriter.writeCharacters("Tilt");
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "0");
    xmlWriter.writeAttribute("Max", "10");
    xmlWriter.writeCharacters("Cap1");
    xmlWriter.writeEndElement();

    /* Overlaps with cap1, shouldn't appear in the channel */
    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "5");
    xmlWriter.writeAttribute("Max", "15");
    xmlWriter.writeCharacters("Cap2");
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "11");
    xmlWriter.writeAttribute("Max", "20");
    xmlWriter.writeCharacters("Cap3");
    xmlWriter.writeEndElement();

    xmlWriter.writeEndDocument();
    xmlWriter.setDevice(NULL);
    buffer.close();

    buffer.open(QIODevice::ReadOnly | QIODevice::Text);
    QXmlStreamReader xmlReader(&buffer);
    xmlReader.readNextStartElement();

    QLCChannel ch;
    QVERIFY(ch.loadXML(xmlReader) == false);
    QVERIFY(ch.name().isEmpty());
    QVERIFY(ch.group() == QLCChannel::Intensity);
    QVERIFY(ch.controlByte() == QLCChannel::MSB);
    QVERIFY(ch.capabilities().size() == 0);
}
コード例 #7
0
ファイル: qlcchannel_test.cpp プロジェクト: alexpaulzor/qlc
void QLCChannel_Test::loadWrongRoot()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Chanel");
    root.setAttribute("Name", "Channel1");
    doc.appendChild(root);

    QDomElement group = doc.createElement("Group");
    root.appendChild(group);
    group.setAttribute("Byte", 1);
    QDomText groupName = doc.createTextNode("Tilt");
    group.appendChild(groupName);

    QDomElement cap1 = doc.createElement("Capability");
    root.appendChild(cap1);
    cap1.setAttribute("Min", 0);
    cap1.setAttribute("Max", 10);
    QDomText cap1name = doc.createTextNode("Cap1");
    cap1.appendChild(cap1name);

    /* Overlaps with cap1, shouldn't appear in the channel */
    QDomElement cap2 = doc.createElement("Capability");
    root.appendChild(cap2);
    cap2.setAttribute("Min", 5);
    cap2.setAttribute("Max", 15);
    QDomText cap2name = doc.createTextNode("Cap2");
    cap2.appendChild(cap2name);

    QDomElement cap3 = doc.createElement("Capability");
    root.appendChild(cap3);
    cap3.setAttribute("Min", 11);
    cap3.setAttribute("Max", 20);
    QDomText cap3name = doc.createTextNode("Cap3");
    cap3.appendChild(cap3name);

    QLCChannel ch;
    QVERIFY(ch.loadXML(&root) == false);
    QVERIFY(ch.name().isEmpty());
    QVERIFY(ch.group() == QLCChannel::Intensity);
    QVERIFY(ch.controlByte() == QLCChannel::MSB);
    QVERIFY(ch.capabilities().size() == 0);
}
コード例 #8
0
ファイル: fixtureeditor.cpp プロジェクト: speakman/qlc
void QLCFixtureEditor::slotEditChannel()
{
	QLCChannel* real = NULL;
	QTreeWidgetItem* item = NULL;

	// Initialize the dialog with the selected logical channel or
	// bail out if there is no current selection
	real = currentChannel();
	if (real == NULL)
		return;
	
	EditChannel ec(this, real);
	if (ec.exec() == QDialog::Accepted)
	{
		// Copy the channel's contents to the real channel
		*real = *(ec.channel());

		item = m_channelList->currentItem();
		item->setText(KChannelsColumnName, real->name());
		item->setText(KChannelsColumnGroup, real->group());
		
		setModified();
	}
}
コード例 #9
0
ファイル: vcsliderproperties.cpp プロジェクト: speakman/qlc
void VCSliderProperties::levelUpdateChannelNode(QCheckListItem* parent,
						Fixture* fxi,
						t_channel ch)
{
	QCheckListItem* item = NULL;
	QLCChannel* channel = NULL;
	QString str;

	Q_ASSERT(parent != NULL);

	channel = fxi->channel(ch);
	Q_ASSERT(channel != NULL);

	item = levelChannelNode(parent, ch);
	if (item == NULL)
		item = new QCheckListItem(parent, channel->name(),
					  QCheckListItem::CheckBox);

	item->setText(KColumnType, channel->group());
	str.setNum(ch);
	item->setText(KColumnID, str);

	levelUpdateCapabilities(item, channel);
}
コード例 #10
0
void EFX::arm()
{
	class Scene* startScene = NULL;
	class Scene* stopScene = NULL;
	QLCFixtureMode* mode = NULL;
	QLCChannel* ch = NULL;
	int serialNumber = 0;
	Fixture* fxi = NULL;

	/* Initialization scene */
	if (m_startSceneID != KNoID && m_startSceneEnabled == true)
		startScene = static_cast <class Scene*>
			(_app->doc()->function(m_startSceneID));

	/* De-initialization scene */
	if (m_stopSceneID != KNoID && m_stopSceneEnabled == true)
		stopScene = static_cast <class Scene*>
			(_app->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 */
		fxi = _app->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. */
		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(); i++)
		{
			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 = NULL;
}
コード例 #11
0
ファイル: qlcchannel_test.cpp プロジェクト: alexpaulzor/qlc
void QLCChannel_Test::load()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Channel");
    root.setAttribute("Name", "Channel1");
    doc.appendChild(root);

    QDomElement group = doc.createElement("Group");
    root.appendChild(group);
    group.setAttribute("Byte", 1);
    QDomText groupName = doc.createTextNode("Tilt");
    group.appendChild(groupName);

    QDomElement colour = doc.createElement("Colour");
    QDomText colourText = doc.createTextNode(QLCChannel::colourToString(QLCChannel::Cyan));
    colour.appendChild(colourText);
    root.appendChild(colour);

    QDomElement cap1 = doc.createElement("Capability");
    root.appendChild(cap1);
    cap1.setAttribute("Min", 0);
    cap1.setAttribute("Max", 10);
    QDomText cap1name = doc.createTextNode("Cap1");
    cap1.appendChild(cap1name);

    /* Overlaps with cap1, shouldn't appear in the channel */
    QDomElement cap2 = doc.createElement("Capability");
    root.appendChild(cap2);
    cap2.setAttribute("Min", 5);
    cap2.setAttribute("Max", 15);
    QDomText cap2name = doc.createTextNode("Cap2");
    cap2.appendChild(cap2name);

    QDomElement cap3 = doc.createElement("Capability");
    root.appendChild(cap3);
    cap3.setAttribute("Min", 11);
    cap3.setAttribute("Max", 20);
    QDomText cap3name = doc.createTextNode("Cap3");
    cap3.appendChild(cap3name);

    /* Invalid capability tag, shouldn't appear in the channel, since it
       is not recognized by the channel. */
    QDomElement cap4 = doc.createElement("apability");
    root.appendChild(cap4);
    cap4.setAttribute("Min", 21);
    cap4.setAttribute("Max", 30);
    QDomText cap4name = doc.createTextNode("Cap4");
    cap4.appendChild(cap4name);

    /* Missing minimum value, shouldn't appear in the channel, because
       loadXML() fails. */
    QDomElement cap5 = doc.createElement("Capability");
    root.appendChild(cap5);
    cap5.setAttribute("Max", 30);
    QDomText cap5name = doc.createTextNode("Cap5");
    cap5.appendChild(cap5name);

    QLCChannel ch;
    QVERIFY(ch.loadXML(&root) == true);
    qDebug() << int(ch.colour());
    QVERIFY(ch.name() == "Channel1");
    QVERIFY(ch.group() == QLCChannel::Tilt);
    QVERIFY(ch.controlByte() == QLCChannel::LSB);
    QVERIFY(ch.colour() == QLCChannel::Cyan);
    QVERIFY(ch.capabilities().size() == 2);
    QVERIFY(ch.capabilities()[0]->name() == "Cap1");
    QVERIFY(ch.capabilities()[1]->name() == "Cap3");
}
コード例 #12
0
ファイル: qlcchannel_test.cpp プロジェクト: alexpaulzor/qlc
void QLCChannel_Test::copy()
{
    QLCChannel* channel = new QLCChannel();
    QVERIFY(channel->capabilities().size() == 0);

    channel->setName("Foobar");
    channel->setGroup(QLCChannel::Tilt);
    channel->setControlByte(QLCChannel::ControlByte(3));
    channel->setColour(QLCChannel::Yellow);

    QLCCapability* cap1 = new QLCCapability(10, 19, "10-19");
    QVERIFY(channel->addCapability(cap1) == true);

    QLCCapability* cap2 = new QLCCapability(50, 59, "50-59");
    QVERIFY(channel->addCapability(cap2) == true);

    QLCCapability* cap3 = new QLCCapability(40, 49, "40-49");
    QVERIFY(channel->addCapability(cap3) == true);

    QLCCapability* cap4 = new QLCCapability(0, 9, "0-9");
    QVERIFY(channel->addCapability(cap4) == true);

    QLCCapability* cap5 = new QLCCapability(200, 209, "200-209");
    QVERIFY(channel->addCapability(cap5) == true);

    QLCCapability* cap6 = new QLCCapability(30, 39, "30-39");
    QVERIFY(channel->addCapability(cap6) == true);

    QLCCapability* cap7 = new QLCCapability(26, 29, "26-29");
    QVERIFY(channel->addCapability(cap7) == true);

    QLCCapability* cap8 = new QLCCapability(20, 25, "20-25");
    QVERIFY(channel->addCapability(cap8) == true);

    /* Create a copy of the original channel */
    QLCChannel* copy = new QLCChannel(channel);

    QVERIFY(copy->name() == "Foobar");
    QVERIFY(copy->group() == QLCChannel::Tilt);
    QVERIFY(copy->controlByte() == QLCChannel::ControlByte(3));
    QVERIFY(copy->colour() == QLCChannel::Yellow);

    /* Verify that the capabilities in the copied channel are also
       copies i.e. their pointers are not the same as the originals. */
    QList <QLCCapability*> caps(copy->capabilities());
    QVERIFY(caps.size() == 8);
    QVERIFY(caps.at(0) != cap1);
    QVERIFY(caps.at(0)->name() == cap1->name());
    QVERIFY(caps.at(0)->min() == cap1->min());
    QVERIFY(caps.at(0)->max() == cap1->max());

    QVERIFY(caps.at(1) != cap2);
    QVERIFY(caps.at(1)->name() == cap2->name());
    QVERIFY(caps.at(1)->min() == cap2->min());
    QVERIFY(caps.at(1)->max() == cap2->max());

    QVERIFY(caps.at(2) != cap3);
    QVERIFY(caps.at(2)->name() == cap3->name());
    QVERIFY(caps.at(2)->min() == cap3->min());
    QVERIFY(caps.at(2)->max() == cap3->max());

    QVERIFY(caps.at(3) != cap4);
    QVERIFY(caps.at(3)->name() == cap4->name());
    QVERIFY(caps.at(3)->min() == cap4->min());
    QVERIFY(caps.at(3)->max() == cap4->max());

    QVERIFY(caps.at(4) != cap5);
    QVERIFY(caps.at(4)->name() == cap5->name());
    QVERIFY(caps.at(4)->min() == cap5->min());
    QVERIFY(caps.at(4)->max() == cap5->max());

    QVERIFY(caps.at(5) != cap6);
    QVERIFY(caps.at(5)->name() == cap6->name());
    QVERIFY(caps.at(5)->min() == cap6->min());
    QVERIFY(caps.at(5)->max() == cap6->max());

    QVERIFY(caps.at(6) != cap7);
    QVERIFY(caps.at(6)->name() == cap7->name());
    QVERIFY(caps.at(6)->min() == cap7->min());
    QVERIFY(caps.at(6)->max() == cap7->max());

    QVERIFY(caps.at(7) != cap8);
    QVERIFY(caps.at(7)->name() == cap8->name());
    QVERIFY(caps.at(7)->min() == cap8->min());
    QVERIFY(caps.at(7)->max() == cap8->max());
}
コード例 #13
0
ファイル: efx.cpp プロジェクト: speakman/qlc
/**
 * Prepare this function for running. This is called when
 * the user sets the mode to Operate. Basically allocates everything
 * that is needed to run the function.
 */
void EFX::arm()
{
	class Scene* startScene = NULL;
	class Scene* stopScene = NULL;
	QLCFixtureMode* mode = NULL;
	QLCChannel* ch = NULL;
	t_fixture_id fxi_id = KNoID;
	Fixture* fxi = NULL;
	int channels = 0;
	int order = 0;

	m_channels = 0;

	/* Initialization scene */
	if (m_startSceneID != KNoID && m_startSceneEnabled == true)
	{
		startScene = static_cast <class Scene*>
			(_app->doc()->function(m_startSceneID));
		Q_ASSERT(startScene != NULL);
	}

	/* De-initialization scene */
	if (m_stopSceneID != KNoID && m_stopSceneEnabled == true)
	{
		stopScene = static_cast <class Scene*>
			(_app->doc()->function(m_stopSceneID));
		Q_ASSERT(stopScene != NULL);
	}

	QListIterator <t_function_id> it(m_fixtures);
	while (it.hasNext() == true)
	{
		fxi_id = it.next();
		Q_ASSERT(fxi_id != KNoID);

		EFXFixture ef(this, fxi_id, m_channels, order, m_direction,
			      startScene, stopScene);

		fxi = _app->doc()->fixture(fxi_id);
		Q_ASSERT(fxi != NULL);

		mode = fxi->fixtureMode();
		Q_ASSERT(mode != NULL);

		channels = 0;

		for (t_channel i = 0; i < mode->channels(); i++)
		{
			ch = mode->channel(i);
			Q_ASSERT(ch != NULL);

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

		/* The fixture must have at least an LSB channel for 8bit
		   precision to get accepted into the EFX */
		if (ef.isValid() == true)
		{
			ef.updateSkipThreshold();
			m_runTimeData.append(ef);
			m_channels += channels;
			order++;
		}
	}

	/* Allocate space for channel data that is set to the eventbuffer */
	if (m_channelData == NULL)
		m_channelData = new unsigned int[m_channels];

	/* Allocate space for the event buffer, 1/2 seconds worth of events */
	if (m_eventBuffer == NULL)
		m_eventBuffer = new EventBuffer(m_channels, KFrequency >> 1);

	/* 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 = NULL;
}
コード例 #14
0
void QLCChannel_Test::load()
{
    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly | QIODevice::Text);
    QXmlStreamWriter xmlWriter(&buffer);

    xmlWriter.writeStartElement("Channel");
    xmlWriter.writeAttribute("Name", "Channel1");

    xmlWriter.writeStartElement("Group");
    xmlWriter.writeAttribute("Byte", "1");
    xmlWriter.writeCharacters("Tilt");
    xmlWriter.writeEndElement();

    xmlWriter.writeTextElement("Colour", QLCChannel::colourToString(QLCChannel::Cyan));

    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "0");
    xmlWriter.writeAttribute("Max", "10");
    xmlWriter.writeCharacters("Cap1");
    xmlWriter.writeEndElement();

    /* Overlaps with cap1, shouldn't appear in the channel */
    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "5");
    xmlWriter.writeAttribute("Max", "15");
    xmlWriter.writeCharacters("Cap2");
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "11");
    xmlWriter.writeAttribute("Max", "20");
    xmlWriter.writeCharacters("Cap3");
    xmlWriter.writeEndElement();

    /* Invalid capability tag, shouldn't appear in the channel, since it
       is not recognized by the channel. */
    xmlWriter.writeStartElement("apability");
    xmlWriter.writeAttribute("Min", "21");
    xmlWriter.writeAttribute("Max", "30");
    xmlWriter.writeCharacters("Cap4");
    xmlWriter.writeEndElement();

    /* Missing minimum value, shouldn't appear in the channel, because
       loadXML() fails. */
    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Max", "30");
    xmlWriter.writeCharacters("Cap5");
    xmlWriter.writeEndElement();

    xmlWriter.writeEndDocument();
    xmlWriter.setDevice(NULL);
    buffer.close();

    buffer.open(QIODevice::ReadOnly | QIODevice::Text);
    QXmlStreamReader xmlReader(&buffer);
    xmlReader.readNextStartElement();

    QLCChannel ch;
    QVERIFY(ch.loadXML(xmlReader) == true);
    qDebug() << int(ch.colour());
    QVERIFY(ch.name() == "Channel1");
    QVERIFY(ch.group() == QLCChannel::Tilt);
    QVERIFY(ch.controlByte() == QLCChannel::LSB);
    QVERIFY(ch.colour() == QLCChannel::Cyan);
    QVERIFY(ch.capabilities().size() == 2);
    QVERIFY(ch.capabilities()[0]->name() == "Cap1");
    QVERIFY(ch.capabilities()[1]->name() == "Cap3");
}
コード例 #15
0
bool AvolitesD4Parser::parseChannels(const QDomElement& elem, QLCFixtureDef* fixtureDef)
{
    QDomElement el = elem.firstChildElement(KD4TagAttribute);
    for (; !el.isNull(); el = el.nextSiblingElement(KD4TagAttribute))
    {
        // Small integrity check
        if (el.attribute(KD4TagID).isEmpty())
            continue;

        // If this attribute is a function (i.e. an attribute used as a control variable for other attributes)
        // then we just ignore it and continue. We can check it by checking if attribute Update on a <Function/> exists
        if (isFunction(el))
            continue;

        QLCChannel* chan = new QLCChannel();
        chan->setName(el.attribute(KD4TagName));
        chan->setGroup(getGroupFromXML(el));
        chan->setColour(getColourFromXML(el));
        chan->setControlByte(QLCChannel::MSB);

        // add channel to fixture definition
        fixtureDef->addChannel(chan);
        m_channels.insert(el.attribute(KD4TagID), chan);

        // if this channel is a NoGroup then we don't need to continue
        // no capabilities nor 16 bit channel
        if (chan->group() == QLCChannel::NoGroup)
            continue;

        // parse capabilities
        if (!parseCapabilities(el, chan))
        {
            m_channels.remove(el.attribute(KD4TagID));
            delete chan;
            return false;
        }

        // If we have a DMX attribute higher than 255 means we have an attribute with a 16bit precision
        // so, we add another channel, with 'Fine' appended to it's name and set the LSB controlbyte

        // NOTE: this can be changed in the future, pending the revamp over adding 16bit capabilities to any channel
        // not only pan/tiltm, therefore I didn't add a constant for Fine and kept it as it.
        if (is16Bit(el))
        {
            QLCChannel* fchan = new QLCChannel();
            fchan->setName(el.attribute(KD4TagName) + " Fine");
            fchan->setGroup(getGroupFromXML(el));
            fchan->setColour(getColourFromXML(el));
            fchan->setControlByte(QLCChannel::LSB);

            // parse capabilities
            if (!parseCapabilities(el, fchan, true))
            {
                delete fchan;
                return false;
            }

            // Finally add channel to fixture definition
            fixtureDef->addChannel(fchan);
            m_channels.insert(el.attribute(KD4TagID) + " Fine", fchan);
        }
    }

    return true;
}
コード例 #16
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();
}