Example #1
0
void ServerCore::processNewDevice(QVariantMap& dataMap)
{
	bool isSelfBroadcast = dataMap.contains(JSON_KEY_COMMAND) && dataMap[JSON_KEY_COMMAND] == CMD_QUERY
		&& (!dataMap.contains(JSON_KEY_UID) || !dataMap.contains(JSON_KEY_DISPLAYNAME)
			|| !dataMap.contains(JSON_KEY_IP));

	if (isSelfBroadcast)
	{
		return;
	}

	QString deviceUID = dataMap[JSON_KEY_UID].toString();
	QString deviceName = dataMap[JSON_KEY_DISPLAYNAME].toString();
	QString deviceIP = dataMap[JSON_KEY_IP].toString();
	QString deviceType = dataMap[JSON_KEY_TYPE].toString();

	DeviceInfo devInfo(deviceUID, deviceName, deviceIP, deviceType);
	DeviceManagerModule()->AddDevice(deviceUID, devInfo);

	QVariantMap paramMap;
	paramMap.insert(JSON_KEY_SEQ, 1234);

	QTcpSocket *socket = new QTcpSocket(this);

	QObject::connect(socket, &QTcpSocket::readyRead, [=]
	{
		QByteArray byteArray = socket->readAll();
		parseSupportCmds(deviceUID, byteArray);
		Q_EMIT deviceAdded(deviceUID);
		socket->disconnectFromHost();
	});

	QObject::connect(socket, static_cast<void(QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error),
		[=](QAbstractSocket::SocketError socketError)
	{
		qDebug() << "Socket Error" << socketError;
	});

	QObject::connect(socket, &QTcpSocket::disconnected, [=]
	{
		socket->deleteLater();
	});

	socket->connectToHost(deviceIP, PORT_SERVER_BROADCAST, QIODevice::ReadWrite);

	socket->waitForConnected();

	QString jsonCmd = JsonGenerator::GenerateJsonCommand(TCP_COMMAND_TYPE::QUERY_DEVICE_SUPPORT_CMDS, paramMap);

	socket->write(jsonCmd.toLatin1());
	socket->flush();

	socket->waitForBytesWritten();
	socket->waitForReadyRead();

	
}
Example #2
0
bool Motion::init()
{
	int cardno = 0;
	int tmp = 0;

	m_instantDiCtrl = AdxInstantDiCtrlCreate();
	m_instantDoCtrl = AdxInstantDoCtrlCreate();
	if ((m_instantDiCtrl != NULL) && (NULL != m_instantDoCtrl))
	{
		cardno++;
		isInitOK = true;

		int deviceNum = 0;
		DeviceInformation devInfo(deviceNum);

		ErrorCode errorCode = m_instantDiCtrl->setSelectedDevice(devInfo);
		if (errorCode != Success)
		{
			//CheckError(errorCode);
			return false;
		}
		m_instantDiCtrl->getSelectedDevice(devInfo);
		errorCode = m_instantDoCtrl->setSelectedDevice(devInfo);
		if (errorCode != Success)
			return false;//CheckError(errorCode);
		m_instantDoCtrl->getSelectedDevice(devInfo);

		m_IportCount = m_instantDiCtrl->getFeatures()->getPortCount();
		m_portData = new byte[m_IportCount];
		memset(m_portData, 0, m_IportCount);


		int portcount = m_instantDoCtrl->getFeatures()->getPortCount();
		errorCode = m_instantDiCtrl->setSelectedDevice(devInfo);
		if (errorCode != Success)
		{
			return false;
		}
		m_instantDiCtrl->getSelectedDevice(devInfo);
		errorCode = m_instantDoCtrl->setSelectedDevice(devInfo);
		if (errorCode != Success)
		{
			return false;
		}
		m_instantDoCtrl->getSelectedDevice(devInfo);
	}
	else
	{
		isInitOK = false;
		return false;
	}
	if (0 == cardno) return false;
	else return true;
}
Example #3
0
void ReadHardware::init() 
{
	// select a device by device number or device description and specify the access mode.
	DeviceInformation devInfo(deviceDescription);
	ret = instantDiCtrl->setSelectedDevice(devInfo);
	if( ret != Success)
	{
		throw LzException(1, "initialize hardware failed");
	}
	// 设置该端口为输入模式
	ICollection<PortDirection>* portDirection = instantDiCtrl->getPortDirection();
	portDirection->getItem(m_nPortNum).setDirection(Input);
}
Example #4
0
//--------------------------------------------------------------
void testApp::draw(){
    // if preview is on the bottom
    if(objects.size()==0){
        drawPreview();
    }
    // draw the objects in z-index order, drawing preview where it belongs in the stack
    for(int i=0;i<objects.size();i++){
        for(int j=0;j<zs.size();j++){
            if(zs[j]==i){
                if(current_z==zs[j]){
                    drawPreview();
                }
                if(objects[j].z == current_object){
                    objects[j].draw(true);
                } else {
                    objects[j].draw(false);
                }
            }
        }
        // if preview is on top
        if(current_z==zs.size()){
            drawPreview();
        }
    }
    if(current_sides == 1){
        ofLine(current_point.x-5, current_point.y-5, current_point.x+5, current_point.y+5);
        ofLine(current_point.x-5, current_point.y+5, current_point.x+5, current_point.y-5);
    }
    devInfo();
    if(oskar){
        ofxOscMessage message_sides;
        message_sides.setRemoteEndpoint("127.0.0.1", 5456);
        message_sides.setAddress("/dionysius_background");
        message_sides.addFloatArg(current_sides);
        sender.sendMessage(message_sides);
    }
}
Example #5
0
FakeStackAllocator::FakeStackAllocator(cudaStream_t stream) : stream_(stream), memStack_(0) {
    const int deviceId = cuda::getDevice();
    memStack_ = initializer.getMemoryPool(deviceId)->getFreeMemStack();
    cuda::DeviceInfo devInfo(deviceId);
    alignment_ = devInfo.textureAlignment();
}