void Scene::arm() { m_channels.clear(); /* Scenes cannot run unless they are children of Doc */ Doc* doc = qobject_cast <Doc*> (parent()); Q_ASSERT(doc != NULL); /* Get exact address numbers from fixtures and fixate them to this scene for running. */ QListIterator <SceneValue> it(m_values); while (it.hasNext() == true) { SceneValue scv(it.next()); Fixture* fxi = doc->fixture(scv.fxi); Q_ASSERT(fxi != NULL); SceneChannel channel; channel.address = fxi->universeAddress() + scv.channel; channel.target = scv.value; m_channels.append(channel); } }
void MasterTimer::fadeAndStopAll(int timeout) { if (timeout == 0) return; Doc* doc = qobject_cast<Doc*> (parent()); Q_ASSERT(doc != NULL); QList<FadeChannel> fcList; QList<Universe *> universes = doc->inputOutputMap()->claimUniverses(); for (int i = 0; i < universes.count(); i++) { QHashIterator <int,uchar> it(universes[i]->intensityChannels()); while (it.hasNext() == true) { it.next(); Fixture* fxi = doc->fixture(doc->fixtureForAddress(it.key())); if (fxi != NULL) { uint ch = it.key() - fxi->universeAddress(); if (fxi->channelCanFade(ch)) { FadeChannel fc(doc, fxi->id(), ch); fc.setStart(it.value()); fc.setTarget(0); fc.setFadeTime(timeout); fcList.append(fc); } } } } doc->inputOutputMap()->releaseUniverses(); // Stop all functions first stopAllFunctions(); // Instruct mastertimer to do a fade out of all // the intensity channels that can fade QMutexLocker faderLocker(&m_faderMutex); foreach(FadeChannel fade, fcList) fader()->add(fade); }
void Fixture_Test::loader() { QDomDocument doc; QDomElement root = doc.createElement("Fixture"); doc.appendChild(root); QDomElement chs = doc.createElement("Channels"); QDomText chsText = doc.createTextNode("18"); chs.appendChild(chsText); root.appendChild(chs); QDomElement name = doc.createElement("Name"); QDomText nameText = doc.createTextNode("Foobar"); name.appendChild(nameText); root.appendChild(name); QDomElement uni = doc.createElement("Universe"); QDomText uniText = doc.createTextNode("3"); uni.appendChild(uniText); root.appendChild(uni); QDomElement model = doc.createElement("Model"); QDomText modelText = doc.createTextNode("Foobar"); model.appendChild(modelText); root.appendChild(model); QDomElement mode = doc.createElement("Mode"); QDomText modeText = doc.createTextNode("Foobar"); mode.appendChild(modeText); root.appendChild(mode); QDomElement type = doc.createElement("Manufacturer"); QDomText typeText = doc.createTextNode("Foobar"); type.appendChild(typeText); root.appendChild(type); QDomElement id = doc.createElement("ID"); QDomText idText = doc.createTextNode("42"); id.appendChild(idText); root.appendChild(id); QDomElement addr = doc.createElement("Address"); QDomText addrText = doc.createTextNode("21"); addr.appendChild(addrText); root.appendChild(addr); Doc* qlcdoc = new Doc(this, m_fixtureDefCache); QVERIFY(qlcdoc != NULL); QVERIFY(qlcdoc->fixtures() == 0); QVERIFY(Fixture::loader(&root, qlcdoc) == true); QVERIFY(qlcdoc->fixtures() == 1); QVERIFY(qlcdoc->fixture(0) == NULL); // No ID auto-assignment Fixture* fxi = qlcdoc->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); delete qlcdoc; }
void EFX::arm() { int serialNumber = 0; Doc* doc = qobject_cast <Doc*> (parent()); Q_ASSERT(doc != NULL); QListIterator <EFXFixture*> it(m_fixtures); while (it.hasNext() == true) { EFXFixture* ef = it.next(); Q_ASSERT(ef != NULL); ef->setSerialNumber(serialNumber++); /* If fxi == NULL, the fixture has been destroyed */ Fixture* fxi = 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. */ const QLCFixtureMode* mode = fxi->fixtureMode(); if (mode == NULL) continue; QList <quint32> intensityChannels; /* Find exact channel numbers for MSB/LSB pan and tilt */ for (quint32 i = 0; i < quint32(mode->channels().size()); i++) { QLCChannel* ch = mode->channel(i); Q_ASSERT(ch != NULL); if (ch->group() == QLCChannel::Pan) { if (ch->controlByte() == QLCChannel::MSB) ef->setMsbPanChannel(fxi->universeAddress() + i); else if (ch->controlByte() == QLCChannel::LSB) ef->setLsbPanChannel(fxi->universeAddress() + i); } else if (ch->group() == QLCChannel::Tilt) { if (ch->controlByte() == QLCChannel::MSB) ef->setMsbTiltChannel(fxi->universeAddress() + i); else if (ch->controlByte() == QLCChannel::LSB) ef->setLsbTiltChannel(fxi->universeAddress() + i); } else if (ch->group() == QLCChannel::Intensity && ch->colour() == QLCChannel::NoColour) // Don't touch RGB/CMY channels { if (ch->searchCapability(/*D*/"immer", false) != NULL || ch->searchCapability(/*I*/"ntensity", false) != NULL) { intensityChannels << (fxi->universeAddress() + i); } } } ef->setIntensityChannels(intensityChannels); ef->setFadeBus(fadeBusID()); } Q_ASSERT(m_fader == NULL); m_fader = new GenericFader; resetElapsed(); }
void EFX::arm() { class Scene* startScene = NULL; class Scene* stopScene = NULL; int serialNumber = 0; Doc* doc = qobject_cast <Doc*> (parent()); Q_ASSERT(doc != NULL); /* Initialization scene */ if (m_startSceneID != Function::invalidId() && m_startSceneEnabled == true) { startScene = static_cast <class Scene*> (doc->function(m_startSceneID)); } /* De-initialization scene */ if (m_stopSceneID != Function::invalidId() && m_stopSceneEnabled == true) { stopScene = static_cast <class Scene*> (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 */ Fixture* fxi = 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. */ const QLCFixtureMode* 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().size(); i++) { QLCChannel* 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 = circlePoint; // Fallback resetElapsed(); }
QString Script::handleSetFixture(const QList<QStringList>& tokens, QList<Universe *> universes) { qDebug() << Q_FUNC_INFO; if (tokens.size() > 4) return QString("Too many arguments"); bool ok = false; quint32 id = 0; quint32 ch = 0; uchar value = 0; double time = 0; id = tokens[0][1].toUInt(&ok); if (ok == false) return QString("Invalid fixture (ID: %1)").arg(tokens[0][1]); for (int i = 1; i < tokens.size(); i++) { QStringList list = tokens[i]; list[0] = list[0].toLower().trimmed(); if (list.size() == 2) { ok = false; if (list[0] == "val" || list[0] == "value") value = uchar(list[1].toUInt(&ok)); else if (list[0] == "ch" || list[0] == "channel") ch = list[1].toUInt(&ok); else if (list[0] == "time") time = list[1].toDouble(&ok); else return QString("Unrecognized keyword: %1").arg(list[0]); if (ok == false) return QString("Invalid value (%1) for keyword: %2").arg(list[1]).arg(list[0]); } } Doc* doc = qobject_cast<Doc*> (parent()); Q_ASSERT(doc != NULL); Fixture* fxi = doc->fixture(id); if (fxi != NULL) { if (ch < fxi->channels()) { int address = fxi->address() + ch; if (address < 512) { GenericFader* gf = fader(); Q_ASSERT(gf != NULL); FadeChannel fc; fc.setFixture(doc, fxi->id()); fc.setChannel(ch); fc.setTarget(value); fc.setFadeTime(time); // If the script has used the channel previously, it might still be in // the bowels of GenericFader so get the starting value from there. // Otherwise get it from universes (HTP channels are always 0 then). quint32 uni = fc.universe(); if (gf->channels().contains(fc) == true) fc.setStart(gf->channels()[fc].current()); else fc.setStart(universes[uni]->preGMValue(address)); fc.setCurrent(fc.start()); gf->add(fc); return QString(); } else { return QString("Invalid address: %1").arg(address); } } else { return QString("Fixture (%1) has no channel number %2").arg(fxi->name()).arg(ch); } } else { return QString("No such fixture (ID: %1)").arg(id); } }