Exemplo n.º 1
0
BOOL OpenContext::GetConfigDescriptor(LPUKWD_GET_CONFIG_DESC_INFO lpConfigInfo, LPDWORD lpSize)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), lpConfigInfo->lpDevice);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}
	UserBuffer<LPVOID> descriptorBuf(UBA_WRITE, lpConfigInfo->lpDescriptorBuffer, lpConfigInfo->dwDescriptorBufferSize);
	if (!descriptorBuf.Valid()) {
		SetLastError(ERROR_NOT_ENOUGH_MEMORY);
		return FALSE;
	}
	BOOL status = FALSE;
	if (lpConfigInfo->dwConfigIndex == UKWD_ACTIVE_CONFIGURATION) {
		status = dev->GetActiveConfigDescriptor(descriptorBuf, lpSize);
	} else {
		status = dev->GetConfigDescriptor(lpConfigInfo->dwConfigIndex, descriptorBuf, lpSize);
	}
	if (!status) {
		ERROR_MSG((TEXT("USBKWrapperDrv!OpenContext::GetConfigDescriptor() - ")
			TEXT("failed to retrieve device 0x%08x config descriptor idx %d\r\n"),
			lpConfigInfo->lpDevice, lpConfigInfo->dwConfigIndex));
		return FALSE;
	}
	descriptorBuf.Flush();
	return TRUE;
}
Exemplo n.º 2
0
BOOL OpenContext::SetActiveConfigValue(LPUKWD_SET_ACTIVE_CONFIG_VALUE_INFO lpConfigValueInfo)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), lpConfigValueInfo->lpDevice);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	if (dev->AnyInterfacesClaimed()) {
		ERROR_MSG((TEXT("USBKWrapperDrv!OpenContext::SetActiveConfigValue() - ")
			TEXT("attempting to set configuration on device 0x%08x with claimed interfaces\r\n"),
			lpConfigValueInfo->lpDevice));
		SetLastError(ERROR_BUSY);
		return FALSE;
	}

	/* WARNING: THIS IS NOT SUPPORTED PROPERLY YET!!
	 * The driver has a prototype implementation for IOCTL_UKW_SET_ACTIVE_CONFIG_VALUE,
	 * which manually sends the SET_CONFIGURATION control transfer. This, however, then
	 * causes WinCE to become out-of-sync with the actual device configuration (most likely
	 * leading to all sorts of fun and games!). Currently, the driver therefore only send
	 * the control transfer if the requested configuration is already active.
	 */
	UCHAR cv = 0;
	GetActiveConfigValue(lpConfigValueInfo->lpDevice, &cv);
	if (cv != lpConfigValueInfo->value) {
		SetLastError(ERROR_NOT_SUPPORTED);
		return FALSE;
	}
	return dev->SetActiveConfigValue(lpConfigValueInfo->value);
}
//added by Cristian.Guef
int NodesRepository::Add(const DevicePtr& node)
{
	if (!nodesByMAC.insert(NodesByMACT::value_type(node->Mac(), node)).second)
	{
		LOG_WARN("Same MAC:" << node->Mac().ToString() << "was detected (will be ignored)!");
		return 0;
	}
	return 1;
}
Exemplo n.º 4
0
BOOL OpenContext::StartBulkTransfer(LPUKWD_BULK_TRANSFER_INFO lpTransferInfo)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), lpTransferInfo->lpDevice);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	// Interface can't be used if device has closed
	if (dev->Closed()) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	// Find the interface for this transfer
	DWORD dwInterface;
	if (!dev->FindInterface(lpTransferInfo->Endpoint, dwInterface)) {
		ERROR_MSG((TEXT("USBKWrapperDrv!OpenContext::StartBulkTransfer() - ")
			TEXT("failed to find interface for endpoint %d on device 0x%08x\r\n"),
			lpTransferInfo->Endpoint, lpTransferInfo->lpDevice));
		SetLastError(ERROR_INVALID_PARAMETER);
		return FALSE;
	}

	// See if it's already been claimed
	if (!dev->InterfaceClaimed(dwInterface, this)) {
		WARN_MSG((TEXT("USBKWrapperDrv!OpenContext::StartBulkTransfer() - ")
			TEXT("using interface %d on device 0x%08x without claiming\r\n"),
			dwInterface, lpTransferInfo->lpDevice));
		if (!dev->ClaimInterface(dwInterface, this)) {
			return FALSE;
		}
	}

	TRANSFERLIFETIME_MSG((TEXT("USBKWrapperDrv!OpenContext::StartBulkTransfer() on ep %x, flag 0x%08x and size %d\r\n"),
		lpTransferInfo->Endpoint, lpTransferInfo->dwFlags, lpTransferInfo->dwDataBufferSize));

	// Construct and start the bulk transfer
	BulkTransfer* bt = new (std::nothrow) BulkTransfer(
			this, dev, dwInterface, lpTransferInfo);
	if (!bt) {
		ERROR_MSG((TEXT("USBKWrapperDrv!OpenContext::StartBulkTransfer() - failed to create bulk transfer, aborting\r\n")));
		SetLastError(ERROR_NOT_ENOUGH_MEMORY);
		return FALSE;
	}
	BOOL ret = bt->Start();
	mTransferList->PutTransfer(bt);
	bt = NULL;
	if (!ret) {
		ERROR_MSG((TEXT("USBKWrapperDrv!OpenContext::StartBulkTransfer() - failed to start bulk transfer %d\r\n"), GetLastError()));
		return FALSE;
	}
	// Ownership of ct has passed to the transfer callback
	return TRUE;
}
Exemplo n.º 5
0
BOOL OpenContext::DetachKernelDriverForInterface(LPUKWD_INTERFACE_INFO lpInterfaceInfo)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), lpInterfaceInfo->lpDevice);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}
	return dev->DetachKernelDriverForInterface(lpInterfaceInfo->dwInterface);
}
Exemplo n.º 6
0
BOOL OpenContext::ReenumerateDevice(UKWD_USB_DEVICE DeviceIdentifier)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), DeviceIdentifier);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}
	return dev->Reenumerate();
}
Exemplo n.º 7
0
BOOL OpenContext::GetActiveConfigValue(UKWD_USB_DEVICE DeviceIdentifier, PUCHAR pConfigurationValue)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), DeviceIdentifier);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}
	return dev->GetActiveConfigValue(pConfigurationValue);
}
Exemplo n.º 8
0
StaticMesh::StaticMesh(DevicePtr dptr, const MeshData& mesh_data) :
		_triangle_buffer(dptr, mesh_data.triangles().size()),
		_vertex_buffer(dptr, mesh_data.vertices().size()),
		_indirect_data(mesh_data.triangles().size() * 3, 1),
		_radius(mesh_data.radius()) {

	CmdBufferRecorder recorder(dptr->create_disposable_cmd_buffer());
	Mapping::stage(_triangle_buffer, recorder, mesh_data.triangles().data());
	Mapping::stage(_vertex_buffer, recorder, mesh_data.vertices().data());
	dptr->graphic_queue().submit<SyncSubmit>(RecordedCmdBuffer(std::move(recorder)));
}
Exemplo n.º 9
0
static vk::Buffer create_buffer(DevicePtr dptr, usize byte_size, vk::BufferUsageFlags usage) {
	y_debug_assert(byte_size);
	if(usage & vk::BufferUsageFlagBits::eUniformBuffer) {
		if(byte_size > dptr->vk_limits().maxUniformBufferRange) {
			y_fatal("Uniform buffer size exceeds maxUniformBufferRange (%).", dptr->vk_limits().maxUniformBufferRange);
		}
	}
	return dptr->vk_device().createBuffer(vk::BufferCreateInfo()
			.setSize(byte_size)
			.setUsage(usage)
			.setSharingMode(vk::SharingMode::eExclusive)
		);
}
Exemplo n.º 10
0
// Called with the mutex lock already held
BOOL OpenContext::PutDevice(UKWD_USB_DEVICE DeviceIdentifier)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), DeviceIdentifier);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}
	mOpenDevices.erase(dev.Get());
	// Put for the reference in mOpenDevices
	mDevice->GetDeviceList()->PutDevice(dev.Get());
	return TRUE;
}
Exemplo n.º 11
0
PlayerBehavior::CONTROLL PlayerBehavior::makeControll( ) {
	PlayerBehavior::CONTROLL controll;

	if ( _controll ) {
		// 自分で動かす
		DevicePtr device = Device::getTask( );
		unsigned char button = device->getButton( );

		CameraPtr camera = Camera::getTask( );
		PlayerCameraPtr p_camera = std::dynamic_pointer_cast< PlayerCamera >( camera );
		Vector move_vec = p_camera->getConvertDeviceVec( );
		Character::STATUS status = _parent->getStatus( );
		move_vec = move_vec.normalize( ) * status.speed;//プレイヤーの進行ベクトル

		controll.move = move_vec;
		if ( button & BUTTON_D ) {
			controll.action = CONTROLL::DEATHBLOW;
		} else if ( button & BUTTON_A ) {
			controll.action = CONTROLL::ATTACK;
		} else {
			controll.action = CONTROLL::NONE;
		}	
	} else {
		// ネットから動かす
		ClientPtr client = Client::getTask( );
		CLIENTDATA data = client->getClientData( );

		Vector target;
		target.x = data.player[ _player_id ].x;
		target.y = data.player[ _player_id ].y;
		Vector vec = target - _parent->getPos( );
		Character::STATUS status = _parent->getStatus( );
		if ( vec.getLength( ) > status.speed * 2 ) {
			vec = vec.normalize( ) * status.speed;
			controll.move = vec;
		}
		switch ( data.player[ _player_id ].action ) {
		case ACTION_NONE:
			controll.action = CONTROLL::NONE;
			break;
		case ACTION_ATTACK:
			controll.action = CONTROLL::ATTACK;
			break;
		case ACTION_DEATHBLOW:
			controll.action = CONTROLL::MUSTDEATHBLOW;
			break;
		}

	}
	return controll;
}
Exemplo n.º 12
0
// Checks that device is valid and is open
// by this context.
BOOL OpenContext::Validate(DevicePtr& device)
{
	if (!device.Valid())
		return FALSE;
	PtrArray<UsbDevice>::iterator it
		= mOpenDevices.find(device.Get());
	if (it == mOpenDevices.end()) {
	    WARN_MSG((TEXT("USBKWrapperDrv!OpenContext::Validate")
			TEXT(" - failed to find device in this context for identifier 0x%08x\r\n"),
			device->GetIdentifier()));
		return FALSE;
	} 
	return TRUE;
}
Exemplo n.º 13
0
static vk::DescriptorSet create_descriptor_set(DevicePtr dptr, vk::DescriptorPool pool, vk::DescriptorSetLayout layout) {
	return dptr->vk_device().allocateDescriptorSets(vk::DescriptorSetAllocateInfo()
			.setDescriptorPool(pool)
			.setDescriptorSetCount(1)
			.setPSetLayouts(&layout)
		).front();
}
Exemplo n.º 14
0
void BodyStateViewImpl::updateDeviceStates(DevicePtr device, int rowIndex)
{
    if(currentBody){
        StateItem* item = static_cast<StateItem*>(stateTreeWidget.topLevelItem(rowIndex));
        int size = device->stateSize();
        buf.resize(size);
        device->writeState(&buf.front());
        int i;
        for(i=0; i < size; ++i){
            item->setText(i + 1, QString::number(buf[i], 'f', 2));
        }
        for(   ; i < item->lastNumValidColumns; ++i){
            item->setText(i + 1, "");
        }
        item->lastNumValidColumns = size;
    }
}
Exemplo n.º 15
0
//-----------------------------------------------------------------------------
GpuPtr Helper::getGpu(int index)
{
    // Check it against selection criteria.
    pair_int gpuBlock = selectDeviceAndBlock(index);
    if (-1 == gpuBlock.first) return GpuPtr();

    scoped_lock lock(mutex);

    // First check to see if this GPU device has been initialized.
    DevicePtr device;
    DevicelPtrMap::iterator dit = devPtrMap.find(gpuBlock.first);
    if (dit == devPtrMap.end())
    {
        device.reset(new Device(gpuBlock.first));
        // Double check to make sure our device is OK
        if (-1 == device->ID()) return GpuPtr();
        devPtrMap.insert(std::make_pair(gpuBlock.first, device));
    }
    else
    {
        device = dit->second;
        // Make sure we activate this per-thread.
        device->setDevice();
    }

    // Now that we have a device, get the block implementation handle.
    GpuPtr impl;
    GpuPtrMap::iterator it = gpuPtrMap.find(index);
    if (it == gpuPtrMap.end())
    {
        impl.reset(new Gpu(device));
        gpuPtrMap.insert(std::make_pair(index, impl));
    }
    else
    {
        impl = it->second;
    }

    if (!atExitRegistered)
    {
        atexit(Helper::destroy);
        atExitRegistered = true;
    }
    return impl;
}
Exemplo n.º 16
0
static std::tuple<vk::Buffer, DeviceMemory> alloc_buffer(DevicePtr dptr, usize buffer_size, vk::BufferUsageFlags usage, MemoryType type) {
	y_debug_assert(buffer_size);

	auto buffer = create_buffer(dptr, buffer_size, usage);
	auto memory = dptr->allocator().alloc(buffer, type);
	bind_buffer_memory(dptr, buffer, memory);

	return {buffer, std::move(memory)};
}
Exemplo n.º 17
0
DevicePtr<cuda::Transformation3D> Transformation3D::CopyToGpu(DevicePtr<cuda::Transformation3D> const gpu_ptr) const {

   gpu_ptr.Construct(fTranslation[0], fTranslation[1], fTranslation[2],
                     fRotation[0], fRotation[1], fRotation[2],
                     fRotation[3], fRotation[4], fRotation[5],
                     fRotation[6], fRotation[7], fRotation[8]);
   CudaAssertError();
   return gpu_ptr;
}
Exemplo n.º 18
0
static vk::ShaderModule create_shader_module(DevicePtr dptr, const SpirVData& data) {
	if(data.is_empty()) {
		return vk::ShaderModule();
	}
	return dptr->vk_device().createShaderModule(vk::ShaderModuleCreateInfo()
			.setCodeSize(data.size())
			.setPCode(data.data())
		);
}
Exemplo n.º 19
0
DevicePtr<cuda::LogicalVolume> LogicalVolume::CopyToGpu(
   DevicePtr<cuda::VUnplacedVolume> const unplaced_vol,
   DevicePtr<cuda::Vector<CudaDaughter_t>> daughters,
   DevicePtr<cuda::LogicalVolume> const gpu_ptr) const
{
   gpu_ptr.Construct( unplaced_vol, daughters );
   CudaAssertError();
   return gpu_ptr;
}
Exemplo n.º 20
0
BOOL OpenContext::SetAltSetting(LPUKWD_SET_ALTSETTING_INFO lpSetAltSettingInfo)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), lpSetAltSettingInfo->lpDevice);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}

	if (!dev->InterfaceClaimed(lpSetAltSettingInfo->dwInterface, this)) {
		WARN_MSG((TEXT("USBKWrapperDrv!OpenContext::SetAltSetting() - ")
			TEXT("using interface %d on device 0x%08x without claiming\r\n"),
			lpSetAltSettingInfo->dwInterface, lpSetAltSettingInfo->lpDevice));
		if (!dev->ClaimInterface(lpSetAltSettingInfo->dwInterface, this)) {
			return FALSE;
		}
	}
	return dev->SetAltSetting(lpSetAltSettingInfo->dwInterface,
						lpSetAltSettingInfo->dwAlternateSetting);
}
Exemplo n.º 21
0
	void BoxClass::TruncateBoxList (Box dev)
	{
		STUB;
		return;
#if 0
		if (!boxList) return;

		if (boxList == dev) {
			boxList = NULL;
			return;
		}

		DevicePtr d = boxList ;
		while (d->GetNext() && d->GetNext() != dev) {
			d = d->GetNext();
		}
		if (d->GetNext()) {
			d -> SetNext(NULL);
		}
#endif
	}
