Commit b55d8fdf by Stefan Schreistetter

Simplified event structure.

parent 46d65b4f
...@@ -13,8 +13,8 @@ Global ...@@ -13,8 +13,8 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F8F11E64-7946-4054-8C27-F0FCAF967F1A}.Debug|Any CPU.ActiveCfg = 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 = Release|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.ActiveCfg = Release|Any CPU
{F8F11E64-7946-4054-8C27-F0FCAF967F1A}.Release|Any CPU.Build.0 = 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 {64D52257-ECA7-4F4D-A901-B14D544A1D0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
......
...@@ -50,6 +50,16 @@ ...@@ -50,6 +50,16 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </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> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
......
...@@ -8,22 +8,18 @@ namespace TrackerBridge ...@@ -8,22 +8,18 @@ namespace TrackerBridge
{ {
public class FakeTracker : IBridgeTracker public class FakeTracker : IBridgeTracker
{ {
private event GazeDataHandler gazeDataAvailable;
public event GazeDataHandler GazeDataAvailable { public event GazeDataHandler GazeDataAvailable {
add { add {
gazeDataAvailable += value; GazeDataProcessor.GazeDataProcessed += value;
GazeDataProcessor.AddClient(value);
} }
remove { remove {
gazeDataAvailable -= value; GazeDataProcessor.GazeDataProcessed -= value;
GazeDataProcessor.RemoveClient(value);
} }
} }
public event EventHandler<Single> TrackingFrequencyChanged; public event EventHandler<Single> TrackingFrequencyChanged;
private Single trackerFrequency; private Single trackerFrequency;
public GazeDataHandler GazeDataAvailableMembers => gazeDataAvailable;
public String SerialNumber => throw new NotImplementedException(); public String SerialNumber => throw new NotImplementedException();
public GazeDataProcessor GazeDataProcessor { get; } public GazeDataProcessor GazeDataProcessor { get; }
......
...@@ -11,6 +11,15 @@ namespace TrackerBridge ...@@ -11,6 +11,15 @@ namespace TrackerBridge
{ {
public class GazeDataProcessor 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 IGazeFilter[] gazeFilters;
private readonly Single screenHeight; private readonly Single screenHeight;
private readonly Single screenWidth; private readonly Single screenWidth;
...@@ -33,27 +42,11 @@ namespace TrackerBridge ...@@ -33,27 +42,11 @@ namespace TrackerBridge
gazeFilters[0] = new GazeDecimator(60); //TODO: Refactor frequency passthrough gazeFilters[0] = new GazeDecimator(60); //TODO: Refactor frequency passthrough
//Chain filters //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() public void Initialize()
{ {
......
...@@ -13,8 +13,6 @@ namespace TrackerBridge ...@@ -13,8 +13,6 @@ namespace TrackerBridge
{ {
event GazeDataHandler GazeDataAvailable; event GazeDataHandler GazeDataAvailable;
event EventHandler<Single> TrackingFrequencyChanged; event EventHandler<Single> TrackingFrequencyChanged;
GazeDataHandler GazeDataAvailableMembers { get; }
GazeDataProcessor GazeDataProcessor { get;} GazeDataProcessor GazeDataProcessor { get;}
String SerialNumber { get; } String SerialNumber { get; }
......
...@@ -9,20 +9,14 @@ namespace TrackerBridge ...@@ -9,20 +9,14 @@ namespace TrackerBridge
{ {
public class TobiiEyeTracker : IBridgeTracker 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 ConnectionEvent;
public event ConnectionEventHandler ConnectionTimeout; public event ConnectionEventHandler ConnectionTimeout;
private event GazeDataHandler gazeDataAvailable;
public event GazeDataHandler GazeDataAvailable { public event GazeDataHandler GazeDataAvailable {
add { add {
gazeDataAvailable += value; GazeDataProcessor.GazeDataProcessed += value;
GazeDataProcessor.AddClient(value);
} }
remove { remove {
gazeDataAvailable -= value; GazeDataProcessor.GazeDataProcessed -= value;
GazeDataProcessor.RemoveClient(value);
} }
} }
public event EventHandler<Single> TrackingFrequencyChanged; public event EventHandler<Single> TrackingFrequencyChanged;
...@@ -33,8 +27,6 @@ namespace TrackerBridge ...@@ -33,8 +27,6 @@ namespace TrackerBridge
public Boolean IsConnected { get; private set; } = false; public Boolean IsConnected { get; private set; } = false;
public String SerialNumber { get; private set; } = null; public String SerialNumber { get; private set; } = null;
public GazeDataHandler GazeDataAvailableMembers => gazeDataAvailable;
public TobiiEyeTracker() public TobiiEyeTracker()
{ {
GazeDataProcessor = new GazeDataProcessor(this); 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