Example #1
0
void FadeChannel_Test::address()
{
    Doc doc(this);
    Fixture* fxi = new Fixture(&doc);
    fxi->setAddress(400);
    fxi->setChannels(5);
    doc.addFixture(fxi);

    FadeChannel fc;
    fc.setChannel(2);
    QCOMPARE(fc.address(), quint32(2));

    fc.setFixture(&doc, fxi->id());
    QCOMPARE(fc.address(), quint32(402));

    fc.setFixture(&doc, 12345);
    QCOMPARE(fc.address(), QLCChannel::invalid());
}
Example #2
0
void KCTimeDict::save(QDataStream &str) const
{
    Hash::const_iterator it = m_hash.constBegin();
    const Hash::const_iterator end = m_hash.constEnd();
    for (; it != end; ++it) {
        str << it.key() << it.value();
    }
    str << QString() << quint32(0);
}
Example #3
0
void AudioRecorder::close()
{
    // Fill the header size placeholders
    quint32 fileSize = size();

    QDataStream out(this);
    // Set the same ByteOrder like in writeHeader()
    out.setByteOrder(QDataStream::LittleEndian);
    // RIFF chunk size
    seek(4);
    out << quint32(fileSize - 8);

    // data chunk size
    seek(40);
    out << quint32(fileSize - 44);

    QFile::close();
}
Example #4
0
QT_BEGIN_NAMESPACE
QDataStream &operator<<(QDataStream &stream, const QList<QNetworkCookie> &list)
{
    stream << JAR_VERSION;
    stream << quint32(list.size());
    for (int i = 0; i < list.size(); ++i)
        stream << list.at(i).toRawForm();
    return stream;
}
QDataStream &operator<<(QDataStream &out, const HighlightingMarkContainer &container)
{
    out << container.line_;
    out << container.column_;
    out << container.length_;
    out << quint32(container.type_);

    return out;
}
Example #6
0
void
APG::ConstraintSolver::fill_population( Population& population )
{
    for ( int i = population.size(); quint32(i) < m_populationSize; i++ ) {
        Meta::TrackList* tl = new Meta::TrackList( sample( m_domain, playlist_size() ) );
        double s = m_constraintTreeRoot->satisfaction( (*tl) );
        population.insert( tl, s );
    }
}
QByteArray QWindowsAudioDeviceInfo::defaultOutputDevice()
{
    QByteArray defaultDevice;
    QDataStream ds(&defaultDevice, QIODevice::WriteOnly);
    ds << quint32(WAVE_MAPPER) // device ID for default device
       << QStringLiteral("Default Output Device");

    return defaultDevice;
}
Example #8
0
void DMXUSB::writeUniverse(quint32 universe, quint32 output, const QByteArray &data)
{
    if (output < quint32(m_outputs.size()))
    {
        QByteArray wholeuniverse(512, 0);
        wholeuniverse.replace(0, data.length(), data);
        m_outputs.at(output)->writeUniverse(universe, output, wholeuniverse);
    }
}
/**
 * Update the object's timers
 */
