Пример #1
0
        public StreamEngineTracker(StreamEngineTracker_Description description)
        {
            _streamEngineInteropWrapper = new StreamEngineInteropWrapper();

            if (description == null)
            {
                description = new StreamEngineTracker_Description();
            }

            // Connect
            var customLog = new tobii_custom_log_t {
                log_func = LogCallback
            };
            StreamEngineContext context;

            if (ConnectionHelper.TryConnect(_streamEngineInteropWrapper, description, out context, customLog) == false)
            {
                throw new Exception("Failed to connect to tracker");
            }
            Context = context;

            // Start background thread that handles processing of data and reconnecting
            _processInBackground = true;
            _backgroundThread    = new Thread(ProcessLoop)
            {
                IsBackground = true
            };
            _backgroundThread.Start();

            // Get connection metadata
            CheckForCapabilities(Context.Device);
            tobii_feature_group_t licenseLevel;

            Interop.tobii_get_feature_group(Context.Device, out licenseLevel);
            LicenseLevel = licenseLevel;
        }
Пример #2
0
        public StreamEngineTracker(StreamEngineTracker_Description description)
        {
            _streamEngineInteropWrapper = new StreamEngineInteropWrapper();
            _customLog = new tobii_custom_log_t {
                log_func = LogCallback
            };

            if (description == null)
            {
                description = new StreamEngineTracker_Description();
            }

            // Connect
            StreamEngineContext context;

            if (ConnectionHelper.TryConnect(_streamEngineInteropWrapper, description, out context, _customLog) == false)
            {
                throw new Exception("Failed to connect to tracker");
            }
            Context = context;

            // Subscribe to requested streams
            tobii_error_t result;

            if (description.WearableDataCallback != null)
            {
                _wearableDataCallbackPointer = GCHandle.Alloc(description.WearableDataCallback);
                result = Interop.tobii_wearable_consumer_data_subscribe(context.Device, WearableDataCallback, GCHandle.ToIntPtr(_wearableDataCallbackPointer));
                if (result != tobii_error_t.TOBII_ERROR_NO_ERROR)
                {
                    throw new Exception("Failed to subscribe to eye tracking data: " + result);
                }
            }

            if (description.WearableAdvancedDataCallback != null)
            {
                _wearableAdvancedDataCallbackPointer = GCHandle.Alloc(description.WearableAdvancedDataCallback);
                result = Interop.tobii_wearable_advanced_data_subscribe(context.Device, AdvancedWearableDataCallback, GCHandle.ToIntPtr(_wearableAdvancedDataCallbackPointer));
                if (result != tobii_error_t.TOBII_ERROR_NO_ERROR)
                {
                    throw new Exception("Failed to subscribe to eye tracking data: " + result);
                }
            }

            if (description.WearableFoveatedDataCallback != null)
            {
                _wearableFoveatedDataCallbackPointer = GCHandle.Alloc(description.WearableFoveatedDataCallback);
                result = Interop.tobii_wearable_foveated_gaze_subscribe(context.Device, WearableFoveatedGazeCallback, GCHandle.ToIntPtr(_wearableFoveatedDataCallbackPointer));
                if (result != tobii_error_t.TOBII_ERROR_NO_ERROR)
                {
                    throw new Exception("Failed to subscribe to eye tracking data: " + result);
                }
            }

            // Get connection metadata
            CheckForCapabilities(Context.Device);
            tobii_feature_group_t licenseLevel;

            Interop.tobii_get_feature_group(Context.Device, out licenseLevel);
            LicenseLevel = licenseLevel;
        }