Skip to content

Commit

Permalink
Merge pull request #181 from iTrace-Dev/development
Browse files Browse the repository at this point in the history
Merge for release
  • Loading branch information
fisherdog1 authored May 31, 2022
2 parents f2b50f9 + 6a63e78 commit 36b13f0
Show file tree
Hide file tree
Showing 56 changed files with 5,391 additions and 1,048 deletions.
19 changes: 19 additions & 0 deletions UnitTestProject1/CoreUnitTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\itrace_core\itrace_core.csproj" />
</ItemGroup>

</Project>
70 changes: 70 additions & 0 deletions UnitTestProject1/SmarteyeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/********************************************************************************************************************************************************
* @file SmarteyeTests.cs
*
* @Copyright (C) 2022 i-trace.org
*
* This file is part of iTrace Infrastructure http://www.i-trace.org/.
* 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.
* 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.
* You should have received a copy of the GNU General Public License along with iTrace Infrastructure. If not, see <https://www.gnu.org/licenses/>.
********************************************************************************************************************************************************/

using iTrace_Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace UnitTestProject1
{
[TestClass]
public class SmarteyeTests
{
[TestMethod]
public void ValidNetstringPass()
{
string netstring = "7:jeffrey,";
string result = NetstringUtils.TrimSENetstring(netstring);

Assert.AreEqual(result, "jeffrey");
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException), "")]
public void BadLengthNetstringNoPass()
{
string netstring = "9:jeffrey,";
string result = NetstringUtils.TrimSENetstring(netstring);
}

[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException), "")]
public void ZeroLengthNetstringNoPass()
{
string netstring = "2:,";
string result = NetstringUtils.TrimSENetstring(netstring);
}

[TestMethod]
[ExpectedException(typeof(ArgumentException),"")]
public void NoLengthNetstringNoPass()
{
string netstring = ":jeffrey,";
string result = NetstringUtils.TrimSENetstring(netstring);
}

[TestMethod]
[ExpectedException(typeof(ArgumentException), "")]
public void NoSeperatorNetstringNoPass()
{
string netstring = "7jeffrey,";
string result = NetstringUtils.TrimSENetstring(netstring);
}

[TestMethod]
[ExpectedException(typeof(ArgumentException), "")]
public void NoCommaNetstringNoPass()
{
string netstring = "7:jeffrey";
string result = NetstringUtils.TrimSENetstring(netstring);
}
}
}
14 changes: 14 additions & 0 deletions XUnitTestProject1/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using Xunit;

namespace XUnitTestProject1
{
public class UnitTest1
{
[Fact]
public void Test1()
{
Console.WriteLine("Test");
}
}
}
15 changes: 15 additions & 0 deletions XUnitTestProject1/XUnitTestProject1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>

</Project>
72 changes: 41 additions & 31 deletions itrace_core.sln
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2047
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itrace_core", "itrace_core\itrace_core.csproj", "{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|x64.ActiveCfg = Debug|x64
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|x64.Build.0 = Debug|x64
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|Any CPU.Build.0 = Release|Any CPU
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|x64.ActiveCfg = Release|x64
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FD8E01EA-52AD-4714-995D-89FF2A3CAE5F}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "itrace_core", "itrace_core\itrace_core.csproj", "{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreUnitTests", "UnitTestProject1\CoreUnitTests.csproj", "{F7B7FC84-7401-4185-BAE0-B78524B26BAE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|x64.ActiveCfg = Debug|x64
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Debug|x64.Build.0 = Debug|x64
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|Any CPU.Build.0 = Release|Any CPU
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|x64.ActiveCfg = Release|x64
{5783FB9E-5502-48CF-89BF-12B3A4DFFCB2}.Release|x64.Build.0 = Release|x64
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Debug|x64.ActiveCfg = Debug|Any CPU
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Debug|x64.Build.0 = Debug|Any CPU
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Release|Any CPU.Build.0 = Release|Any CPU
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Release|x64.ActiveCfg = Release|Any CPU
{F7B7FC84-7401-4185-BAE0-B78524B26BAE}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FD8E01EA-52AD-4714-995D-89FF2A3CAE5F}
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions itrace_core/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
<setting name="websocket_port" serializeAs="String">
<value>7007</value>
</setting>
<setting name="smarteye_ip_address" serializeAs="String">
<value>192.169.100.42</value>
</setting>
<setting name="smarteye_ip_port" serializeAs="String">
<value>5800</value>
</setting>
<setting name="calibration_monitor" serializeAs="String">
<value>0</value>
</setting>
</iTrace_Core.Properties.Settings>
</userSettings>
</configuration>
14 changes: 13 additions & 1 deletion itrace_core/App.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
<Application x:Class="iTrace_Core.App"
<!--
/********************************************************************************************************************************************************
* @file App.xaml
*
* @Copyright (C) 2022 i-trace.org
*
* This file is part of iTrace Infrastructure http://www.i-trace.org/.
* 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.
* 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.
* You should have received a copy of the GNU General Public License along with iTrace Infrastructure. If not, see <https://www.gnu.org/licenses/>.
********************************************************************************************************************************************************/
-->
<Application x:Class="iTrace_Core.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:iTrace_Core"
Expand Down
13 changes: 12 additions & 1 deletion itrace_core/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
using System;
/********************************************************************************************************************************************************
* @file App.xaml.cs
*
* @Copyright (C) 2022 i-trace.org
*
* This file is part of iTrace Infrastructure http://www.i-trace.org/.
* 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.
* 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.
* You should have received a copy of the GNU General Public License along with iTrace Infrastructure. If not, see <https://www.gnu.org/licenses/>.
********************************************************************************************************************************************************/

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
Expand Down
109 changes: 108 additions & 1 deletion itrace_core/CalibrationResult.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
using System.Collections.Generic;
/********************************************************************************************************************************************************
* @file CalibrationResult.cs
*
* @Copyright (C) 2022 i-trace.org
*
* This file is part of iTrace Infrastructure http://www.i-trace.org/.
* 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.
* 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.
* You should have received a copy of the GNU General Public License along with iTrace Infrastructure. If not, see <https://www.gnu.org/licenses/>.
********************************************************************************************************************************************************/

