/// <summary> /// Connects to Tobii Pro Eye-Tracker /// </summary> /// <returns>Connection Success Message</returns> public override async Task <ApiResponseData> ConnectAsync() { IPAdress = "tet-tcp://" + Settings.Default.EyeTrackerIP + "/"; try { EyeTracker = EyeTrackingOperations.GetEyeTracker(IPAdress); } catch (Exception ex) { // Likely wrong URI Format return(new ApiResponseData { Message = ex.Message }); } if (EyeTracker != null) { // Connection established Logger.Debug("Connected to " + EyeTracker.DeviceName + " width IP " + IPAdress); Console.WriteLine("Connected to " + EyeTracker.DeviceName + " width IP " + IPAdress); SubscribeToGazeDataAsync(); IsConnected = true; return(new ApiResponseData { Success = true }); } else { return(new ApiResponseData { Message = "Unable to connect to EyeTracker with IP " + IPAdress }); } }
// internal methods async void SearchEyeTrackers() { var collection = await EyeTrackingOperations.FindAllEyeTrackersAsync(); if (collection.Count > 0) { var tracker = collection[0]; try { _eyeTracker = EyeTrackingOperations.GetEyeTracker(tracker.Address); } catch (Exception ex) { Error(this, ex.Message); } if (_eyeTracker != null) { Ready(this, _eyeTracker.DeviceName); } } else { Invoke(nameof(SearchEyeTrackers), 5); } }