void CueStack_Test::flash() { CueStack cs(m_doc); QCOMPARE(cs.isFlashing(), false); QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 0); // Disable flashing when it's already disabled -> fail cs.setFlashing(false); QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 0); QCOMPARE(cs.isFlashing(), false); cs.setFlashing(false); QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 0); QCOMPARE(cs.isFlashing(), false); // Enable flashing without cues -> fail cs.setFlashing(true); QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 0); QCOMPARE(cs.isFlashing(), false); Cue cue; cue.setValue(0, 255); cue.setValue(128, 42); cs.appendCue(cue); QList<Universe*> ua; ua.append(new Universe(0, new GrandMaster())); ua.at(0)->setChannelCapability(0, QLCChannel::Intensity); ua.at(0)->setChannelCapability(128, QLCChannel::Intensity); cs.setFlashing(true); QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 1); QCOMPARE(cs.isFlashing(), true); cs.writeDMX(m_doc->masterTimer(), ua); QCOMPARE(ua[0]->preGMValues()[0], (char) 255); QCOMPARE(ua[0]->preGMValues()[128], (char) 42); ua[0]->zeroIntensityChannels(); cs.setFlashing(true); QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 1); cs.writeDMX(m_doc->masterTimer(), ua); QCOMPARE(ua[0]->preGMValues()[0], (char) 255); QCOMPARE(ua[0]->preGMValues()[128], (char) 42); ua[0]->zeroIntensityChannels(); cs.setFlashing(false); QCOMPARE(cs.isFlashing(), false); QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 0); cs.writeDMX(m_doc->masterTimer(), ua); QCOMPARE(ua[0]->preGMValues()[0], (char) 0); QCOMPARE(ua[0]->preGMValues()[128], (char) 0); ua[0]->zeroIntensityChannels(); }
void CueStack_Test::postRun() { QLCFixtureDef* def = m_doc->fixtureDefCache()->fixtureDef("Futurelight", "DJScan250"); QVERIFY(def != NULL); QLCFixtureMode* mode = def->modes().first(); QVERIFY(mode != NULL); Fixture* fxi = new Fixture(m_doc); fxi->setFixtureDefinition(def, mode); fxi->setName("Test Scanner"); fxi->setAddress(10); fxi->setUniverse(0); m_doc->addFixture(fxi); MasterTimer mt(m_doc); QList<Universe*> ua; ua.append(new Universe(0, new GrandMaster())); CueStack cs(m_doc); cs.setFadeInSpeed(100); cs.setFadeOutSpeed(200); cs.setDuration(300); Cue cue; cue.setName("One"); cue.setValue(0, 255); cue.setValue(1, 255); cue.setValue(500, 255); cue.setValue(10, 255); // LTP cue.setValue(11, 255); // LTP cs.appendCue(cue); cue = Cue(); cue.setName("Two"); cue.setValue(500, 255); cue.setValue(3, 255); cue.setValue(4, 255); cue.setValue(11, 255); // LTP cs.appendCue(cue); cs.preRun(); // Switch to cue one cs.switchCue(-1, 0, ua); QCOMPARE(cs.m_fader->channels().size(), 5); QSignalSpy cueSpy(&cs, SIGNAL(currentCueChanged(int))); QSignalSpy stopSpy(&cs, SIGNAL(stopped())); cs.postRun(&mt); QCOMPARE(cs.m_fader, (GenericFader*) NULL); QCOMPARE(cs.m_currentIndex, -1); QCOMPARE(cueSpy.size(), 1); QCOMPARE(cueSpy.at(0).size(), 1); QCOMPARE(cueSpy.at(0).at(0).toInt(), -1); QCOMPARE(stopSpy.size(), 1); // Only HTP channels go to MasterTimer's GenericFader QCOMPARE(mt.m_fader->channels().size(), 3); FadeChannel fc; fc.setChannel(0); QCOMPARE(mt.m_fader->channels().contains(fc), true); fc.setChannel(1); QCOMPARE(mt.m_fader->channels().contains(fc), true); fc.setChannel(500); QCOMPARE(mt.m_fader->channels().contains(fc), true); }
void CueStack_Test::switchCue() { QLCFixtureDef* def = m_doc->fixtureDefCache()->fixtureDef("Futurelight", "DJScan250"); QVERIFY(def != NULL); QLCFixtureMode* mode = def->modes().first(); QVERIFY(mode != NULL); Fixture* fxi = new Fixture(m_doc); fxi->setFixtureDefinition(def, mode); fxi->setName("Test Scanner"); fxi->setAddress(10); fxi->setUniverse(0); m_doc->addFixture(fxi); QList<Universe*> ua; ua.append(new Universe(0, new GrandMaster())); CueStack cs(m_doc); cs.setFadeInSpeed(100); cs.setFadeOutSpeed(200); cs.setDuration(300); Cue cue; cue.setName("One"); cue.setValue(0, 255); cue.setValue(1, 255); cue.setValue(500, 255); cue.setValue(10, 255); // LTP cue.setValue(11, 255); // LTP cue.setFadeInSpeed(20); cue.setFadeOutSpeed(40); cs.appendCue(cue); cue = Cue(); cue.setName("Two"); cue.setValue(500, 255); cue.setValue(3, 255); cue.setValue(4, 255); cue.setValue(11, 255); // LTP cue.setFadeInSpeed(60); cue.setFadeOutSpeed(80); cs.appendCue(cue); cs.preRun(); // Do nothing with invalid cue indices cs.switchCue(-1, -1, ua); QCOMPARE(cs.m_fader->channels().size(), 0); cs.switchCue(-1, 3, ua); QCOMPARE(cs.m_fader->channels().size(), 0); // Switch to cue one cs.switchCue(3, 0, ua); QCOMPARE(cs.m_fader->channels().size(), 5); FadeChannel fc; fc.setChannel(0); QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(255)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(0)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(20)); fc.setChannel(1); QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(255)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(1)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(20)); fc.setChannel(10); QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(255)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(10)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(20)); fc.setChannel(11); QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(255)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(11)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(20)); fc.setChannel(500); QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(255)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(500)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(20)); fc.setChannel(3); QCOMPARE(cs.m_fader->channels()[fc].channel(), QLCChannel::invalid()); fc.setChannel(4); QCOMPARE(cs.m_fader->channels()[fc].channel(), QLCChannel::invalid()); fc.setChannel(0); cs.m_fader->m_channels[fc].setCurrent(127); fc.setChannel(1); cs.m_fader->m_channels[fc].setCurrent(127); fc.setChannel(10); cs.m_fader->m_channels[fc].setCurrent(127); fc.setChannel(11); cs.m_fader->m_channels[fc].setCurrent(127); fc.setChannel(500); cs.m_fader->m_channels[fc].setCurrent(127); // Switch to cue two cs.switchCue(0, 1, ua); QCOMPARE(cs.m_fader->channels().size(), 7); fc.setChannel(0); QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(127)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(127)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(0)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(40)); fc.setChannel(1); QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(127)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(127)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(1)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(40)); fc.setChannel(11); // LTP channel also in the next cue QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(127)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(127)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(255)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(11)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(60)); fc.setChannel(500); QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(127)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(127)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(255)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(500)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(60)); fc.setChannel(3); QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(255)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(3)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(60)); fc.setChannel(4); QCOMPARE(cs.m_fader->channels()[fc].start(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].current(), uchar(0)); QCOMPARE(cs.m_fader->channels()[fc].target(), uchar(255)); QCOMPARE(cs.m_fader->channels()[fc].channel(), uint(4)); QCOMPARE(cs.m_fader->channels()[fc].fadeTime(), uint(60)); // Stop cs.switchCue(1, -1, ua); QCOMPARE(cs.m_fader->channels().size(), 7); MasterTimer mt(m_doc); cs.postRun(&mt); }