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);
}
Ejemplo n.º 2
0
XN_DDK_API XnStatus XnPropertySetEnumeratorGetCurrentPropertyInfo(const XnPropertySetEnumerator* pEnumerator, XnPropertyType* pnType, const XnChar** pstrModule, const XnChar** pstrProp)
{
	XN_VALIDATE_INPUT_PTR(pEnumerator);
	XN_VALIDATE_OUTPUT_PTR(pnType);
	XN_VALIDATE_OUTPUT_PTR(pstrModule);
	XN_VALIDATE_OUTPUT_PTR(pstrProp);

	XnProperty* pProp = pEnumerator->itProp->Value();
	*pnType = pProp->GetType();
	*pstrModule = pProp->GetModule();
	*pstrProp = pProp->GetName();

	return (XN_STATUS_OK);
}
Ejemplo n.º 3
0
XnStatus XnFileDevice::HandleNewStream(const XnChar *strType, const XnChar *strName, const XnActualPropertiesHash *pInitialValues)
{
    XnStatus nRetVal = XN_STATUS_OK;

    // check if we need to ignore that (stream was not removed upon Rewind).
    XnNodeInfoMap::Iterator it = m_ignoreNewNodes.End();
    if (m_ignoreNewNodes.Find(strName, it) == XN_STATUS_OK)
    {
        // ignore
        return (XN_STATUS_OK);
    }

    XnProductionNodeType type = GetNodeType(strType);
    if (type == -1)
    {
        XN_LOG_WARNING_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_FILE, "Invalid node type: %s", strType);
    }

    // find compression type
    XnActualIntProperty* pComp = NULL;
    nRetVal = pInitialValues->Get(XN_STREAM_PROPERTY_COMPRESSION, (XnProperty*&)pComp);
    XN_IS_STATUS_OK(nRetVal);

    XnCodecID codecID = XnCodec::GetCodecIDFromCompressionFormat((XnCompressionFormats)pComp->GetValue());
    if (codecID == XN_CODEC_NULL)
    {
        XN_LOG_WARNING_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_FILE, "Invalid compression type: %llu", pComp->GetValue());
    }

    // notify we have a new node
    nRetVal = m_pNotifications->OnNodeAdded(m_pNotificationsCookie, strName, type, codecID);
    XN_IS_STATUS_OK(nRetVal);

    // we support the mirror capability
    nRetVal = m_pNotifications->OnNodeIntPropChanged(m_pNotificationsCookie, strName, XN_CAPABILITY_MIRROR, 1);
    XN_IS_STATUS_OK(nRetVal);

    // we support the extended serialization capability
    nRetVal = m_pNotifications->OnNodeIntPropChanged(m_pNotificationsCookie, strName, XN_CAPABILITY_EXTENDED_SERIALIZATION, 1);
    XN_IS_STATUS_OK(nRetVal);

    // now write state
    for (XnActualPropertiesHash::ConstIterator it = pInitialValues->Begin(); it != pInitialValues->End(); ++it)
    {
        XnProperty* pProp = it->Value();

        switch (pProp->GetType())
        {
        case XN_PROPERTY_TYPE_INTEGER:
        {
            XnActualIntProperty* pIntProp = (XnActualIntProperty*)pProp;
            nRetVal = HandleIntProperty(strName, pProp->GetName(), pIntProp->GetValue());
        }
        break;
        case XN_PROPERTY_TYPE_REAL:
        {
            XnActualRealProperty* pRealProp = (XnActualRealProperty*)pProp;
            nRetVal = HandleRealProperty(strName, pProp->GetName(), pRealProp->GetValue());
        }
        break;
        case XN_PROPERTY_TYPE_STRING:
        {
            XnActualStringProperty* pStrProp = (XnActualStringProperty*)pProp;
            nRetVal = HandleStringProperty(strName, pProp->GetName(), pStrProp->GetValue());
        }
        break;
        case XN_PROPERTY_TYPE_GENERAL:
        {
            XnActualGeneralProperty* pGenProp = (XnActualGeneralProperty*)pProp;
            nRetVal = HandleGeneralProperty(strName, pProp->GetName(), pGenProp->GetValue());
        }
        break;
        default:
            XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_FILE, "Unknown property type: %d", pProp->GetType());
        }

        XN_IS_STATUS_OK(nRetVal);
    }

    // at this stage, a node should exist with this name
    xn::ProductionNode node;
    nRetVal = m_context.GetProductionNodeByName(strName, node);
    XN_IS_STATUS_OK(nRetVal);

    // S2D & RW
    if (type == XN_NODE_TYPE_DEPTH)
    {
        nRetVal = UpdateS2DTables(xn::DepthGenerator(node));
        XN_IS_STATUS_OK(nRetVal);

        nRetVal = UpdateRWData(xn::DepthGenerator(node));
        XN_IS_STATUS_OK(nRetVal);
    }

    // notify end-of-state
    nRetVal = m_pNotifications->OnNodeStateReady(m_pNotificationsCookie, strName);
    XN_IS_STATUS_OK(nRetVal);

    // add it to the map
    XnNodeInfo nodeInfo = {0};
    nRetVal = m_nodeInfoMap.Set(strName, nodeInfo);
    XN_IS_STATUS_OK(nRetVal);

    // create codec
    nRetVal = CreateCodec(node);
    XN_IS_STATUS_OK(nRetVal);

    // check IR compatibility
    nRetVal = CheckIRCompatibility(node);
    XN_IS_STATUS_OK(nRetVal);

    return (XN_STATUS_OK);
}
XnStatus XnSensorProductionNode::NotifyExState(XnNodeNotifications* pNotifications, void* pCookie)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	// get all properties
	XN_PROPERTY_SET_CREATE_ON_STACK(props);
	nRetVal = m_pSensor->GetAllProperties(&props, FALSE, GetModuleName());
	XN_IS_STATUS_OK(nRetVal);

	XnActualPropertiesHash* pPropsHash = props.pData->begin().Value();

	// filter properties (remove the ones already exposed as OpenNI interfaces)
	FilterProperties(pPropsHash);

	const XnChar* astrIntProps[200] = {0};
	const XnChar* astrRealProps[200] = {0};
	const XnChar* astrStringProps[200] = {0};
	const XnChar* astrGeneralProps[200] = {0};

	XnUInt32 nIntProps = 0;
	XnUInt32 nRealProps = 0;
	XnUInt32 nStringProps = 0;
	XnUInt32 nGeneralProps = 0;

	// enumerate over properties
	for (XnActualPropertiesHash::Iterator it = pPropsHash->begin(); it != pPropsHash->end(); ++it)
	{
		XnProperty* pProp = it.Value();

		switch (pProp->GetType())
		{
		case XN_PROPERTY_TYPE_INTEGER:
			{
				XnActualIntProperty* pIntProp = (XnActualIntProperty*)pProp;
				pNotifications->OnNodeIntPropChanged(pCookie, GetInstanceName(), pProp->GetName(), pIntProp->GetValue());
				astrIntProps[nIntProps++] = pProp->GetName();
			}
			break;
		case XN_PROPERTY_TYPE_REAL:
			{
				XnActualRealProperty* pRealProp = (XnActualRealProperty*)pProp;
				pNotifications->OnNodeRealPropChanged(pCookie, GetInstanceName(), pProp->GetName(), pRealProp->GetValue());
				astrRealProps[nRealProps++] = pProp->GetName();
			}
			break;
		case XN_PROPERTY_TYPE_STRING:
			{
				XnActualStringProperty* pStrProp = (XnActualStringProperty*)pProp;
				pNotifications->OnNodeStringPropChanged(pCookie, GetInstanceName(), pProp->GetName(), pStrProp->GetValue());
				astrStringProps[nStringProps++] = pProp->GetName();
			}
			break;
		case XN_PROPERTY_TYPE_GENERAL:
			{
				XnActualGeneralProperty* pGenProp = (XnActualGeneralProperty*)pProp;
				pNotifications->OnNodeGeneralPropChanged(pCookie, GetInstanceName(), pProp->GetName(), pGenProp->GetValue().nDataSize, pGenProp->GetValue().pData);
				astrGeneralProps[nGeneralProps++] = pProp->GetName();
			}
			break;
		default:
			XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DEVICE_SENSOR, "Unknown property type: %d", pProp->GetType());
		}
	}

	// TODO: also register to these properties, and if changed, notify.

	// store notifications object
	m_pNotifications = pNotifications;
	m_pCookie = pCookie;

	return (XN_STATUS_OK);
}