using System.Collections.Generic;
using System.Windows;
using System.Windows.Forms;
using System.Xml;

namespace iTrace_Core
{
abstract class CalibrationResult
{
public abstract void WriteToXMLWriter(XmlTextWriter xmlTextWriter);
public abstract bool IsValid();
}

class EmptyCalibrationResult : CalibrationResult
{
public override void WriteToXMLWriter(XmlTextWriter xmlTextWriter) { }
public override bool IsValid() //TODO
{
throw new System.NotImplementedException();
}
}

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

public override bool IsValid() //TODO
{
throw new System.NotImplementedException();
}

public List<Point> GetLeftEyePoints()
{
List<Point> leftEyePoints = new List<Point>();
Expand Down Expand Up @@ -121,6 +143,11 @@ public GazePointCalibrationResult(string xmlCalibrationData, int numberOfPoints)
SessionManager.GetInstance().GenerateCalibrationTimeStamp();
}

public override bool IsValid() //TODO
{
throw new System.NotImplementedException();
}

public override void WriteToXMLWriter(XmlTextWriter xmlTextWriter)
{
XmlNode recNode = XmlDoc.FirstChild;
Expand Down Expand Up @@ -154,4 +181,84 @@ public override void WriteToXMLWriter(XmlTextWriter xmlTextWriter)
xmlTextWriter.WriteEndElement();
}
}

class SmartEyeCalibrationResult : CalibrationResult
{
//These are the calibration vectors produced by the SE gaze calibration dialogue
private List<SETarget> calibrationTargets;
private SEWorldModel worldModel;
public ScreenMapping screenMapping { get; private set; }

public SmartEyeCalibrationResult(SEWorldModel worldModel, List<SETarget> calibrationTargets)
{
//TODO: world model sanity checks

this.worldModel = worldModel;
this.calibrationTargets = calibrationTargets;
this.screenMapping = new ScreenMapping(worldModel.GetScreens(), Screen.AllScreens);

SessionManager.GetInstance().GenerateCalibrationTimeStamp();
}

public override bool IsValid() //TODO
{
return screenMapping.IsValid() && calibrationTargets.Count > 0;
}

public override void WriteToXMLWriter(XmlTextWriter xmlTextWriter)
{
worldModel.WriteToXMLWriter(xmlTextWriter);

xmlTextWriter.WriteStartElement("calibration");
xmlTextWriter.WriteAttributeString("timestamp", SessionManager.GetInstance().CurrentCalibrationTimeStamp);

foreach (SETarget target in calibrationTargets)
{
xmlTextWriter.WriteStartElement("calibration_point");
xmlTextWriter.WriteAttributeString("targetId", target.targetId.ToString());

//Write X and Y of calibration point as percent of screen size. This may require extracting from the world model string!
//xmlTextWriter.WriteAttributeString("x", "0.5");
//xmlTextWriter.WriteAttributeString("y", "0.5");

int max = target.errorsxl.Length >= target.errorsxr.Length ? target.errorsxl.Length : target.errorsxr.Length;

for (int i = 0; i < max; i++)
{
xmlTextWriter.WriteStartElement("sample");

if (i < target.errorsxl.Length)
{
xmlTextWriter.WriteAttributeString("left_x", target.errorsxl[i].ToString());
xmlTextWriter.WriteAttributeString("left_y", target.errorsyl[i].ToString());
xmlTextWriter.WriteAttributeString("left_validity", "1");
} else
{
xmlTextWriter.WriteAttributeString("left_x", "0.0");
xmlTextWriter.WriteAttributeString("left_y", "0.0");
xmlTextWriter.WriteAttributeString("left_validity", "0");
}

if (i < target.errorsxr.Length)
{
xmlTextWriter.WriteAttributeString("right_x", target.errorsxr[i].ToString());
xmlTextWriter.WriteAttributeString("right_y", target.errorsyr[i].ToString());
xmlTextWriter.WriteAttributeString("right_validity", "1");
}
else
{
xmlTextWriter.WriteAttributeString("right_x", "0.0");
xmlTextWriter.WriteAttributeString("right_y", "0.0");
xmlTextWriter.WriteAttributeString("right_validity", "0");
}

xmlTextWriter.WriteEndElement();
}

xmlTextWriter.WriteEndElement();
}

xmlTextWriter.WriteEndElement();
}
}
}
Loading

0 comments on commit 36b13f0

Please sign in to comment.