Esempio n. 1
0
        // establich connection to eyetracker device
        private void ConnectToTrackerAndStartTracking(EyetrackerInfo info)
        {
            try
            {
                if (FEyetracker == null)
                {
                    // get tracker representation from EyetrackerInfo
                    FEyetracker = EyetrackerFactory.CreateEyetracker(info);
                }

                FEyetracker.ConnectionError -= HandleConnectionError;

                // Trigger device-status-update event for IS1Node
                UpdateDeviceStatus(FTrackerInfo.Status);

                FConnectionName = info.ProductId;
                if (FSyncManager == null)
                {
                    FSyncManager = new SyncManager(FClock, info);
                    FSyncManager.SyncStateChanged += HandleSyncStateChanged;
                }

                SyncState st = FSyncManager.SyncState;
                if (st.StateFlag == SyncStateFlag.Unsynchronized)
                {
                    // TODO: handle the case that eyetracker is unsynchronized to make sure that et-status gets OK
                }

                // register eventhandlers
                FEyetracker.ConnectionError += HandleConnectionError;

                // trigger device-status-update event for IS1Node
                UpdateDeviceStatus(FTrackerInfo.Status);
            }
            catch (EyetrackerException ee)
            {
                if (ee.ErrorCode == 0x20000402)
                {
                    // trigger custom-error event for IS1Node
                    OnCustomError("EyetrackerException occured (errorCode " + ee.ErrorCode.ToString() + ") - Failed to upgrade protocol." +
                                  "This probably means that the firmware needs to be upgraded to a version that supports the new sdk.");
                }
                else
                {
                    // trigger custom-error event for IS1Node
                    OnCustomError("EyetrackerException occured (errorCode " + ee.ErrorCode.ToString() + ") - Eyetracker responded with error" + ee);
                }
                DisconnectEyetracker(false);
            }
            catch (Exception e)
            {
                // trigger custom-error event for IS1Node
                OnCustomError("Could not connect to eyetracker. " + "Connection failed" + "(" + e.Message + ")");
                DisconnectEyetracker(false);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Unsubscribes from events and disconnects eyetracker.
 /// </summary>
 public void Disconnect()
 {
     if (eyetracker != null)
     {
         eyetracker.ConnectionError -= ConnectionError;
         eyetracker.Dispose();
         eyetracker = null;
         info       = null;
     }
 }
Esempio n. 3
0
        // EyetrackerUpdated
        private void _browser_EyetrackerUpdated(object sender, EyetrackerInfoEventArgs e)
        {
            EyetrackerInfo Info = e.EyetrackerInfo;

            if (FEyetrackerInfo.Contains(Info))
            {
                int Index = FEyetrackerInfo.IndexOf(Info);
                FEyetrackerInfo.RemoveAt(Index);
                FEyetrackerInfo.Insert(Index, Info);
            }
            FUpdate = true;
            FLogger.Log(LogType.Debug, "Eyetracker has been updated");
        }
Esempio n. 4
0
        void FEyetrackerInfo_Changed(IDiffSpread <EyetrackerInfo> spread)
        {
            int c = spread.SliceCount;

            if (spread.SliceCount == 0)
            {
                if (FEyetrackerInfo != null)
                {
                    FEyetrackerInfo = null;
                }
            }
            else
            {
                FEyetrackerInfo = spread[0];
            }
            FConnectionChanged = true;
        }
Esempio n. 5
0
        private static ListViewItem CreateTrackerListViewItem(EyetrackerInfo info)
        {
            var trackerItem = new ListViewItem(info.ProductId);
            trackerItem.Name = info.ProductId;

            var sb = new StringBuilder();
            sb.AppendLine("Model: " + info.Model);
            sb.AppendLine("Status: " + info.Status);
            sb.AppendLine("Generation: " + info.Generation);
            sb.AppendLine("Product Id: " + info.ProductId);
            sb.AppendLine("Given Name: " + info.GivenName);
            sb.AppendLine("Firmware Version: " + info.Version);

            trackerItem.ToolTipText = sb.ToString();
            trackerItem.Tag = info;

            return trackerItem;
        }
Esempio n. 6
0
        /// <summary>
        /// Unsubscribes from events and disconnects eyetracker.
        /// </summary>
        public void Disconnect()
        {
            if (eyetracker != null)
            {
                eyetracker.ConnectionError -= ConnectionError;
                foreach (EventHandler <FramerateChangedEventArgs> handler in framerateChangedHandlers)
                {
                    eyetracker.FramerateChanged -= handler;
                }
                foreach (EventHandler <GazeDataEventArgs> handler in gazeDataHandlers)
                {
                    eyetracker.GazeDataReceived -= handler;
                }

                eyetracker.Dispose();
                eyetracker = null;
                info       = null;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// This methods connects to the tracker.
        /// </summary>
        /// <param name="info">
        /// A <see cref="EyetrackerInfo"/>with information about the
        ///   eyetracker to connect to.
        /// </param>
        private void ConnectToTracker(EyetrackerInfo info)
        {
            try
            {
                connectedTracker = EyetrackerFactory.CreateEyetracker(info);
                connectedTracker.ConnectionError       += this.HandleConnectionError;
                this.tobiiSettings.ConnectedTrackerName = connectedTracker.GetUnitName();

                this.tobiiClock  = new Clock();
                this.syncManager = new SyncManager(this.tobiiClock, info);

                connectedTracker.GazeDataReceived += this.ConnectedTrackerGazeDataReceived;
                connectedTracker.StartTracking();
            }
            catch (EyetrackerException ee)
            {
                if (ee.ErrorCode == 0x20000402)
                {
                    MessageBox.Show(
                        Resources.TobiiTracker_ConnectToTrackerFailed,
                        "Upgrade Failed",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Eyetracker responded with error " + ee, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                this.DisconnectTracker();
            }
            catch (Exception)
            {
                MessageBox.Show(
                    "Could not connect to eyetracker.",
                    "Connection Failed",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                this.DisconnectTracker();
            }
        }
Esempio n. 8
0
        private void ConnectToTracker(EyetrackerInfo info)
        {
            try
            {
                _connectedTracker = EyetrackerFactory.CreateEyetracker(info);
                _connectedTracker.ConnectionError += HandleConnectionError;
                _connectionName = info.ProductId;

                _syncManager = new SyncManager(_clock, info);

                _connectedTracker.GazeDataReceived += _connectedTracker_GazeDataReceived;
                _connectedTracker.FramerateChanged += _connectedTracker_FramerateChanged;
            }
            catch (EyetrackerException ee)
            {
                if(ee.ErrorCode == 0x20000402)
                {
                    MessageBox.Show("Failed to upgrade protocol. " +
                        "This probably means that the firmware needs" +
                        " to be upgraded to a version that supports the new sdk.","Upgrade Failed",MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Eyetracker responded with error " + ee, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                DisconnectTracker();
            }
            catch(Exception)
            {
                MessageBox.Show("Could not connect to eyetracker.","Connection Failed",MessageBoxButtons.OK,MessageBoxIcon.Error);
                DisconnectTracker();
            }

            UpdateUIElements();
        }
Esempio n. 9
0
 public EyetrackerConnector(EyetrackerInfo info)
 {
     this.Info = info;
 }
Esempio n. 10
0
 /// <summary>
 /// Unsubscribes from events and disconnects eyetracker.
 /// </summary>
 public void Disconnect()
 {
     if (eyetracker != null)
     {
         eyetracker.ConnectionError -= ConnectionError;
         eyetracker.Dispose();
         eyetracker = null;
         info = null;
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Unsubscribes from events and disconnects eyetracker.
        /// </summary>
        public void Disconnect()
        {
            if (eyetracker != null)
            {
                eyetracker.ConnectionError -= ConnectionError;
                foreach (EventHandler<FramerateChangedEventArgs> handler in framerateChangedHandlers)
                {
                    eyetracker.FramerateChanged -= handler;
                }
                foreach (EventHandler<GazeDataEventArgs> handler in gazeDataHandlers)
                {
                    eyetracker.GazeDataReceived -= handler;
                }

                eyetracker.Dispose();
                eyetracker = null;
                info = null;
            }
        }
Esempio n. 12
0
 public EyetrackerConnector(EyetrackerInfo info)
 {
     this.Info = info;
 }
Esempio n. 13
0
    /// <summary>
    /// This methods connects to the tracker.
    /// </summary>
    /// <param name="info">
    /// A <see cref="EyetrackerInfo"/>with information about the
    ///   eyetracker to connect to.
    /// </param>
    private void ConnectToTracker(EyetrackerInfo info)
    {
      try
      {
        connectedTracker = EyetrackerFactory.CreateEyetracker(info);
        connectedTracker.ConnectionError += this.HandleConnectionError;
        this.tobiiSettings.ConnectedTrackerName = connectedTracker.GetUnitName();

        this.tobiiClock = new Clock();
        this.syncManager = new SyncManager(this.tobiiClock, info);

        connectedTracker.GazeDataReceived += this.ConnectedTrackerGazeDataReceived;
        connectedTracker.StartTracking();
      }
      catch (EyetrackerException ee)
      {
        if (ee.ErrorCode == 0x20000402)
        {
          MessageBox.Show(
            Resources.TobiiTracker_ConnectToTrackerFailed, 
            "Upgrade Failed", 
            MessageBoxButtons.OK, 
            MessageBoxIcon.Error);
        }
        else
        {
          MessageBox.Show("Eyetracker responded with error " + ee, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        this.DisconnectTracker();
      }
      catch (Exception)
      {
        MessageBox.Show(
          "Could not connect to eyetracker.", 
          "Connection Failed", 
          MessageBoxButtons.OK, 
          MessageBoxIcon.Error);
        this.DisconnectTracker();
      }
    }
Esempio n. 14
0
 private void EyetrackerFound(object sender, EyetrackerInfoEventArgs e)
 {
     // When an eyetracker is found on the network
     trackerInfo = e.EyetrackerInfo;
     StatusText.Text = string.Format("Found {0}.", trackerInfo.Model);
 }
Esempio n. 15
0
 private void EyetrackerFound(object sender, EyetrackerInfoEventArgs e)
 {
     // When an eyetracker is found on the network
     trackerInfo = e.EyetrackerInfo;
     LogEvent.Engine.Write(string.Format("Found {0}.", trackerInfo.Model));
 }
Esempio n. 16
0
        private void ConnectToTracker(EyetrackerInfo info)
        {
            try
            {
                LogEvent.Engine.Write("Tracker: Connecting to " + info.Model);
                tracker = EyetrackerFactory.CreateEyetracker(info);
                tracker.ConnectionError += HandleConnectionError;
                connectionName = info.ProductId;
                syncManager = new SyncManager(clock, info);

                tracker.GazeDataReceived += tracker_GazeDataReceived;
                tracker.FramerateChanged += tracker_FramerateChanged;
                LogEvent.Engine.Write(string.Format("Connected to {0} FrameRate {1}.", info.Model, tracker.GetFramerate()));
                tracker.SetFramerate(60);
                ListFramerates();
                IsConnected = true;
            }
            catch (EyetrackerException ee)
            {
                foreach (TraceListener tl in Trace.Listeners)
                {
                    tl.Flush();
                    tl.Dispose();
                }

                if (ee.ErrorCode == 0x20000402)
                {
                    LogEvent.Engine.Write("Failed to upgrade protocol. " +
                                          "This probably means that the firmware needs" +
                                          " to be upgraded to a version that supports the new sdk.");
                }
                else
                    LogEvent.Engine.Write("Eyetracker responded with error " + ee);

                DisconnectTracker();
            }
            catch (Exception)
            {
                foreach (TraceListener tl in Trace.Listeners)
                {
                    tl.Flush();
                    tl.Dispose();
                }
                LogEvent.Engine.Write("Could not connect to eyetracker.");
                DisconnectTracker();
            }
        }