Skip to content

Commit 36b13f0

Browse files
authored
Merge pull request #181 from iTrace-Dev/development
Merge for release
2 parents f2b50f9 + 6a63e78 commit 36b13f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5391
-1048
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
12+
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\itrace_core\itrace_core.csproj" />
17+
</ItemGroup>
18+
19+
</Project>

UnitTestProject1/SmarteyeTests.cs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/********************************************************************************************************************************************************
2+
* @file SmarteyeTests.cs
3+
*
4+
* @Copyright (C) 2022 i-trace.org
5+
*
6+
* This file is part of iTrace Infrastructure http://www.i-trace.org/.
7+
* iTrace Infrastructure is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
8+
* iTrace Infrastructure is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
9+
* You should have received a copy of the GNU General Public License along with iTrace Infrastructure. If not, see <https://www.gnu.org/licenses/>.
10+
********************************************************************************************************************************************************/
11+
12+
using iTrace_Core;
13+
using Microsoft.VisualStudio.TestTools.UnitTesting;
14+
using System;
15+
16+
namespace UnitTestProject1
17+
{
18+
[TestClass]
19+
public class SmarteyeTests
20+
{
21+
[TestMethod]
22+
public void ValidNetstringPass()
23+
{
24+
string netstring = "7:jeffrey,";
25+
string result = NetstringUtils.TrimSENetstring(netstring);
26+
27+
Assert.AreEqual(result, "jeffrey");
28+
}
29+
30+
[TestMethod]
31+
[ExpectedException(typeof(ArgumentOutOfRangeException), "")]
32+
public void BadLengthNetstringNoPass()
33+
{
34+
string netstring = "9:jeffrey,";
35+
string result = NetstringUtils.TrimSENetstring(netstring);
36+
}
37+
38+
[TestMethod]
39+
[ExpectedException(typeof(ArgumentOutOfRangeException), "")]
40+
public void ZeroLengthNetstringNoPass()
41+
{
42+
string netstring = "2:,";
43+
string result = NetstringUtils.TrimSENetstring(netstring);
44+
}
45+
46+
[TestMethod]
47+
[ExpectedException(typeof(ArgumentException),"")]
48+
public void NoLengthNetstringNoPass()
49+
{
50+
string netstring = ":jeffrey,";
51+
string result = NetstringUtils.TrimSENetstring(netstring);
52+
}
53+
54+
[TestMethod]
55+
[ExpectedException(typeof(ArgumentException), "")]
56+
public void NoSeperatorNetstringNoPass()
57+
{
58+
string netstring = "7jeffrey,";
59+
string result = NetstringUtils.TrimSENetstring(netstring);
60+
}
61+
62+
[TestMethod]
63+
[ExpectedException(typeof(ArgumentException), "")]
64+
public void NoCommaNetstringNoPass()
65+
{
66+
string netstring = "7:jeffrey";
67+
string result = NetstringUtils.TrimSENetstring(netstring);
68+
}
69+
}
70+
}