Exemplo n.º 22
0
void P44VdcHost::identifyHandler(JsonCommPtr aJsonComm, DevicePtr aDevice)
{
  MainLoop::currentMainLoop().cancelExecutionTicket(learnIdentifyTicket);
  if (aDevice) {
    sendCfgApiResponse(aJsonComm, JsonObject::newString(aDevice->getDsUid().getString()), ErrorPtr());
    // end monitor mode
    setUserActionMonitor(NULL);
  }
  else {
    sendCfgApiResponse(aJsonComm, JsonObjectPtr(), Error::err<P44VdcError>(408, "identify timeout"));
    setUserActionMonitor(NULL);
  }
  learnIdentifyRequest.reset();
}
Exemplo n.º 23
0
DepthCameraPtr TintinCDKCameraFactory::getDepthCamera(DevicePtr device)
{
  if(device->interfaceID() == Device::USB)
  {
    USBDevice &d = (USBDevice &)*device;
    
    if(d.vendorID() == TINTIN_CDK_VENDOR_ID && 
      (d.productID() == TINTIN_CDK_PRODUCT_BULK || d.productID() == TINTIN_CDK_PRODUCT_UVC))
    {
      return DepthCameraPtr(new TintinCDKCamera(device));
    }
  }
  
  return 0;
}
Exemplo n.º 24
0
void ColladaBodyLoaderImpl::setSensor(DaeNode* extNode, Link* link, Body& body)
{
    DaeLink* nodeLink = static_cast<DaeLink*>(extNode);

    DaeResultSensors* sensors = parser->findSensor(nodeLink->id);
    if (sensors->size() <= 0) {
        return;
    }

    // ForceSensor--------->force6d
    // GyroSensor---------->no type(empty string)
    // AccelerrationSensor->imu(unit sensor)
    // VisionSensor-------->pin-hole-camera
       
    for (DaeResultSensors::iterator iters = sensors->begin(); iters != sensors->end(); iters++) {
        DaeSensor* sensor = *iters;
        DevicePtr device = createSensor(sensor);
        device->setLink(link);
        device->setLocalTranslation(extNode->transform.translate + sensor->transform.translate);
        device->setLocalRotation   (extNode->transform.rotate.matrix() * sensor->transform.rotate.matrix());
        body.addDevice(device); 
    } 

}
Exemplo n.º 25
0
DevicePtr ColladaBodyLoaderImpl::createSensor(DaeSensor* sensor)
{
    DevicePtr device;
    if (sensor->type.size() <= 0) {
        device = new RateGyroSensor;
    } else 
        if (iequals(sensor->type, "base_force6d")) {
            device = new ForceSensor;
        } else
            if (iequals(sensor->type, "base_imu")) {
                device = new AccelerationSensor;
            } else 
                if (iequals(sensor->type, "base_pinhole_camera")) {
                    device = new Camera;
                    Camera* camera = static_cast<Camera*>(device.get());
                    camera->setResolution(sensor->imageDimensions[0], sensor->imageDimensions[1]);
                    camera->setNearDistance(sensor->focalLength);
                    camera->setFieldOfView (sensor->focalLength);
                } else {
                    throwException((format(_("invalid sensor-type:%1%")) % sensor->type).str());
                }      

    return device;
}
Exemplo n.º 26
0
static vk::DescriptorPool create_descriptor_pool(DevicePtr dptr, const std::unordered_map<vk::DescriptorType, u32>& binding_counts) {
	auto sizes = core::vector_with_capacity<vk::DescriptorPoolSize>(binding_counts.size());
	std::transform(binding_counts.begin(), binding_counts.end(), std::back_inserter(sizes), [](const auto& count) {
			return vk::DescriptorPoolSize()
					.setType(count.first)
					.setDescriptorCount(count.second)
				;
		});

	return dptr->vk_device().createDescriptorPool(vk::DescriptorPoolCreateInfo()
			.setPoolSizeCount(sizes.size())
			.setPPoolSizes(sizes.begin())
			.setMaxSets(1)
		);
}
Exemplo n.º 27
0
/**
 * \brief Construct a camera from a camera description
 *
 * \param name		Name of the camera
 * \return Camera with that name
 */
