예제 #1
0
void LedDeviceAlienFx::setColors(const QList<QRgb> & colors)
{
    DEBUG_MID_LEVEL << Q_FUNC_INFO;
    if (m_isInitialized)
    {
        unsigned int numDevs = 0;
        LFX_RESULT result = lfxGetNumDevicesFunction(&numDevs);

        for(unsigned int devIndex = 0; devIndex < numDevs; devIndex++)
        {
            unsigned int numLights = 0;
            result = lfxGetNumLightsFunction(devIndex, &numLights);

            LFX_COLOR lfxColor;

            lfxColor.red   = qRed   ( colors[0] );
            lfxColor.green = qGreen ( colors[0] );
            lfxColor.blue  = qBlue  ( colors[0] );
            lfxColor.brightness = 255;

            for(unsigned int lightIndex = 0; lightIndex < numLights; lightIndex++)
                lfxSetLightColorFunction(devIndex, lightIndex, &lfxColor);
            lfxUpdateFunction();
        }
        emit ioDeviceSuccess(true);
    }
    DEBUG_MID_LEVEL << Q_FUNC_INFO;

    // Request new colors
    emit commandCompleted(true);
}
예제 #2
0
void HciManager::handleHciEventPacket(const quint8 *data, int size)
{
    if (size < HCI_EVENT_HDR_SIZE) {
        qCWarning(QT_BT_BLUEZ) << "Unexpected HCI event packet size:" << size;
        return;
    }

    hci_event_hdr *header = (hci_event_hdr *) data;

    size -= HCI_EVENT_HDR_SIZE;
    data += HCI_EVENT_HDR_SIZE;

    if (header->plen != size) {
        qCWarning(QT_BT_BLUEZ) << "Invalid HCI event packet size";
        return;
    }

    qCDebug(QT_BT_BLUEZ) << "HCI event triggered, type:" << hex << header->evt;

    switch (header->evt) {
    case EVT_ENCRYPT_CHANGE:
    {
        const evt_encrypt_change *event = (evt_encrypt_change *) data;
        qCDebug(QT_BT_BLUEZ) << "HCI Encrypt change, status:"
                             << (event->status == 0 ? "Success" : "Failed")
                             << "handle:" << hex << event->handle
                             << "encrypt:" << event->encrypt;

        QBluetoothAddress remoteDevice = addressForConnectionHandle(event->handle);
        if (!remoteDevice.isNull())
            emit encryptionChangedEvent(remoteDevice, event->status == 0);
    }
        break;
    case EVT_CMD_COMPLETE: {
        auto * const event = reinterpret_cast<const evt_cmd_complete *>(data);
        static_assert(sizeof *event == 3, "unexpected struct size");

        // There is always a status byte right after the generic structure.
        Q_ASSERT(size > static_cast<int>(sizeof *event));
        const quint8 status = data[sizeof *event];
        const auto additionalData = QByteArray(reinterpret_cast<const char *>(data)
                                               + sizeof *event + 1, size - sizeof *event - 1);
        emit commandCompleted(event->opcode, status, additionalData);
    }
        break;
    case LeMetaEvent:
        handleLeMetaEvent(data);
        break;
    default:
        break;
    }

}
예제 #3
0
bool InterfaceAvr::receiveBytes(QByteArray &bytes, int numBytes)
{
	int result = 0;
	int byteCounter = 0;
	unsigned char character;
//	QByteArray ba;


	// clear given argument
	bytes.clear();

	do
	{
		// reading one char. Must return 1 (one character succussfull read).
		result = serialPort->readAtmelPort(&character, 1);

		if (result == 1)
		{
			byteCounter++;

			// append received char to byte array
			bytes.append(character);
		}

	} while ( (result == 1) && (byteCounter != numBytes) ); // remark: timeout is implemented in readAtmelPort

	if (result != 1)
	{
		// ERROR (error message already emitted from readAtmelPort!)
		qDebug() << "error at receiveBytes";

		return false;
	}

	// copy 3 chars to QString to pointer to return the QString
	QString string = QString::fromUtf8(bytes.data(), 3);

	// check result!
	if (string.startsWith("$M>")) // @todo: place this fixed string somewhere else
	{
		// emit completed command to simulationThread
		emit commandCompleted( bytes ); // check format. maybe bytes.data() ?!??

//		qDebug(QString("Received data: %1\n").arg(bytes.data()));

		return true;
	}


	return false;
}
예제 #4
0
int AsyncIOCommand::execute(AsyncIOChannel& channel)
{
	delete _pException;
	_pException = 0;

	_state = CMD_IN_PROGRESS;
	try
	{
		_result = executeImpl(channel);
		_state = CMD_COMPLETED;
		_completed.set();
		AsyncIOEvent completedEvent(this, &channel, AsyncIOEvent::EV_COMMAND_COMPLETED);
		commandCompleted(this, completedEvent);
		channel.commandCompleted(this, completedEvent);
		return _result;
	}
	catch (Exception& exc)
	{
		_pException = exc.clone();
		_state = CMD_FAILED;
		_completed.set();
		AsyncIOEvent failedEvent(this, &channel, AsyncIOEvent::EV_COMMAND_FAILED);
		commandFailed(this, failedEvent);
		channel.commandFailed(this, failedEvent);
		throw;
	}
	catch (std::exception& exc)
	{
		_pException = new Exception(exc.what());
		_state = CMD_FAILED;
		_completed.set();
		AsyncIOEvent failedEvent(this, &channel, AsyncIOEvent::EV_COMMAND_FAILED);
		commandFailed(this, failedEvent);
		channel.commandFailed(this, failedEvent);
		throw;
	}
	catch (...)
	{
		_pException = new Exception("Unknown exception");
		_state = CMD_FAILED;
		_completed.set();
		AsyncIOEvent failedEvent(this, &channel, AsyncIOEvent::EV_COMMAND_FAILED);
		commandFailed(this, failedEvent);
		channel.commandFailed(this, failedEvent);
		throw;
	}
}
예제 #5
0
void PlayerDriver::HandleCommandsProcessCallback(void)
{
    status_t returnStatus = UNKNOWN_ERROR;
    PlayerCommand* ec = DoProcessQueue(returnStatus);

    // Schedule for next command if any
    if (!m_CommandQueue.isEmpty())
    {
        m_pCommandsProcessCallback->ScheduleRelative(m_pScheduler, 0);
    }

    if (ec)
    {
        // signal for completion
        commandCompleted(ec, returnStatus);
    }
}
예제 #6
0
void LedDeviceAlienFx::requestFirmwareVersion()
{
    emit firmwareVersion("unknown (alienfx)");
    emit commandCompleted(true);
}
예제 #7
0
void LedDeviceAlienFx::setBrightness(int /*value*/)
{
    // TODO
    emit commandCompleted(true);
}
예제 #8
0
void LedDeviceAlienFx::setGamma(double /*value*/)
{
    // TODO
    emit commandCompleted(true);
}
예제 #9
0
void LedDeviceAlienFx::setSmoothSlowdown(int /*value*/)
{
    emit commandCompleted(true);
}
예제 #10
0
void LedDeviceAlienFx::setColorDepth(int /*value*/)
{
    emit commandCompleted(true);
}
예제 #11
0
void LedDeviceAlienFx::setRefreshDelay(int /*value*/)
{
    emit commandCompleted(true);
}
예제 #12
0
void LedDeviceAlienFx::offLeds()
{
    emit commandCompleted(true);
}
예제 #13
0
파일: Controller.cpp 프로젝트: hefee/Charm
void Controller::rollbackCommand( CharmCommand* command )
{
    command->rollback( this );
    // send it back to the view:
    emit commandCompleted( command );
}
예제 #14
0
파일: Controller.cpp 프로젝트: hefee/Charm
void Controller::executeCommand( CharmCommand* command )
{
    command->execute( this );
    // send it back to the view:
    emit commandCompleted( command );
}