void Chaser_Test::tap() { Scene* s1 = new Scene(m_doc); m_doc->addFunction(s1); Scene* s2 = new Scene(m_doc); m_doc->addFunction(s2); Scene* s3 = new Scene(m_doc); m_doc->addFunction(s3); Scene* s4 = new Scene(m_doc); m_doc->addFunction(s4); Chaser* c = new Chaser(m_doc); c->addStep(s1->id()); c->addStep(s2->id()); c->addStep(s3->id()); c->addStep(s4->id()); m_doc->addFunction(c); c->preRun(m_doc->masterTimer()); QVERIFY(c->m_runner != NULL); QCOMPARE(c->duration(), uint(0)); c->write(m_doc->masterTimer(), QList<Universe*>()); QCOMPARE(c->m_runner->m_next, false); c->tap(); QTest::qWait(MasterTimer::tick()); c->tap(); QCOMPARE(c->m_runner->m_next, true); }
static Chaser* createChaser(Doc* doc) { Fixture* fxi = new Fixture(doc); fxi->setChannels(1); doc->addFixture(fxi); Scene* s1 = new Scene(doc); s1->setName("First"); s1->setValue(fxi->id(), 0, 255); doc->addFunction(s1); Scene* s2 = new Scene(doc); s2->setName("Second"); s2->setValue(fxi->id(), 0, 127); doc->addFunction(s2); Scene* s3 = new Scene(doc); s3->setName("Third"); s3->setValue(fxi->id(), 0, 64); doc->addFunction(s3); Scene* s4 = new Scene(doc); s4->setName("Fourth"); s4->setValue(fxi->id(), 0, 32); doc->addFunction(s4); Chaser* c = new Chaser(doc); c->addStep(ChaserStep(s1->id())); c->addStep(ChaserStep(s2->id())); c->addStep(ChaserStep(s3->id())); c->addStep(ChaserStep(s4->id())); doc->addFunction(c); return c; }
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); }
void FunctionWizard::accept() { PaletteGenerator pal(m_doc, fixtures()); if (m_coloursCheck->isChecked() == true) pal.createColours(); if (m_goboCheck->isChecked() == true) pal.createGobos(); if (m_shutterCheck->isChecked() == true) pal.createShutters(); if (m_intensityCheck->isChecked() == true) { QList <Scene*> sceneList; // Random chaser sceneList = IntensityGenerator::randomScenes(fixtures(), m_doc, QDateTime::currentDateTime().toTime_t()); if (sceneList.size() > 0) { int i = 0; Chaser* chaser = new Chaser(m_doc); chaser->setName(tr("Random Multi")); m_doc->addFunction(chaser); foreach (Scene* scene, sceneList) { scene->setName(tr("Random Step %1").arg(++i)); m_doc->addFunction(scene); chaser->addStep(scene->id()); }
bool IntensityGenerator::createSequenceChaser(bool forward) { // Create a sequence chaser Chaser* chaser = new Chaser(m_doc); if (forward == true) { chaser->setName("Intensity - Sequence Forward"); chaser->setDirection(Function::Forward); } else { chaser->setName("Intensity - Sequence Backward"); chaser->setDirection(Function::Backward); } if (m_doc->addFunction(chaser) == false) { // Abort if doc won't accept the chaser delete chaser; return false; } else { for (int i = 0; i < m_sequence.size(); i++) chaser->addStep(m_sequence[i]->id()); return true; } }
bool IntensityGenerator::createRandomChaser() { if (m_random.size() == 0) return false; // Abort if doc can't fit the chaser and its members if (m_doc->functionsFree() < quint32(m_random.size() + 1)) return false; // Abort immediately if doc won't take all sequence steps QListIterator <Scene*> it(m_random); while (it.hasNext() == true) { if (m_doc->addFunction(it.next()) == false) return false; } // Create the random chaser Chaser* chaser = new Chaser(m_doc); chaser->setName("Intensity - Random"); if (m_doc->addFunction(chaser) == false) { // Abort if doc won't accept the chaser delete chaser; return false; } else { for (int i = 0; i < m_random.size(); i++) chaser->addStep(m_random[i]->id()); return true; } }
void Chaser_Test::tap() { Doc* doc = new Doc(this, m_cache); Fixture* fxi = new Fixture(doc); 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); Chaser* c = new Chaser(doc); c->setName("Chaser"); c->setRunOrder(Chaser::PingPong); c->setDirection(Chaser::Backward); c->addStep(s1->id()); QVERIFY(c->m_tapped == false); c->slotBusTapped(Bus::defaultFade()); QVERIFY(c->m_tapped == false); c->slotBusTapped(Bus::defaultHold()); QVERIFY(c->m_tapped == true); delete doc; }
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); } }
bool IntensityGenerator::createOddEvenChaser() { if (m_odd == NULL || m_even == NULL) return false; // Abort if doc can't fit the chaser and its two members if (m_doc->functionsFree() < 3) return false; // Create the chaser only if both steps contain something if (m_odd->values().size() != 0 && m_even->values().size() != 0) { // Abort if doc won't take the scenes if (m_doc->addFunction(m_odd) == false) return false; if (m_doc->addFunction(m_even) == false) return false; Chaser* chaser = new Chaser(m_doc); chaser->setName("Intensity - Even/Odd"); chaser->addStep(m_odd->id()); chaser->addStep(m_even->id()); // Abort if doc won't take the chaser if (m_doc->addFunction(chaser) == false) { delete chaser; return false; } else { return true; } } else { return false; } }
void Chaser_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); Chaser* c = new Chaser(doc); c->setName("Chaser"); c->addStep(s1->id()); c->addStep(123); // Nonexistent function c->addStep(s2->id()); c->addStep(55); // Nonexistent function QVERIFY(c->steps().size() == 4); c->arm(); QVERIFY(c->steps().size() == 2); // Nonexistent functions are removed delete doc; }
void VCCueList::addFunctions(QVariantList idsList, int insertIndex) { if (idsList.isEmpty()) return; if (isEditing()) { Chaser *ch = chaser(); if (ch == NULL) return; if (insertIndex == -1) insertIndex = ch->stepsCount(); for (QVariant vID : idsList) // C++11 { quint32 fid = vID.toUInt(); ChaserStep step(fid); if (ch->durationMode() == Chaser::PerStep) { Function *func = m_doc->function(fid); if (func == NULL) continue; step.duration = func->totalDuration(); if (step.duration == 0) step.duration = 1000; step.hold = step.duration; } Tardis::instance()->enqueueAction(Tardis::ChaserAddStep, ch->id(), QVariant(), insertIndex); ch->addStep(step, insertIndex++); } ChaserEditor::updateStepsList(m_doc, chaser(), m_stepsList); emit stepsListChanged(); } else { Function *f = m_doc->function(idsList.first().toUInt()); if (f == NULL || f->type() != Function::ChaserType) return; setChaserID(f->id()); } }
void Chaser_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()); Chaser* c = new Chaser(doc); c->setName("Chaser"); c->addStep(s1->id()); c->addStep(s2->id()); QVERIFY(c->steps().size() == 2); c->arm(); QVERIFY(c->steps().size() == 2); delete doc; }
void Chaser_Test::writeBusZeroPingPongForward() { Doc* doc = new Doc(this, m_cache); Bus::instance()->setValue(Bus::defaultFade(), 0); Bus::instance()->setValue(Bus::defaultHold(), 0); Fixture* fxi = new Fixture(doc); 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, 127); s2->setValue(fxi->id(), 1, 127); doc->addFunction(s2); Scene* s3 = new Scene(doc); s3->setName("Scene2"); s3->setValue(fxi->id(), 0, 0); s3->setValue(fxi->id(), 1, 0); doc->addFunction(s3); Chaser* c = new Chaser(doc); c->setName("Chaser"); c->setRunOrder(Chaser::PingPong); c->addStep(s1->id()); c->addStep(s2->id()); c->addStep(s3->id()); s1->arm(); s2->arm(); s3->arm(); c->arm(); QByteArray uni; MasterTimerStub* mts = new MasterTimerStub(this, NULL, uni); QVERIFY(c->stopped() == true); mts->startFunction(c); QVERIFY(c->stopped() == false); /* Since hold bus' value is 0 each call to write() starts the next step in chaser. Last step comes first because the chaser is now running backwards. */ c->write(mts, &uni); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s1); QVERIFY(s1->stopped() == false); c->write(mts, &uni); QVERIFY(s1->stopped() == true); mts->stopFunction(s1); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s2); QVERIFY(s2->stopped() == false); c->write(mts, &uni); QVERIFY(s2->stopped() == true); mts->stopFunction(s2); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s3); QVERIFY(s3->stopped() == false); c->write(mts, &uni); QVERIFY(s3->stopped() == true); mts->stopFunction(s3); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s2); QVERIFY(s2->stopped() == false); c->write(mts, &uni); QVERIFY(s2->stopped() == true); mts->stopFunction(s2); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s1); QVERIFY(s1->stopped() == false); c->write(mts, &uni); QVERIFY(s1->stopped() == true); mts->stopFunction(s1); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s2); QVERIFY(s2->stopped() == false); c->write(mts, &uni); QVERIFY(s2->stopped() == true); mts->stopFunction(s2); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s3); QVERIFY(s3->stopped() == false); c->write(mts, &uni); QVERIFY(s3->stopped() == true); mts->stopFunction(s3); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s2); QVERIFY(s2->stopped() == false); c->write(mts, &uni); QVERIFY(s2->stopped() == true); mts->stopFunction(s2); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s1); QVERIFY(s1->stopped() == false); c->stop(); QVERIFY(c->stopped() == true); mts->stopFunction(c); QVERIFY(s1->stopped() == true); QVERIFY(s2->stopped() == true); QVERIFY(s3->stopped() == true); c->disarm(); s1->disarm(); s2->disarm(); s3->disarm(); delete mts; delete doc; }
void Chaser_Test::writeBusZeroSingleShotBackward() { Doc* doc = new Doc(this, m_cache); Bus::instance()->setValue(Bus::defaultFade(), 0); Bus::instance()->setValue(Bus::defaultHold(), 0); Fixture* fxi = new Fixture(doc); 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); Chaser* c = new Chaser(doc); c->setName("Chaser"); c->setRunOrder(Chaser::SingleShot); c->setDirection(Chaser::Backward); c->addStep(s1->id()); c->addStep(s2->id()); s1->arm(); s2->arm(); c->arm(); QByteArray uni; MasterTimerStub* mts = new MasterTimerStub(this, NULL, uni); QVERIFY(c->stopped() == true); mts->startFunction(c); QVERIFY(c->stopped() == false); /* SingleShot will stop automatically after the last step */ c->write(mts, &uni); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s2); QVERIFY(s2->stopped() == false); c->write(mts, &uni); QVERIFY(s2->stopped() == true); mts->stopFunction(s2); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s1); QVERIFY(s1->stopped() == false); c->write(mts, &uni); QVERIFY(c->stopped() == true); mts->stopFunction(c); QVERIFY(s1->stopped() == true); QVERIFY(s2->stopped() == true); c->disarm(); s1->disarm(); s2->disarm(); delete mts; delete doc; }
void Chaser_Test::writeBusZeroLoopForward() { Doc* doc = new Doc(this, m_cache); Bus::instance()->setValue(Bus::defaultFade(), 0); Bus::instance()->setValue(Bus::defaultHold(), 0); Fixture* fxi = new Fixture(doc); 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); Chaser* c = new Chaser(doc); c->setName("Chaser"); c->addStep(s1->id()); c->addStep(s2->id()); s1->arm(); s2->arm(); c->arm(); QByteArray uni; MasterTimerStub* mts = new MasterTimerStub(this, NULL, uni); QVERIFY(c->stopped() == true); mts->startFunction(c); QVERIFY(c->stopped() == false); /* Since hold bus' value is 0 each call to write() starts the next step in chaser. The functions must be manually removed from the stub, which is OK (we're not testing the timer now), as long as the correct step is always marked as stopped. */ c->write(mts, &uni); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s1); QVERIFY(s1->stopped() == false); c->write(mts, &uni); QVERIFY(s1->stopped() == true); mts->stopFunction(s1); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s2); QVERIFY(s2->stopped() == false); c->write(mts, &uni); QVERIFY(s2->stopped() == true); mts->stopFunction(s2); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s1); QVERIFY(s1->stopped() == false); c->write(mts, &uni); QVERIFY(s1->stopped() == true); mts->stopFunction(s1); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s2); QVERIFY(s2->stopped() == false); c->write(mts, &uni); QVERIFY(s2->stopped() == true); mts->stopFunction(s2); QVERIFY(c->stopped() == false); QVERIFY(mts->m_functionList.size() == 2); QVERIFY(mts->m_functionList[0] == c); QVERIFY(mts->m_functionList[1] == s1); QVERIFY(s1->stopped() == false); c->stop(); mts->stopFunction(c); QVERIFY(c->stopped() == true); QVERIFY(s1->stopped() == true); QVERIFY(s2->stopped() == true); c->disarm(); s1->disarm(); s2->disarm(); delete mts; delete doc; }