Ejemplo n.º 1
0
/*********************************************************************
 * Status
 *********************************************************************/
QString ChannelsGroup::status(Doc *doc) const
{
    QString info;

    QString title("<TR><TD CLASS='hilite' COLSPAN='3'><CENTER>%1</CENTER></TD></TR>");
    info += "<TABLE COLS='3' WIDTH='100%'>";

    // Fixture title
    info += title.arg(name());

    /********************************************************************
     * Channels
     ********************************************************************/

    // Title row
    info += QString("<TR><TD CLASS='subhi'>%1</TD>").arg(tr("Fixture"));
    info += QString("<TD CLASS='subhi'>%1</TD>").arg(tr("Channel"));
    info += QString("<TD CLASS='subhi'>%1</TD></TR>").arg(tr("Description"));

    foreach (SceneValue value, m_channels)
    {
        Fixture *fixture = doc->fixture(value.fxi);
        if (fixture == NULL)
            return QString();
        const QLCFixtureMode *mode = fixture->fixtureMode();
        QString chInfo("<TR><TD>%1</TD><TD>%2</TD><TD>%3</TD></TR>");
        if (mode != NULL)
        {
            info += chInfo.arg(fixture->name()).arg(value.channel + 1)
                .arg(mode->channels().at(value.channel)->name());
        }
        else
        {
            info += chInfo.arg(fixture->name()).arg(value.channel + 1)
                .arg(QString(tr("Channel %1")).arg(value.channel));
        }
    }
Ejemplo n.º 2
0
TEST(BLEReturnLongSysExData, MultipleData)
{
  using testing::ElementsAreArray;
  using testing::_;
  using testing::Args;
  Fixture f;
  static uint8_t longSysEx1[9] =
  {
    0x80, 0x80, 0xf0, 0x47, 0x7f, 0x15, 0x5c, 0x00, 0x01
  };
  static uint8_t longSysEx2[9] =
  {
    0x80, 0x21, 0x46, 0x47, 0x7f, 0x15, 0x5c, 0x80, 0xf7
  };
 
  static uint8_t sysExResult[14] =
  { 0xf0, 0x47, 0x7f, 0x15, 0x5c, 0x00, 0x01, 0x21, 0x46,
    0x47, 0x7f, 0x15, 0x5c,  0xf7
  }; 

  EXPECT_CALL(f.getMock(), SendSysEx(_,_,0)).With(Args<0,1>(ElementsAreArray(sysExResult)));
  f.parseDataArray(longSysEx1, 9);
  f.parseDataArray(longSysEx2, 9);
}
Ejemplo n.º 3
0
TEST(ChgrpTest, testSimpleChgrp ) {
    Fixture f;
    ExperimenterGroupPtr g1 = f.newGroup();
    ExperimenterGroupPtr g2 = f.newGroup();
    ExperimenterPtr user = f.newUser(g1);
    f.addExperimenter(g2, user);

    client_ptr c = f.login(user->getOmeName()->getValue());
    ServiceFactoryPrx sf = c->getSession();
    IAdminPrx admin = sf->getAdminService();
    ASSERT_EQ(g1->getId()->getValue(), admin->getEventContext()->groupId);

    IQueryPrx iquery = sf->getQueryService();
    IUpdatePrx iupdate = sf->getUpdateService();

    ImagePtr image = new ImageI();
    image->setName( rstring("testSimpleChgrp") );
    image->setAcquisitionDate( rtime(0) );
    image = ImagePtr::dynamicCast( iupdate->saveAndReturnObject( image ) );

    std::map<string, string> options;
    ChgrpPtr chgrp = new Chgrp();
    chgrp->type = "/Image";
    chgrp->id = image->getId()->getValue();
    chgrp->grp = g2->getId()->getValue();
    chgrp->options = options;

    HandlePrx handle = sf->submit( chgrp );
    CmdCallbackIPtr cb = new CmdCallbackI(c, handle);
    ResponsePtr rsp = cb->loop(10, 500);
    ERRPtr err = ERRPtr::dynamicCast(rsp);
    if (err) {
        FAIL() << "ERR returned";
    }

}
Ejemplo n.º 4
0
void FadeChannel_Test::group()
{
    Doc doc(this);

    FadeChannel fc;

    // Only a channel given, no fixture at the address -> intensity
    fc.setChannel(2);
    QCOMPARE(fc.group(&doc), QLCChannel::Intensity);

    Fixture* fxi = new Fixture(&doc);
    fxi->setAddress(10);
    fxi->setChannels(5);
    doc.addFixture(fxi);

    // Fixture and channel given, fixture is a dimmer -> intensity
    fc.setFixture(&doc, fxi->id());
    QCOMPARE(fc.group(&doc), QLCChannel::Intensity);

    QDir dir(INTERNAL_FIXTUREDIR);
    dir.setFilter(QDir::Files);
    dir.setNameFilters(QStringList() << QString("*%1").arg(KExtFixture));
    QVERIFY(doc.fixtureDefCache()->load(dir) == true);

    QLCFixtureDef* def = doc.fixtureDefCache()->fixtureDef("Futurelight", "DJScan250");
    QVERIFY(def != NULL);

    QLCFixtureMode* mode = def->modes().first();
    QVERIFY(mode != NULL);

    fxi = new Fixture(&doc);
    fxi->setAddress(0);
    fxi->setFixtureDefinition(def, mode);
    doc.addFixture(fxi);

    // Fixture and channel given, but channel is beyond fixture's channels -> intensity
    fc.setFixture(&doc, fxi->id());
    fc.setChannel(50);
    QCOMPARE(fc.group(&doc), QLCChannel::Intensity);

    // Only a channel given, no fixture given but a fixture occupies the address.
    // Check that reverse address -> fixture lookup works.
    fc.setFixture(&doc, Fixture::invalidId());
    fc.setChannel(2);
    QCOMPARE(fc.group(&doc), QLCChannel::Colour);

    // Fixture and channel given, but fixture doesn't exist -> intensity
    fc.setFixture(&doc, 12345);
    fc.setChannel(2);
    QCOMPARE(fc.group(&doc), QLCChannel::Intensity);
}
Ejemplo n.º 5
0
void FunctionWizard::addFixture(quint32 fxi_id)
{
    Fixture* fxi = _app->doc()->fixture(fxi_id);
    Q_ASSERT(fxi != NULL);

    QTreeWidgetItem* item = new QTreeWidgetItem(m_fixtureTree);
    item->setText(KColumnName, fxi->name());
    item->setData(KColumnID, Qt::UserRole, fxi_id);

    QStringList caps;
    if (!IntensityGenerator::findChannels(fxi, QLCChannel::Colour).isEmpty())
        caps << QLCChannel::groupToString(QLCChannel::Colour);

    if (!IntensityGenerator::findChannels(fxi, QLCChannel::Gobo).isEmpty())
        caps << QLCChannel::groupToString(QLCChannel::Gobo);

    if (!IntensityGenerator::findChannels(fxi, QLCChannel::Shutter).isEmpty())
        caps << QLCChannel::groupToString(QLCChannel::Shutter);

    if (!IntensityGenerator::findChannels(fxi, QLCChannel::Intensity).isEmpty())
        caps << QLCChannel::groupToString(QLCChannel::Intensity);

    item->setText(KColumnCaps, caps.join(", "));
}
Ejemplo n.º 6
0
void FixtureGroup_Test::copy()
{
    FixtureGroup grp1(m_doc);
    grp1.setSize(QSize(4, 4));
    grp1.setName("Pertti Pasanen");
    grp1.setId(99);
    for (quint32 id = 0; id < 16; id++)
    {
        Fixture* fxi = new Fixture(m_doc);
        fxi->setChannels(1);
        m_doc->addFixture(fxi);
        grp1.assignFixture(fxi->id());
    }
    QCOMPARE(grp1.fixtureList().size(), 16);

    FixtureGroup grp2(m_doc);
    grp2.copyFrom(&grp1);
    QCOMPARE(grp2.size(), QSize(4, 4));
    QCOMPARE(grp2.name(), QString("Pertti Pasanen"));
    QVERIFY(grp2.id() != quint32(99)); // ID must not be copied
    QCOMPARE(grp2.fixtureList().size(), 16);
    for (quint32 id = 0; id < 16; id++)
        QVERIFY(grp2.fixtureList().contains(id) == true);
}
Ejemplo n.º 7
0
void EFXFixture_Test::start()
{
    UniverseArray array(512 * 4);
    MasterTimerStub mts(m_doc, array);

    EFX e(m_doc);
    e.setFadeInSpeed(1000);
    e.setFadeOutSpeed(2000);
    EFXFixture* ef = new EFXFixture(&e);
    ef->setFixture(0);
    e.addFixture(ef);

    Fixture* fxi = m_doc->fixture(0);
    QVERIFY(fxi != NULL);

    e.preRun(&mts);

    // Fade intensity == 0, no need to do fade-in
    ef->setFadeIntensity(0);
    ef->start(&mts, &array);
    QCOMPARE(e.m_fader->m_channels.size(), 0);
    ef->m_started = false;

    // Fade intensity > 0, need to do fade-in
    ef->setFadeIntensity(1);
    ef->start(&mts, &array);
    QCOMPARE(e.m_fader->m_channels.size(), 1);

    FadeChannel fc;
    fc.setFixture(fxi->id());
    fc.setChannel(fxi->masterIntensityChannel());
    QVERIFY(e.m_fader->m_channels.contains(fc) == true);
    QCOMPARE(e.m_fader->m_channels[fc].fadeTime(), uint(1000));

    e.postRun(&mts, &array);
}
Ejemplo n.º 8
0
void EFXFixture_Test::setPoint8bit()
{
    const QLCFixtureDef* def = m_doc->fixtureDefCache()->fixtureDef("Futurelight", "DJScan250");
    QVERIFY(def != NULL);
    const QLCFixtureMode* mode = def->modes().first();
    QVERIFY(mode != NULL);

    Fixture* fxi = new Fixture(m_doc);
    fxi->setFixtureDefinition(def, mode);
    m_doc->addFixture(fxi);

    EFX e(m_doc);
    EFXFixture ef(&e);
    ef.setFixture(fxi->id());

    UniverseArray array(512 * 4);
    ef.setPoint(&array, 5.4, 1.5); // PMSB: 5, PLSB: 0.4, TMSB: 1 (102), TLSB: 0.5(127)
    QVERIFY(array.preGMValues()[0] == (char) 5);
    QVERIFY(array.preGMValues()[1] == (char) 1);
    QVERIFY(array.preGMValues()[2] == (char) 0); /* No LSB channels */
    QVERIFY(array.preGMValues()[3] == (char) 0); /* No LSB channels */

    m_doc->deleteFixture(fxi->id());
}
Ejemplo n.º 9
0
void FixtureGroup::assignFixture(quint32 id, const QLCPoint& pt)
{
    Fixture* fxi = doc()->fixture(id);
    Q_ASSERT(fxi != NULL);
    QLCPoint tmp = pt;

    for (int i = 0; i < fxi->heads(); i++)
    {
        if (pt.isNull())
        {
            assignHead(pt, GroupHead(fxi->id(), i));
        }
        else
        {
            assignHead(tmp, GroupHead(fxi->id(), i));
            tmp.setX(tmp.x() + 1);
            if (tmp.x() >= size().width())
            {
                tmp.setX(0);
                tmp.setY(tmp.y() + 1);
            }
        }
    }
}
Ejemplo n.º 10
0
// ----------------------------------------------------------------------------
//
SceneActor::SceneActor( Venue* venue, FixtureGroup *fg ) :
    m_uid( fg->getUID() ),
    m_group( true ),
    m_channels(0)
{
    reset_channel_values();

    if ( fg->getNumChannelValues() > 0 ) {
        m_channels = fg->getNumChannelValues();
        fg->getChannelValues( m_channel_values );
    }
    else {
        Fixture* pf = venue->getGroupRepresentative( fg->getUID() );

        if ( pf != NULL ) {         // Make sure this is not an empty group
            m_channels = pf->getNumChannels();

            // Copy channel defaults
            for ( channel_t channel=0; channel < m_channels; channel++ ) {
                m_channel_values[ channel ] = pf->getChannel( channel )->getDefaultValue();
            }
        }
    }
}
Ejemplo n.º 11
0
static TestResult *
tcase_run_checked_setup (SRunner * sr, TCase * tc)
{
  TestResult *tr = NULL;
  List *l;
  Fixture *f;
  enum fork_status fstat = srunner_fork_status (sr);

  l = tc->ch_sflst;
  if (fstat == CK_FORK) {
    send_ctx_info (CK_CTX_SETUP);
  }

  for (list_front (l); !list_at_end (l); list_advance (l)) {
    if (fstat == CK_NOFORK) {
      send_ctx_info (CK_CTX_SETUP);
    }
    f = list_val (l);
    f->fun ();

    /* Stop the setup and return the failure if nofork mode. */
    if (fstat == CK_NOFORK) {
      tr = receive_result_info_nofork (tc->name, "checked_setup", 0);
      if (tr->rtype != CK_PASS) {
        break;
      }

      free (tr->file);
      free (tr->msg);
      free (tr);
      tr = NULL;
    }
  }

  return tr;
}
Ejemplo n.º 12
0
void SceneEditor::slotRemoveFixtureClicked()
{
    int r = QMessageBox::question(
                this, tr("Remove fixtures"),
                tr("Do you want to remove the selected fixture(s)?"),
                QMessageBox::Yes, QMessageBox::No);

    if (r == QMessageBox::Yes)
    {
        QListIterator <Fixture*> it(selectedFixtures());
        while (it.hasNext() == true)
        {
            Fixture* fixture = it.next();
            Q_ASSERT(fixture != NULL);

            removeFixtureTab(fixture);
            removeFixtureItem(fixture);

            /* Remove all values associated to the fixture */
            for (quint32 i = 0; i < fixture->channels(); i++)
                m_scene->unsetValue(fixture->id(), i);
        }
    }
}
Ejemplo n.º 13
0
void MonitorFixture::slotChannelStyleChanged(Monitor::ChannelStyle style)
{
    QString str;
    int i = 0;

    m_channelStyle = style;

    /* Check that this MonitorFixture represents a fixture */
    if (m_fixture == Fixture::invalidId())
        return;

    Fixture* fxi = m_doc->fixture(m_fixture);
    Q_ASSERT(fxi != NULL);

    /* Start channel numbering from this fixture's address */
    if (style == Monitor::DMXChannels)
        i = fxi->address() + 1;
    else
        i = 1;

    QListIterator <QLabel*> it(m_channelLabels);
    while (it.hasNext() == true)
        it.next()->setText(str.sprintf("<B>%.3d</B>", i++));
}
Ejemplo n.º 14
0
/** Test scene running with bus value 1 (takes two cycles) */
void Scene_Test::writeBusOne()
{
    Doc* doc = new Doc(this, m_cache);

    Bus::instance()->setValue(Bus::defaultFade(), 1);

    Fixture* fxi = new Fixture(doc);
    fxi->setAddress(0);
    fxi->setUniverse(0);
    fxi->setChannels(10);
    doc->addFixture(fxi);

    Scene* s1 = new Scene(doc);
    s1->setName("First");
    s1->setValue(fxi->id(), 0, 255);
    s1->setValue(fxi->id(), 1, 127);
    s1->setValue(fxi->id(), 2, 0);
    doc->addFunction(s1);

    s1->arm();

    QByteArray uni(4 * 512, 0);
    MasterTimerStub* mts = new MasterTimerStub(this, NULL, uni);

    QVERIFY(s1->stopped() == true);
    mts->startFunction(s1);
    QVERIFY(s1->stopped() == false);

    QVERIFY(uni[0] == (char) 0);
    QVERIFY(uni[1] == (char) 0);
    QVERIFY(uni[2] == (char) 0);

    s1->write(mts, &uni);
    QVERIFY(s1->stopped() == false);
    QVERIFY(uni[0] == (char) 127);
    QVERIFY(uni[1] == (char) 63);
    QVERIFY(uni[2] == (char) 0);

    s1->write(mts, &uni);
    QVERIFY(s1->stopped() == true);
    QVERIFY(uni[0] == (char) 255);
    QVERIFY(uni[1] == (char) 127);
    QVERIFY(uni[2] == (char) 0);

    mts->stopFunction(s1);
    QVERIFY(s1->stopped() == true);
    QVERIFY(uni[0] == (char) 255);
    QVERIFY(uni[1] == (char) 127);
    QVERIFY(uni[2] == (char) 0);

    s1->disarm();

    delete mts;
    delete doc;
}
Ejemplo n.º 15
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;
			}
		}
	}
}
Ejemplo n.º 16
0
void Chaser_Test::quickChaser()
{
    Fixture* fxi = new Fixture(m_doc);
    fxi->setAddress(0);
    fxi->setUniverse(0);
    fxi->setChannels(1);
    m_doc->addFixture(fxi);

    Chaser* c = new Chaser(m_doc);
    // A really quick chaser
    c->setDuration(0);
    m_doc->addFunction(c);

    Scene* s1 = new Scene(m_doc);
    s1->setValue(fxi->id(), 0, 255);
    m_doc->addFunction(s1);
    c->addStep(s1->id());

    Scene* s2 = new Scene(m_doc);
    s2->setValue(fxi->id(), 0, 127);
    m_doc->addFunction(s2);
    c->addStep(s2->id());

    MasterTimer timer(m_doc);

    QVERIFY(c->isRunning() == false);
    QVERIFY(c->stopped() == true);
    c->start(&timer, FunctionParent::master());

    timer.timerTick();
    for (uint i = 0; i < 12; ++i)
    {
        timer.timerTick();
        QVERIFY(c->isRunning() == true);
        QVERIFY(c->stopped() == false);
        // always one function running while the other is not
        QVERIFY(s1->isRunning() == true || s2->isRunning() == true);
        QVERIFY(s1->stopped() == true || s2->stopped() == true);
    }

    c->stop(FunctionParent::master());

    timer.timerTick();

    QVERIFY(c->isRunning() == false);
    QVERIFY(c->stopped() == true);
    QVERIFY(s1->isRunning() == false);
    QVERIFY(s1->stopped() == true);
    QVERIFY(s2->isRunning() == false);
    QVERIFY(s2->stopped() == true);
}
Ejemplo n.º 17
0
void IntensityGenerator_Test::sequenceScenes()
{
    Doc doc(this, m_fixtureDefCache);
    QList <Fixture*> fixtures;

    Fixture* fxi = new Fixture(&doc);
    fxi->setChannels(4);
    fixtures << fxi;

    Fixture* fxi2 = new Fixture(&doc);
    const QLCFixtureDef* def = m_fixtureDefCache.fixtureDef("Futurelight", "DJScan250");
    Q_ASSERT(def != NULL);
    Q_ASSERT(def->modes().first() != NULL);
    Q_ASSERT(def->modes().first()->channels().size() == 6);
    fxi2->setFixtureDefinition(def, def->modes().first());
    fixtures << fxi2;

    QList <Scene*> scenes = IntensityGenerator::sequenceScenes(fixtures, &doc);
    QCOMPARE(scenes.size(), 5);

    QCOMPARE(scenes[0]->values().size(), 1);
    QCOMPARE(scenes[0]->values()[0].fxi, fxi->id());
    QCOMPARE(scenes[0]->values()[0].channel, quint32(0));
    QCOMPARE(scenes[0]->values()[0].value, uchar(UCHAR_MAX));

    QCOMPARE(scenes[1]->values().size(), 1);
    QCOMPARE(scenes[1]->values()[0].fxi, fxi->id());
    QCOMPARE(scenes[1]->values()[0].channel, quint32(1));
    QCOMPARE(scenes[1]->values()[0].value, uchar(UCHAR_MAX));

    QCOMPARE(scenes[2]->values().size(), 1);
    QCOMPARE(scenes[2]->values()[0].fxi, fxi->id());
    QCOMPARE(scenes[2]->values()[0].channel, quint32(2));
    QCOMPARE(scenes[2]->values()[0].value, uchar(UCHAR_MAX));

    QCOMPARE(scenes[3]->values().size(), 1);
    QCOMPARE(scenes[3]->values()[0].fxi, fxi->id());
    QCOMPARE(scenes[3]->values()[0].channel, quint32(3));
    QCOMPARE(scenes[3]->values()[0].value, uchar(UCHAR_MAX));

    QCOMPARE(scenes[4]->values().size(), 1);
    QCOMPARE(scenes[4]->values()[0].fxi, fxi->id());
    QCOMPARE(scenes[4]->values()[0].channel, quint32(5));
    QCOMPARE(scenes[4]->values()[0].value, uchar(128));
}
Ejemplo n.º 18
0
void PhysicsWorld::FindAllCollisions() {
	contactManager.numOldContacts = contactManager.numContacts;
	assert(contactManager.numOldContacts < MaxNumContacts );
	memcpy(contactManager.oldContacts, contactManager.contacts, contactManager.numOldContacts * sizeof(Contact));
	contactManager.numContacts = 0;
	/*
		O(n^2) collsion detection ( or worse LOL )
		Check all fixtures vs all fixtures for collisions, 
		We dont collide fixtures that are from the same body
	*/ 
	for ( size_t i = 0; i < numBodies; i++ ) {
		for ( size_t j = i + 1; j < numBodies; j++ ) {
			if ( (bodies[i]->type != eDynamic && bodies[j]->type != eDynamic) ) {
				continue;
			}
			if ( contactManager.contactFilter && !contactManager.contactFilter->ShouldCollide(bodies[i], bodies[j]) ) {
				continue;
			}
			Fixture *fi = bodies[i]->GetFixtureList();
			while ( fi ) {
				Fixture *fj = bodies[j]->GetFixtureList();
				while ( fj ) {
					if ( fi->IsSensor( ) || fj->IsSensor( ) ) {
						if ( CheckOverlap(fi->GetShape(), bodies[i]->GetPosition(), fj->GetShape(), bodies[j]->GetPosition()) )	{
							contactManager.contactListener->OnSensor(fi, fj);
						}
					} else {
						// check collision and add to the contact list if they intersect
						contactManager.AddPair(fi, fj);
					}
					fj = fj->GetNext();
				}
				fi = fi->GetNext();
			}
		}
	}
	contactManager.MergeContacts();
}		
Ejemplo n.º 19
0
void Chaser_Test::write()
{
    Fixture* fxi = new Fixture(m_doc);
    fxi->setAddress(0);
    fxi->setUniverse(0);
    fxi->setChannels(1);
    m_doc->addFixture(fxi);

    Chaser* c = new Chaser(m_doc);
    c->setDuration(MasterTimer::tick() * 10);
    m_doc->addFunction(c);

    Scene* s1 = new Scene(m_doc);
    s1->setValue(fxi->id(), 0, 255);
    m_doc->addFunction(s1);
    c->addStep(s1->id());

    Scene* s2 = new Scene(m_doc);
    s2->setValue(fxi->id(), 0, 127);
    m_doc->addFunction(s2);
    c->addStep(s2->id());

    MasterTimer timer(m_doc);

    QVERIFY(c->isRunning() == false);
    QVERIFY(c->stopped() == true);
    c->start(&timer);

    timer.timerTick();
    for (uint i = MasterTimer::tick(); i < c->duration(); i += MasterTimer::tick())
    {
        timer.timerTick();
        QVERIFY(c->isRunning() == true);
        QVERIFY(c->stopped() == false);
        QVERIFY(s1->isRunning() == true);
        QVERIFY(s2->isRunning() == false);
    }

    for (uint i = 0; i < c->duration(); i += MasterTimer::tick())
    {
        timer.timerTick();
        QVERIFY(c->isRunning() == true);
        QVERIFY(c->stopped() == false);
        QVERIFY(s1->isRunning() == false);
        QVERIFY(s2->isRunning() == true);
    }
}
Ejemplo n.º 20
0
void Fixture_Test::loader()
{
    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly | QIODevice::Text);
    QXmlStreamWriter xmlWriter(&buffer);

    xmlWriter.writeStartElement("Fixture");

    xmlWriter.writeTextElement("Channels", "18");
    xmlWriter.writeTextElement("Name", "Foobar");
    xmlWriter.writeTextElement("Universe", "3");
    xmlWriter.writeTextElement("Model", "Foobar");
    xmlWriter.writeTextElement("Mode", "Foobar");
    xmlWriter.writeTextElement("Manufacturer", "Foobar");
    xmlWriter.writeTextElement("ID", "42");
    xmlWriter.writeTextElement("Address", "21");

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

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

    QVERIFY(m_doc != NULL);
    QVERIFY(m_doc->fixtures().size() == 0);

    QVERIFY(Fixture::loader(xmlReader, m_doc) == true);
    QVERIFY(m_doc->fixtures().size() == 1);
    QVERIFY(m_doc->fixture(0) == NULL); // No ID auto-assignment

    Fixture* fxi = m_doc->fixture(42);
    QVERIFY(fxi != NULL);
    QVERIFY(fxi->name() == "Foobar");
    QVERIFY(fxi->channels() == 18);
    QVERIFY(fxi->address() == 21);
    QVERIFY(fxi->universe() == 3);
    QVERIFY(fxi->fixtureDef() != NULL);
    QVERIFY(fxi->fixtureMode() != NULL);
}
Ejemplo n.º 21
0
void Contact::Destroy(Contact* contact, BlockAllocator* allocator)
{
    assert(s_initialized == true);

    Fixture* fixtureA = contact->m_fixtureA;
    Fixture* fixtureB = contact->m_fixtureB;

    if (contact->m_manifold.pointCount > 0 &&
            fixtureA->IsSensor() == false &&
            fixtureB->IsSensor() == false)
    {
        fixtureA->GetBody()->SetAwake(true);
        fixtureB->GetBody()->SetAwake(true);
    }

    Shape::Type typeA = fixtureA->GetType();
    Shape::Type typeB = fixtureB->GetType();

    assert(0 <= typeA && typeB < Shape::e_typeCount);
    assert(0 <= typeA && typeB < Shape::e_typeCount);

    ContactDestroyFcn* destroyFcn = s_registers[typeA][typeB].destroyFcn;
    destroyFcn(contact, allocator);
}
Ejemplo n.º 22
0
bool EFXFixture::isValid() const
{
    Fixture* fxi = doc()->fixture(head().fxi);

    if (fxi == NULL)
        return false;
    else if (head().head >= fxi->heads())
        return false;
    else if (m_mode == PanTilt && fxi->panMsbChannel(head().head) == QLCChannel::invalid() && // Maybe a device can pan OR tilt
             fxi->tiltMsbChannel(head().head) == QLCChannel::invalid())   // but not both. Teh sux0r.
        return false;
    else if (m_mode == Dimmer && fxi->masterIntensityChannel(head().head) == QLCChannel::invalid() )
        return false;
    else if (m_mode == RGB && fxi->rgbChannels(head().head).size () == 0)
        return false;
    else
        return true;
}
Ejemplo n.º 23
0
bool SceneEditor::isColorToolAvailable()
{
    FixtureConsole* fc;
    Fixture* fxi;
    QColor color;
    quint32 cyan, magenta, yellow;
    quint32 red, green, blue;

    /* QObject cast fails unless the widget is a FixtureConsole */
    fc = qobject_cast<FixtureConsole*> (m_tab->currentWidget());
    if (fc == NULL)
        return false;

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

    cyan = fxi->channel("cyan", Qt::CaseInsensitive, QLCChannel::Colour);
    magenta = fxi->channel("magenta", Qt::CaseInsensitive, QLCChannel::Colour);
    yellow = fxi->channel("yellow", Qt::CaseInsensitive, QLCChannel::Colour);
    red = fxi->channel("red", Qt::CaseInsensitive, QLCChannel::Colour);
    green = fxi->channel("green", Qt::CaseInsensitive, QLCChannel::Colour);
    blue = fxi->channel("blue", Qt::CaseInsensitive, QLCChannel::Colour);

    if (cyan != QLCChannel::invalid() && magenta != QLCChannel::invalid() &&
            yellow != QLCChannel::invalid())
    {
        return true;
    }
    else if (red != QLCChannel::invalid() && green != QLCChannel::invalid() &&
             blue != QLCChannel::invalid())
    {
        return true;
    }
    else
    {
        return false;
    }
}
Ejemplo n.º 24
0
void IntensityGenerator_Test::fullZeroScenes()
{
    Doc doc(this, m_fixtureDefCache);

    QList <Fixture*> fixtures;

    Fixture* fxi = new Fixture(&doc);
    fxi->setChannels(4);
    fixtures << fxi;

    Fixture* fxi2 = new Fixture(&doc);
    const QLCFixtureDef* def = m_fixtureDefCache.fixtureDef("Futurelight", "DJScan250");
    Q_ASSERT(def != NULL);
    Q_ASSERT(def->modes().first() != NULL);
    Q_ASSERT(def->modes().first()->channels().size() == 6);
    fxi2->setFixtureDefinition(def, def->modes().first());
    fixtures << fxi2;

    QList <Scene*> scenes = IntensityGenerator::fullZeroScenes(fixtures, &doc);
    QCOMPARE(scenes.size(), 2);

    QCOMPARE(scenes[1]->values().size(), 0);
    QCOMPARE(scenes[0]->values().size(), 5);
    QCOMPARE(scenes[0]->values()[0].fxi, fxi->id());
    QCOMPARE(scenes[0]->values()[0].channel, quint32(0));
    QCOMPARE(scenes[0]->values()[0].value, uchar(UCHAR_MAX));
    QCOMPARE(scenes[0]->values()[1].fxi, fxi->id());
    QCOMPARE(scenes[0]->values()[1].channel, quint32(1));
    QCOMPARE(scenes[0]->values()[1].value, uchar(UCHAR_MAX));
    QCOMPARE(scenes[0]->values()[2].fxi, fxi->id());
    QCOMPARE(scenes[0]->values()[2].channel, quint32(2));
    QCOMPARE(scenes[0]->values()[2].value, uchar(UCHAR_MAX));
    QCOMPARE(scenes[0]->values()[3].fxi, fxi->id());
    QCOMPARE(scenes[0]->values()[3].channel, quint32(3));
    QCOMPARE(scenes[0]->values()[3].value, uchar(UCHAR_MAX));
    QCOMPARE(scenes[0]->values()[4].fxi, fxi2->id());
    QCOMPARE(scenes[0]->values()[4].channel, quint32(5));
    QCOMPARE(scenes[0]->values()[4].value, uchar(128));

    QCOMPARE(scenes[1]->values().size(), 0);
    // Zero scene needs no values because non-participating HTP channels are faded
    // automatically to zero
}
Ejemplo n.º 25
0
void Collection_Test::armMissingFunction()
{
	Doc* doc = new Doc(this, m_cache);

	Fixture* fxi = new Fixture(doc);
	fxi->setName("Test Fixture");
	fxi->setAddress(0);
	fxi->setUniverse(0);
	fxi->setChannels(2);
	doc->addFixture(fxi);

	Scene* s1 = new Scene(doc);
	s1->setName("Scene1");
	s1->setValue(fxi->id(), 0, UCHAR_MAX);
	s1->setValue(fxi->id(), 1, UCHAR_MAX);
	doc->addFunction(s1);

	Scene* s2 = new Scene(doc);
	s2->setName("Scene2");
	s2->setValue(fxi->id(), 0, 0);
	s2->setValue(fxi->id(), 1, 0);
	doc->addFunction(s2);

	Collection* c = new Collection(doc);
	c->setName("Collection");
	c->addFunction(s1->id());
	c->addFunction(123); // Nonexistent function
	c->addFunction(s2->id());
	c->addFunction(55); // Nonexistent function

	QVERIFY(c->functions().size() == 4);
	c->arm();
	QVERIFY(c->functions().size() == 2); // Nonexistent functions are removed

	delete doc;
}
Ejemplo n.º 26
0
void Collection_Test::armSuccess()
{
	Doc* doc = new Doc(this, m_cache);

	Fixture* fxi = new Fixture(doc);
	fxi->setName("Test Fixture");
	fxi->setAddress(0);
	fxi->setUniverse(0);
	fxi->setChannels(2);
	doc->addFixture(fxi);

	Scene* s1 = new Scene(doc);
	s1->setName("Scene1");
	s1->setValue(fxi->id(), 0, UCHAR_MAX);
	s1->setValue(fxi->id(), 1, UCHAR_MAX);
	doc->addFunction(s1);
	QVERIFY(s1->id() != Function::invalidId());

	Scene* s2 = new Scene(doc);
	s2->setName("Scene2");
	s2->setValue(fxi->id(), 0, 0);
	s2->setValue(fxi->id(), 1, 0);
	doc->addFunction(s2);
	QVERIFY(s2->id() != Function::invalidId());

	Collection* c = new Collection(doc);
	c->setName("Collection");
	c->addFunction(s1->id());
	c->addFunction(s2->id());

	QVERIFY(c->functions().size() == 2);
	c->arm();
	QVERIFY(c->functions().size() == 2);

	delete doc;
}
Ejemplo n.º 27
0
bool Doc::replaceFixtures(QList<Fixture*> newFixturesList)
{
    // Delete all fixture instances
    QListIterator <quint32> fxit(m_fixtures.keys());
    while (fxit.hasNext() == true)
    {
        Fixture* fxi = m_fixtures.take(fxit.next());
        delete fxi;
    }
    m_latestFixtureId = 0;
    m_addresses.clear();

    foreach(Fixture *fixture, newFixturesList)
    {
        quint32 id = fixture->id();
        // create a copy of the original cause remapping will
        // destroy it later
        Fixture *newFixture = new Fixture(this);
        newFixture->setID(id);
        newFixture->setName(fixture->name());
        newFixture->setAddress(fixture->address());
        newFixture->setUniverse(fixture->universe());
        if (fixture->fixtureDef() != NULL && fixture->fixtureMode() != NULL)
        {
            QLCFixtureDef *def = fixtureDefCache()->fixtureDef(fixture->fixtureDef()->manufacturer(),
                                                               fixture->fixtureDef()->model());
            QLCFixtureMode *mode = NULL;
            if (def != NULL)
                mode = def->mode(fixture->fixtureMode()->name());
            newFixture->setFixtureDefinition(def, mode);
        }
        else
            newFixture->setChannels(fixture->channels());
        newFixture->setExcludeFadeChannels(fixture->excludeFadeChannels());
        m_fixtures.insert(id, newFixture);

        /* Patch fixture change signals thru Doc */
        connect(newFixture, SIGNAL(changed(quint32)),
                this, SLOT(slotFixtureChanged(quint32)));

        /* Keep track of fixture addresses */
        for (uint i = newFixture->universeAddress();
             i < newFixture->universeAddress() + newFixture->channels(); i++)
        {
            m_addresses[i] = id;
        }
        m_latestFixtureId = id;
    }
Ejemplo n.º 28
0
void Doc::clearContents()
{
    emit clearing();

    m_clipboard->resetContents();

    if (m_monitorProps != NULL)
        m_monitorProps->reset();

    destroyAudioCapture();

    // Delete all function instances
    QListIterator <quint32> funcit(m_functions.keys());
    while (funcit.hasNext() == true)
    {
        Function* func = m_functions.take(funcit.next());
        if (func == NULL)
            continue;
        emit functionRemoved(func->id());
        delete func;
    }

    // Delete all fixture groups
    QListIterator <quint32> grpit(m_fixtureGroups.keys());
    while (grpit.hasNext() == true)
    {
        FixtureGroup* grp = m_fixtureGroups.take(grpit.next());
        quint32 grpID = grp->id();
        delete grp;
        emit fixtureGroupRemoved(grpID);
    }

    // Delete all fixture instances
    QListIterator <quint32> fxit(m_fixtures.keys());
    while (fxit.hasNext() == true)
    {
        Fixture* fxi = m_fixtures.take(fxit.next());
        quint32 fxID = fxi->id();
        delete fxi;
        emit fixtureRemoved(fxID);
    }

    // Delete all channels groups
    QListIterator <quint32> grpchans(m_channelsGroups.keys());
    while (grpchans.hasNext() == true)
    {
        ChannelsGroup* grp = m_channelsGroups.take(grpchans.next());
        emit channelsGroupRemoved(grp->id());
        delete grp;
    }

    m_orderedGroups.clear();

    m_latestFunctionId = 0;
    m_latestFixtureId = 0;
    m_latestFixtureGroupId = 0;
    m_latestChannelsGroupId = 0;
    m_addresses.clear();

    emit cleared();
}
Ejemplo n.º 29
0
void AddFixture_Test::initialScanner()
{
    Fixture* fxi = new Fixture(m_doc);
    fxi->setName("My scanner");

    QLCFixtureDef* def = m_doc->fixtureDefCache()->fixtureDef("Martin", "MAC300");
    Q_ASSERT(def != NULL);
    Q_ASSERT(def != NULL);
    Q_ASSERT(def->channels().size() > 0);
    QLCFixtureMode* mode = def->modes().first();
    Q_ASSERT(def->modes().size() > 1);

    fxi->setFixtureDefinition(def, mode);
    fxi->setUniverse(2);
    fxi->setAddress(484);
    m_doc->addFixture(fxi);

    AddFixture af(NULL, m_doc, fxi);
    QVERIFY(m_doc == af.m_doc);
    QVERIFY(af.fixtureDef() == def);
    QVERIFY(af.mode() == mode);
    QVERIFY(af.name() == QString("My scanner"));
    QVERIFY(af.address() == 484);
    QVERIFY(af.universe() == 2);
    QVERIFY(af.amount() == 1);
    QVERIFY(af.gap() == 0);
    QVERIFY(af.channels() == fxi->channels());

    // Check that all makes & models are put to the tree
    QStringList makers(m_doc->fixtureDefCache()->manufacturers());
    QVERIFY(makers.isEmpty() == false);
    for (int i = 0; i < af.m_tree->topLevelItemCount(); i++)
    {
        QTreeWidgetItem* top = af.m_tree->topLevelItem(i);

        if (top->text(0) != KXMLFixtureGeneric)
        {
            QStringList models(m_doc->fixtureDefCache()->models(top->text(0)));
            for (int j = 0; j < top->childCount(); j++)
            {
                QTreeWidgetItem* child = top->child(j);
                QCOMPARE(child->childCount(), 0);
                QCOMPARE(models.removeAll(child->text(0)), 1);
            }

            QCOMPARE(makers.removeAll(top->text(0)), 1);
        }
        else
        {
            QCOMPARE(i, af.m_tree->topLevelItemCount() - 1); // Generic should be last
            QCOMPARE(top->childCount(), 3);
            QCOMPARE(top->child(0)->text(0), QString(KXMLFixtureGeneric));

            QStringList models(m_doc->fixtureDefCache()->models(top->text(0)));
            for (int j = 0; j < top->childCount(); j++)
            {
                QTreeWidgetItem* child = top->child(j);
                QCOMPARE(child->childCount(), 0);
                QCOMPARE(models.removeAll(child->text(0)), child->text(0) == KXMLFixtureGeneric ? 0 : 1);
            }

            QCOMPARE(makers.removeAll(top->text(0)), 1);
        }
    }
    QVERIFY(makers.isEmpty() == true);

    // Generic / Generic should be selected for dimmers
    QVERIFY(af.m_tree->currentItem() != NULL);
    QCOMPARE(af.m_tree->currentItem()->text(0), def->model());
    QVERIFY(af.m_tree->currentItem()->parent() != NULL);
    QCOMPARE(af.m_tree->currentItem()->parent()->text(0), def->manufacturer());

    QVERIFY(af.m_modeCombo->isEnabled() == true);
    QCOMPARE(af.m_modeCombo->count(), def->modes().size());
    QCOMPARE(af.m_modeCombo->itemText(0), mode->name());

    QVERIFY(af.m_universeCombo->isEnabled() == true);
    QCOMPARE(af.m_universeCombo->currentIndex(), 2);
    QCOMPARE(af.m_universeCombo->count(), 4);

    QVERIFY(af.m_addressSpin->isEnabled() == true);
    QCOMPARE(af.m_addressSpin->value(), 485);

    QVERIFY(af.m_channelsSpin->isEnabled() == false);
    QCOMPARE(af.m_channelsSpin->value(), (int) fxi->channels());

    QVERIFY(af.m_nameEdit->isEnabled() == true);
    QCOMPARE(af.m_nameEdit->text(), QString("My scanner"));
    QVERIFY(af.m_nameEdit->isModified() == true);

    QVERIFY(af.m_multipleGroup->isEnabled() == false);
    QVERIFY(af.m_gapSpin->isEnabled() == false);
    QCOMPARE(af.m_gapSpin->value(), 0);

    QVERIFY(af.m_amountSpin->isEnabled() == false);
    QCOMPARE(af.m_amountSpin->value(), 1);
}
Ejemplo n.º 30
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;
}