void QLCFixtureMode_Test::removeChannel() { QLCFixtureMode* mode = new QLCFixtureMode(m_fixtureDef); mode->insertChannel(m_ch1, 0); mode->insertChannel(m_ch2, 1); mode->insertChannel(m_ch3, 2); mode->insertChannel(m_ch4, 3); /* Remove one channel in the middle */ QVERIFY(mode->channels().size() == 4); mode->removeChannel(m_ch2); QVERIFY(mode->channels().size() == 3); QVERIFY(mode->channel(0) == m_ch1); QVERIFY(mode->channel(1) == m_ch3); QVERIFY(mode->channel(2) == m_ch4); QVERIFY(mode->channel(3) == NULL); /* Remove the same channel again. Shouldn't change anything. */ mode->removeChannel(m_ch2); QVERIFY(mode->channels().size() == 3); QVERIFY(mode->channel(0) == m_ch1); QVERIFY(mode->channel(1) == m_ch3); QVERIFY(mode->channel(2) == m_ch4); QVERIFY(mode->channel(3) == NULL); /* Remove last channel. */ mode->removeChannel(m_ch4); QVERIFY(mode->channels().size() == 2); QVERIFY(mode->channel(0) == m_ch1); QVERIFY(mode->channel(1) == m_ch3); QVERIFY(mode->channel(2) == NULL); QVERIFY(mode->channel(3) == NULL); /* Remove first channel. */ mode->removeChannel(m_ch1); QVERIFY(mode->channels().size() == 1); QVERIFY(mode->channel(0) == m_ch3); QVERIFY(mode->channel(1) == NULL); QVERIFY(mode->channel(2) == NULL); QVERIFY(mode->channel(3) == NULL); /* Remove last channel. */ mode->removeChannel(m_ch3); QVERIFY(mode->channels().size() == 0); QVERIFY(mode->channel(0) == NULL); QVERIFY(mode->channel(1) == NULL); QVERIFY(mode->channel(2) == NULL); QVERIFY(mode->channel(3) == NULL); delete mode; }
void QLCFixtureMode_Test::channelByIndex() { QLCFixtureMode* mode = new QLCFixtureMode(m_fixtureDef); mode->insertChannel(m_ch1, 0); mode->insertChannel(m_ch2, 1); mode->insertChannel(m_ch3, 2); mode->insertChannel(m_ch4, 3); QVERIFY(mode->channel(0) == m_ch1); QVERIFY(mode->channel(1) == m_ch2); QVERIFY(mode->channel(2) == m_ch3); QVERIFY(mode->channel(3) == m_ch4); QVERIFY(mode->channel(12) == NULL); delete mode; }
void QLCFixtureMode_Test::channelByName() { QLCFixtureMode* mode = new QLCFixtureMode(m_fixtureDef); mode->insertChannel(m_ch1, 0); mode->insertChannel(m_ch2, 1); mode->insertChannel(m_ch3, 2); mode->insertChannel(m_ch4, 3); QVERIFY(mode->channel("Channel 1") == m_ch1); QVERIFY(mode->channel("Channel 2") == m_ch2); QVERIFY(mode->channel("Channel 3") == m_ch3); QVERIFY(mode->channel("Channel 4") == m_ch4); QVERIFY(mode->channel("Foobar") == NULL); QVERIFY(mode->channel("") == NULL); delete mode; }
void QLCFixtureMode_Test::copy() { QLCFixtureMode* mode = new QLCFixtureMode(m_fixtureDef); mode->setName("Test Mode"); mode->insertChannel(m_ch1, 0); mode->insertChannel(m_ch2, 1); mode->insertChannel(m_ch3, 2); mode->insertChannel(m_ch4, 3); /* Create a copy of the mode to the same fixtureDef as the original */ QLCFixtureMode* copy = new QLCFixtureMode(m_fixtureDef, mode); QVERIFY(copy != NULL); QVERIFY(copy->name() == "Test Mode"); QVERIFY(copy->channels().size() == 4); QVERIFY(copy->channel(0) == m_ch1); QVERIFY(copy->channel(1) == m_ch2); QVERIFY(copy->channel(2) == m_ch3); QVERIFY(copy->channel(3) == m_ch4); delete copy; copy = NULL; /* Create another fixture def with some channels matching, some not */ QLCFixtureDef* anotherDef = new QLCFixtureDef(); QLCChannel* ch1 = new QLCChannel(); ch1->setName("Channel 1"); // Should match anotherDef->addChannel(ch1); QLCChannel* ch2 = new QLCChannel(); ch2->setName("Channel 2, not the same name"); // Shouldn't match anotherDef->addChannel(ch2); QLCChannel* ch3 = new QLCChannel(); ch3->setName("Channel 3, still not the same name"); // Shouldn't match anotherDef->addChannel(ch3); QLCChannel* ch4 = new QLCChannel(); ch4->setName("Channel 4"); // Should match anotherDef->addChannel(ch4); QLCChannel* ch5 = new QLCChannel(); ch5->setName("Channel 5"); // Shouldn't match since original has 4 chans anotherDef->addChannel(ch5); /* Create a copy of the mode to the other fixtureDef */ copy = new QLCFixtureMode(anotherDef, mode); QVERIFY(copy->name() == "Test Mode"); QVERIFY(copy->channels().size() == 2); QVERIFY(copy->channel(0)->name() == "Channel 1"); QVERIFY(copy->channel(0) == ch1); QVERIFY(copy->channel(1)->name() == "Channel 4"); QVERIFY(copy->channel(1) == ch4); delete copy; delete anotherDef; }
void QLCFixtureMode_Test::insertChannel() { QLCFixtureMode* mode = new QLCFixtureMode(m_fixtureDef); mode->setName("Test"); QVERIFY(mode->insertChannel(NULL, 0) == false); QVERIFY(mode->channels().size() == 0); /* Channel that doesn't belong to mode->fixtureDef() */ QLCChannel* ch = new QLCChannel(); ch->setName("Rogue"); mode->insertChannel(ch, 0); QVERIFY(mode->channels().size() == 0); delete ch; /* First channel */ mode->insertChannel(m_ch1, 0); QVERIFY(mode->channel(0) == m_ch1); /* Second prepended */ mode->insertChannel(m_ch2, 0); QVERIFY(mode->channel(0) == m_ch2); QVERIFY(mode->channel(1) == m_ch1); /* Third appended way over the end */ mode->insertChannel(m_ch3, 10); QVERIFY(mode->channel(0) == m_ch2); QVERIFY(mode->channel(1) == m_ch1); QVERIFY(mode->channel(2) == m_ch3); /* Fourth inserted in-between */ mode->insertChannel(m_ch4, 1); QVERIFY(mode->channel(0) == m_ch2); QVERIFY(mode->channel(1) == m_ch4); QVERIFY(mode->channel(2) == m_ch1); QVERIFY(mode->channel(3) == m_ch3); delete mode; }
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; }
/** * 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; }