CameraPtr	SxCameraLocator::getCamera0(const DeviceName& name) {
	std::string	sname = name.unitname();
	debug(LOG_DEBUG, DEBUG_LOG, 0, "analyzing '%s'", sname.c_str());
	// parse the name string
	int	busnumber = 0, deviceaddress = 0;
	sxparse(sname, busnumber, deviceaddress);
	debug(LOG_DEBUG, DEBUG_LOG, 0,
		"looking for busnumber=%d, deviceaddress=%d",
		busnumber, deviceaddress);

	// find the device with this bus number and address
	std::vector<DevicePtr>	d = context.devices();
	std::vector<DevicePtr>::const_iterator	i;
	for (i = d.begin(); i != d.end(); i++) {
		DevicePtr	dptr = (*i);
		if ((dptr->getBusNumber() == busnumber) &&
			(dptr->getDeviceAddress() == deviceaddress)) {
			debug(LOG_DEBUG, DEBUG_LOG, 0, "found matching device");
			dptr->open();
			return CameraPtr(new SxCamera(dptr));
		}
	}
	throw SxError("cannot create a camera from a name");
}
Exemplo n.º 28
0
DescriptorSet::DescriptorSet(DevicePtr dptr, core::ArrayView<Binding> bindings) : DescriptorSetBase(dptr) {
	if(!bindings.is_empty()) {
		auto layout_bindings = core::vector_with_capacity<vk::DescriptorSetLayoutBinding>(bindings.size());

		std::unordered_map<vk::DescriptorType, u32> binding_counts;
		for(const auto& binding : bindings) {
			layout_bindings << binding.descriptor_set_layout_binding(layout_bindings.size());
			++binding_counts[binding.vk_descriptor_type()];
		}

		auto layout = dptr->create_descriptor_set_layout(layout_bindings);
		_pool = create_descriptor_pool(dptr, binding_counts);
		_set = create_descriptor_set(dptr, _pool, layout);
		update_sets(dptr, _set, layout_bindings, bindings);
	}
}
Exemplo n.º 29
0
static void update_sets(DevicePtr dptr, vk::DescriptorSet set, const core::Vector<vk::DescriptorSetLayoutBinding>& /*layout_binding*/, const core::ArrayView<Binding>& bindings) {
	auto writes = core::vector_with_capacity<vk::WriteDescriptorSet>(bindings.size());
	for(const auto& binding : bindings) {
		auto w = vk::WriteDescriptorSet()
				.setDstSet(set)
				.setDstBinding(u32(writes.size()))
				.setDstArrayElement(0)
				.setDescriptorCount(1)
				.setDescriptorType(binding.vk_descriptor_type())
			;

		if(binding.is_buffer()) {
			w.setPBufferInfo(&binding.descriptor_info().buffer);
		} else if(binding.is_image()) {
			w.setPImageInfo(&binding.descriptor_info().image);
		} else {
			y_fatal("Unknown descriptor type.");
		}

		writes << w;
	}
	dptr->vk_device().updateDescriptorSets(u32(writes.size()), writes.begin(), 0, nullptr);
}
Exemplo n.º 30
0
void VRMLBodyLoaderImpl::readDeviceNode(LinkInfo& iLink, VRMLProtoInstance* deviceNode, const Affine3& T)
{
    const string& typeName = deviceNode->proto->protoName;
    if(isVerbose) putMessage(typeName + " node " + deviceNode->defName);
    
    DeviceFactoryMap::iterator p = deviceFactories.find(typeName);
    if(p == deviceFactories.end()){
        os() << str(format("Sensor type %1% is not supported.\n") % typeName) << endl;
    } else {
        DeviceFactory& factory = p->second;
        DevicePtr device = factory(deviceNode);
        if(device){
            device->setLink(iLink.link);
            const Matrix3 RsT = iLink.link->Rs();
            device->setLocalTranslation(RsT * (T * device->localTranslation()));
            device->setLocalRotation(RsT * (T.linear() * device->localRotation()));
            body->addDevice(device);
        }
    }
}