Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Eye-Tracking Classroom
/
gaze-server.cs
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6906eca1
authored
Oct 01, 2019
by
Stefan Schreistetter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved mock gaze input via mouse.
parent
3cdd786a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
GazeWebSocketServer/Program.cs
+8
-12
No files found.
GazeWebSocketServer/Program.cs
View file @
6906eca1
using
System
;
using
System
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
System.Threading
;
using
WebSocketSharp
;
using
WebSocketSharp.Server
;
using
Tobii.Research
;
using
TrackerBridge
;
using
TrackerBridge
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
using
System.Drawing
;
using
System.Drawing
;
using
System.Timers
;
namespace
GazeWebSocketServer
namespace
GazeWebSocketServer
{
{
...
@@ -20,7 +17,7 @@ namespace GazeWebSocketServer
...
@@ -20,7 +17,7 @@ namespace GazeWebSocketServer
if
(
args
.
Length
>
0
&&
args
[
0
]
==
"-d"
)
if
(
args
.
Length
>
0
&&
args
[
0
]
==
"-d"
)
{
{
Task
.
Run
(()
=>
SimulateGazeData
(
30
0
));
Task
.
Run
(()
=>
SimulateGazeData
Hz
(
12
0
));
}
}
else
else
{
{
...
@@ -36,21 +33,20 @@ namespace GazeWebSocketServer
...
@@ -36,21 +33,20 @@ namespace GazeWebSocketServer
Console
.
ReadLine
();
Console
.
ReadLine
();
}
}
private
static
void
SimulateGazeData
(
UInt16
frequencyHz
)
private
static
void
SimulateGazeData
Hz
(
Int32
frequency
)
{
{
TimeSpan
period
=
new
TimeSpan
(
Convert
.
ToInt64
((
1.0
/
frequencyHz
)
*
10
e7
)
);
System
.
Timers
.
Timer
timer
=
new
System
.
Timers
.
Timer
(
1.0
/
frequency
);
while
(
true
)
timer
.
Elapsed
+=
(
Object
sender
,
ElapsedEventArgs
e
)
=>
{
{
DateTime
start
=
DateTime
.
Now
;
Point
mousePosition
=
Control
.
MousePosition
;
Point
mousePosition
=
Control
.
MousePosition
;
GazeData
data
=
new
GazeData
(
mousePosition
.
X
,
mousePosition
.
Y
,
mousePosition
.
X
,
mousePosition
.
Y
,
0
,
0
);
GazeData
data
=
new
GazeData
(
mousePosition
.
X
,
mousePosition
.
Y
,
mousePosition
.
X
,
mousePosition
.
Y
,
0
,
0
);
if
(
gazeServer
!=
null
&&
gazeServer
.
isRunning
)
if
(
gazeServer
!=
null
&&
gazeServer
.
isRunning
)
{
{
gazeServer
.
Publish
(
data
);
gazeServer
.
Publish
(
data
);
}
}
TimeSpan
delay
=
period
-
(
DateTime
.
Now
-
start
)
;
}
;
Thread
.
Sleep
(
delay
.
Ticks
>=
0
?
delay
.
Milliseconds
:
0
)
;
timer
.
AutoReset
=
true
;
}
timer
.
Start
();
}
}
private
static
void
OnGazeDataAvailable
(
TobiiEyeTracker
sender
,
GazeData
data
)
private
static
void
OnGazeDataAvailable
(
TobiiEyeTracker
sender
,
GazeData
data
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment