XnStatus XnExportedSensorDevice::EnumerateProductionTrees(xn::Context& context, xn::NodeInfoList& TreesList, xn::EnumerationErrors* /*pErrors*/) { XnStatus nRetVal = XN_STATUS_OK; // enumerate connected sensors XnUInt32 nCount = 0; // check if sensor is connected nRetVal = XnSensor::Enumerate(NULL, &nCount); if (nRetVal != XN_STATUS_OUTPUT_BUFFER_OVERFLOW) { // no sensor connected return XN_STATUS_DEVICE_NOT_CONNECTED; } // allocate according to count XnConnectionString* pConnStrings; XN_VALIDATE_CALLOC(pConnStrings, XnConnectionString, nCount); nRetVal = XnSensor::Enumerate(pConnStrings, &nCount); if (nRetVal != XN_STATUS_OK) { xnOSFree(pConnStrings); return (nRetVal); } XnProductionNodeDescription Description; GetDescription(&Description); for (XnUInt32 i = 0; i < nCount; ++i) { // Each connection string is a sensor. Return it if it wasn't created already. if (FindCreatedDevice(context.GetUnderlyingObject(), pConnStrings[i]) == m_createdDevices.End()) { nRetVal = TreesList.Add(Description, pConnStrings[i], NULL); if (nRetVal != XN_STATUS_OK) { xnOSFree(pConnStrings); return (nRetVal); } } } xnOSFree(pConnStrings); return (XN_STATUS_OK); }
XnBool Context_IsValid(xn::Context& self) { return (self.GetUnderlyingObject() != NULL); }
XnStatus XnExportedSensorDevice::Create(xn::Context& context, const XnChar* strInstanceName, const XnChar* strCreationInfo, xn::NodeInfoList* /*pNeededTrees*/, const XnChar* strConfigurationDir, xn::ModuleProductionNode** ppInstance) { XnStatus nRetVal = XN_STATUS_OK; XnChar strGlobalConfigFile[XN_FILE_MAX_PATH]; nRetVal = XnSensor::ResolveGlobalConfigFileName(strGlobalConfigFile, XN_FILE_MAX_PATH, strConfigurationDir); XN_IS_STATUS_OK(nRetVal); // multi-process is not supported on Mac #if (XN_PLATFORM == XN_PLATFORM_MACOSX) XnBool bEnableMultiProcess = FALSE; #else XnBool bEnableMultiProcess = XN_SENSOR_DEFAULT_MULTI_PROCESS; XnUInt32 nValue; if (XN_STATUS_OK == xnOSReadIntFromINI(strGlobalConfigFile, XN_SENSOR_SERVER_CONFIG_FILE_SECTION, XN_MODULE_PROPERTY_ENABLE_MULTI_PROCESS, &nValue)) { bEnableMultiProcess = (nValue == TRUE); } #endif XnDeviceBase* pSensor = NULL; if (bEnableMultiProcess) { XN_VALIDATE_NEW(pSensor, XnSensorClient); } else { XN_VALIDATE_NEW(pSensor, XnSensor); } XnDeviceConfig config; config.DeviceMode = XN_DEVICE_MODE_READ; config.cpConnectionString = strCreationInfo; config.SharingMode = XN_DEVICE_EXCLUSIVE; config.pInitialValues = NULL; if (strConfigurationDir != NULL) { if (bEnableMultiProcess) { XnSensorClient* pClient = (XnSensorClient*)pSensor; pClient->SetConfigDir(strConfigurationDir); } else { XnSensor* pActualSensor = (XnSensor*)pSensor; pActualSensor->SetGlobalConfigFile(strGlobalConfigFile); } } nRetVal = pSensor->Init(&config); if (nRetVal != XN_STATUS_OK) { XN_DELETE(pSensor); return (nRetVal); } XnSensorDevice* pDevice = XN_NEW(XnSensorDevice, context, pSensor, strInstanceName); if (pDevice == NULL) { XN_DELETE(pSensor); return (XN_STATUS_ALLOC_FAILED); } nRetVal = pDevice->Init(); if (nRetVal != XN_STATUS_OK) { XN_DELETE(pDevice); XN_DELETE(pSensor); return (nRetVal); } nRetVal = m_createdDevices.AddLast(DeviceKey(context.GetUnderlyingObject(), strCreationInfo)); if (nRetVal != XN_STATUS_OK) { XN_DELETE(pDevice); XN_DELETE(pSensor); return (nRetVal); } *ppInstance = pDevice; return (XN_STATUS_OK); }
BP::object Context_FindExistingNode_wrapped(xn::Context& self, XnProductionNodeType type) { XnNodeHandle ret = NULL; xnFindExistingRefNodeByType(self.GetUnderlyingObject(), type, &ret); return wrapNode(ret); }