/// <summary> /// Connects the tracker. /// </summary> /// <returns> /// <strong>True</strong> if connection succeded, otherwise /// <strong>false</strong>. /// </returns> public override bool Connect() { try { // Start the eye tribe server if (!IOHelpers.IsProcessOpen("EyeTribe")) { this.StartEyeTribeProcess(); } else { InformationDialog.Show( "EyeTribe server is running", "The eye tribe server is already running, so we connect to this instance. Please note: it may be using a different tracking rate than specified in the settings tab.", false, MessageBoxIcon.Information); } // Connect client if (!GazeManager.Instance.Activate(GazeManager.ApiVersion.VERSION_1_0, GazeManager.ClientMode.Push)) { throw new Exception("Could not connect to the eye tribe tracker, please start the server manually and try again."); } //this.eyeTribeTrackStatus.Connect(); // Register this class for events GazeManager.Instance.AddGazeListener(this); //GazeManager.Instance.AddTrackerStateListener(this); } catch (Exception ex) { var dlg = new ConnectionFailedDialog { ErrorMessage = ex.Message }; dlg.ShowDialog(); this.CleanUp(); return false; } return true; }
/// <summary> /// Connects to the Haytham camera system via UDP connection. /// </summary> /// <returns> /// <strong>True</strong> if connection succeded, otherwise /// <strong>false</strong>. /// </returns> public override bool Connect() { try { this.haythamClient = new HaythamClient { ServerIPAddress = IPAddress.Parse(this.Settings.HaythamServerIPAddress) }; this.haythamClient.CalibrationFinished += this.CalibrationFinished; this.haythamClient.GazeDataReceived += this.GazeDataReceived; this.haythamClient.TrackStatusDataChanged += this.HaythamClientTrackStatusDataChanged; if (!this.clientStatus.HasFlag(HaythamStatus.IsConnected)) { if (!this.haythamClient.Connect()) { throw new Exception("Connection to haytham server failed."); } //else //{ // // Show track status control // this.trackControlsSplitContainer.Panel1Collapsed = true; // this.trackControlsSplitContainer.Panel2Collapsed = false; //} } } catch (Exception ex) { var dlg = new ConnectionFailedDialog { ErrorMessage = ex.Message }; dlg.ShowDialog(); this.CleanUp(); return false; } this.clientStatus = this.clientStatus | HaythamStatus.IsConnected; return true; }
/// <summary> /// Start tracking. /// </summary> public override void Record() { // Check if Quick Glance is running. if (!this.Connect()) { // If not, try to start it. If this fails warn the user and assume manual starting. if (!this.StartQuickGlance()) { var dlg = new ConnectionFailedDialog { ErrorMessage = "Quick Glance is not running. Please connect the tracker, start Quick Glance and try again." }; dlg.ShowDialog(); this.Stop(); return; } } if (this.IsRecording) { return; } this.IsRecording = true; this.dataCollector = new Thread(this.StartDataCollecting); this.dataCollector.Start(); }
/////////////////////////////////////////////////////////////////////////////// // Inherited methods // /////////////////////////////////////////////////////////////////////////////// #region OVERRIDES /// <summary> /// Connects to the SMI iView system. /// </summary> /// <returns><strong>True</strong> if connection succeded, otherwise /// <strong>false</strong>.</returns> public override bool Connect() { try { // Connect to the SMI server if necessary if (!this.smiClient.IsConnected) { this.smiClient.Connect(); } } catch (Exception ex) { var dlg = new ConnectionFailedDialog { ErrorMessage = ex.Message }; dlg.ShowDialog(); this.CleanUp(); return false; } return true; }
/////////////////////////////////////////////////////////////////////////////// // Construction and Initializing methods // /////////////////////////////////////////////////////////////////////////////// #region CONSTRUCTION /// <summary> /// Initializes a new instance of the <see cref="SmartEyeClient"/> class. /// </summary> /// <param name="setting">The settings</param> public SmartEyeClient(SmartEyeSetting setting) { this.smartEyeSettings = setting; this.IsClosingDown = false; this.RpcIsConnected = false; this.dataIds = new List<TrackerDataId>(); this.KillRunningEyeTrackerProcess(); Process smartEyeTrackingProcess; var smartEyeVersion = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Smart Eye AB\Shared", "EyeTrackerCoreVersion", null); if (smartEyeVersion != null) { var smartEyeTrackingPath = Registry.GetValue( string.Format(@"HKEY_CURRENT_USER\Software\Smart Eye AB\Eye tracker core {0}\DefaultPaths", smartEyeVersion.ToString()), "ProgramDirectory", null); if (smartEyeTrackingPath != null) { smartEyeTrackingProcess = new Process { StartInfo = { WorkingDirectory = smartEyeTrackingPath.ToString(), FileName = smartEyeTrackingPath + "\\eye_tracker_core.exe", UseShellExecute = false, RedirectStandardError = true } }; } else { ConnectionFailedDialog dlg = new ConnectionFailedDialog(); dlg.ErrorMessage = "Cannot start Smart Eye Tracker Core Process, registry parameters not correct."; dlg.ShowDialog(); return; } } else { ConnectionFailedDialog dlg = new ConnectionFailedDialog(); dlg.ErrorMessage = "Cannot start Smart Eye Tracker Core Process, registry parameters not correct."; dlg.ShowDialog(); return; } try { if (!smartEyeTrackingProcess.Start()) { ConnectionFailedDialog dlg = new ConnectionFailedDialog(); dlg.ErrorMessage = "Cannot start Smart Eye Tracker Core Process." + Environment.NewLine + Environment.NewLine + "If this error is recurring, please make sure the hardware is connected and set up correctly, and try to reconnect."; dlg.ShowDialog(); return; } } catch (Exception ex) { ConnectionFailedDialog dlg = new ConnectionFailedDialog(); dlg.ErrorMessage = "Cannot start Smart Eye Tracker Core Process, failed with the following message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + "If this error is recurring, please make sure the hardware is connected and set up correctly, and try to reconnect."; dlg.ShowDialog(); ExceptionMethods.HandleExceptionSilent(ex); return; } this.CreateRPC(); this.CreateUDP(this.smartEyeSettings.SmartEyeServerAddress, this.smartEyeSettings.OgamaPort); }
/////////////////////////////////////////////////////////////////////////////// // Inherited methods // /////////////////////////////////////////////////////////////////////////////// #region OVERRIDES /// <summary> /// Connects the track status object to the eyetech system. /// </summary> /// <returns><strong>True</strong> if connection succeeded, otherwise /// <strong>false</strong>.</returns> public override bool Connect() { // Check if Quick Glance is running. if (this.IsConnected) { return true; } // Try to start quickglance if (this.StartQuickGlance()) { return true; } // Show a message and exit if QuickGlance could not be ran automagically. var dlg = new ConnectionFailedDialog { ErrorMessage = "Quick Glance could not be found. Please start/install and try again" }; dlg.ShowDialog(); this.CleanUp(); return false; }
/// <summary> /// Starts calibration. /// </summary> /// <param name="isRecalibrating">whether to use recalibration or not.</param> /// <returns><strong>True</strong> if calibration succeded, otherwise /// <strong>false</strong>.</returns> public override bool Calibrate(bool isRecalibrating) { try { bool isOpen; ApiError result = this.api.IsOpen(out isOpen); if (result != ApiError.NoError) { ConnectionFailedDialog dlg = new ConnectionFailedDialog(); string errorMessage; this.api.GetLastError(out errorMessage); if (errorMessage.Length == 0) { errorMessage = "Intelligaze Error: " + result.ToString() + ". Make sure Intelligaze is running."; } dlg.ErrorMessage = errorMessage; dlg.ShowDialog(); this.CleanUp(); return false; } // Connect the calibration procedure if necessary if (!isOpen) { // Try to Open API if (!this.Connect()) { this.CleanUp(); return false; } } result = this.api.PerformCalibration(this.Settings.NumCalibPoint, (PointLocationEnum)this.Settings.CalibArea, this.Settings.RandomizeCalibPointOrder, this.Settings.SlowMode, this.Settings.PlayAudioFeedback, (EyeTypeEnum)this.Settings.Eye, false, this.Settings.SkipBadPoints, true, this.Settings.CalibBackgroundColor.ToArgb(), this.Settings.CalibPointColor.ToArgb(), string.Empty); if (result != ApiError.NoError) { string errorMessage; this.api.GetLastError(out errorMessage); if (errorMessage.Length == 0) { errorMessage = "Calibration Error: " + result.ToString(); } InformationDialog.Show( "Calibration error", errorMessage, false, MessageBoxIcon.Error); this.CleanUp(); return false; } } catch (Exception ex) { InformationDialog.Show( "Calibration failed", "Alea calibration failed with the following message: " + Environment.NewLine + ex.Message, false, MessageBoxIcon.Error); this.CleanUp(); return false; } return true; }
/// <summary> /// Connects the track status object to the tobii system. /// </summary> /// <returns> /// <strong>True</strong> if connection succeded, otherwise /// <strong>false</strong>. /// </returns> public override bool Connect() { try { if (availableEyetracker.Count == 0) { throw new EyetrackerException(1, "No tobii eyetracker system found"); } this.ConnectToTracker(availableEyetracker[0]); } catch (Exception ex) { var dlg = new ConnectionFailedDialog { ErrorMessage = ex.Message }; dlg.ShowDialog(); this.CleanUp(); return false; } return true; }
/// <summary> /// Connect to the alea system. /// </summary> /// <returns><strong>True</strong> if connection succeded, otherwise /// <strong>false</strong>.</returns> public override bool Connect() { // Check intelligaze process if (!IOHelpers.IsProcessOpen("IntelliGaze")) { const string FILENAME = "Intelligaze.exe"; // Intelligaze not open. Try to open string fullpath = GetIntelligazePath(); if (fullpath.Length == 0 || !new FileInfo(fullpath + "\\" + FILENAME).Exists) { ConnectionFailedDialog dlg = new ConnectionFailedDialog(); dlg.ErrorMessage = "Can't find Intelligaze folder. Maybe Intelligaze is not installed or installation is corrupted." + Environment.NewLine + "Please reinstall Intelligaze."; dlg.ShowDialog(); return false; } // Start Intelligaze with background param Process process = new Process(); process.StartInfo.WorkingDirectory = fullpath; process.StartInfo.FileName = FILENAME; process.StartInfo.Arguments = "background"; process.StartInfo.UseShellExecute = true; if (!process.Start()) { ConnectionFailedDialog dlg = new ConnectionFailedDialog(); dlg.ErrorMessage = "Can't start Intelligaze Process."; dlg.ShowDialog(); return false; } } bool isOpen; ApiError result = this.api.IsOpen(out isOpen); // API open? if (result != ApiError.NoError) { ConnectionFailedDialog dlg = new ConnectionFailedDialog(); string errorMessage; this.api.GetLastError(out errorMessage); if (errorMessage.Length == 0) { errorMessage = "Intelligaze Error: Method IsOpen" + Environment.NewLine + result.ToString(); } dlg.ErrorMessage = errorMessage; dlg.ShowDialog(); this.CleanUp(); return false; } if (!isOpen) { // API is not open ... try to open API Stopwatch timeoutStopwatch = new Stopwatch(); // Timeout is 20 seconds timeoutStopwatch.Start(); do { // Try to open API result = this.api.Open("(ogama)=2", this.Settings.ServerAddress, this.Settings.ServerPort, this.Settings.ClientAddress, this.Settings.ClientPort); } while (result != ApiError.NoError && timeoutStopwatch.ElapsedMilliseconds < 20000); timeoutStopwatch.Stop(); if (result != ApiError.NoError) { ConnectionFailedDialog dlg = new ConnectionFailedDialog(); string errorMessage; this.api.GetLastError(out errorMessage); if (errorMessage.Length == 0) { errorMessage = "Intelligaze Error: Can't open API." + Environment.NewLine + "Reason: " + result.ToString(); } dlg.ErrorMessage = errorMessage; dlg.ShowDialog(); this.CleanUp(); return false; } } // Register Callbacks this.api.SetCalibrationDoneCB(Marshal.GetFunctionPointerForDelegate(APICalibrationDone).ToInt32(), IntPtr.Zero); this.api.SetRawDataCB(Marshal.GetFunctionPointerForDelegate(APIRawDataReceived).ToInt32(), IntPtr.Zero); // enable datastreaming ... important to do it here, otherwise user get mousecursor control this.api.DataStreaming(1); // hide status window this.api.HideStatusWindow(); return true; }
/////////////////////////////////////////////////////////////////////////////// // Inherited methods // /////////////////////////////////////////////////////////////////////////////// #region OVERRIDES /// <summary> /// Connects to the ITU GazeTracker camera system. /// </summary> /// <returns><strong>True</strong> if connection succeded, otherwise /// <strong>false</strong>.</returns> public override bool Connect() { try { if (!this.gazeTrackerApiClient.Connect()) { return false; } this.eyeVideo.Start(); this.SetPresentationScreen(); // Video preview window (tracker visualizes image processing) this.gazeTrackerApiClient.CalibrationFinishedEvent += this.GazeTrackerApiClientCalibrationFinishedEvent; this.adjustButton.Enabled = true; } catch (Exception ex) { var dlg = new ConnectionFailedDialog { ErrorMessage = ex.Message }; dlg.ShowDialog(); this.CleanUp(); return false; } return true; }
/////////////////////////////////////////////////////////////////////////////// // Inherited methods // /////////////////////////////////////////////////////////////////////////////// #region OVERRIDES /// <summary> /// Connects to the Gazetracker camera system via UDP connection. /// </summary> /// <returns><strong>True</strong> if connection succeded, otherwise /// <strong>false</strong>.</returns> public override bool Connect() { try { this.client = new Client { IPAddress = IPAddress.Parse(this.Settings.GazeDataServerIPAddress), PortReceive = this.Settings.GazeDataServerPort, PortSend = this.Settings.CommandServerPort }; this.client.ClientConnectionChanged += this.ClientClientConnectionChanged; this.client.ErrorOccured += this.ClientErrorOccured; this.client.Calibration.OnEnd += this.Calibration_OnEnd; this.client.GazeData.OnGazeData += this.GazeData_OnGazeData; if (!this.client.IsRunning) { this.client.Connect(); } } catch (Exception ex) { var dlg = new ConnectionFailedDialog { ErrorMessage = ex.Message }; dlg.ShowDialog(); this.CleanUp(); return false; } this.clientStatus.IsConnected = true; return true; }
/// <summary> /// Connect to the mirametrix system. /// </summary> /// <returns><strong>True</strong> if connection succeded, otherwise /// <strong>false</strong>.</returns> public override bool Connect() { bool connectionSucceeded; try { connectionSucceeded = this.memNetworkManager.Connect(); // Check the screen size, in ProcessReceivedMessage we receive the answer // and set the correct size this.memNetworkManager.SendMessage("<GET ID=\"SCREEN_SIZE\" />\r\n"); // Get the timer tick frequency default value QueryPerformanceFrequency(out this.tickFrequency); // Get the timer tick frequency for high resolution timing from the mirametrix API this.memNetworkManager.SendMessage("<GET ID=\"TIME_TICK_FREQUENCY\" />\r\n"); // Get the displayed screen for configure Ogama having the same this.memNetworkManager.SendMessage("<GET ID=\"SCREEN_SELECTED\" />\r\n"); if (this.memSettings.CalibrationType.Equals(1)) { this.Calibrate(false); } } catch (Exception ex) { var dlg = new ConnectionFailedDialog { ErrorMessage = ex.Message }; dlg.ShowDialog(); this.CleanUp(); return false; } return connectionSucceeded; }
/// <summary> /// Connect to the Gazepoint system. /// </summary> /// <returns><strong>True</strong> if connection succeded, otherwise /// <strong>false</strong>.</returns> public override bool Connect() { bool connectionSucceeded; try { connectionSucceeded = this.memNetworkManager.Connect(); if (this.memSettings.CalibrationType.Equals(1)) { this.Calibrate(false); } } catch (Exception ex) { var dlg = new ConnectionFailedDialog { ErrorMessage = ex.Message }; dlg.ShowDialog(); this.CleanUp(); return false; } return connectionSucceeded; }