Commit b55d8fdf by Stefan Schreistetter

Simplified event structure.

parent 46d65b4f
......@@ -13,8 +13,8 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F8F11E64-7946-4054-8C27-F0FCAF967F1A}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{F8F11E64-7946-4054-8C27-F0FCAF967F1A}.Debug|Any CPU.Build.0 = Release|Any CPU
{F8F11E64-7946-4054-8C27-F0FCAF967F1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8F11E64-7946-4054-8C27-F0FCAF967F1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8F11E64-7946-4054-8C27-F0FCAF967F1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8F11E64-7946-4054-8C27-F0FCAF967F1A}.Release|Any CPU.Build.0 = Release|Any CPU
{64D52257-ECA7-4F4D-A901-B14D544A1D0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
......
......@@ -50,6 +50,16 @@
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Tracker|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Tracker\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
......
......@@ -8,22 +8,18 @@ namespace TrackerBridge
{
public class FakeTracker : IBridgeTracker
{
private event GazeDataHandler gazeDataAvailable;
public event GazeDataHandler GazeDataAvailable {
add {
gazeDataAvailable += value;
GazeDataProcessor.AddClient(value);
GazeDataProcessor.GazeDataProcessed += value;
}
remove {
gazeDataAvailable -= value;
GazeDataProcessor.RemoveClient(value);
GazeDataProcessor.GazeDataProcessed -= value;
}
}
public event EventHandler<Single> TrackingFrequencyChanged;
private Single trackerFrequency;
public GazeDataHandler GazeDataAvailableMembers => gazeDataAvailable;
public String SerialNumber => throw new NotImplementedException();
public GazeDataProcessor GazeDataProcessor { get; }
......
......@@ -11,6 +11,15 @@ namespace TrackerBridge
{
public class GazeDataProcessor
{
public event GazeDataHandler GazeDataProcessed {
add {
gazeFilters[gazeFilters.Length - 1].OutputAvailable += value;
}
remove {
gazeFilters[gazeFilters.Length - 1].OutputAvailable -= value;
}
}
private readonly IGazeFilter[] gazeFilters;
private readonly Single screenHeight;
private readonly Single screenWidth;
......@@ -33,28 +42,12 @@ namespace TrackerBridge
gazeFilters[0] = new GazeDecimator(60); //TODO: Refactor frequency passthrough
//Chain filters
for(Int32 index= 0; index < gazeFilters.Length; index++)
for(Int32 index= 0; index < gazeFilters.Length-1; index++)
{
if(index == gazeFilters.Length - 1)
{
gazeFilters[index].OutputAvailable += tracker.GazeDataAvailableMembers;
}
else
{
gazeFilters[index].OutputAvailable += gazeFilters[index + 1].Input;
}
gazeFilters[index].OutputAvailable += gazeFilters[index + 1].Input;
}
}
public void AddClient(GazeDataHandler gazeDataHandler)
{
gazeFilters[gazeFilters.Length - 1].OutputAvailable += gazeDataHandler;
}
public void RemoveClient(GazeDataHandler gazeDataHandler)
{
gazeFilters[gazeFilters.Length - 1].OutputAvailable -= gazeDataHandler;
}
public void Initialize()
{
foreach (IGazeFilter filter in gazeFilters)
......
......@@ -13,8 +13,6 @@ namespace TrackerBridge
{
event GazeDataHandler GazeDataAvailable;
event EventHandler<Single> TrackingFrequencyChanged;
GazeDataHandler GazeDataAvailableMembers { get; }
GazeDataProcessor GazeDataProcessor { get;}
String SerialNumber { get; }
......
......@@ -9,20 +9,14 @@ namespace TrackerBridge
{
public class TobiiEyeTracker : IBridgeTracker
{
//public delegate void ConnectionEventHandler(TobiiEyeTracker sender);
//public delegate void GazeDataHandler(TobiiEyeTracker sender, GazeData data);
public event ConnectionEventHandler ConnectionEvent;
public event ConnectionEventHandler ConnectionTimeout;
private event GazeDataHandler gazeDataAvailable;
public event GazeDataHandler GazeDataAvailable {
add {
gazeDataAvailable += value;
GazeDataProcessor.AddClient(value);
GazeDataProcessor.GazeDataProcessed += value;
}
remove {
gazeDataAvailable -= value;
GazeDataProcessor.RemoveClient(value);
GazeDataProcessor.GazeDataProcessed -= value;
}
}
public event EventHandler<Single> TrackingFrequencyChanged;
......@@ -33,8 +27,6 @@ namespace TrackerBridge
public Boolean IsConnected { get; private set; } = false;
public String SerialNumber { get; private set; } = null;
public GazeDataHandler GazeDataAvailableMembers => gazeDataAvailable;
public TobiiEyeTracker()
{
GazeDataProcessor = new GazeDataProcessor(this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment