public EyeXGazePointDataStream(EyeXHost host, EyeXGazePointType gazePointType) { _eyeXHost = host; _gazePointType = gazePointType; // create a global interactor for the data stream and register it with the EyeXHost. var interactor = new EyeXGlobalInteractor(InteractorId, AssignGazePointDataBehavior, HandleEvent); _eyeXHost.RegisterGlobalInteractor(interactor); }
/// <summary> /// Stops streaming gaze point data of a given type. /// </summary> /// <param name="gazePointType">Gaze point type.</param> public void StopStreaming(EyeXGazePointType gazePointType) { EyeXGazePointDataStream dataStream; if (_gazePointDataStreams.TryGetValue(gazePointType, out dataStream)) { if (dataStream.UsageCount > 1) { dataStream.UsageCount--; } else { _gazePointDataStreams.Remove(gazePointType); dataStream.Dispose(); } } }
/// <summary> /// Gets the most recent value from a data stream. /// </summary> /// <param name="gazePointType">Gaze point type.</param> /// <returns>The value.</returns> public EyeXGazePoint GetLastGazePoint(EyeXGazePointType gazePointType) { EyeXGazePointDataStream dataStream; if (_gazePointDataStreams.TryGetValue(gazePointType, out dataStream)) { return dataStream.Last; } else { return EyeXGazePoint.Invalid; } }
/// <summary> /// Starts streaming gaze point data of a given type. /// </summary> /// <param name="gazePointType">Gaze point type.</param> public void StartStreaming(EyeXGazePointType gazePointType) { EyeXGazePointDataStream dataStream; if (_gazePointDataStreams.TryGetValue(gazePointType, out dataStream)) { // already streaming this kind of data. dataStream.UsageCount++; } else { dataStream = new EyeXGazePointDataStream(EyeXHost.GetInstance(), gazePointType); _gazePointDataStreams.Add(gazePointType, dataStream); } }
/// <summary> /// Gets the number of fixations since the stream started /// </summary> /// <param name="gazePointType">Gaze point type.</param> /// <returns>The value.</returns> public int GetLastFixationCount(EyeXGazePointType gazePointType) { EyeXGazePointDataStream dataStream; if (_gazePointDataStreams.TryGetValue(gazePointType, out dataStream)) { return dataStream.FixationCount; } else { return -1; } }