void Telemetry::setUpdatePeriod(UAVObject *obj, qint32 periodMs)
{
    // Find object type (not instance!) and update its period
    for (int n = 0; n < objList.length(); ++n) {
        if (objList[n].obj->getObjID() == obj->getObjID()) {
            objList[n].updatePeriodMs     = periodMs;
            objList[n].timeToNextUpdateMs = quint32((float)periodMs * (float)qrand() / (float)RAND_MAX); // avoid bunching of updates
        }
    }
}
void QLCInputProfile_Test::channelNumber()
{
    QLCInputProfile ip;
    QVERIFY(ip.channels().size() == 0);

    QLCInputChannel* ich1 = new QLCInputChannel();
    ip.insertChannel(0, ich1);

    QLCInputChannel* ich2 = new QLCInputChannel();
    ip.insertChannel(6510, ich2);

    QLCInputChannel* ich3 = new QLCInputChannel();
    ip.insertChannel(5, ich3);

    QCOMPARE(ip.channelNumber(NULL), InputMap::invalidChannel());
    QCOMPARE(ip.channelNumber(ich1), quint32(0));
    QCOMPARE(ip.channelNumber(ich2), quint32(6510));
    QCOMPARE(ip.channelNumber(ich3), quint32(5));
}
Example #11
0
void KisImageLayerMoveCommand::redo()
{
    if( m_newAbove || m_index == quint32(-1) )
    {
        m_image->moveNode(m_layer, m_newParent, m_newAbove);
    } else {
        m_image->moveNode(m_layer, m_newParent, m_index);
    }
    m_layer->setDirty();
}
Example #12
0
void Bus_Test::defaults()
{
    QVERIFY(Bus::count() == 32);
    QVERIFY(Bus::defaultFade() == 0);
    QVERIFY(Bus::defaultHold() == 1);
    QCOMPARE(Bus::defaultPalette(), quint32(31));
    QVERIFY(Bus::instance()->name(0) == QString("Fade"));
    QVERIFY(Bus::instance()->name(1) == QString("Hold"));
    QCOMPARE(Bus::instance()->name(31), QString("Palette"));
}
Example #13
0
QScriptValue toScriptValue(QScriptEngine *eng, const Container &cont)
{
    QScriptValue a = eng->newArray();
    typename Container::const_iterator begin = cont.begin();
    typename Container::const_iterator end = cont.end();
    typename Container::const_iterator it;
    for (it = begin; it != end; ++it)
        a.setProperty(quint32(it - begin), qScriptValueFromValue(eng, *it));
    return a;
}
Example #14
0
quint32 SMFProcessor::estimateRemainingTime(const MidiEventList &midiEvents, int currentEventIx) {
	MasterClockNanos tick = midiTick;
	MasterClockNanos totalNanos = 0;
	for (int i = currentEventIx; i < midiEvents.count(); i++) {
		const MidiEvent &e = midiEvents.at(i);
		totalNanos += e.getTimestamp() * tick;
		if (e.getType() == SET_TEMPO) tick = parser.getMidiTick(e.getShortMessage());
	}
	return quint32(totalNanos / MasterClock::NANOS_PER_SECOND);
}
void IntensityGenerator_Test::fullZeroScenes()
{
    Doc doc(this, m_fixtureDefCache);

    QList <Fixture*> fixtures;

    Fixture* fxi = new Fixture(&doc);
    fxi->setChannels(4);
    fixtures << fxi;

    Fixture* fxi2 = new Fixture(&doc);
    const QLCFixtureDef* def = m_fixtureDefCache.fixtureDef("Futurelight", "DJScan250");
    Q_ASSERT(def != NULL);
    Q_ASSERT(def->modes().first() != NULL);
    Q_ASSERT(def->modes().first()->channels().size() == 6);
    fxi2->setFixtureDefinition(def, def->modes().first());
    fixtures << fxi2;

    QList <Scene*> scenes = IntensityGenerator::fullZeroScenes(fixtures, &doc);
    QCOMPARE(scenes.size(), 2);

    QCOMPARE(scenes[1]->values().size(), 0);
    QCOMPARE(scenes[0]->values().size(), 5);
    QCOMPARE(scenes[0]->values()[0].fxi, fxi->id());
    QCOMPARE(scenes[0]->values()[0].channel, quint32(0));
    QCOMPARE(scenes[0]->values()[0].value, uchar(UCHAR_MAX));
    QCOMPARE(scenes[0]->values()[1].fxi, fxi->id());
    QCOMPARE(scenes[0]->values()[1].channel, quint32(1));
    QCOMPARE(scenes[0]->values()[1].value, uchar(UCHAR_MAX));
    QCOMPARE(scenes[0]->values()[2].fxi, fxi->id());
    QCOMPARE(scenes[0]->values()[2].channel, quint32(2));
    QCOMPARE(scenes[0]->values()[2].value, uchar(UCHAR_MAX));
    QCOMPARE(scenes[0]->values()[3].fxi, fxi->id());
    QCOMPARE(scenes[0]->values()[3].channel, quint32(3));
    QCOMPARE(scenes[0]->values()[3].value, uchar(UCHAR_MAX));
    QCOMPARE(scenes[0]->values()[4].fxi, fxi2->id());
    QCOMPARE(scenes[0]->values()[4].channel, quint32(5));
    QCOMPARE(scenes[0]->values()[4].value, uchar(128));

    QCOMPARE(scenes[1]->values().size(), 0);
    // Zero scene needs no values because non-participating HTP channels are faded
    // automatically to zero
}
Example #16
0
bool Peperoni::openOutput(quint32 output)
{
    if (m_usbdmx == NULL)
        return false;

    if (output < quint32(m_devices.size()))
        return m_devices.at(output)->open();

    return false;
}
Example #17
0
void PlaybackController::jumpTo(int pos)
{
	Q_ASSERT(m_indexloader);

	if(pos == m_reader->currentIndex())
		return;

	if(waitForExporter())
		return;

	// If the target position is behind current position or sufficiently far ahead, jump
	// to the closest snapshot point first
	if(pos < m_reader->currentIndex() || pos - m_reader->currentIndex() > 500) {
		int seIdx=0;
		const Index &index = m_indexloader->index();
		for(int i=1;i<index.snapshots().size();++i) {
			const SnapshotEntry &next = index.snapshots().at(i);
			if(int(next.pos) > pos)
				break;

			seIdx = i;
		}

		// When jumping forward, don't restore the snapshot if the snapshot is behind
		// the current position
		if(pos < m_reader->currentIndex() || index.snapshots().at(seIdx).pos > quint32(m_reader->currentIndex()))
			jumptToSnapshot(seIdx);
	}

	// Now the current position is somewhere before the target position: replay commands
	while(m_reader->currentIndex() < pos && !m_reader->isEof()) {
		MessageRecord next = m_reader->readNext();
		switch(next.status) {
		case MessageRecord::OK:
			if(next.message->type() == protocol::MSG_INTERVAL) {
				// skip intervals
				delete next.message;
			} else {
				emit commandRead(protocol::MessagePtr(next.message));
			}
			break;
		case MessageRecord::INVALID:
			qWarning() << "Unrecognized command " << next.error.type << "of length" << next.error.len;
			break;
		case MessageRecord::END_OF_RECORDING:
			emit endOfFileReached();
			break;
		}
	}

	if(m_exporter && m_autosave)
		exportFrame();

	updateIndexPosition();
}
Example #18
0
bool DataLoad::writeFile(const QString &fileName, const QString &tablename)
{
    QFile file(fileName);
    if (!file.open(QIODevice::WriteOnly)) {
        QMessageBox::warning(this, tr("Spreadsheet"),
                             tr("Cannot write file %1:\n%2.")
                             .arg(file.fileName())
                             .arg(file.errorString()));
        return false;
    }

    QDataStream out(&file);
    out.setVersion(QDataStream::Qt_4_8);

    out << quint32(0x12345678);

    QApplication::setOverrideCursor(Qt::WaitCursor);

    QSqlDatabase dbconn = QSqlDatabase::database("bosch");

    QSqlQuery *query = new QSqlQuery(dbconn);
    query->exec(QString("SELECT * FROM %1").arg(tablename));
    QSqlRecord sqlRecord;
    sqlRecord = query->record();
    out << quint32(sqlRecord.count());
    for (int i = 0; i < sqlRecord.count(); i++) {
        out << sqlRecord.fieldName(i);
    }
    quint32 num = 0;
    while (query->next()) num++;
    out << quint32(num);
    query->first();
    num = 0;
    do {
        for (int i = 0; i < sqlRecord.count(); i++) {
            out  << query->value(i).toString();
        }
    } while (query->next());

    QApplication::restoreOverrideCursor();
    return true;
}
void VCXYPadFixtureEditor_Test::accept()
{
    QList <VCXYPadFixture> list;

    VCXYPadFixture fxi(m_doc);
    fxi.setDisplayMode(VCXYPadFixture::Percentage);

    fxi.setHead(GroupHead(0, 0));
    fxi.setX(0, 1, false);
    fxi.setY(0, 1, false);
    list << fxi;

    fxi.setHead(GroupHead(1, 0));
    fxi.setX(0.5, 0.6, true);
    fxi.setY(0.5, 0.6, true);
    list << fxi;

    VCXYPadFixtureEditor fe(NULL, list);
    fe.m_xMin->setValue(10);
    fe.m_xMax->setValue(20);
    fe.m_yMin->setValue(30);
    fe.m_yMax->setValue(40);
    fe.accept();
    QCOMPARE(fe.m_xMin->value(), 10);
    QCOMPARE(fe.m_xMax->value(), 20);
    QCOMPARE(fe.m_yMin->value(), 30);
    QCOMPARE(fe.m_yMax->value(), 40);

    list = fe.fixtures();
    QCOMPARE(list[0].head().fxi, quint32(0));
    QCOMPARE(list[0].head().head, 0);
    QCOMPARE(list[0].xMin(), qreal(0.1));
    QCOMPARE(list[0].xMax(), qreal(0.2));
    QCOMPARE(list[0].yMin(), qreal(0.3));
    QCOMPARE(list[0].yMax(), qreal(0.4));
    QCOMPARE(list[1].head().fxi, quint32(1));
    QCOMPARE(list[1].head().head, 0);
    QCOMPARE(list[1].xMin(), qreal(0.1));
    QCOMPARE(list[1].xMax(), qreal(0.2));
    QCOMPARE(list[1].yMin(), qreal(0.3));
    QCOMPARE(list[1].yMax(), qreal(0.4));
}
Example #20
0
void SceneSerializer::serializeNodes(QDataStream* out, QObject* p)
{
    auto nodes = p->findChildren<Node*>(QString(),
                                        Qt::FindDirectChildrenOnly);
    *out << quint32(nodes.length());

    for (auto node : nodes)
    {
        serializeNode(out, node);
    }
}
Example #21
0
QModelIndex RecipeModel::index(int row, int column, const QModelIndex &parent) const
{
    if(!hasIndex(row, column, parent))
        return QModelIndex();

    if(!parent.isValid()) {
        return createIndex(row, column, quint32(row));
    }

    return QModelIndex();
}
Example #22
0
bool WavHeader::writeDataLength(QIODevice &device, qint64 dataLength)
{
    bool result = false;
    if (!device.isSequential()) {
        device.seek(40);
        unsigned char dataLengthLE[4];
        qToLittleEndian<quint32>(quint32(dataLength), dataLengthLE);
        result = (device.write(reinterpret_cast<const char *>(dataLengthLE), 4) == 4);
    }
    return result;
}
static inline QDataStream &operator<<(QDataStream &out, const QNetworkCacheMetaData::AttributesMap &hash)
{
    out << quint32(hash.size());
    QNetworkCacheMetaData::AttributesMap::ConstIterator it = hash.end();
    QNetworkCacheMetaData::AttributesMap::ConstIterator begin = hash.begin();
    while (it != begin) {
        --it;
        out << int(it.key()) << it.value();
    }
    return out;
}
Example #24
0
File: alg.cpp Project: AoD314/pat
	void Alg::send_message_to_server(std::vector<std::string> msgs)
	{
		QByteArray arr_block;
		QDataStream out(&arr_block, QIODevice::WriteOnly);
		out.setVersion(QDataStream::Qt_4_7);

		out << quint32(0);

		for(size_t i = 0; i < msgs.size(); ++i)
		{
			out << QString(msgs.at(i).c_str());
		}

		out.device()->seek(0);
		out << quint32(arr_block.size() - sizeof(quint32));

		socket->write(arr_block);

		socket->waitForBytesWritten();
	}
