From 4dca5182486cb199d3306ad0fc5bbb8ab0bcafb0 Mon Sep 17 00:00:00 2001 From: Stefan Schreistetter Date: Tue, 27 Aug 2019 14:52:04 +0200 Subject: [PATCH] Added new default value for TrackerSerialNumber. Changed the App.config for debugging on Neil. Added Tobii timestamps to message. Activated KeepClean feature of WebSocketServer. --- GazeWebSocketServer/App.config | 4 ++-- GazeWebSocketServer/ConfigurationData.cs | 2 +- GazeWebSocketServer/GazeCoordinateBehavior.cs | 8 ++++---- GazeWebSocketServer/GazeData.cs | 12 +++++++++--- GazeWebSocketServer/GazeDataProcessor.cs | 4 +++- GazeWebSocketServer/Program.cs | 3 ++- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/GazeWebSocketServer/App.config b/GazeWebSocketServer/App.config index 2a61590..8b1af1f 100644 --- a/GazeWebSocketServer/App.config +++ b/GazeWebSocketServer/App.config @@ -1,8 +1,8 @@  - - + + diff --git a/GazeWebSocketServer/ConfigurationData.cs b/GazeWebSocketServer/ConfigurationData.cs index 13beb98..1fa58ba 100644 --- a/GazeWebSocketServer/ConfigurationData.cs +++ b/GazeWebSocketServer/ConfigurationData.cs @@ -30,7 +30,7 @@ namespace GazeWebSocketServer public static void InitializeUnexistingWithDefaults() { - InitializeSetting("TrackerSerialNumber", ""); + InitializeSetting("TrackerSerialNumber", "TPSP1-"); InitializeSetting("TrackerFrequency_Hz", "600"); InitializeSetting("WebSocketPort", "8001"); InitializeSetting("WebSocketEndpoint", "/gaze"); diff --git a/GazeWebSocketServer/GazeCoordinateBehavior.cs b/GazeWebSocketServer/GazeCoordinateBehavior.cs index 09738ed..52dd255 100644 --- a/GazeWebSocketServer/GazeCoordinateBehavior.cs +++ b/GazeWebSocketServer/GazeCoordinateBehavior.cs @@ -17,10 +17,10 @@ namespace GazeWebSocketServer eyeTrackerClient.Start(this); } - ~GazeCoordinateBehavior() - { - eyeTrackerClient.Stop(); - } + //~GazeCoordinateBehavior() + //{ + // eyeTrackerClient.Stop(); + //} //protected override void OnOpen() //{ diff --git a/GazeWebSocketServer/GazeData.cs b/GazeWebSocketServer/GazeData.cs index a7ac3ea..c9db035 100644 --- a/GazeWebSocketServer/GazeData.cs +++ b/GazeWebSocketServer/GazeData.cs @@ -13,17 +13,23 @@ namespace GazeWebSocketServer public readonly float rightX; public readonly float rightY; - public GazeData(float leftX, float leftY, float rightX, float rightY) + public readonly long trackerTimeStamp; + public readonly long systemTimeStamp; + + public GazeData(float leftX, float leftY, float rightX, float rightY, long trackerTimeStamp, long systemTimeStamp) { this.leftX = leftX; this.leftY = leftY; this.rightX = rightX; this.rightY = rightY; - } + this.trackerTimeStamp = trackerTimeStamp; + this.systemTimeStamp = systemTimeStamp; + } public override string ToString() { - return $"\"{leftX}\", \"{leftY}\", \"{rightX}\", \"{rightY}\""; + FormattableString message = $"{leftX};{leftY};{rightX};{rightY};{trackerTimeStamp};{systemTimeStamp}"; + return FormattableString.Invariant(message); } } } diff --git a/GazeWebSocketServer/GazeDataProcessor.cs b/GazeWebSocketServer/GazeDataProcessor.cs index 6f53b81..adc6a58 100644 --- a/GazeWebSocketServer/GazeDataProcessor.cs +++ b/GazeWebSocketServer/GazeDataProcessor.cs @@ -24,7 +24,9 @@ namespace GazeWebSocketServer GazeData data = new GazeData(e.LeftEye.GazePoint.PositionOnDisplayArea.X*screenWidth, e.LeftEye.GazePoint.PositionOnDisplayArea.Y*screenHeight, e.RightEye.GazePoint.PositionOnDisplayArea.X*screenWidth, - e.RightEye.GazePoint.PositionOnDisplayArea.Y*screenHeight); + e.RightEye.GazePoint.PositionOnDisplayArea.Y*screenHeight, + e.DeviceTimeStamp, + e.SystemTimeStamp); return data; } } diff --git a/GazeWebSocketServer/Program.cs b/GazeWebSocketServer/Program.cs index 8bd4a4a..19003e0 100644 --- a/GazeWebSocketServer/Program.cs +++ b/GazeWebSocketServer/Program.cs @@ -13,9 +13,10 @@ namespace GazeWebSocketServer ConfigurationData config = ConfigurationData.ParseToObject(); var wssv = new WebSocketServer(config.WebSocketPort); + wssv.KeepClean = true; GazeCoordinateBehavior behavior = new GazeCoordinateBehavior(config); wssv.AddWebSocketService(config.WebSocketEndpoint, () => behavior); - + wssv.Start(); Console.ReadKey(true); wssv.Stop(); -- libgit2 0.26.0