/// <summary>
/// Connects to found eyetrackers, synchronizes CPU and eyetracker clocks, and attaches event handlers.
/// </summary>
/// <param name="sender"></param>
/// <param name="e">Contains found EyetrackerInfo</param>
static void EyetrackerFound(object sender, EyetrackerInfoEventArgs e)
{
EyetrackerConnector connector = new EyetrackerConnector(e.EyetrackerInfo);
connector.Connect();
// sync CPU and Eyetracker clocks
SyncManager syncManager = new SyncManager(clock, e.EyetrackerInfo, EventThreadingOptions.BackgroundThread);
// detect fixations
FixationDetector fixations = new FixationDetector(syncManager);
connector.Eyetracker.GazeDataReceived += fixations.GazeDataReceived;
/*/ 1. print each event to console
* ConsolePrinter printer = new ConsolePrinter(syncManager);
* //connector.Eyetracker.GazeDataReceived += printer.GazeDataReceived;
* fixations.FixDetector.FixationEnd += printer.FixationEnd;//*/
/*/ 2. windowed print to console
* WindowingConsolePrinter printer = new WindowingConsolePrinter(syncManager);
* //connector.Eyetracker.GazeDataReceived += printer.GazeDataReceived;
* fixations.FixDetector.FixationEnd += printer.FixationEnd;
*
* printer.StartWindow();
* while (true)
* {
* Thread.Sleep(windowDuration);
* printer.ProcessWindow(cumulativeWindows);
* }//*/
// 3. process windows with EMDAT
EmdatProcessor processor = new EmdatProcessor(syncManager);
if (aoiFilePath != null)
{
processor.AoiFilePath = aoiFilePath;
}
connector.Eyetracker.GazeDataReceived += processor.GazeDataReceived;
fixations.FixDetector.FixationEnd += processor.FixationEnd;
processor.StartWindow();
while (true)
{
Thread.Sleep(windowDuration);
processor.ProcessWindow(cumulativeWindows);
}//*/
}