XUnitTestProject1/UnitTest1.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using Xunit;
3+
4+
namespace XUnitTestProject1
5+
{
6+
public class UnitTest1
7+
{
8+
[Fact]
9+
public void Test1()
10+
{
11+
Console.WriteLine("Test");
12+
}
13+
}
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
11+
<PackageReference Include="xunit" Version="2.4.0" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
13+
</ItemGroup>
14+
15+
</Project>

itrace_core.sln

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27703.2047
5-
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itrace_core", "itrace_core\itrace_core.csproj", "{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}"
7-
EndProject
8-
Global
9-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10-
Debug|Any CPU = Debug|Any CPU
11-
Debug|x64 = Debug|x64
12-
Release|Any CPU = Release|Any CPU
13-
Release|x64 = Release|x64
14-
EndGlobalSection
15-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17-
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|x64.ActiveCfg = Debug|x64
19-
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|x64.Build.0 = Debug|x64
20-
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
21-
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|Any CPU.Build.0 = Release|Any CPU
22-
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|x64.ActiveCfg = Release|x64
23-
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|x64.Build.0 = Release|x64
24-
EndGlobalSection
25-
GlobalSection(SolutionProperties) = preSolution
26-
HideSolutionNode = FALSE
27-
EndGlobalSection
28-
GlobalSection(ExtensibilityGlobals) = postSolution
29-
SolutionGuid = {FD8E01EA-52AD-4714-995D-89FF2A3CAE5F}
30-
EndGlobalSection
31-
EndGlobal
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31624.102
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itrace_core", "itrace_core\itrace_core.csproj", "{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreUnitTests", "UnitTestProject1\CoreUnitTests.csproj", "{F7B7FC84-7401-4185-BAE0-B78524B26BAE}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Debug|x64 = Debug|x64
14+
Release|Any CPU = Release|Any CPU
15+
Release|x64 = Release|x64
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|x64.ActiveCfg = Debug|x64
21+
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|x64.Build.0 = Debug|x64
22+
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|x64.ActiveCfg = Release|x64
25+
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|x64.Build.0 = Release|x64
26+
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Debug|x64.ActiveCfg = Debug|Any CPU
29+
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Debug|x64.Build.0 = Debug|Any CPU
30+
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Release|x64.ActiveCfg = Release|Any CPU
33+
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Release|x64.Build.0 = Release|Any CPU
34+
EndGlobalSection
35+
GlobalSection(SolutionProperties) = preSolution
36+
HideSolutionNode = FALSE
37+
EndGlobalSection
38+
GlobalSection(ExtensibilityGlobals) = postSolution
39+
SolutionGuid = {FD8E01EA-52AD-4714-995D-89FF2A3CAE5F}
40+
EndGlobalSection
41+
EndGlobal

itrace_core/App.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
<setting name="websocket_port" serializeAs="String">
1919
<value>7007</value>
2020
</setting>
21+
<setting name="smarteye_ip_address" serializeAs="String">
22+
<value>192.169.100.42</value>
23+
</setting>
24+
<setting name="smarteye_ip_port" serializeAs="String">
25+
<value>5800</value>
26+
</setting>
27+
<setting name="calibration_monitor" serializeAs="String">
28+
<value>0</value>
29+
</setting>
2130
</iTrace_Core.Properties.Settings>
2231
</userSettings>
2332
</configuration>

itrace_core/App.xaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
<Application x:Class="iTrace_Core.App"
1+
<!--
2+
/********************************************************************************************************************************************************
3+
* @file App.xaml
4+
*
5+
* @Copyright (C) 2022 i-trace.org
6+
*
7+
* This file is part of iTrace Infrastructure http://www.i-trace.org/.
8+
* iTrace Infrastructure is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
9+
* iTrace Infrastructure is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10+
* You should have received a copy of the GNU General Public License along with iTrace Infrastructure. If not, see <https://www.gnu.org/licenses/>.
11+
********************************************************************************************************************************************************/
12+
-->
13+
<Application x:Class="iTrace_Core.App"
214
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
315
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
416
xmlns:local="clr-namespace:iTrace_Core"

itrace_core/App.xaml.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
using System;
1+
/********************************************************************************************************************************************************
2+
* @file App.xaml.cs
3+
*
4+
* @Copyright (C) 2022 i-trace.org
5+
*
6+
* This file is part of iTrace Infrastructure http://www.i-trace.org/.
7+
* iTrace Infrastructure is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
8+
* iTrace Infrastructure is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
9+
* You should have received a copy of the GNU General Public License along with iTrace Infrastructure. If not, see <https://www.gnu.org/licenses/>.
10+
********************************************************************************************************************************************************/
11+
12+
using System;
213
using System.Collections.Generic;
314
using System.Configuration;
415
using System.Data;

itrace_core/CalibrationResult.cs

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1-
using System.Collections.Generic;
1+
/********************************************************************************************************************************************************
2+
* @file CalibrationResult.cs
3+
*
4+
* @Copyright (C) 2022 i-trace.org
5+
*
6+
* This file is part of iTrace Infrastructure http://www.i-trace.org/.
7+
* iTrace Infrastructure is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
8+
* iTrace Infrastructure is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
9+
* You should have received a copy of the GNU General Public License along with iTrace Infrastructure. If not, see <https://www.gnu.org/licenses/>.
10+
********************************************************************************************************************************************************/
11+
12+
using System.Collections.Generic;
213
using System.Windows;
14+
using System.Windows.Forms;
315
using System.Xml;
416

517
namespace iTrace_Core
618
{
719
abstract class CalibrationResult
820
{
921
public abstract void WriteToXMLWriter(XmlTextWriter xmlTextWriter);
22+
public abstract bool IsValid();
1023
}
1124

1225
class EmptyCalibrationResult : CalibrationResult
1326
{
1427
public override void WriteToXMLWriter(XmlTextWriter xmlTextWriter) { }
28+
public override bool IsValid() //TODO
29+
{
30+
throw new System.NotImplementedException();
31+
}
1532
}
1633

1734
class TobiiCalibrationResult : CalibrationResult
@@ -29,6 +46,11 @@ public TobiiCalibrationResult(Tobii.Research.CalibrationResult calibrationResult
2946
SessionManager.GetInstance().GenerateCalibrationTimeStamp();
3047
}
3148

49+
public override bool IsValid() //TODO
50+
{
51+
throw new System.NotImplementedException();
52+
}
53+
3254
public List<Point> GetLeftEyePoints()
3355
{
3456
List<Point> leftEyePoints = new List<Point>();
@@ -121,6 +143,11 @@ public GazePointCalibrationResult(string xmlCalibrationData, int numberOfPoints)
121143
SessionManager.GetInstance().GenerateCalibrationTimeStamp();
122144
}
123145

146+
public override bool IsValid() //TODO
147+
{
148+
throw new System.NotImplementedException();
149+
}
150+
124151
public override void WriteToXMLWriter(XmlTextWriter xmlTextWriter)
125152
{
126153
XmlNode recNode = XmlDoc.FirstChild;
@@ -154,4 +181,84 @@ public override void WriteToXMLWriter(XmlTextWriter xmlTextWriter)
154181
xmlTextWriter.WriteEndElement();
155182
}
156183
}
184+
185+
class SmartEyeCalibrationResult : CalibrationResult
186+
{
187+
//These are the calibration vectors produced by the SE gaze calibration dialogue
188+
private List<SETarget> calibrationTargets;
189+
private SEWorldModel worldModel;
190+
public ScreenMapping screenMapping { get; private set; }
191+
192+
public SmartEyeCalibrationResult(SEWorldModel worldModel, List<SETarget> calibrationTargets)
193+
{
194+
//TODO: world model sanity checks
195+
196+
this.worldModel = worldModel;
197+
this.calibrationTargets = calibrationTargets;
198+
this.screenMapping = new ScreenMapping(worldModel.GetScreens(), Screen.AllScreens);
199+
200+
SessionManager.GetInstance().GenerateCalibrationTimeStamp();
201+
}
202+
203+
public override bool IsValid() //TODO
204+
{
205+
return screenMapping.IsValid() && calibrationTargets.Count > 0;
206+
}
207+
208+
public override void WriteToXMLWriter(XmlTextWriter xmlTextWriter)
209+
{
210+
worldModel.WriteToXMLWriter(xmlTextWriter);
211+
212+
xmlTextWriter.WriteStartElement("calibration");
213+
xmlTextWriter.WriteAttributeString("timestamp", SessionManager.GetInstance().CurrentCalibrationTimeStamp);
214+
215+
foreach (SETarget target in calibrationTargets)
216+
{
217+
xmlTextWriter.WriteStartElement("calibration_point");
218+
xmlTextWriter.WriteAttributeString("targetId", target.targetId.ToString());
219+
220+
//Write X and Y of calibration point as percent of screen size. This may require extracting from the world model string!
221+
//xmlTextWriter.WriteAttributeString("x", "0.5");
222+
//xmlTextWriter.WriteAttributeString("y", "0.5");
223+
224+
int max = target.errorsxl.Length >= target.errorsxr.Length ? target.errorsxl.Length : target.errorsxr.Length;
225+
226+
for (int i = 0; i < max; i++)
227+
{
228+
xmlTextWriter.WriteStartElement("sample");
229+
230+
if (i < target.errorsxl.Length)
231+
{
232+
xmlTextWriter.WriteAttributeString("left_x", target.errorsxl[i].ToString());
233+
xmlTextWriter.WriteAttributeString("left_y", target.errorsyl[i].ToString());
234+
xmlTextWriter.WriteAttributeString("left_validity", "1");
235+
} else
236+
{
237+
xmlTextWriter.WriteAttributeString("left_x", "0.0");
238+
xmlTextWriter.WriteAttributeString("left_y", "0.0");
239+
xmlTextWriter.WriteAttributeString("left_validity", "0");
240+
}
241+
242+
if (i < target.errorsxr.Length)
243+
{
244+
xmlTextWriter.WriteAttributeString("right_x", target.errorsxr[i].ToString());
245+
xmlTextWriter.WriteAttributeString("right_y", target.errorsyr[i].ToString());
246+
xmlTextWriter.WriteAttributeString("right_validity", "1");
247+
}
248+
else
249+
{
250+
xmlTextWriter.WriteAttributeString("right_x", "0.0");
251+
xmlTextWriter.WriteAttributeString("right_y", "0.0");
252+
xmlTextWriter.WriteAttributeString("right_validity", "0");
253+
}
254+
255+
xmlTextWriter.WriteEndElement();
256+
}
257+
258+
xmlTextWriter.WriteEndElement();
259+
}
260+
261+
xmlTextWriter.WriteEndElement();
262+
}
263+
}
157264
}

0 commit comments

Comments
 (0)