XnStatus XnDeviceModuleHolder::UnsafeSetProperties(const XnActualPropertiesHash& props)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	for (XnActualPropertiesHash::ConstIterator it = props.Begin(); it != props.End(); ++it)
	{
		XnProperty* pRequestProp = it->Value();
		XnProperty* pProp = NULL;

		// check if property already exist
		nRetVal = m_pModule->GetProperty(pRequestProp->GetName(), &pProp);
		if (nRetVal == XN_STATUS_DEVICE_PROPERTY_DONT_EXIST)
		{
			// property doesn't exist. create it now
			nRetVal = CreateProperty(pRequestProp);
			XN_IS_STATUS_OK(nRetVal);
		}
		else if (nRetVal == XN_STATUS_OK)
		{
			// property exists. Change its value
			nRetVal = UnsafeSetProperty(pRequestProp, pProp);
			XN_IS_STATUS_OK(nRetVal);
		}
		else
		{
			// error
			return (nRetVal);
		}

	} // props loop
	
	return (XN_STATUS_OK);
}
XnStatus XnServerSensorInvoker::RegisterToProps(XnPropertySet* pProps)
{
	XnStatus nRetVal = XN_STATUS_OK;
	XnCallbackHandle hDummy = NULL;

	for (XnPropertySetData::Iterator itMod = pProps->pData->Begin(); itMod != pProps->pData->End(); ++itMod)
	{
		XnActualPropertiesHash* pHash = itMod->Value();

		XnDeviceModule* pModule;
		nRetVal = m_sensor.FindModule(itMod->Key(), &pModule);
		XN_IS_STATUS_OK(nRetVal);

		for (XnActualPropertiesHash::Iterator itProp = pHash->Begin(); itProp != pHash->End(); ++itProp)
		{
			XnProperty* pProp;
			nRetVal = pModule->GetProperty(itProp->Key(), &pProp);
			XN_IS_STATUS_OK(nRetVal);

			// no need to keep the handle. We only want to unregister when the stream is destroyed, and then
			// it happens anyway.
			nRetVal = pProp->OnChangeEvent().Register(PropertyChangedCallback, this, hDummy);
			XN_IS_STATUS_OK(nRetVal);
		}
	}

	return (XN_STATUS_OK);
}
コード例 #3
0
ファイル: XnPropertySet.cpp プロジェクト: 02031991/Sensor
XN_DDK_API XnStatus XnPropertySetCloneModule(const XnPropertySet* pSource, XnPropertySet* pDest, const XnChar* strModule, const XnChar* strNewName)
{
	XnStatus nRetVal = XN_STATUS_OK;

	XnActualPropertiesHash* pModuleProps = NULL;
	nRetVal = pSource->pData->Get(strModule, pModuleProps);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = XnPropertySetAddModule(pDest, strNewName);
	XN_IS_STATUS_OK(nRetVal);

	for (XnActualPropertiesHash::ConstIterator it = pModuleProps->Begin(); it != pModuleProps->End(); ++it)
	{
		XnProperty* pProp = it->Value();
		switch (pProp->GetType())
		{
		case XN_PROPERTY_TYPE_INTEGER:
			{
				XnActualIntProperty* pIntProp = (XnActualIntProperty*)pProp;
				nRetVal = XnPropertySetAddIntProperty(pDest, strNewName, pIntProp->GetName(), pIntProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_REAL:
			{
				XnActualRealProperty* pRealProp = (XnActualRealProperty*)pProp;
				nRetVal = XnPropertySetAddRealProperty(pDest, strNewName, pRealProp->GetName(), pRealProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_STRING:
			{
				XnActualStringProperty* pStrProp = (XnActualStringProperty*)pProp;
				nRetVal = XnPropertySetAddStringProperty(pDest, strNewName, pStrProp->GetName(), pStrProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_GENERAL:
			{
				XnActualGeneralProperty* pGenProp = (XnActualGeneralProperty*)pProp;
				nRetVal = XnPropertySetAddGeneralProperty(pDest, strNewName, pGenProp->GetName(), &pGenProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		default:
			XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d", pProp->GetType());
		}
	}

	return (XN_STATUS_OK);
}
コード例 #4
0
ファイル: XnDataPacker.cpp プロジェクト: githubgzc/Sensor
XnStatus XnDataPacker::WritePropertySetProperties(const XnPropertySet* pSet)
{
    XnStatus nRetVal = XN_STATUS_OK;

    for (XnPropertySetData::Iterator it = pSet->pData->Begin(); it != pSet->pData->End(); ++it)
    {
        XnActualPropertiesHash* pModule = it->Value();
        for (XnActualPropertiesHash::ConstIterator itProp = pModule->Begin(); itProp != pModule->End(); ++itProp)
        {
            switch (itProp->Value()->GetType())
            {
            case XN_PROPERTY_TYPE_INTEGER:
            {
                XnActualIntProperty* pProp = (XnActualIntProperty*)itProp->Value();
                nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue());
                XN_IS_STATUS_OK(nRetVal);
                break;
            }
            case XN_PROPERTY_TYPE_REAL:
            {
                XnActualRealProperty* pProp = (XnActualRealProperty*)itProp->Value();
                nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue());
                XN_IS_STATUS_OK(nRetVal);
                break;
            }
            case XN_PROPERTY_TYPE_STRING:
            {
                XnActualStringProperty* pProp = (XnActualStringProperty*)itProp->Value();
                nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue());
                XN_IS_STATUS_OK(nRetVal);
                break;
            }
            case XN_PROPERTY_TYPE_GENERAL:
            {
                XnActualGeneralProperty* pProp = (XnActualGeneralProperty*)itProp->Value();
                nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue());
                XN_IS_STATUS_OK(nRetVal);
                break;
            }
            default:
                XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d", itProp->Value()->GetType());
            }
        }
    }

    StartWritingIntenalObject(XN_PACKED_PROPERTY_SET_PROPERTIES_END_MARKER);
    EndWritingInternalObject();

    return (XN_STATUS_OK);
}
コード例 #5
0
XnStatus XnActualPropertiesHash::CopyFrom(const XnActualPropertiesHash& other)
{
	XnStatus nRetVal = XN_STATUS_OK;

	Clear();
	strncpy(m_strName, other.m_strName, XN_DEVICE_MAX_STRING_LENGTH);

	for (ConstIterator it = other.Begin(); it != other.End(); ++it)
	{
		switch (it->Value()->GetType())
		{
		case XN_PROPERTY_TYPE_INTEGER:
			{
				XnActualIntProperty* pProp = (XnActualIntProperty*)it->Value();
				nRetVal = Add(pProp->GetId(), pProp->GetName(), pProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_REAL:
			{
				XnActualRealProperty* pProp = (XnActualRealProperty*)it->Value();
				nRetVal = Add(pProp->GetId(), pProp->GetName(), pProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_STRING:
			{
				XnActualStringProperty* pProp = (XnActualStringProperty*)it->Value();
				nRetVal = Add(pProp->GetId(), pProp->GetName(), pProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_GENERAL:
			{
				XnActualGeneralProperty* pProp = (XnActualGeneralProperty*)it->Value();
				nRetVal = Add(pProp->GetId(), pProp->GetName(), pProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		default:
			XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d\n", it->Value()->GetType());
		}
	}

	return (XN_STATUS_OK);
}
XnStatus XnDeviceModule::UnsafeBatchConfig(const XnActualPropertiesHash& props)
{
	XnStatus nRetVal = XN_STATUS_OK;

	for (XnActualPropertiesHash::ConstIterator it = props.Begin(); it != props.End(); ++it)
	{
		XnProperty* pRequestProp = it->Value();
		switch (pRequestProp->GetType())
		{
		case XN_PROPERTY_TYPE_INTEGER:
			{
				XnActualIntProperty* pProp = (XnActualIntProperty*)pRequestProp;
				nRetVal = UnsafeUpdateProperty(pProp->GetName(), pProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_REAL:
			{
				XnActualRealProperty* pProp = (XnActualRealProperty*)pRequestProp;
				nRetVal = UnsafeUpdateProperty(pProp->GetName(), pProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_STRING:
			{
				XnActualStringProperty* pProp = (XnActualStringProperty*)pRequestProp;
				nRetVal = UnsafeUpdateProperty(pProp->GetName(), pProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_GENERAL:
			{
				XnActualGeneralProperty* pProp = (XnActualGeneralProperty*)pRequestProp;
				nRetVal = UnsafeUpdateProperty(pProp->GetName(), pProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		default:
			XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d\n", pRequestProp->GetType());
		} // type switch
	} // props loop

	return (XN_STATUS_OK);
}