Пример #1
0
        ///////////////////////////////////////////////////////////////////////////////
        // Construction and Initializing methods                                     //
        ///////////////////////////////////////////////////////////////////////////////
        #region CONSTRUCTION

        /// <summary>
        /// Initializes a new instance of the <see cref="SmartEyeCalibrationRunner"/> class.
        /// </summary>
        /// <param name="client">The <see cref="SmartEyeClient"/></param>
        /// <param name="settings">The <see cref="SmartEyeSetting"/></param>
        public SmartEyeCalibrationRunner(SmartEyeClient client, SmartEyeSetting settings)
        {
            this.client = client;
            this.client.UdpSocket.PacketReceived += this.BaseClientOnPacketReceived;
            this.client.PropertyChanged          += this.SmartEyeClientPropertyChanged;

            this.settings = settings;

            this.smartEyeCalibrationForm          = new SmartEyeCalibrationForm();
            this.smartEyeCalibrationForm.Load    += this.SmartEyeCalibrationFormLoaded;
            this.smartEyeCalibrationForm.KeyDown += this.SmartEyeCalibrationFormKeyDown;

            this.initTimer = new Timer()
            {
                Interval = 50
            };
            this.initTimer.Tick += this.CheckStartCalibration;

            this.collectSamplesTimer = new Timer()
            {
                Interval = 50
            };
            this.collectSamplesTimer.Tick += this.CheckCollectSamples;

            this.HasShownMessage = false;
        }
Пример #2
0
        /// <summary>
        /// An implementation of this method should do all
        /// connection routines for the specific hardware, so that the
        /// system is ready for calibration.
        /// </summary>
        /// <returns><strong>True</strong> if successful connected to tracker,
        /// otherwise <strong>false</strong>.</returns>
        public override bool Connect()
        {
            if (!this.ValidateAddresses(this.smartEyeSettings))
            {
                return(false);
            }

            if (this.smartEyeClient == null)
            {
                this.smartEyeClient = new SmartEyeClient(this.smartEyeSettings);
            }
            else
            {
                this.smartEyeClient.CreateRPC();
                this.smartEyeClient.CreateUDP(this.smartEyeSettings.SmartEyeServerAddress, this.smartEyeSettings.OgamaPort);
            }

            this.smartEyeClient.PropertyChanged   += this.SmartEyeClientPropertyChanged;
            this.smartEyeClient.GazeDataAvailable += this.SmartEyeGazeDataAvailable;

            if (this.smartEyeClient.MajorVersion >= 1 && this.smartEyeClient.MinorVersion >= 1)
            {
                this.StartLiveImageThread();
            }

            return(this.smartEyeClient.RpcIsConnected);
        }
Пример #3
0
        /// <summary>
        /// Do a clean up for Smart Eye Tracker, so that the
        /// system is ready for shut down.
        /// </summary>
        public override void CleanUp()
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                if (this.liveImageThread != null && this.liveImageThread.IsAlive)
                {
                    this.stopliveImageThread = true;
                }

                this.smartEyeTrackStatus.OnGazeData(new SmartEyeGazeData());

                if (this.smartEyeClient != null)
                {
                    this.smartEyeClient.PropertyChanged   -= this.SmartEyeClientPropertyChanged;
                    this.smartEyeClient.GazeDataAvailable -= this.SmartEyeGazeDataAvailable;
                    this.smartEyeClient.Dispose();
                    this.smartEyeClient = null;
                }
            }
            catch (Exception ex)
            {
                if (this.smartEyeSettings.SilentMode)
                {
                    ExceptionMethods.HandleExceptionSilent(ex);
                }
                else
                {
                    ExceptionMethods.HandleException(ex);
                }
            }

            base.CleanUp();

            Cursor.Current = Cursors.Default;
        }
Пример #4
0
    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes a new instance of the <see cref="SmartEyeCalibrationRunner"/> class.
    /// </summary>
    /// <param name="client">The <see cref="SmartEyeClient"/></param>
    /// <param name="settings">The <see cref="SmartEyeSetting"/></param>
    public SmartEyeCalibrationRunner(SmartEyeClient client, SmartEyeSetting settings)
    {
      this.client = client;
      this.client.UdpSocket.PacketReceived += this.BaseClientOnPacketReceived;
      this.client.PropertyChanged += this.SmartEyeClientPropertyChanged;

      this.settings = settings;

      this.smartEyeCalibrationForm = new SmartEyeCalibrationForm();
      this.smartEyeCalibrationForm.Load += this.SmartEyeCalibrationFormLoaded;
      this.smartEyeCalibrationForm.KeyDown += this.SmartEyeCalibrationFormKeyDown;

      this.initTimer = new Timer() { Interval = 50 };
      this.initTimer.Tick += this.CheckStartCalibration;

      this.collectSamplesTimer = new Timer() { Interval = 50 };
      this.collectSamplesTimer.Tick += this.CheckCollectSamples;

      this.HasShownMessage = false;
    }
Пример #5
0
    /// <summary>
    /// Do a clean up for Smart Eye Tracker, so that the
    /// system is ready for shut down.
    /// </summary>
    public override void CleanUp()
    {
      Cursor.Current = Cursors.WaitCursor;

      try
      {
        if (this.liveImageThread != null && this.liveImageThread.IsAlive)
        {
          this.stopliveImageThread = true;
        }

        this.smartEyeTrackStatus.OnGazeData(new SmartEyeGazeData());

        if (this.smartEyeClient != null)
        {
          this.smartEyeClient.PropertyChanged -= this.SmartEyeClientPropertyChanged;
          this.smartEyeClient.GazeDataAvailable -= this.SmartEyeGazeDataAvailable;
          this.smartEyeClient.Dispose();
          this.smartEyeClient = null;
        }
      }
      catch (Exception ex)
      {
        if (this.smartEyeSettings.SilentMode)
        {
          ExceptionMethods.HandleExceptionSilent(ex);
        }
        else
        {
          ExceptionMethods.HandleException(ex);
        }
      }

      base.CleanUp();

      Cursor.Current = Cursors.Default;
    }
Пример #6
0
    /// <summary>
    /// An implementation of this method should do all 
    /// connection routines for the specific hardware, so that the
    /// system is ready for calibration.
    /// </summary>
    /// <returns><strong>True</strong> if successful connected to tracker,
    /// otherwise <strong>false</strong>.</returns>
    public override bool Connect()
    {
      if (!this.ValidateAddresses(this.smartEyeSettings))
      {
        return false;
      }

      if (this.smartEyeClient == null)
      {
        this.smartEyeClient = new SmartEyeClient(this.smartEyeSettings);
      }
      else
      {
        this.smartEyeClient.CreateRPC();
        this.smartEyeClient.CreateUDP(this.smartEyeSettings.SmartEyeServerAddress, this.smartEyeSettings.OgamaPort);
      }

      this.smartEyeClient.PropertyChanged += this.SmartEyeClientPropertyChanged;
      this.smartEyeClient.GazeDataAvailable += this.SmartEyeGazeDataAvailable;

      if (this.smartEyeClient.MajorVersion >= 1 && this.smartEyeClient.MinorVersion >= 1)
      {
        this.StartLiveImageThread();
      }

      return this.smartEyeClient.RpcIsConnected;
    }