Example #25
0
void Doc_Test::removeFixtureGroup()
{
    QSignalSpy spy(m_doc, SIGNAL(fixtureGroupRemoved(quint32)));
    QCOMPARE(m_doc->fixtureGroups().size(), 0);
    QCOMPARE(m_doc->m_latestFixtureGroupId, quint32(0));

    QCOMPARE(m_doc->deleteFixtureGroup(0), false);
    QCOMPARE(spy.size(), 0);

    FixtureGroup* grp = new FixtureGroup(m_doc);
    QCOMPARE(m_doc->addFixtureGroup(grp), true);
    grp = new FixtureGroup(m_doc);
    QCOMPARE(m_doc->addFixtureGroup(grp), true);
    grp = new FixtureGroup(m_doc);
    QCOMPARE(m_doc->addFixtureGroup(grp), true);
    QCOMPARE(m_doc->fixtureGroups().size(), 3);
    QVERIFY(m_doc->fixtureGroup(0) != NULL);
    QVERIFY(m_doc->fixtureGroup(1) != NULL);
    QVERIFY(m_doc->fixtureGroup(2) != NULL);

    QCOMPARE(m_doc->deleteFixtureGroup(0), true);
    QCOMPARE(spy.size(), 1);
    QCOMPARE(spy[0].size(), 1);
    QCOMPARE(spy[0][0].toUInt(), quint32(0));
    QCOMPARE(m_doc->fixtureGroups().size(), 2);
    QVERIFY(m_doc->fixtureGroup(0) == NULL);
    QVERIFY(m_doc->fixtureGroup(1) != NULL);
    QVERIFY(m_doc->fixtureGroup(2) != NULL);

    QCOMPARE(m_doc->deleteFixtureGroup(0), false);
    QCOMPARE(spy.size(), 1);

    QCOMPARE(m_doc->deleteFixtureGroup(1), true);
    QCOMPARE(spy.size(), 2);
    QCOMPARE(spy[1].size(), 1);
    QCOMPARE(spy[1][0].toUInt(), quint32(1));
    QCOMPARE(m_doc->fixtureGroups().size(), 1);
    QVERIFY(m_doc->fixtureGroup(0) == NULL);
    QVERIFY(m_doc->fixtureGroup(1) == NULL);
    QVERIFY(m_doc->fixtureGroup(2) != NULL);
}
Example #26
0
void OS2LPlugin::slotProcessTCPPackets()
{
    QTcpSocket *socket = (QTcpSocket *)sender();
    if (socket == NULL)
        return;

    QHostAddress senderAddress = socket->peerAddress();
    QByteArray message = socket->readAll();
    QJsonDocument json = QJsonDocument::fromJson(message);

    qDebug() << "[TCP] Received" << message.length() << "bytes from" << senderAddress.toString();
    QJsonObject jsonObj = json.object();
    QJsonValue jEvent = jsonObj.value("evt");
    if (jEvent.isUndefined())
        return;

    QString event = jEvent.toString();

    if (event == "btn")
    {
        QJsonValue jName = jsonObj.value("name");
        QJsonValue jState = jsonObj.value("state");
        qDebug() << "Got button event with name" << jName.toString() << "and state" << jState.toString();
        uchar value = jState.toString() == "off" ? 0 : 255;
        emit valueChanged(m_inputUniverse, 0, getHash(jName.toString()), value, jName.toString());
    }
    else if (event == "cmd")
    {
        QJsonValue jId = jsonObj.value("id");
        QJsonValue jParam = jsonObj.value("param");
        qDebug() << "Got CMD message" << jId.toInt() << "with param" << jParam.toDouble();
        quint32 channel = quint32(jId.toInt());
        QString cmd = QString("cmd%1").arg(channel);
        emit valueChanged(m_inputUniverse, 0, quint32(jId.toInt()), uchar(jParam.toDouble()), cmd);
    }
    else if (event == "beat")
    {
       qDebug() << "Got beat message" << message;
       emit valueChanged(m_inputUniverse, 0, 8341, 255, "beat");
    }
}
Example #27
0
QString OutputPatch::outputName() const
{
    if (m_plugin != NULL && m_output != QLCIOPlugin::invalidLine() &&
        m_output < quint32(m_plugin->outputs().size()))
    {
        return m_plugin->outputs()[m_output];
    }
    else
    {
        return KOutputNone;
    }
}
Example #28
0
quint32 TimeSync::getTimeT()
{
    TimeSync* timeSync=TimeSync::global();
    if(timeSync->additionalTimer==0)return QDateTime::currentDateTime().toTime_t();

    qint64 additionalBuffer=0;
    timeSync->mutex.lock();
    additionalBuffer=timeSync->additionalTimer->elapsed();
    timeSync->mutex.unlock();

    return timeSync->startTime+timeSync->timeShift+quint32(additionalBuffer/1000);
}
Example #29
0
void KisImageLayerAddCommand::redo()
{
    if (m_aboveThis || m_index == quint32(-1)) {
        m_image->addNode(m_layer, m_parent, m_aboveThis);
    } else {
        m_image->addNode(m_layer, m_parent, m_index);
    }

    if (m_doRedoUpdates) {
        m_layer->setDirty(m_image->bounds());
    }
}
Example #30
0
void SeafileTrayIcon::showMessage(const QString & title, const QString & message, MessageIcon icon, int millisecondsTimeoutHint)
{
#ifdef Q_WS_X11
    QList<QVariant> args = QList<QVariant>() << "seafile" << quint32(0) << "dialog-information"
                                             << title << message << QStringList () << QVariantMap() << qint32(-1);
    QDBusMessage method = QDBusMessage::createMethodCall("org.freedesktop.Notifications","/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify");
    method.setArguments(args);
    QDBusConnection::sessionBus().asyncCall(method);
#else
    QSystemTrayIcon::showMessage(title, message, icon, millisecondsTimeoutHint);
#endif
}