From 69276919f6a44b3ebb6c25508a17ba12cf4a6bcd Mon Sep 17 00:00:00 2001 From: Aaron Linnell Date: Mon, 16 May 2022 11:27:33 -0500 Subject: [PATCH] SmartEyeTracker is properly closed when refreshing trackers list --- itrace_core/SmartEyeTracker.cs | 12 ++++++++++++ itrace_core/TrackerManager.cs | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/itrace_core/SmartEyeTracker.cs b/itrace_core/SmartEyeTracker.cs index 72270c8..adb4694 100644 --- a/itrace_core/SmartEyeTracker.cs +++ b/itrace_core/SmartEyeTracker.cs @@ -165,6 +165,18 @@ public SmartEyeTracker() TrackerInit(); } + //Disconnect any connections, performed before refreshing the tracker list + public void CleanupConnections() + { + if (LatentClient.Connected) + LatentClient.Close(); + + if (RpcClient.Connected) + RpcClient.Close(); + + RealtimeClient.Close(); + } + //Retrieve the World Model and calibration error vectors. Returns true on success private Boolean GetWorldCalibration() { diff --git a/itrace_core/TrackerManager.cs b/itrace_core/TrackerManager.cs index d5cd570..d53c7a1 100644 --- a/itrace_core/TrackerManager.cs +++ b/itrace_core/TrackerManager.cs @@ -28,6 +28,14 @@ public TrackerManager() public void FindTrackers() { + //Ensure all trackers are cleaned up (Namely SmartEye must be fully disconnected) + foreach (ITracker tracker in EyeTrackers) + { + //Consider making this common to ITracker + if (tracker is SmartEyeTracker) + ((SmartEyeTracker)tracker).CleanupConnections(); + } + EyeTrackers.Clear(); EyeTrackers.Add(new MouseTracker()); FindTobiiDevices();