Пример #1
0
    /**
     *  @brief	Create an instance of the PXCSenseManager instance.
     *  @return The PXCMSenseManager instance.
     */
    public static PXCMSenseManager CreateInstance()
    {
        IntPtr           senseManager2 = PXCMSenseManager_CreateInstance();
        PXCMSenseManager senseManager  = (senseManager2 != IntPtr.Zero) ? new PXCMSenseManager(senseManager2, true) : null;

        if (senseManager == null)
        {
            return(senseManager);
        }

        try
        {
            PXCMSession session = senseManager.QuerySession();
            if (session == null)
            {
                return(senseManager);
            }

            try
            {
                PXCMMetadata md = session.QueryInstance <PXCMMetadata>();
                if (md == null)
                {
                    return(senseManager);
                }

                string frameworkName = null;
#if PH_CS
                frameworkName = "CSharp";
#elif PH_UNITY
                frameworkName = "Unity";
#endif
                if (!string.IsNullOrEmpty(frameworkName))
                {
                    md.AttachBuffer(1296451664, System.Text.Encoding.Unicode.GetBytes(frameworkName));
                }
            }
            catch (Exception)
            {
                session.Dispose();
            }
        }
        catch { }
        return(senseManager);
    }
Пример #2
0
        public HandlerDIR(PXCMSenseManager sm, Handler handler)
        {
            this.sm      = sm;
            this.handler = handler;
            HandlerSet handlerSet = new HandlerSet();

            gchandles = new List <GCHandle>();

            if (handler.onConnect != null)
            {
                OnConnectDIRDelegate dir = new OnConnectDIRDelegate(OnConnect);
                gchandles.Add(GCHandle.Alloc(dir));
                handlerSet.onConnect = Marshal.GetFunctionPointerForDelegate(dir);
            }
            if (handler.onModuleSetProfile != null)
            {
                OnModuleSetProfileDIRDelegate dir = new OnModuleSetProfileDIRDelegate(OnModuleSetProfile);
                gchandles.Add(GCHandle.Alloc(dir));
                handlerSet.onModuleSetProfile = Marshal.GetFunctionPointerForDelegate(dir);
            }
            if (handler.onModuleProcessedFrame != null)
            {
                OnModuleProcessedFrameDIRDelegate dir = new OnModuleProcessedFrameDIRDelegate(OnModuleProcessedFrame);
                gchandles.Add(GCHandle.Alloc(dir));
                handlerSet.onModuleProcessedFrame = Marshal.GetFunctionPointerForDelegate(dir);
            }
            if (handler.onNewSample != null)
            {
                OnNewSampleDIRDelegate dir = new OnNewSampleDIRDelegate(OnNewSample);
                gchandles.Add(GCHandle.Alloc(dir));
                handlerSet.onNewSample = Marshal.GetFunctionPointerForDelegate(dir);
            }
            if (handler.onStatus != null)
            {
                OnStatusDIRDelegate dir = new OnStatusDIRDelegate(OnStatus);
                gchandles.Add(GCHandle.Alloc(dir));
                handlerSet.onStatus = Marshal.GetFunctionPointerForDelegate(dir);
            }

            dirUnmanaged = PXCMSenseManager_AllocHandlerDIR(handlerSet);
        }
Пример #3
0
            public HandlerDIR(PXCMSenseManager sm, Handler handler)
            {
                this.sm = sm;
                this.handler = handler;
                HandlerSet handlerSet = new HandlerSet();
                gchandles = new List<GCHandle>();

                if (handler.onConnect != null)
                {
                    OnConnectDIRDelegate dir = new OnConnectDIRDelegate(OnConnect);
                    gchandles.Add(GCHandle.Alloc(dir));
                    handlerSet.onConnect = Marshal.GetFunctionPointerForDelegate(dir);
                }
                if (handler.onModuleSetProfile != null)
                {
                    OnModuleSetProfileDIRDelegate dir = new OnModuleSetProfileDIRDelegate(OnModuleSetProfile);
                    gchandles.Add(GCHandle.Alloc(dir));
                    handlerSet.onModuleSetProfile = Marshal.GetFunctionPointerForDelegate(dir);
                }
                if (handler.onModuleProcessedFrame != null)
                {
                    OnModuleProcessedFrameDIRDelegate dir = new OnModuleProcessedFrameDIRDelegate(OnModuleProcessedFrame);
                    gchandles.Add(GCHandle.Alloc(dir));
                    handlerSet.onModuleProcessedFrame = Marshal.GetFunctionPointerForDelegate(dir);
                }
                if (handler.onNewSample != null)
                {
                    OnNewSampleDIRDelegate dir = new OnNewSampleDIRDelegate(OnNewSample);
                    gchandles.Add(GCHandle.Alloc(dir));
                    handlerSet.onNewSample = Marshal.GetFunctionPointerForDelegate(dir);
                }
                if (handler.onStatus != null)
                {
                    OnStatusDIRDelegate dir = new OnStatusDIRDelegate(OnStatus);
                    gchandles.Add(GCHandle.Alloc(dir));
                    handlerSet.onStatus = Marshal.GetFunctionPointerForDelegate(dir);
                }

                dirUnmanaged = PXCMSenseManager_AllocHandlerDIR(handlerSet);
            }