本文整理汇总了C++中Doc::addFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ Doc::addFunction方法的具体用法?C++ Doc::addFunction怎么用?C++ Doc::addFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doc
的用法示例。
在下文中一共展示了Doc::addFunction方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tap
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;
}
示例2: flashUnflash
void Scene_Test::flashUnflash()
{
Doc* doc = new Doc(this, m_cache);
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, 123);
s1->setValue(fxi->id(), 1, 45);
s1->setValue(fxi->id(), 2, 67);
doc->addFunction(s1);
s1->arm();
QByteArray uni(4 * 512, 0);
MasterTimerStub* mts = new MasterTimerStub(this, NULL, uni);
QVERIFY(mts->m_dmxSourceList.size() == 0);
s1->flash(mts);
QVERIFY(mts->m_dmxSourceList.size() == 1);
QVERIFY(s1->stopped() == true);
QVERIFY(s1->flashing() == true);
s1->writeDMX(mts, &uni);
QVERIFY(uni[0] == char(123));
QVERIFY(uni[1] == char(45));
QVERIFY(uni[2] == char(67));
s1->flash(mts);
QVERIFY(mts->m_dmxSourceList.size() == 1);
QVERIFY(s1->stopped() == true);
QVERIFY(s1->flashing() == true);
s1->writeDMX(mts, &uni);
QVERIFY(uni[0] == char(123));
QVERIFY(uni[1] == char(45));
QVERIFY(uni[2] == char(67));
s1->unFlash(mts);
QVERIFY(mts->m_dmxSourceList.size() == 1);
QVERIFY(s1->stopped() == true);
QVERIFY(s1->flashing() == false);
s1->writeDMX(mts, &uni);
QVERIFY(mts->m_dmxSourceList.size() == 0);
QVERIFY(uni[0] == char(0));
QVERIFY(uni[1] == char(0));
QVERIFY(uni[2] == char(0));
s1->disarm();
delete doc;
}
示例3: writeBusOne
/** 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;
}
示例4: armMissingFunction
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;
}
示例5: armSuccess
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;
}
示例6: arm
void Scene_Test::arm()
{
Doc* doc = new Doc(this, m_cache);
Fixture* fxi = new Fixture(doc);
fxi->setName("Test Fixture");
fxi->setAddress(15);
fxi->setUniverse(3);
fxi->setChannels(10);
doc->addFixture(fxi);
Scene* s1 = new Scene(doc);
s1->setName("First");
s1->setValue(fxi->id(), 0, 123);
s1->setValue(fxi->id(), 7, 45);
s1->setValue(fxi->id(), 3, 67);
doc->addFunction(s1);
QVERIFY(s1->armedChannels().size() == 0);
s1->arm();
QVERIFY(s1->armedChannels().size() == 3);
SceneChannel ch;
ch = s1->armedChannels().at(0);
QVERIFY(ch.address == fxi->universeAddress());
QVERIFY(ch.start == 0);
QVERIFY(ch.current == 0);
QVERIFY(ch.target == 123);
ch = s1->armedChannels().at(1);
QVERIFY(ch.address == fxi->universeAddress() + 7);
QVERIFY(ch.start == 0);
QVERIFY(ch.current == 0);
QVERIFY(ch.target == 45);
ch = s1->armedChannels().at(2);
QVERIFY(ch.address == fxi->universeAddress() + 3);
QVERIFY(ch.start == 0);
QVERIFY(ch.current == 0);
QVERIFY(ch.target == 67);
s1->disarm();
QVERIFY(s1->armedChannels().size() == 0);
QVERIFY(s1->values().size() == 3);
delete doc;
}
示例7: write
void Collection_Test::write()
{
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(4);
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(), 2, UCHAR_MAX);
s2->setValue(fxi->id(), 3, UCHAR_MAX);
doc->addFunction(s2);
Collection* c = new Collection(doc);
c->setName("Collection");
c->addFunction(s1->id());
c->addFunction(s2->id());
s1->arm();
s2->arm();
c->arm();
QByteArray uni;
MasterTimerStub* mts = new MasterTimerStub(this, NULL, uni);
/* Collection starts all of its members immediately when it is started
itself. */
QVERIFY(c->stopped() == true);
mts->startFunction(c);
QVERIFY(c->stopped() == false);
c->write(mts, &uni);
QVERIFY(c->stopped() == false);
QVERIFY(mts->m_functionList.size() == 3);
QVERIFY(mts->m_functionList[0] == c);
QVERIFY(mts->m_functionList[1] == s1);
QVERIFY(mts->m_functionList[2] == s2);
/* All write calls to the collection "succeed" as long as there are
members running. */
c->write(mts, &uni);
QVERIFY(c->stopped() == false);
QVERIFY(mts->m_functionList.size() == 3);
QVERIFY(mts->m_functionList[0] == c);
QVERIFY(mts->m_functionList[1] == s1);
QVERIFY(mts->m_functionList[2] == s2);
c->write(mts, &uni);
QVERIFY(c->stopped() == false);
QVERIFY(mts->m_functionList.size() == 3);
QVERIFY(mts->m_functionList[0] == c);
QVERIFY(mts->m_functionList[1] == s1);
QVERIFY(mts->m_functionList[2] == s2);
/* S2 is still running after this so the collection is also running */
mts->stopFunction(s1);
QVERIFY(s1->stopped() == true);
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);
/* Now the collection must also tell it's ready to be stopped */
mts->stopFunction(s2);
QVERIFY(s2->stopped() == true);
QVERIFY(c->stopped() == true);
mts->stopFunction(c);
c->disarm();
s1->disarm();
s2->disarm();
delete mts;
delete doc;
}
示例8: writeBusZeroPingPongForward
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);
//.........这里部分代码省略.........
示例9: writeBusZeroSingleShotBackward
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;
}
示例10: writeBusZeroLoopForward
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;
//.........这里部分代码省略.........
示例11: writeNonZeroStartingValues
/** Test scene running with initial values something else than zero */
void Scene_Test::writeNonZeroStartingValues()
{
Doc* doc = new Doc(this, m_cache);
Bus::instance()->setValue(Bus::defaultFade(), 2);
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);
uni[0] = (char) 100;
uni[1] = (char) 255;
uni[2] = (char) 3;
s1->write(mts, &uni);
QVERIFY(s1->stopped() == false);
QVERIFY(uni[0] == (char) 151);
QVERIFY(uni[1] == (char) 213);
// Result is 3 on AMD64, 2 on IA32
QVERIFY(uni[2] == (char) 3 || uni[2] == (char) 2);
s1->write(mts, &uni);
QVERIFY(s1->stopped() == false);
QVERIFY(uni[0] == (char) 203);
QVERIFY(uni[1] == (char) 170);
// Result is 2 on AMD64, 1 in IA32
QVERIFY(uni[2] == (char) 2 || uni[2] == (char) 1);
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;
}